Skip to content

Commit dc96bdb

Browse files
committed
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.
2 parents 46220ca + 82cea9f commit dc96bdb

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

contrib/fast-import/git-p4

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,8 @@ class P4Submit(Command):
627627

628628
if self.interactive:
629629
submitTemplate = self.prepareLogMessage(template, logMessage)
630+
if os.environ.has_key("P4DIFF"):
631+
del(os.environ["P4DIFF"])
630632
diff = read_pipe("p4 diff -du ...")
631633

632634
for newFile in filesToAdd:
@@ -650,7 +652,10 @@ class P4Submit(Command):
650652
defaultEditor = "vi"
651653
if platform.system() == "Windows":
652654
defaultEditor = "notepad"
653-
editor = os.environ.get("EDITOR", defaultEditor);
655+
if os.environ.has_key("P4EDITOR"):
656+
editor = os.environ.get("P4EDITOR")
657+
else:
658+
editor = os.environ.get("EDITOR", defaultEditor);
654659
system(editor + " " + fileName)
655660
tmpFile = open(fileName, "rb")
656661
message = tmpFile.read()
@@ -882,21 +887,21 @@ class P4Sync(Command):
882887
while j < len(filedata):
883888
stat = filedata[j]
884889
j += 1
885-
text = ''
890+
text = [];
886891
while j < len(filedata) and filedata[j]['code'] in ('text', 'unicode', 'binary'):
887-
tmp = filedata[j]['data']
888-
if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
889-
tmp = re.sub(r'(?i)\$(Id|Header):[^$]*\$',r'$\1$', tmp)
890-
elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'binary+k'):
891-
tmp = re.sub(r'(?i)\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r'$\1$', tmp)
892-
text += tmp
892+
text.append(filedata[j]['data'])
893893
j += 1
894-
894+
text = ''.join(text)
895895

896896
if not stat.has_key('depotFile'):
897897
sys.stderr.write("p4 print fails with: %s\n" % repr(stat))
898898
continue
899899

900+
if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
901+
text = re.sub(r'(?i)\$(Id|Header):[^$]*\$',r'$\1$', text)
902+
elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'binary+k'):
903+
text = re.sub(r'(?i)\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r'$\1$', text)
904+
900905
contents[stat['depotFile']] = text
901906

902907
for f in filesForCommit:

0 commit comments

Comments
 (0)