diff options
-rwxr-xr-x | build/util/lastchange.py | 21 | ||||
-rwxr-xr-x | webkit/build/webkit_version.py | 23 |
2 files changed, 31 insertions, 13 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 diff --git a/webkit/build/webkit_version.py b/webkit/build/webkit_version.py index 5811072..f488a2e 100755 --- a/webkit/build/webkit_version.py +++ b/webkit/build/webkit_version.py @@ -45,21 +45,24 @@ def GetWebKitRevision(webkit_dir, version_file): # "svn info" tells us what we want, but third_party/WebKit does *not* # point at the upstream repo. So instead we run svn info on the directory - # containing the versioning file (which is some subdirectory of WebKit), - # then strip that path back off of the resulting URL. + # containing the versioning file (which is some subdirectory of WebKit). version_file_dir = os.path.dirname(version_file) version_info = lastchange.FetchVersionInfo( default_lastchange=None, directory=os.path.join(webkit_dir, version_file_dir)) - # Now compute the real WebKit URL by stripping off the version file - # directory from the URL we get out of version_info. - # Further, we want to strip off the "http://svn..." from the left. - # This is the root URL from the repository. - assert version_info.url.startswith(version_info.root) - assert version_info.url.endswith(version_file_dir) - webkit_url = version_info.url[len(version_info.root):-len(version_file_dir)] - webkit_url = webkit_url.strip('/') + if (version_info.url.startswith(version_info.root) and + version_info.url.endswith(version_file_dir)): + # Now compute the real WebKit URL by stripping off the version file + # directory from the URL we get out of version_info. + # Further, we want to strip off the "http://svn..." from the left. + # This is the root URL from the repository. + webkit_url = version_info.url[len(version_info.root):-len(version_file_dir)] + webkit_url = webkit_url.strip('/') + else: + # The data isn't as we expect: perhaps they're using git without svn? + # Just dump the output directly. + webkit_url = version_info.url return "%s@%s" % (webkit_url, version_info.revision) |