# HG changeset patch # User Pierre-Yves David # Date 2015-01-09 05:36:12 # Node ID 49caef4559126a07f6070b789db7992e8cd684ce # Parent a857755144dc9f9bb4f0f1d177f80dfcebe08a1b transplant: properly skip empty changeset (issue4423) If resolving a merge conflict result in an empty changesets, we now properly skip the changeset instead of crashing. Original patch from Robert Collins . diff --git a/hgext/transplant.py b/hgext/transplant.py --- a/hgext/transplant.py +++ b/hgext/transplant.py @@ -301,8 +301,12 @@ class transplanter(object): '''recover last transaction and apply remaining changesets''' if os.path.exists(os.path.join(self.path, 'journal')): n, node = self.recover(repo, source, opts) - self.ui.status(_('%s transplanted as %s\n') % (short(node), - short(n))) + if n: + self.ui.status(_('%s transplanted as %s\n') % (short(node), + short(n))) + else: + self.ui.status(_('%s skipped due to empty diff\n') + % (short(node),)) seriespath = os.path.join(self.path, 'series') if not os.path.exists(seriespath): self.transplants.write() @@ -343,12 +347,16 @@ class transplanter(object): revlog.hex(parent)) if merge: repo.setparents(p1, parents[1]) - n = repo.commit(message, user, date, extra=extra, - editor=self.getcommiteditor()) - if not n: - raise util.Abort(_('commit failed')) - if not merge: - self.transplants.set(n, node) + modified, added, removed, deleted = repo.status()[:4] + if merge or modified or added or removed or deleted: + n = repo.commit(message, user, date, extra=extra, + editor=self.getcommiteditor()) + if not n: + raise util.Abort(_('commit failed')) + if not merge: + self.transplants.set(n, node) + else: + n = None self.unlog() return n, node diff --git a/tests/test-transplant.t b/tests/test-transplant.t --- a/tests/test-transplant.t +++ b/tests/test-transplant.t @@ -768,6 +768,22 @@ test transplanting a patch turning into searching for changes applying 7a7d57e15850 skipping emptied changeset 7a7d57e15850 + +Test empty result in --continue + + $ hg transplant -s ../binarysource 1 + searching for changes + applying 645035761929 + file b already exists + 1 out of 1 hunks FAILED -- saving rejects to file b.rej + patch failed to apply + abort: fix up the merge and run hg transplant --continue + [255] + $ hg status + ? b.rej + $ hg transplant --continue + 645035761929 skipped due to empty diff + $ cd .. Explicitly kill daemons to let the test exit on Windows