PATCH: git-p4 optional handling of RCS keywords [was: Re: git-p4 and keyword expansion]
For some reason, my mail did not go through the git mailing list, I am resending. Please excuse if it is a duplicate!
----- Forwarded Message ----
Quoted 208 lines
From: dhruva <[email protected]>
To: Simon Hausmann <[email protected]>
Cc: GIT SCM <[email protected]>; Jing Xue <[email protected]>
Sent: Wednesday, 10 September, 2008 10:48:23 AM
Subject: Re: PATCH: git-p4 optional handling of RCS keywords [was: Re: git-p4 and keyword expansion]My earlier patch has an error... (I have almost always stumbled on first patch!)
here is the fixed one:
contrib/fast-import/git-p4 +0
-0@@ -16,6 +16,9 @@ from sets import Set;verbose = False
contrib/fast-import/git-p4 +3
-0+# Handling of RCS keyowrds. To ensure backward compatibility, the default +# is to strip keywords. Default behavior is controlled here +kwstrip = Truedef
p4_build_cmd(cmd):
"""Build a suitable p4 command line.contrib/fast-import/git-p4 +0
-3@@ -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)contrib/fast-import/git-p4 +4
-0+ 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
contrib/fast-import/git-p4 +10
-2@@ -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 + elif "true" == kwval: + kwstrip = True + if cmd.needsGit: if cmd.gitdir == None: cmd.gitdir = os.path.abspath(".git") -dhruva ----- Original Message ----Quoted 5 lines
From: dhruva
To: Simon Hausmann
Cc: GIT SCM ; Jing Xue
Sent: Wednesday, 10 September, 2008 10:43:26 AM
Subject: PATCH: git-p4 optional handling of RCS keywords [was: Re: git-p4 andkeyword expansion]
Quoted 5 lines
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,
Quoted 34 lines
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 = falseThe patch to git-p4 (based on origin/next branch):
contrib/fast-import/git-p4 +0
-0@@ -16,6 +16,9 @@ from sets import Set;verbose = False
contrib/fast-import/git-p4 +3
-0+# Handling of RCS keyowrds. To ensure backward compatibility, the default +# is to strip keywords. Default behavior is controlled here +kwstrip = Truedef
p4_build_cmd(cmd):
"""Build a suitable p4 command line.contrib/fast-import/git-p4 +0
-3@@ -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',Quoted 3 lines
'binary+k'):
- text =re.sub(r'\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r'$\1$',
contrib/fast-import/git-p4
Quoted 5 lines
text)
contrib/fast-import/git-p4 +4
-0+ 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',
Quoted 3 lines
'binary+k'):
+ text =re.sub(r'\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r'$\1$',
Quoted 66 lines
text)
contents[stat['depotFile']] = text
contrib/fast-import/git-p4 +10
-1@@ -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 ----Quoted 19 lines
From: Jing Xue
To: dhruva
Cc: GIT SCM
Sent: Tuesday, 9 September, 2008 11:08:48 PM
Subject: Re: git-p4 and keyword expansionQuoted 1 line · dhruva
Hello,
Hi,
Quoted 8 lines
I feel the configuration must be set the first time only, when you clone using 'git-p4 clone'. Altering it in between will be very confusing!
Ideally, the setting must be transferred when the git repo (cloned from git-p4) is cloned using standard git. Is it something possible (well, I am new to git and am exploring. Any extra information would help).Quoted 8 lines
Quoted 6 lines
My proposal is as follows:
1. Add an extra command line argument to 'git-p4 clone' to either enable/disable keyword expansion
2. Store that information under the .git folder in a file that is copied when someone clones that repo
3. Use the stored information in future 'git-p4 sync/rebase'Any way to make it optional would be welcome by me.
Done
Quoted 3 lines
If you do come up with a "formal" patch, you might want to explicitly add Simon Hausmann to the To list, for he's the git-p4 author.
Done
-dhruva
Quoted 7 lines
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 2 lines
Unlimited freedom, unlimited storage. Get it now, on
http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/
Unlimited freedom, unlimited storage. Get it now, on http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/