diff hgext/shelve.py @ 39894:d9ba836fc234

shelve: find shelvedctx from bundle even if they are already in the repo We use the new "duplicates" node tracking to find the tip of the bundle even if it already exists in the repository. Such logic is not supposed to be needed in theory. If the shelve was made using internal-phase, we already know its node. Otherwise, the bundle content should have been stripped. However, handling it makes the shelve code more robust and provide a good example of "revduplicates" usage.
author Boris Feld <boris.feld@octobus.net>
date Thu, 20 Sep 2018 17:47:05 +0200
parents 42a6b228dd2e
children e2697acd9381
line wrap: on
line diff
--- a/hgext/shelve.py	Wed Sep 19 12:19:28 2018 +0200
+++ b/hgext/shelve.py	Thu Sep 20 17:47:05 2018 +0200
@@ -144,11 +144,17 @@
             if not phases.supportinternal(self.repo):
                 targetphase = phases.secret
             gen = exchange.readbundle(self.repo.ui, fp, self.fname, self.vfs)
-            bundle2.applybundle(self.repo, gen, self.repo.currenttransaction(),
+            pretip = self.repo['tip']
+            tr = self.repo.currenttransaction()
+            bundle2.applybundle(self.repo, gen, tr,
                                 source='unshelve',
                                 url='bundle:' + self.vfs.join(self.fname),
                                 targetphase=targetphase)
-            return self.repo['tip']
+            shelvectx = self.repo['tip']
+            if pretip == shelvectx:
+                shelverev = tr.changes['revduplicates'][-1]
+                shelvectx = self.repo[shelverev]
+            return shelvectx
         finally:
             fp.close()