aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2013-08-01 13:06:01 +0000
committerlloyd <[email protected]>2013-08-01 13:06:01 +0000
commit93d331a4b02bb2635eb04ee389715682cd97cf5c (patch)
treed37d63c4a2cf4b04b033bee0e242772014ad216a
parente672994f7072e4082da880a6200e0ec93afb7c0b (diff)
parentb558599476b51cedea4b8f14d6c6e1588b652a9d (diff)
merge of '19075b770dc61680a32bd34f961a0eca024062e9'
and '6d38eeb5902175eca436b0314ec203974ace879d'
-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):