summaryrefslogtreecommitdiffstats
path: root/build/util
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-26 19:19:07 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-26 19:19:07 +0000
commit975daed58cc20d3b40e7feda4123ceeb05188260 (patch)
treeb9cacc56b0618da60f09554b53db18dfe8b2ad43 /build/util
parent4b2866b35e1d220636b5b732ba78b1d9fe6e385e (diff)
downloadchromium_src-975daed58cc20d3b40e7feda4123ceeb05188260.zip
chromium_src-975daed58cc20d3b40e7feda4123ceeb05188260.tar.gz
chromium_src-975daed58cc20d3b40e7feda4123ceeb05188260.tar.bz2
lastchange: give up on git-svn
Just put the git hash in the revision fields. Developers who are using git aren't making releases. BUG=70909 Review URL: http://codereview.chromium.org/6348023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72661 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/util')
-rwxr-xr-xbuild/util/lastchange.py53
1 files changed, 24 insertions, 29 deletions
diff --git a/build/util/lastchange.py b/build/util/lastchange.py
index a530474..8376b54 100755
--- a/build/util/lastchange.py
+++ b/build/util/lastchange.py
@@ -18,38 +18,20 @@ class VersionInfo(object):
self.root = root
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.
- try:
- status = subprocess.call(['git', 'config', '--get-regexp', '^svn'],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- cwd=directory)
- return status == 0
- except OSError:
- return False
-
-
-def FetchSVNRevision(command, directory):
+def FetchGitRevision(directory):
"""
- Fetch the Subversion branch and revision for the a given directory
- by running the given command (e.g. "svn info").
+ Fetch the Git hash for the a given directory.
Errors are swallowed.
Returns:
a VersionInfo object or None on error.
"""
-
# Force shell usage under cygwin & win32. This is a workaround for
# mysterious loss of cwd while invoking cygwin's git.
# 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.
+ command = ['git', 'rev-parse', 'HEAD']
if sys.platform in ('cygwin', 'win32'):
command = ['sh', '-c', ' '.join(command)]
try:
@@ -58,6 +40,25 @@ def FetchSVNRevision(command, directory):
stderr=subprocess.PIPE,
cwd=directory)
except OSError:
+ return None
+ return VersionInfo('git', 'git', proc.stdout.read().strip()[:7])
+
+
+def FetchSVNRevision(directory):
+ """
+ Fetch the Subversion branch and revision for the a given directory.
+
+ Errors are swallowed.
+
+ Returns:
+ a VersionInfo object or None on error.
+ """
+ try:
+ proc = subprocess.Popen(['svn', 'info'],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ cwd=directory)
+ except OSError:
# command is apparently either not installed or not executable.
return None
if not proc:
@@ -66,9 +67,7 @@ def FetchSVNRevision(command, directory):
attrs = {}
for line in proc.stdout:
line = line.strip()
- # git-svn can print out extra "Rebuilding ..." lines, which we don't
- # care about and want to skip over.
- if not line or ': ' not in line:
+ if not line:
continue
key, val = line.split(': ', 1)
attrs[key] = val
@@ -88,11 +87,7 @@ def FetchVersionInfo(default_lastchange, directory=None):
Returns the last change (in the form of a branch, revision tuple),
from some appropriate revision control system.
"""
- version_info = FetchSVNRevision(['svn', 'info'], directory)
- # N.B. test for git-svn before trying 'git svn info', as the info
- # command will hang if git-svn hasn't been set up.
- if not version_info and IsGitSVN(directory):
- version_info = FetchSVNRevision(['git', 'svn', 'info'], directory)
+ version_info = FetchSVNRevision(directory) or FetchGitRevision(directory)
if not version_info:
if default_lastchange and os.path.exists(default_lastchange):
revision = open(default_lastchange, 'r').read().strip()