Index: build/util/lastchange.py |
diff --git a/build/util/lastchange.py b/build/util/lastchange.py |
index 4d7a1fe808d4a2707c0378ddef54d3f41a267144..0c3037961ad385f880a564a3e2123af52923bc2f 100755 |
--- a/build/util/lastchange.py |
+++ b/build/util/lastchange.py |
@@ -102,117 +102,26 @@ def FetchGitRevision(directory): |
return None |
-def IsGitSVN(directory): |
- """ |
- Checks whether git-svn has been set up. |
- |
- Errors are swallowed. |
- |
- Returns: |
- whether git-svn has been set up. |
- """ |
- # To test whether git-svn has been set up, query the config for any |
- # svn-related configuration. This command exits with an error code |
- # if there aren't any matches, so ignore its output. |
- proc = RunGitCommand(directory, ['config', '--get-regexp', '^svn']) |
- if proc: |
- return (proc.wait() == 0) |
- return False |
- |
- |
-def FetchGitSVNURL(directory): |
- """ |
- Fetch URL of SVN repository bound to git. |
- |
- Errors are swallowed. |
- |
- Returns: |
- SVN URL. |
- """ |
- if IsGitSVN(directory): |
- proc = RunGitCommand(directory, ['svn', 'info', '--url']) |
- if proc: |
- output = proc.communicate()[0].strip() |
- if proc.returncode == 0: |
- match = re.search(r'^\w+://.*$', output, re.M) |
- if match: |
- return match.group(0) |
- return '' |
- |
- |
-def FetchGitSVNRoot(directory): |
- """ |
- Fetch root of SVN repository bound to git. |
- |
- Errors are swallowed. |
- |
- Returns: |
- SVN root repository. |
- """ |
- if IsGitSVN(directory): |
- git_command = ['config', '--get-regexp', '^svn-remote.svn.url$'] |
- proc = RunGitCommand(directory, git_command) |
- if proc: |
- output = proc.communicate()[0].strip() |
- if proc.returncode == 0: |
- # Zero return code implies presence of requested configuration variable. |
- # Its value is second (last) field of output. |
- match = re.search(r'\S+$', output) |
- if match: |
- return match.group(0) |
- return '' |
- |
- |
-def LookupGitSVNRevision(directory, depth): |
+def FetchGitSVNRevision(directory): |
""" |
- Fetch the Git-SVN identifier for the local tree. |
- Parses first |depth| commit messages. |
+ Fetch the SVN revision for a given directory through Git. |
Errors are swallowed. |
""" |
- if not IsGitSVN(directory): |
- return None |
- git_re = re.compile(r'^\s*git-svn-id:\s+(\S+)@(\d+)') |
- proc = RunGitCommand(directory, ['log', '-' + str(depth)]) |
+ proc = RunGitCommand(directory, ['log', '-1', |
+ '--grep=git-svn-id', '--format=%b']) |
tony
2011/06/14 18:56:31
The previous code would add -dirty to if there wer
haraken1
2011/06/15 04:20:41
Sorry. I reverted the feature.
|
if proc: |
- for line in proc.stdout: |
- match = git_re.match(line) |
+ output = proc.communicate()[0].strip() |
+ if proc.returncode == 0 and output: |
+ # Extract both the last changed SVN revision and the SVN url |
+ # git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85528 0039d316... |
+ match = re.search(r'git-svn-id: (svn://.*)@([0-9]+)', output, |
tony
2011/06/14 18:56:31
Does this always work? What if someone checked ou
haraken1
2011/06/15 04:20:41
I corrected the regular expression into 'git-svn-i
|
+ re.MULTILINE) |
Denis Lagno
2011/06/14 17:04:18
MULTILINE is redundant here
haraken1
2011/06/15 04:20:41
I removed it.
|
if match: |
- id = match.group(2) |
- if id: |
- proc.stdout.close() # Cut pipe for fast exit. |
- return id |
+ return VersionInfo(match.group(1), 'git', match.group(2)) |
Denis Lagno
2011/06/14 17:04:18
is it ok to return 'git' as SVN root?
lastchange
haraken1
2011/06/15 04:20:41
Of course, we should return the SVN root if we can
Denis Lagno
2011/06/15 12:25:34
well, it works for some checkouts (mine for exampl
haraken1
2011/06/15 16:22:53
hmmm..., my inclination is to unify the result as
|
return None |
Evan Martin
2011/06/10 17:10:14
Did you intend to include this change?
haraken1
2011/06/10 23:01:00
Yes. My intention is to extract the revision numbe
tony
2011/06/14 18:56:31
Is it possible to have tweak_info_plist just impor
haraken1
2011/06/15 04:20:41
Done.
|
-def IsGitSVNDirty(directory): |
- """ |
- Checks whether our git-svn tree contains clean trunk or some branch. |
- |
- Errors are swallowed. |
- """ |
- # For git branches the last commit message is either |
- # some local commit or a merge. |
- return LookupGitSVNRevision(directory, 1) is None |
- |
- |
-def FetchGitSVNRevision(directory): |
- """ |
- Fetch the Git-SVN identifier for the local tree. |
- |
- Errors are swallowed. |
- """ |
- # We assume that at least first 999 commit messages contain svn evidence. |
- revision = LookupGitSVNRevision(directory, 999) |
- if not revision: |
- return None |
- if IsGitSVNDirty(directory): |
- revision = revision + '-dirty' |
- url = FetchGitSVNURL(directory) |
- root = FetchGitSVNRoot(directory) |
- return VersionInfo(url, root, revision) |
- |
- |
def FetchVersionInfo(default_lastchange, directory=None): |
""" |
Returns the last change (in the form of a branch, revision tuple), |