3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License version 2
5 # as published by the Free Software Foundation.
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
12 # You should have received a copy of the GNU General Public License
13 # along with this program; if not, write to the Free Software
14 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
22 Create a wx-style active list on stdout based on a Mercurial
23 workspace in support of webrev's Mercurial support.
27 # NB: This assumes the normal onbld directory structure
31 sys
.path
.insert(1, os
.path
.join(os
.path
.dirname(__file__
), "..", "lib",
32 "python%d.%d" % sys
.version_info
[:2]))
34 # Allow running from the source tree, using the modules in the source tree
35 sys
.path
.insert(2, os
.path
.join(os
.path
.dirname(__file__
), ".."))
37 from onbld
.Scm
import Version
40 Version
.check_version()
41 except Version
.VersionMismatch
, versionerror
:
42 sys
.stderr
.write("Error: %s\n" % versionerror
)
46 import getopt
, binascii
47 from mercurial
import error
, hg
, ui
, util
48 from onbld
.Scm
.WorkSpace
import WorkSpace
52 sys
.stderr
.write("usage: %s [-p parent] -w workspace\n" %
53 os
.path
.basename(__file__
))
59 opts
= getopt
.getopt(argv
, 'w:o:p:')[0]
60 except getopt
.GetoptError
, e
:
61 sys
.stderr
.write(str(e
) + '\n')
80 repository
= hg
.repository(ui
.ui(), wspath
)
81 except error
.RepoError
, e
:
82 sys
.stderr
.write("failed to open repository: %s\n" % e
)
85 ws
= WorkSpace(repository
)
86 act
= ws
.active(parentpath
)
88 node
= act
.parenttip
.node()
89 parenttip
= binascii
.hexlify(node
)
94 fh
= open(outputfile
, 'w')
95 except EnvironmentError, e
:
96 sys
.stderr
.write("could not open output file: %s\n" % e
)
101 fh
.write("HG_PARENT=%s\n" % parenttip
)
103 entries
= [i
for i
in act
]
106 for entry
in entries
:
107 if entry
.is_renamed() or entry
.is_copied():
108 fh
.write("%s %s\n" % (entry
.name
, entry
.parentname
))
110 fh
.write("%s\n" % entry
.name
)
113 comments
= filter(lambda x
: x
and not x
.isspace(),
118 fh
.write('%s\n' % '\n'.join(comments
))
120 fh
.write("*** NO COMMENTS ***\n")
123 if __name__
== '__main__':
126 except KeyboardInterrupt:
128 except util
.Abort
, msg
:
129 sys
.stderr
.write("Abort: %s\n" % msg
)