DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (5216dd412535)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
#!/usr/bin/python
#
# The output of this script is a splicemap.
#
# A splicemap is used by the mercurial 'convert' extension to direct its
# splicing operation.
#
# The script assumes you already have a destination repository
# containing a conversion somewhere in its history, but that you've
# possibly mixed some new commits on top of that conversion. It outputs
# a splicemap that picks up the conversion where it left off (with the
# first descendant, in the source repo, of the src rev given by --start,
# if or rather the first descendant that would be included by the
# conversion's filemap) and connects them to the current tip of the
# destination repo.
#

from mercurial import ui, hg
from hgext.convert.filemap import filemapper
from optparse import OptionParser

import sys

parser = OptionParser()

parser.add_option("-s", "--src", dest="src",
                  help="source repository", metavar="REPO")

parser.add_option("-d", "--dst", dest="dst",
                  help="destination repository", metavar="REPO")

parser.add_option("-t", "--start", dest="start",
                  help="starting revid in source repository", metavar="REV")

parser.add_option("-f", "--filemap", dest="filemap",
                  help="filemap used in conversion", metavar="PATH")

(options, args) = parser.parse_args()

if not (options.src and options.dst and options.start):
    parser.print_help()
    exit(1)

u = ui.ui()

src_repo = hg.repository(u, options.src)
dst_repo = hg.repository(u, options.dst)

fm = None
if options.filemap:
    fm = filemapper(u, options.filemap)

last_converted_src = src_repo[options.start]

dst_tip = dst_repo.changectx(dst_repo.changelog.tip()).hex()
revs = last_converted_src.children()

while len(revs) != 0:
    tmp = revs
    revs = []
    for child in tmp:
        for f in child.files():
            if (not fm) or fm(f):
                u.write("%s %s\n" % (child.hex(), dst_tip))
                exit(0);
        revs.extend(child.children())

sys.stderr.write("No candidate child found in source repository\n")
exit(1)