threads / patch / 15526

patchOptional shrinking of RCS keywords in git-p4

Subject: [PATCH] Optional shrinking of RCS keywords in git-p4

## tl;dr

3 messages between Sep 15, 2008 and Sep 15, 2008. Diffs are folded; open one to read it.

replies: 2people: 3as markdown or json

Dhruva Krishnamurthy· Sep 15, 2008, 05:58 UTC · lore

Modifying RCS keywords prevents submitting to p4 from git due to missing hunks. New option git-p4.kwstrip set to true or false controls the behavior.

Signed-off-by: Dhruva Krishnamurthy <dhruva@ymail.com>
---
 contrib/fast-import/git-p4 |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
Show changes to contrib/fast-import/git-p4 +16 −1
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 2216cac..ac8b7f7 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,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")
-- 
1.6.0.1.454.g63d55
David Brown· Sep 15, 2008, 06:09 UTC · re: Dhruva Krishnamurthy · lore

Re: [PATCH] Optional shrinking of RCS keywords in git-p4

On Mon, Sep 15, 2008 at 11:28:51AM +0530, Dhruva Krishnamurthy wrote:
>Modifying RCS keywords prevents submitting to p4 from git due to missing hunks.
>New option git-p4.kwstrip set to true or false controls the behavior.

I'm a little curious about what the problem here is. I've been stripping keywords out of P4 and submitting changes for many years, and never had a problem.

I'm just wondering if we're not fixing the wrong problem here.
David
Junio C Hamano· Sep 15, 2008, 06:17 UTC · re: Dhruva Krishnamurthy · lore

Re: [PATCH] Optional shrinking of RCS keywords in git-p4

Dhruva Krishnamurthy <dhruva@ymail.com> writes:
> Modifying RCS keywords prevents submitting to p4 from git due to missing hunks.
Hmm.  How are "missing hunks" caused?  Do you mean:
 - the substituted values from the expanded keywords are stripped out by
   default (with kwstrip=True) when you check out from p4;
 - when you submit your changes back, p4 side expects you to send the file
   with keywords just as it originally expanded;
and this causes the contents mismatch, leading p4 to reject your change?

The patch itself looks fine; I just wanted to make sure commit log explains what was fixed.

← back to recent threads