PATCH: git-p4 optional handling of RCS keywords [was: Re: git-p4 and keyword expansion]

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: dhruva
Date: Tuesday, September 9, 2008 - 10:13 pm

Hello,
 I would like to submit my first patch to the git community.

I have introduced a new configuration option to 'git-p4' "kwstrip". If enabled, the RCS keywords gets unexpanded like it is done with out the patch and disabling it explicitly retains the RCS keywords as in the original p4 source. The default (in the absence) is 'false' to ensure backward compatibility. To override, you can put the following lines in your '.gitconfig' file..

[git-p4]
        kwstrip = false



The patch to git-p4 (based on origin/next branch):

diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 2216cac..ad37d0b 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -16,6 +16,9 @@ from sets import Set;

 verbose = False

+# Handling of RCS keyowrds. To ensure backward compatibility, the default
+# is to strip keywords. Default behavior is controlled here
+kwstrip = True

 def p4_build_cmd(cmd):
     """Build a suitable p4 command line.
@@ -975,10 +978,11 @@ class P4Sync(Command):
                 sys.stderr.write("p4 print fails with: %s\n" % repr(stat))
                 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'\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r'$\1$', text)
+            if kwstrip:
+                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'\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r'$\1$', text)

             contents[stat['depotFile']] = text

@@ -1850,6 +1854,16 @@ def main():
         (cmd, args) = parser.parse_args(sys..argv[2:], cmd);
     global verbose
     verbose = cmd.verbose
+
+    global kwstrip
+    kwval = gitConfig("git-p4.kwstrip")
+    if len(kwval) > 0:
+       kwval = kwval.lower();
+        if "false" == kwval:
+            kwstrip = False
+        else if "true" == kwval:
+            kwstrip = True
+
     if cmd.needsGit:
         if cmd.gitdir == None:
             cmd.gitdir = os.path.abspath(".git")



----- Original Message ----

Done



Done

-dhruva



      Add more friends to your messenger and enjoy! Go to http://in.messenger.yahoo.com/invite/

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
PATCH: git-p4 optional handling of RCS keywords [was: Re: ..., dhruva, (Tue Sep 9, 10:13 pm)
Re: PATCH: git-p4 optional handling of RCS keywords, Junio C Hamano, (Tue Sep 9, 10:35 pm)