patch for issue 4423

Robert Collins robertc at robertcollins.net
Tue Oct 28 03:39:45 CDT 2014


Hi - resending here as apparently they can't be discussed in the bug
tracker. This is a driveby - it fixed it for me, but I make no claims
about correctness, other use cases or testing.

-Rob

diff -r 6df4bc39f682 hgext/transplant.py
--- a/hgext/transplant.py Mon Oct 27 23:47:41 2014 -0500
+++ b/hgext/transplant.py Tue Oct 28 19:55:15 2014 +1300
@@ -302,8 +302,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()
@@ -344,12 +348,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 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


-- 
Robert Collins <rbtcollins at hp.com>
Distinguished Technologist
HP Converged Cloud
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug-4423.patch
Type: text/x-patch
Size: 1891 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20141028/a9f7abbc/attachment.bin>


More information about the Mercurial-devel mailing list