{"thread":{"id":"15471","subject":"Fw: PATCH: git-p4 optional handling of RCS keywords [was: Re: git-p4 and keyword expansion]","startedAt":"2008-09-10T05:20:30Z","lastAt":"2008-09-10T05:20:30Z","messageCount":1,"participants":["dhruva"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"90312","messageId":"972463.79535.qm@web95005.mail.in2.yahoo.com","threadId":"15471","inReplyTo":null,"subject":"Fw: PATCH: git-p4 optional handling of RCS keywords [was: Re: git-p4 and keyword expansion]","fromName":"dhruva","fromEmail":"dhruva@ymail.com","sentAt":"2008-09-10T05:20:30Z","receivedAt":"2008-09-10T05:20:30Z","isPatch":false,"sender":{"key":"dhruva@ymail.com","avatar":null},"body":"For some reason, my mail did not go through the git mailing list, I am resending. Please excuse if it is a duplicate!\n\n\n\n----- Forwarded Message ----\n> From: dhruva <dhruva@ymail.com>\n> To: Simon Hausmann <simon@lst.de>\n> Cc: GIT SCM <git@vger.kernel.org>; Jing Xue <jingxue@digizenstudio.com>\n> Sent: Wednesday, 10 September, 2008 10:48:23 AM\n> Subject: Re: PATCH: git-p4 optional handling of RCS keywords [was: Re: git-p4 and keyword expansion]\n> \n> My earlier patch has an error... (I have almost always stumbled on first patch!)\n> \n> here is the fixed one:\n> \n> diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\n> index 2216cac..c67b2e5 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,10 +978,11 @@ 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> -                text = re.sub(r'(?i)\\$(Id|Header):[^$]*\\$',r'$\\1$', text)\n> -            elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', \n> 'binary+k'):\n> -                text = \n> re.sub(r'\\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\\$',r'$\\1$', \n> text)\n> +            if kwstrip:\n> +                if 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', \n> 'binary+k'):\n> +                    text = \n> re.sub(r'\\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\\$',r'$\\1$', \n> text)\n> \n>              contents[stat['depotFile']] = text\n> \n> @@ -1850,6 +1854,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 \"false\" == kwval:\n> +            kwstrip = False\n> +        elif \"true\" == kwval:\n> +            kwstrip = True\n> +\n>      if cmd.needsGit:\n>          if cmd.gitdir == None:\n>              cmd.gitdir = os.path.abspath(\".git\")\n> \n> \n> \n> -dhruva\n> \n> \n> ----- Original Message ----\n> > From: dhruva \n> > To: Simon Hausmann \n> > Cc: GIT SCM ; Jing Xue \n> > Sent: Wednesday, 10 September, 2008 10:43:26 AM\n> > Subject: PATCH: git-p4 optional handling of RCS keywords [was: Re: git-p4 and \n> keyword expansion]\n> > \n> > Hello,\n> > I would like to submit my first patch to the git community.\n> > \n> > I have introduced a new configuration option to 'git-p4' \"kwstrip\". If \n> enabled, \n> > the RCS keywords gets unexpanded like it is done with out the patch and \n> > disabling it explicitly retains the RCS keywords as in the original p4 source. \n> \n> > The default (in the absence) is 'false' to ensure backward compatibility. To \n> > override, you can put the following lines in your '.gitconfig' file..\n> > \n> > [git-p4]\n> >         kwstrip = false\n> > \n> > \n> > \n> > The patch to git-p4 (based on origin/next branch):\n> > \n> > diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\n> > index 2216cac..ad37d0b 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,10 +978,11 @@ 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> > -                text = re.sub(r'(?i)\\$(Id|Header):[^$]*\\$',r'$\\1$', text)\n> > -            elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', \n> > 'binary+k'):\n> > -                text = \n> > \n> re.sub(r'\\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\\$',r'$\\1$', \n> \n> > text)\n> > +            if kwstrip:\n> > +                if 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', \n> 'unicode+k', \n> > 'binary+k'):\n> > +                    text = \n> > \n> re.sub(r'\\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\\$',r'$\\1$', \n> \n> > text)\n> > \n> >              contents[stat['depotFile']] = text\n> > \n> > @@ -1850,6 +1854,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 \"false\" == kwval:\n> > +            kwstrip = False\n> > +        else if \"true\" == kwval:\n> > +            kwstrip = True\n> > +\n> >      if cmd.needsGit:\n> >          if cmd.gitdir == None:\n> >              cmd.gitdir = os.path.abspath(\".git\")\n> > \n> > \n> > \n> > ----- Original Message ----\n> > > From: Jing Xue \n> > > To: dhruva \n> > > Cc: GIT SCM \n> > > Sent: Tuesday, 9 September, 2008 11:08:48 PM\n> > > Subject: Re: git-p4 and keyword expansion\n> > > \n> > > On Tue, Sep 09, 2008 at 04:44:11PM +0530, dhruva wrote:\n> > > > Hello,\n> > > \n> > > Hi,\n> > > \n> > > > I feel the configuration must be set the first time only, when you\n> > > > clone using 'git-p4 clone'. Altering it in between will be very\n> > > > confusing!\n> > > > Ideally, the setting must be transferred when the git repo\n> > > > (cloned from git-p4) is cloned using standard git. Is it something\n> > > > possible (well, I am new to git and am exploring. Any extra\n> > > > information would help).\n> > > >\n> > > > My proposal is as follows:\n> > > > 1. Add an extra command line argument to 'git-p4 clone' to either  \n> > > > enable/disable keyword expansion\n> > > > 2. Store that information under the .git folder in a file that is  \n> > > > copied when someone clones that repo\n> > > > 3. Use the stored information in future 'git-p4 sync/rebase'\n> > > \n> > > Any way to make it optional would be welcome by me.\n> > \n> > Done\n> > \n> > \n> > > If you do come up with a \"formal\" patch, you might want to\n> > > explicitly add Simon Hausmann to the To list, for he's the git-p4\n> > > author.\n> > \n> > Done\n> > \n> > -dhruva\n> > \n> > \n> > \n> >       Add more friends to your messenger and enjoy! Go to \n> > http://in.messenger.yahoo.com/invite/\n> > \n> > --\n> > To unsubscribe from this list: send the line \"unsubscribe git\" in\n> > the body of a message to majordomo@vger.kernel.org\n> > More majordomo info at  http://vger.kernel.org/majordomo-info.html\n> \n> \n> \n>       Unlimited freedom, unlimited storage. Get it now, on \n> http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/\n\n\n\n      Unlimited freedom, unlimited storage. Get it now, on http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/\n"}]}