Skip to content

Commit cb585a9

Browse files
Pete Wyckoffgitster
authored andcommitted
git-p4: keyword flattening fixes
Join the text before looking for keywords. There is nothing to prevent the p4 output marshaller from splitting in the middle of a keyword, although it has never been known to happen. Also remove the (?i) regexp modifier; perforce keywords are documented as case-sensitive. Remove the "\n" end-character match. I don't know why that is in there, and every keyword in a fairly large production p4 repository always ends with a $. Acked-by: Luke Diamand <[email protected]> Signed-off-by: Pete Wyckoff <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 97a21ca commit cb585a9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

contrib/fast-import/git-p4

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,9 +1285,13 @@ class P4Sync(Command, P4UserMap):
12851285
# even though in theory somebody may want that.
12861286
if type_base in ("text", "unicode", "binary"):
12871287
if "ko" in type_mods:
1288-
contents = map(lambda text: re.sub(r'(?i)\$(Id|Header):[^$]*\$', r'$\1$', text), contents)
1288+
text = ''.join(contents)
1289+
text = re.sub(r'\$(Id|Header):[^$]*\$', r'$\1$', text)
1290+
contents = [ text ]
12891291
elif "k" in type_mods:
1290-
contents = map(lambda text: re.sub(r'\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$\n]*\$', r'$\1$', text), contents)
1292+
text = ''.join(contents)
1293+
text = re.sub(r'\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$', r'$\1$', text)
1294+
contents = [ text ]
12911295

12921296
self.gitStream.write("M %s inline %s\n" % (git_mode, relPath))
12931297

0 commit comments

Comments
 (0)