# HG changeset patch # User Siddharth Agarwal # Date 1392265708 28800 # Node ID ab2be1d994e6277ac7bd4f871ae8dbe46812094c # Parent 104f536be5c74b9e64d32a5ff1dbeda74ecefdff hg2git: factor out subrepo parsing into a separate function This code will be used in multiple contexts in an upcoming patch. diff --git a/hggit/hg2git.py b/hggit/hg2git.py --- a/hggit/hg2git.py +++ b/hggit/hg2git.py @@ -11,7 +11,6 @@ import util - class IncrementalChangesetExporter(object): """Incrementally export Mercurial changesets to Git trees. @@ -263,11 +262,17 @@ parent_tree[os.path.basename(d)] = (stat.S_IFDIR, tree.id) def _handle_subrepos(self, ctx, dirty_trees): - substate = util.parse_hgsubstate(ctx['.hgsubstate'].data().splitlines()) - sub = util.OrderedDict() + def parse_subrepos(ctx): + sub = util.OrderedDict() + if '.hgsub' in ctx: + sub = util.parse_hgsub(ctx['.hgsub'].data().splitlines()) + substate = util.OrderedDict() + if '.hgsubstate' in ctx: + substate = util.parse_hgsubstate( + ctx['.hgsubstate'].data().splitlines()) + return sub, substate - if '.hgsub' in ctx: - sub = util.parse_hgsub(ctx['.hgsub'].data().splitlines()) + sub, substate = parse_subrepos(ctx) for path, sha in substate.iteritems(): # Ignore non-Git repositories keeping state in .hgsubstate.