{"thread":{"id":"15489","subject":"Re: PATCH: git-p4 optional handling of RCS keywords","startedAt":"2008-09-11T09:18:52Z","lastAt":"2008-09-11T09:18:52Z","messageCount":1,"participants":["dhruva"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"90430","messageId":"680862.54393.qm@web95006.mail.in2.yahoo.com","threadId":"15489","inReplyTo":null,"subject":"Re: PATCH: git-p4 optional handling of RCS keywords","fromName":"dhruva","fromEmail":"dhruva@ymail.com","sentAt":"2008-09-11T09:18:52Z","receivedAt":"2008-09-11T09:18:52Z","isPatch":false,"sender":{"key":"dhruva@ymail.com","avatar":null},"body":">From aa822b35925b893de049b6cc4d1531dc476ade56 Mon Sep 17 00:00:00 2001\nFrom: Dhruva Krishnamurthy <dhruva@siml6.eng.btc.netapp.in>\nDate: Thu, 11 Sep 2008 14:36:32 +0530\nSubject: [PATCH] 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\n\n\nSigned-off-by: Dhruva Krishnamurthy <dhruva@ymail.com>\n---\n contrib/fast-import/git-p4 |   17 ++++++++++++++++-\n 1 files changed, 16 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex 2216cac..ac8b7f7 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -16,6 +16,9 @@ from sets import Set;\n\n verbose = False\n\n+# Handling of RCS keyowrds. To ensure backward compatibility, the default\n+# is to strip keywords. Default behavior is controlled here\n+kwstrip = True\n\n def p4_build_cmd(cmd):\n     \"\"\"Build a suitable p4 command line.\n@@ -975,7 +978,9 @@ class P4Sync(Command):\n                 sys.stderr.write(\"p4 print fails with: %s\\n\" % repr(stat))\n                 continue\n\n-            if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):\n+            if not kwstrip:\n+               pass\n+            elif stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):\n                 text = re.sub(r'(?i)\\$(Id|Header):[^$]*\\$',r'$\\1$', text)\n             elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'binary+k'):\n                 text = re.sub(r'\\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\\$',r'$\\1$', text)\n@@ -1850,6 +1855,16 @@ def main():\n         (cmd, args) = parser.parse_args(sys.argv[2:], cmd);\n     global verbose\n     verbose = cmd.verbose\n+\n+    global kwstrip\n+    kwval = gitConfig(\"git-p4.kwstrip\")\n+    if len(kwval) > 0:\n+       kwval = kwval.lower();\n+        if kwval == \"false\":\n+            kwstrip = False\n+        elif kwval == \"true\":\n+            kwstrip = True\n+\n     if cmd.needsGit:\n         if cmd.gitdir == None:\n             cmd.gitdir = os.path.abspath(\".git\")\n--\n1.6.0.1.442.g17b2f\n\n-dhruva\n\n\n\n      Get an email ID as yourname@ymail.com or yourname@rocketmail.com. Click here http://in.promos.yahoo.com/address\n"}]}