git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pete Wyckoff <pw@padd.com>
To: Luke Diamand <luke@diamand.org>
Cc: git@vger.kernel.org, Eric Scouten <eric@scouten.com>
Subject: Re: [PATCHv3] git-p4: add initial support for RCS keywords
Date: Tue, 21 Feb 2012 07:18:34 -0500	[thread overview]
Message-ID: <20120221121834.GB18317@padd.com> (raw)
In-Reply-To: <1329258835-17223-2-git-send-email-luke@diamand.org>

luke@diamand.org wrote on Tue, 14 Feb 2012 22:33 +0000:
> diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt
[..]
> +git-p4.attemptRCSCleanup:
> +    If enabled, 'git p4 submit' will attempt to sort cleanup RCS keywords
> +    ($Header$, etc). These would otherwise cause merge conflicts and prevent
> +    the submit going ahead. This option should be considered experimental at
> +    present.

=> "attempt to cleanup"

> diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
[..]
> +#
> +# return the raw p4 type of a file (text, text+ko, etc)
> +#
> +def p4_type(file):
> +    files = p4_read_pipe_lines(["files", file])
> +    info = files[0]
> +    m = re.search(r'\(([a-z0-9A-Z+]+)\)\s*$', info)
> +    if m:
> +        ret = m.group(1)
> +        if verbose:
> +            print "%s => %s" % (file, ret)
> +        return ret
> +    else:
> +        die("Could not extract file type from '%s'" % info)

p4 fstat -T headType
gives just the type, no need to parse the info string

> +#
> +# Given a type base and modifier, return a regexp matching
> +# the keywords that can be expanded in the file
> +#
> +def p4_keywords_regexp_for_type(base, type_mods):
> +    if base in ("text", "unicode", "binary"):
> +        if "ko" in type_mods:
> +            return r'\$(Id|Header)[^$]*\$'
> +        elif "k" in type_mods:
> +            return r'\$(Id|Header|Author|Date|DateTime|Change|File|Revision)[^$]*\$'

Still no ":"?  Won't that match too much?

> +    def patchRCSKeywords(self, file, pattern):

Nice, clean.

>      def p4UserForCommit(self,id):
[..]
> +                for line in read_pipe_lines(diffcmd):
> +                    # read diff lines: for each file reported, if it can have
> +                    # keywords expanded, and the diff contains keywords, then
> +                    # try zapping the p4 file.
> +                    m = re.match(r'^diff --git a/(.*)\s+b/(.*)', line)

I'm still sort of iffy on this.  You have editedFiles, and could
just use that directly.  Grepping through the diff won't give you
any more information.

> +                    if pattern:
> +                        print line

Debugging?  Maybe add a leading comment saying why this line.

> @@ -1585,15 +1685,11 @@ class P4Sync(Command, P4UserMap):
>  
>          # Note that we do not try to de-mangle keywords on utf16 files,
>          # even though in theory somebody may want that.
> -        if type_base in ("text", "unicode", "binary"):
> -            if "ko" in type_mods:
> -                text = ''.join(contents)
> -                text = re.sub(r'\$(Id|Header):[^$]*\$', r'$\1$', text)
> -                contents = [ text ]
> -            elif "k" in type_mods:
> -                text = ''.join(contents)
> -                text = re.sub(r'\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$', r'$\1$', text)
> -                contents = [ text ]
> +        pattern = p4_keywords_regexp_for_type(type_base, type_mods)
> +        if pattern:
> +            text = ''.join(contents)
> +            text = re.sub(pattern, r'$\1$', text)
> +            contents = [ text ]

Nice.  Glad you refactored this.

Fix the colon thing at least, then happy to add my Acked-By.

Sorry for the delay.

		-- Pete

  parent reply	other threads:[~2012-02-21 12:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-14 22:33 [PATCHv3] git-p4: RCS keyword handling Luke Diamand
2012-02-14 22:33 ` [PATCHv3] git-p4: add initial support for RCS keywords Luke Diamand
2012-02-14 22:58   ` Junio C Hamano
2012-02-21 12:18   ` Pete Wyckoff [this message]
2012-02-21 16:54     ` Eric Scouten
2012-02-21 17:25       ` Junio C Hamano
2012-02-21 17:59         ` Eric Scouten

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120221121834.GB18317@padd.com \
    --to=pw@padd.com \
    --cc=eric@scouten.com \
    --cc=git@vger.kernel.org \
    --cc=luke@diamand.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).