Bug 55024

Summary: fix svn revision number finding when creating git patches
Product: WebKit Reporter: Ojan Vafai <ojan>
Component: New BugsAssignee: Ojan Vafai <ojan>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, aroben, eric, evan, kalman
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Other   
OS: OS X 10.5   
Attachments:
Description Flags
Patch tony: review+

Description Ojan Vafai 2011-02-22 23:34:35 PST
fix revision number finding when creating git patches
Comment 1 Ojan Vafai 2011-02-22 23:36:49 PST
Created attachment 83452 [details]
Patch
Comment 2 Adam Barth 2011-02-23 01:19:58 PST
Obligatory deferring to evmar.  :)
Comment 3 Adam Roben (:aroben) 2011-02-23 08:07:09 PST
Comment on attachment 83452 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=83452&action=review

> Tools/Scripts/webkitpy/common/checkout/scm.py:752
> +        git_log = self.run(['git', 'log', '-10'])
> +        match = re.search("^\s*git-svn-id:.*@(?P<svn_revision>\d+)\ .*$", git_log, re.MULTILINE)
> +        if not match:

I think you can just use "git svn info". It seems to work at least in simple cases. I haven't tried it with a merge commit, though.
Comment 4 Evan Martin 2011-02-23 09:41:24 PST
Here's how this is done within git-svn (as translated into my python).
git-svn doesn't have the -100 limit.

http://neugierig.org/software/git/?url=git-cl/tree/git-cl#n143

142	        # The -100 is an arbitrary limit so we don't search forever.
143	        cmd = ['git', 'log', '-100', '--pretty=medium']
144	        proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
145	        for line in proc.stdout:
146	          match = git_svn_re.match(line)
147	          if match:
148	            url = match.group(1)
151	            proc.stdout.close()  # Cut pipe.
152	            break


I think Ojan's is probably fine too though.

"git svn info" will fail if you have a git checkout that isn't a git-svn checkout.  Not sure if that applies here.
Comment 5 Tony Chang 2011-02-23 10:37:44 PST
Comment on attachment 83452 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=83452&action=review

This or evan's version looks fine.

> Tools/Scripts/webkitpy/common/checkout/scm.py:751
> +        match = re.search("^\s*git-svn-id:.*@(?P<svn_revision>\d+)\ .*$", git_log, re.MULTILINE)

Nit: I'm not sure the .*$ gives you anything (aren't you always going to have something before the end of the line?)
Comment 6 Ojan Vafai 2011-02-23 22:27:25 PST
(In reply to comment #4)
> 142            # The -100 is an arbitrary limit so we don't search forever.
> 143            cmd = ['git', 'log', '-100', '--pretty=medium']

I wasn't sure what limit to set. 10 is probably too small. I'll make it 25 for now.

> "git svn info" will fail if you have a git checkout that isn't a git-svn checkout. 

Right.
Comment 7 Ojan Vafai 2011-02-24 00:14:13 PST
Committed r79520: <http://trac.webkit.org/changeset/79520>