From 5f3a7fa6f3ba45d875ec437c5df9e712f3c6b5a2 Mon Sep 17 00:00:00 2001 From: Bryan O'Sullivan Date: Tue, 1 Sep 2009 11:18:33 -0700 Subject: Patch in some other useful scripts from trunk. --- indra/lib/python/indra/util/llversion.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'indra/lib') diff --git a/indra/lib/python/indra/util/llversion.py b/indra/lib/python/indra/util/llversion.py index 770b861ddc..c48ab679f4 100644 --- a/indra/lib/python/indra/util/llversion.py +++ b/indra/lib/python/indra/util/llversion.py @@ -1,7 +1,7 @@ """@file llversion.py @brief Utility for parsing llcommon/llversion${server}.h for the version string and channel string - Utility that parses svn info for branch and revision + Utility that parses hg or svn info for branch and revision $LicenseInfo:firstyear=2006&license=mit$ @@ -79,8 +79,8 @@ def get_svn_status_matching(regular_expression): status, output = commands.getstatusoutput('svn info %s' % get_src_root()) m = regular_expression.search(output) if not m: - print "Failed to parse svn info output, resultfollows:" - print output + print >> sys.stderr, "Failed to parse svn info output, result follows:" + print >> sys.stderr, output raise Exception, "No matching svn status in "+src_root return m.group(1) @@ -92,4 +92,25 @@ def get_svn_revision(): last_rev_re = re.compile('Last Changed Rev: (\d+)') return get_svn_status_matching(last_rev_re) - +def get_hg_repo(): + status, output = commands.getstatusoutput('hg showconfig paths.default') + if status: + print >> sys.stderr, output + sys.exit(1) + if not output: + print >> sys.stderr, 'ERROR: cannot find repo we cloned from' + sys.exit(1) + return output + +def get_hg_changeset(): + status, output = commands.getstatusoutput('hg id -i') + if status: + print >> sys.stderr, output + sys.exit(1) + return output + +def using_svn(): + return os.path.isdir(os.path.join(get_src_root(), '.svn')) + +def using_hg(): + return os.path.isdir(os.path.join(get_src_root(), '.hg')) -- cgit v1.2.3 From dd628f29af0fcd0ec5f62ee71fc201c1e523a32a Mon Sep 17 00:00:00 2001 From: Bryan O'Sullivan Date: Tue, 1 Sep 2009 11:54:34 -0700 Subject: Use rev numbers instead of changeset IDs for now. --- indra/lib/python/indra/util/llversion.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'indra/lib') diff --git a/indra/lib/python/indra/util/llversion.py b/indra/lib/python/indra/util/llversion.py index c48ab679f4..2718a85f41 100644 --- a/indra/lib/python/indra/util/llversion.py +++ b/indra/lib/python/indra/util/llversion.py @@ -103,11 +103,21 @@ def get_hg_repo(): return output def get_hg_changeset(): - status, output = commands.getstatusoutput('hg id -i') + # The right thing to do: + # status, output = commands.getstatusoutput('hg id -i') + # if status: + # print >> sys.stderr, output + # sys.exit(1) + + # The temporary hack: + status, output = commands.getstatusoutput('hg parents --template "{rev}"') if status: print >> sys.stderr, output sys.exit(1) - return output + lines = output.splitlines() + if len(lines) > 1: + print >> sys.stderr, 'ERROR: working directory has %d parents' % len(lines) + return lines[0] def using_svn(): return os.path.isdir(os.path.join(get_src_root(), '.svn')) -- cgit v1.2.3