git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: PATCH: git-p4 optional handling of RCS keywords

From
Simon Hausmann <simon@lst.de>
Date
Sep 10, 2008, 19:18 UTC
Message-ID
<200809102119.01630.simon@lst.de>
In-Reply-To
<646617.59689.qm@web95011.mail.in2.yahoo.com>
On Wednesday 10 September 2008 08:29:56 dhruva wrote:
Show 42 quoted lines
> Hi,
>  Incorporated the style tip, sure makes it look cleaner.
>
> diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
> index 2216cac..3e72e43 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 "false" == kwval:
> +            kwstrip = False
> +        elif "true" == kwval:
> +            kwstrip = True

I have another style nitpick, sorry :). Please use "kwval == "false" instead of the other way around.

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.

Simon
Message 1 of 1 in “Re: PATCH: git-p4 optional handling of RCS keywords”
  1. Simon HausmannSep 10, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.