# HG changeset patch # User Matt Mackall # Date 2014-08-27 16:35:34 # Node ID bdc0e04df243d3995c7266bf7d138fddd0449ba6 # Parent 5678b0e3608f397d125bb38f389f1ebf8ff79c7d # Parent 0c838e7459a55726d3f55b29b0d7b26ca4ada2cb merge with stable diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -651,6 +651,9 @@ def tryimportone(ui, repo, hunk, parents p2 = repo[nullid] except error.RepoError: p1, p2 = parents + if p2.node() == nullid: + ui.warn(_("warning: import the patch as a normal revision\n" + "(use --exact to import the patch as a merge)\n")) else: p1, p2 = parents @@ -911,9 +914,10 @@ class changeset_printer(object): self.ui.write(_("phase: %s\n") % _(ctx.phasestr()), label='log.phase') for parent in parents: + label = 'log.parent changeset.%s' % self.repo[parent[0]].phasestr() # i18n: column positioning for "hg log" self.ui.write(_("parent: %d:%s\n") % parent, - label='log.parent changeset.%s' % ctx.phasestr()) + label=label) if self.ui.debugflag: mnode = ctx.manifestnode() diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3221,14 +3221,23 @@ def graft(ui, repo, *revs, **opts): ctx = repo[rev] n = ctx.extra().get('source') if n in ids: - r = repo[n].rev() + try: + r = repo[n].rev() + except error.RepoLookupError: + r = None if r in revs: ui.warn(_('skipping revision %s (already grafted to %s)\n') % (r, rev)) revs.remove(r) elif ids[n] in revs: - ui.warn(_('skipping already grafted revision %s ' - '(%s also has origin %d)\n') % (ids[n], rev, r)) + if r is None: + ui.warn(_('skipping already grafted revision %s ' + '(%s also has unknown origin %s)\n') + % (ids[n], rev, n)) + else: + ui.warn(_('skipping already grafted revision %s ' + '(%s also has origin %d)\n') + % (ids[n], rev, r)) revs.remove(ids[n]) elif ctx.hex() in ids: r = ids[ctx.hex()] diff --git a/tests/test-graft.t b/tests/test-graft.t --- a/tests/test-graft.t +++ b/tests/test-graft.t @@ -678,3 +678,14 @@ graft --continue after --force grafting revision 28 $ cat a abc + +Continue testing same origin policy, using revision numbers from test above +but do some destructive editing of the repo: + + $ hg up -qC 7 + $ hg tag -l -r 13 tmp + $ hg --config extensions.mq= strip 2 + saved backup bundle to $TESTTMP/a/.hg/strip-backup/5c095ad7e90f-backup.hg (glob) + $ hg graft tmp + skipping already grafted revision 8 (2 also has unknown origin 5c095ad7e90f871700f02dd1fa5012cb4498a2d4) + [255] diff --git a/tests/test-import-merge.t b/tests/test-import-merge.t --- a/tests/test-import-merge.t +++ b/tests/test-import-merge.t @@ -72,6 +72,8 @@ Test without --exact and diff.p1 != work 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg import ../merge.diff applying ../merge.diff + warning: import the patch as a normal revision + (use --exact to import the patch as a merge) $ tipparents 2:890ecaa90481 addc $ hg strip --no-backup tip @@ -105,6 +107,8 @@ Test with --bypass and diff.p1 != workin 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg import --bypass ../merge.diff applying ../merge.diff + warning: import the patch as a normal revision + (use --exact to import the patch as a merge) $ tipparents 2:890ecaa90481 addc $ hg strip --no-backup tip