Mercurial > public > mercurial-scm > hg-stable
diff tests/drawdag.py @ 33558:0103e7187237
drawdag: include files from both parents in merge commits
Consider a graph like this:
D
|\
B C
|/
A
drawdag will add a file called A in commit A, file B in B, file C in
C. That's fine and expected. In merge commits like D, I would expect
the files and their contents to be taken from the parent commits, so
commit D in this example would have files A, B, and C. However,
drawdag will instead add the file D compared to the first
parent. Depending on whether B or C got a smaller nodeid, the contents
of D would be {A, B, D} or {A, C, D}. This patch changes it to to be
{A, B, C}.
Differential Revision: https://phab.mercurial-scm.org/D92
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 14 Jul 2017 22:32:58 -0700 |
parents | 0830c841fc7f |
children | 0531ffd59a98 |
line wrap: on
line diff
--- a/tests/drawdag.py Mon Jul 17 15:54:15 2017 -0700 +++ b/tests/drawdag.py Fri Jul 14 22:32:58 2017 -0700 @@ -235,22 +235,21 @@ return '' class simplecommitctx(context.committablectx): - def __init__(self, repo, name, parentctxs, added=None): + def __init__(self, repo, name, parentctxs, added): opts = { - 'changes': scmutil.status([], added or [], [], [], [], [], []), + 'changes': scmutil.status([], list(added), [], [], [], [], []), 'date': '0 0', 'extra': {'branch': 'default'}, } super(simplecommitctx, self).__init__(self, name, **opts) self._repo = repo - self._name = name + self._added = added self._parents = parentctxs - self._parents.sort(key=lambda c: c.node()) while len(self._parents) < 2: self._parents.append(repo[node.nullid]) def filectx(self, key): - return simplefilectx(key, self._name) + return simplefilectx(key, self._added[key]) def commit(self): return self._repo.commitctx(self) @@ -317,7 +316,17 @@ if name in committed: continue pctxs = [repo[committed[n]] for n in parents] - ctx = simplecommitctx(repo, name, pctxs, [name]) + pctxs.sort(key=lambda c: c.node()) + added = {} + if len(parents) > 1: + # If it's a merge, take the files and contents from the parents + for f in pctxs[1].manifest(): + if f not in pctxs[0].manifest(): + added[f] = pctxs[1][f].data() + else: + # If it's not a merge, add a single file + added[name] = name + ctx = simplecommitctx(repo, name, pctxs, added) n = ctx.commit() committed[name] = n tagsmod.tag(repo, name, n, message=None, user=None, date=None,