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 <luke@diamand.org> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pete Wyckoff committed
Oct 16, 2011 at 10:46 UTC
cb585a9cda70320647cc5d69e71bedc929244189
1 file changed
+6
-2
contrib/fast-import/git-p4
+6
-2
@@ -1285,9 +1285,13 @@ class P4Sync(Command, P4UserMap):
1285
# even though in theory somebody may want that.
1286
if type_base in ("text", "unicode", "binary"):
1287
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 ]
1291
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 ]
1295
1296
self.gitStream.write("M %s inline %s\n" % (git_mode, relPath))
1297