Mercurial > hg-git
changeset 648:bd63cdfbc1de
hg2git: make _handle_subrepos worked in the removed case
A test for this will be included in an upcoming patch.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Wed, 12 Feb 2014 21:19:04 -0800 |
parents | 3ceacdd23abe |
children | 53423381c540 |
files | hggit/hg2git.py |
diffstat | 1 files changed, 30 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/hggit/hg2git.py Wed Feb 12 20:34:09 2014 -0800 +++ b/hggit/hg2git.py Wed Feb 12 21:19:04 2014 -0800 @@ -272,13 +272,41 @@ ctx['.hgsubstate'].data().splitlines()) return sub, substate + sub, substate = parse_subrepos(self._ctx) newsub, newsubstate = parse_subrepos(newctx) + # For each path, the logic is described by the following table. 'no' + # stands for 'the subrepo doesn't exist', 'git' stands for 'git + # subrepo', and 'hg' stands for 'hg or other subrepo'. + # + # old new | action + # * git | link (1) + # git hg | delete (2) + # git no | delete (3) + # + # All other combinations are 'do nothing'. + # + # git links without corresponding submodule paths are stored as subrepos + # with a substate but without an entry in .hgsub. + + def isgit(sub, path): + return path not in sub or sub[path].startswith('[git]') + + for path, sha in substate.iteritems(): + if not isgit(sub, path): + # old = hg -- will be handled in next loop + continue + # old = git + if path not in newsubstate or not isgit(newsub, path): + # new = hg or no, case (2) or (3) + self._remove_path(path, dirty_trees) + for path, sha in newsubstate.iteritems(): - # Ignore non-Git repositories keeping state in .hgsubstate. - if path in newsub and not newsub[path].startswith('[git]'): + if not isgit(newsub, path): + # new = hg or no; the only cases we care about are handled above continue + # case (1) d = os.path.dirname(path) dirty_trees.add(d) tree = self._dirs.setdefault(d, dulobjs.Tree())