diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-24 18:22:26 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-24 18:22:26 +0000 |
commit | 2f0cbb232b15ed0f1e0e05654a9caca0ae3d5290 (patch) | |
tree | 62e49efa9f282b6d8b8652893a4c3450857f3ae2 /build/util/lastchange.py | |
parent | 110785be2414b3f041bf502368bb44e212a3c975 (diff) | |
download | chromium_src-2f0cbb232b15ed0f1e0e05654a9caca0ae3d5290.zip chromium_src-2f0cbb232b15ed0f1e0e05654a9caca0ae3d5290.tar.gz chromium_src-2f0cbb232b15ed0f1e0e05654a9caca0ae3d5290.tar.bz2 |
lastchange: handle the git-but-not-git-svn case
When we're using a git checkout of WebKit that hasn't had git-svn
set up, ignore the missing versioning information rather than
failing.
BUG=70606,private mails
Review URL: http://codereview.chromium.org/6267010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72351 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/util/lastchange.py')
-rwxr-xr-x | build/util/lastchange.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/build/util/lastchange.py b/build/util/lastchange.py index 07e2a69..15c0a1f 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, @@ -71,14 +84,16 @@ def FetchVersionInfo(default_lastchange, directory=None): from some appropriate revision control system. """ version_info = FetchSVNRevision(['svn', 'info'], directory) - if not version_info: + # 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) 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 |