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

Unified Diff: build/util/lastchange.py

Issue 6267010: lastchange: handle the git-but-not-git-svn case (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') | no next file with comments »
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 07e2a69545ae2f62653b036811c7a472e0536081..4b39a0a2df8325d2be9fd70ff0525f98886416ba 100755
--- a/build/util/lastchange.py
+++ b/build/util/lastchange.py
@@ -19,6 +19,19 @@ class VersionInfo(object):
self.revision = revision
+def IsGitSVN(directory):
+ """Return true if the directory is managed by git-svn."""
+
+ # 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.
+ status = subprocess.call(['git', 'config', '--get-regexp', '^svn'],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ cwd=directory)
+ return status == 0
+
+
def FetchSVNRevision(command, directory):
"""
Fetch the Subversion branch and revision for the a given directory
@@ -35,7 +48,7 @@ def FetchSVNRevision(command, directory):
# We can't just pass shell=True to Popen, as under win32 this will
# cause CMD to be used, while we explicitly want a cygwin shell.
if sys.platform in ('cygwin', 'win32'):
- command = [ 'sh', '-c', ' '.join(command) ];
+ command = ['sh', '-c', ' '.join(command)]
try:
proc = subprocess.Popen(command,
stdout=subprocess.PIPE,
@@ -72,13 +85,16 @@ def FetchVersionInfo(default_lastchange, directory=None):
"""
version_info = FetchSVNRevision(['svn', 'info'], directory)
if not version_info:
- version_info = FetchSVNRevision(['git', 'svn', 'info'], directory)
+ # Check that this is a git-svn repo before running 'git svn info',
+ # as that will hang if not.
+ if IsGitSVN(directory):
tony 2011/01/24 17:57:44 Nit: Maybe merge this condition with the 'not vers
+ version_info = FetchSVNRevision(['git', 'svn', 'info'], directory)
if not version_info:
if default_lastchange and os.path.exists(default_lastchange):
revision = open(default_lastchange, 'r').read().strip()
version_info = VersionInfo(None, None, revision)
else:
- version_info = VersionInfo('', '', '0')
+ version_info = VersionInfo('unknown', '', '0')
return version_info
« no previous file with comments | « no previous file | webkit/build/webkit_version.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698