git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 5/5] git-p4: keyword flattening fixes

From
PWPete Wyckoff <pw@padd.com>
Date
Sep 18, 2011, 01:33 UTC
Message-ID
<20110918013334.GF4619@arf.padd.com>
In-Reply-To
<20110918012634.GA4578@arf.padd.com>

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 $.

Signed-off-by: Pete Wyckoff <pw@padd.com>
---
 contrib/fast-import/git-p4 |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index eee288d..782b891 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -1285,9 +1285,13 @@ class P4Sync(Command, P4UserMap):
         # even though in theory somebody may want that.
         if type_base in ("text", "unicode", "binary"):
             if "ko" in type_mods:
-                contents = map(lambda text: re.sub(r'(?i)\$(Id|Header):[^$]*\$', r'$\1$', text), contents)
+                text = ''.join(contents)
+                text = re.sub(r'\$(Id|Header):[^$]*\$', r'$\1$', text)
+                contents = [ text ]
             elif "k" in type_mods:
-                contents = map(lambda text: re.sub(r'\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$\n]*\$', r'$\1$', text), contents)
+                text = ''.join(contents)
+                text = re.sub(r'\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$', r'$\1$', text)
+                contents = [ text ]
 
         self.gitStream.write("M %s inline %s\n" % (git_mode, relPath))
 
-- 
1.7.6.3
Previous: Pete WyckoffNext: Luke Diamand
Message 12 of 13 in “git-p4 filetype handling”
  1. 0/5 git-p4 filetype handlingPete Wyckoff, Sep 18, 2011
  2. 1/5 git-p4 tests: refactor, split out common functionsPete Wyckoff, Sep 18, 2011
  3. Junio C HamanoSep 18, 2011
  4. Pete WyckoffSep 21, 2011
  5. Junio C HamanoSep 21, 2011
  6. Junio C HamanoSep 21, 2011
  7. 2/5 git-p4: handle utf16 filetype properlyPete Wyckoff, Sep 18, 2011
  8. Luke DiamandSep 23, 2011
  9. 2/5 git-p4: handle utf16 filetype properlyPete Wyckoff, Sep 18, 2011
  10. 3/5 git-p4: recognize all p4 filetypesPete Wyckoff, Sep 18, 2011
  11. 4/5 git-p4: stop ignoring apple filetypePete Wyckoff, Sep 18, 2011
  12. 5/5 git-p4: keyword flattening fixesPete Wyckoff, Sep 18, 2011
  13. Luke DiamandSep 23, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.