Mercurial > public > mercurial-scm > hg-stable
diff hgext/transplant.py @ 23781:49caef455912
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 <robertc@robertcollins.net>.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 08 Jan 2015 21:36:12 -0800 |
parents | 86c0d8c1484f |
children | f1eaf03dd608 |
line wrap: on
line diff
--- a/hgext/transplant.py Thu Jan 08 21:30:22 2015 +0100 +++ b/hgext/transplant.py Thu Jan 08 21:36:12 2015 -0800 @@ -301,8 +301,12 @@ '''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 @@ 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