提交 dc96bdb9 编写于 作者: J Junio C Hamano

Merge branch 'git-p4' of git://repo.or.cz/git/git-p4

* 'git-p4' of git://repo.or.cz/git/git-p4:
  git-p4: Use P4EDITOR environment variable when set
  git-p4: Unset P4DIFF environment variable when using 'p4 -du diff'
  git-p4: Optimize the fetching of data from perforce.
...@@ -627,6 +627,8 @@ class P4Submit(Command): ...@@ -627,6 +627,8 @@ class P4Submit(Command):
if self.interactive: if self.interactive:
submitTemplate = self.prepareLogMessage(template, logMessage) submitTemplate = self.prepareLogMessage(template, logMessage)
if os.environ.has_key("P4DIFF"):
del(os.environ["P4DIFF"])
diff = read_pipe("p4 diff -du ...") diff = read_pipe("p4 diff -du ...")
for newFile in filesToAdd: for newFile in filesToAdd:
...@@ -650,7 +652,10 @@ class P4Submit(Command): ...@@ -650,7 +652,10 @@ class P4Submit(Command):
defaultEditor = "vi" defaultEditor = "vi"
if platform.system() == "Windows": if platform.system() == "Windows":
defaultEditor = "notepad" defaultEditor = "notepad"
editor = os.environ.get("EDITOR", defaultEditor); if os.environ.has_key("P4EDITOR"):
editor = os.environ.get("P4EDITOR")
else:
editor = os.environ.get("EDITOR", defaultEditor);
system(editor + " " + fileName) system(editor + " " + fileName)
tmpFile = open(fileName, "rb") tmpFile = open(fileName, "rb")
message = tmpFile.read() message = tmpFile.read()
...@@ -882,21 +887,21 @@ class P4Sync(Command): ...@@ -882,21 +887,21 @@ class P4Sync(Command):
while j < len(filedata): while j < len(filedata):
stat = filedata[j] stat = filedata[j]
j += 1 j += 1
text = '' text = [];
while j < len(filedata) and filedata[j]['code'] in ('text', 'unicode', 'binary'): while j < len(filedata) and filedata[j]['code'] in ('text', 'unicode', 'binary'):
tmp = filedata[j]['data'] text.append(filedata[j]['data'])
if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
tmp = re.sub(r'(?i)\$(Id|Header):[^$]*\$',r'$\1$', tmp)
elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'binary+k'):
tmp = re.sub(r'(?i)\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r'$\1$', tmp)
text += tmp
j += 1 j += 1
text = ''.join(text)
if not stat.has_key('depotFile'): if not stat.has_key('depotFile'):
sys.stderr.write("p4 print fails with: %s\n" % repr(stat)) sys.stderr.write("p4 print fails with: %s\n" % repr(stat))
continue continue
if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
text = re.sub(r'(?i)\$(Id|Header):[^$]*\$',r'$\1$', text)
elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'binary+k'):
text = re.sub(r'(?i)\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r'$\1$', text)
contents[stat['depotFile']] = text contents[stat['depotFile']] = text
for f in filesForCommit: for f in filesForCommit:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册