3 # The output of this script is a splicemap.
5 # A splicemap is used by the mercurial 'convert' extension to direct its
8 # The script assumes you already have a destination repository
9 # containing a conversion somewhere in its history, but that you've
10 # possibly mixed some new commits on top of that conversion. It outputs
11 # a splicemap that picks up the conversion where it left off (with the
12 # first descendant, in the source repo, of the src rev given by --start,
13 # if or rather the first descendant that would be included by the
14 # conversion's filemap) and connects them to the current tip of the
18 from mercurial import ui, hg
19 from hgext.convert.filemap import filemapper
20 from optparse import OptionParser
24 parser = OptionParser()
26 parser.add_option("-s", "--src", dest="src",
27 help="source repository", metavar="REPO")
29 parser.add_option("-d", "--dst", dest="dst",
30 help="destination repository", metavar="REPO")
32 parser.add_option("-t", "--start", dest="start",
33 help="starting revid in source repository", metavar="REV")
35 parser.add_option("-f", "--filemap", dest="filemap",
36 help="filemap used in conversion", metavar="PATH")
38 (options, args) = parser.parse_args()
40 if not (options.src and options.dst and options.start):
46 src_repo = hg.repository(u, options.src)
47 dst_repo = hg.repository(u, options.dst)
51 fm = filemapper(u, options.filemap)
53 last_converted_src = src_repo[options.start]
55 dst_tip = dst_repo.changectx(dst_repo.changelog.tip()).hex()
56 revs = last_converted_src.children()
62 for f in child.files():
64 u.write("%s %s\n" % (child.hex(), dst_tip))
66 revs.extend(child.children())
68 sys.stderr.write("No candidate child found in source repository\n")