Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3072)

Unified Diff: build/util/lastchange.py

Issue 6354014: webkit: expose webkit branch and revision number in about pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webkit/build/webkit_version.py » ('j') | webkit/glue/webkit_glue.gypi » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/util/lastchange.py
diff --git a/build/util/lastchange.py b/build/util/lastchange.py
index 1846babac8d76c87976b562726a337c98da399f9..ef20797af237d5eca5765368ac0f8d15707b9c68 100755
--- a/build/util/lastchange.py
+++ b/build/util/lastchange.py
@@ -14,40 +14,56 @@ import subprocess
import sys
-def FetchSVNRevision(command):
+def FetchSVNRevision(command, directory):
"""
- Fetch the Subversion revision for the local tree.
+ Fetch the Subversion branch and revision for the a given directory
+ by running the given command (e.g. "svn info").
Errors are swallowed.
+
+ Returns:
+ a tuple of (url, revision) or None on error.
"""
try:
proc = subprocess.Popen(command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
+ cwd=directory,
shell=(sys.platform=='win32'))
except OSError:
# command is apparently either not installed or not executable.
return None
if proc:
- svn_re = re.compile('^Revision:\s+(\d+)', re.M)
- match = svn_re.search(proc.stdout.read())
- if match:
- return match.group(1)
+ output = proc.stdout.read()
+ match = re.search('^Revision:\s+(\d+)', output, re.M)
+ if not match:
+ return None
+ revision = match.group(1)
+
+ match = re.search('^Repository Root:\s+(\S+)', output, re.M)
+ if not match:
+ return None
+ url = match.group(1)
+
+ return (url, revision)
+
return None
-def FetchChange(default_lastchange):
+def FetchChange(default_lastchange, directory=None):
"""
- Returns the last change, from some appropriate revision control system.
+ Returns the last change (in the form of a branch, revision tuple),
+ from some appropriate revision control system.
"""
- change = FetchSVNRevision(['svn', 'info'])
+ change = FetchSVNRevision(['svn', 'info'], directory)
if not change and sys.platform in ('linux2',):
- change = FetchSVNRevision(['git', 'svn', 'info'])
+ change = FetchSVNRevision(['git', 'svn', 'info'], directory)
if not change:
if default_lastchange and os.path.exists(default_lastchange):
- change = open(default_lastchange, 'r').read().strip()
+ revision = open(default_lastchange, 'r').read().strip()
+ change = (None, revision)
else:
- change = '0'
+ change = ('', '0')
return change
@@ -90,12 +106,12 @@ def main(argv=None):
parser.print_help()
sys.exit(2)
- change = FetchChange(opts.default_lastchange)
+ url, revision = FetchChange(opts.default_lastchange)
if opts.revision_only:
- print change
+ print revision
else:
- contents = "LASTCHANGE=%s\n" % change
+ contents = "LASTCHANGE=%s\n" % revision
if out_file:
WriteIfChanged(out_file, contents)
else:
« no previous file with comments | « no previous file | webkit/build/webkit_version.py » ('j') | webkit/glue/webkit_glue.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698