aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2013-07-31 16:01:45 +0000
committerlloyd <[email protected]>2013-07-31 16:01:45 +0000
commitb558599476b51cedea4b8f14d6c6e1588b652a9d (patch)
tree48219f9a9acaf75b8045d5e9c19e7f27eb163a57
parent7818291494c0dbc159c9dc8bd301ba9c6139156a (diff)
If we can't get a revid from monotone, try git as well.
-rwxr-xr-xconfigure.py51
1 files changed, 32 insertions, 19 deletions
diff --git a/configure.py b/configure.py
index 011f16c06..78d8aa2bd 100755
--- a/configure.py
+++ b/configure.py
@@ -42,30 +42,43 @@ def flatten(l):
return sum(l, [])
def get_vc_revision():
- try:
- mtn = subprocess.Popen(['mtn', 'automate', 'heads'],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- universal_newlines=True)
- (stdout, stderr) = mtn.communicate()
+ def get_vc_revision(cmdlist):
+ try:
+ cmdname = cmdlist[0]
- if mtn.returncode != 0:
- logging.debug('Error getting rev from monotone - %d (%s)'
- % (mtn.returncode, stderr))
- return 'unknown'
+ vc = subprocess.Popen(cmdlist,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ universal_newlines=True)
- rev = str(stdout).strip()
- logging.debug('Monotone reported revision %s' % (rev))
+ (stdout, stderr) = vc.communicate()
- return 'mtn:' + rev
- except OSError as e:
- logging.debug('Error getting rev from monotone - %s' % (e[1]))
- return 'unknown'
- except Exception as e:
- logging.debug('Error getting rev from monotone - %s' % (e))
- return 'unknown'
+ if vc.returncode != 0:
+ logging.debug('Error getting rev from %s - %d (%s)'
+ % (cmdname, vc.returncode, stderr))
+ return None
+
+ rev = str(stdout).strip()
+ logging.debug('%s reported revision %s' % (cmdname, rev))
+
+ return '%s:%s' % (cmdname, rev)
+ except OSError as e:
+ logging.debug('Error getting rev from %s - %s' % (cmdname, e.strerror))
+ return None
+ except Exception as e:
+ logging.debug('Error getting rev from %s - %s' % (cmdname, e))
+ return None
+
+ vc_commands = [['mtn', 'automate', 'heads'],
+ ['git', 'rev-parse', 'HEAD']]
+
+ for vc_cmd in vc_commands:
+ rev = get_vc_revision(vc_cmd)
+ if rev is not None:
+ return rev
+ return 'unknown'
class BuildConfigurationInformation(object):