PATCH: git-p4 optional handling of RCS keywords
Hello,
Commit message: Modifying RCS keywords prevents submitting to p4 from git due to missing hunks. Optional shrinking of RCS keywords in git-p4. New option git-p4.kwstrip set to true or false controls the behavior..
contrib/fast-import/git-p4 +16 -1
@@ -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,7 +978,9 @@ 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'): + if not kwstrip: + pass + elif 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)
@@ -1850,6 +1855,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 kwval == "false": + kwstrip = False + elif kwval == "true": + kwstrip = True + if cmd.needsGit: if cmd.gitdir == None: cmd.gitdir = os..path.abspath(".git")
-dhruva
----- Original Message ----
Quoted 9 lines
From: Simon Hausmann <[email protected]>
Review
Quoted 5 lines
(quoted diff) +5
-0+ kwval = kwval.lower(); + if "false" == kwval: + kwstrip = False + elif "true" == kwval: + kwstrip = TrueI have another style nitpick, sorry :). Please use "kwval == "false" instead of the other way around.
There was a reason for keeping the constant as lvalue to avoid typos like '=' instead from '==' from 'C' school, I realize that python throws an error when such things happen. Must say that programming languages are becoming smarter and taking away the charm of programming...
Quoted 2 lines
Otherwise your patch looks good to me, I think it's a very good option to add. Please resend with commit message so that Junio can include it.
Add more friends to your messenger and enjoy! Go to http://in.messenger.yahoo.com/invite/
Quoted 4 lines · dhruva
Hello,
Commit message: Modifying RCS keywords prevents submitting to p4 from git due to missing hunks. Optional shrinking of RCS keywords in git-p4. New option git-p4.kwstrip set to true or false controls the behavior..
<snip away the diff>
Me guesses that Junio (who gets loads of patches) would be happy if you do:
1) Squash these changes down to one single commit
2) Run git format-patch -1
3) Send it to the list either with git send-email, or otherwise send the 0001-<your-commit-summary>.patch to the list directly if your mailer supports it.
The reason is simply that the maintainer can simply use git am <your-raw-mail-message-file> to commit it, instead of having to manually sift through the emails.
Otherwise, this is nice work. Thanks.
-Tor Arvid-