summaryrefslogtreecommitdiff
path: root/usr/src/tools/scripts/hg-active.py
diff options
context:
space:
mode:
authorMark J. Nelson <Mark.J.Nelson@Sun.COM>2008-08-06 16:29:39 -0600
committerMark J. Nelson <Mark.J.Nelson@Sun.COM>2008-08-06 16:29:39 -0600
commit9a70fc3be3b1e966bf78825cdb8d509963a6f0a1 (patch)
tree37cd6d18c9cdf3a8d6012e657cd17a9783f5a182 /usr/src/tools/scripts/hg-active.py
parent733c059aa6d54dc62d25850c71f71091e10d0aaa (diff)
downloadillumos-joyent-9a70fc3be3b1e966bf78825cdb8d509963a6f0a1.tar.gz
6733918 Teamware has retired, please welcome your new manager, Mercurial
4758439 some files use "current date" sccs keywords 6560843 asm sources should not rely on .file "%M%" for naming STT_FILE symbols 6560958 Solaris:: perl modules should not use SCCS keywords in version information 6729074 webrev doesn't deal well with remote ssh hg parents
Diffstat (limited to 'usr/src/tools/scripts/hg-active.py')
-rw-r--r--usr/src/tools/scripts/hg-active.py39
1 files changed, 27 insertions, 12 deletions
diff --git a/usr/src/tools/scripts/hg-active.py b/usr/src/tools/scripts/hg-active.py
index 192cf3b7aa..2617d745a2 100644
--- a/usr/src/tools/scripts/hg-active.py
+++ b/usr/src/tools/scripts/hg-active.py
@@ -18,8 +18,6 @@
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
-#
'''
Create a wx-style active list on stdout based on a Mercurial
@@ -42,7 +40,7 @@ except Version.VersionMismatch, e:
sys.exit(1)
import getopt, binascii
-from mercurial import hg, repo
+from mercurial import hg, repo, util
from onbld.Scm.WorkSpace import WorkSpace
def usage():
@@ -52,17 +50,20 @@ def usage():
def main(argv):
try:
- opts, args = getopt.getopt(argv, 'w:p:')
+ opts = getopt.getopt(argv, 'w:o:p:')[0]
except getopt.GetoptError, e:
sys.stderr.write(str(e) + '\n')
usage()
parentpath = None
wspath = None
+ outputfile = None
for opt, arg in opts:
if opt == '-w':
wspath = arg
+ elif opt == '-o':
+ outputfile = arg
elif opt == '-p':
parentpath = arg
@@ -74,36 +75,50 @@ def main(argv):
except repo.RepoError, e:
sys.stderr.write("failed to open repository: %s\n" % e)
sys.exit(1)
-
+
ws = WorkSpace(repository)
act = ws.active(parentpath)
node = act.parenttip.node()
parenttip = binascii.hexlify(node)
- print "HG_PARENT=" + parenttip
+
+ fh = None
+ if outputfile:
+ try:
+ fh = open(outputfile, 'w')
+ except EnvironmentError, e:
+ sys.stderr.write("could not open output file: %s\n" % e)
+ sys.exit(1)
+ else:
+ fh = sys.stdout
+
+ fh.write("HG_PARENT=%s\n" % parenttip)
entries = [i for i in act]
entries.sort()
for entry in entries:
if entry.is_renamed():
- print "%s %s" % (entry.name, entry.parentname)
+ fh.write("%s %s\n" % (entry.name, entry.parentname))
else:
- print entry.name
+ fh.write("%s\n" % entry.name)
# Strip blank lines.
comments = filter(lambda x: x and not x.isspace(),
entry.comments)
- print
+ fh.write('\n')
if comments:
- print '\n'.join(comments)
+ fh.write('%s\n' % '\n'.join(comments))
else:
- print "*** NO COMMENTS ***"
- print
+ fh.write("*** NO COMMENTS ***\n")
+ fh.write('\n')
if __name__ == '__main__':
try:
main(sys.argv[1:])
except KeyboardInterrupt:
sys.exit(1)
+ except util.Abort, msg:
+ sys.stderr.write("Abort: %s\n" % msg)
+ sys.exit(1)