shelve: properly process bundle2 bundle
authorPierre-Yves David <pierre-yves.david@fb.com>
Mon, 19 Oct 2015 15:42:50 +0200
changeset 26799 ae03d4190321
parent 26798 38dcb85f9370
child 26800 7cac6ee41be7
shelve: properly process bundle2 bundle
hgext/shelve.py
--- a/hgext/shelve.py	Tue Oct 20 03:07:23 2015 +0200
+++ b/hgext/shelve.py	Mon Oct 19 15:42:50 2015 +0200
@@ -27,7 +27,7 @@
 from mercurial.node import nullid, nullrev, bin, hex
 from mercurial import changegroup, cmdutil, scmutil, phases, commands
 from mercurial import error, hg, mdiff, merge, patch, repair, util
-from mercurial import templatefilters, exchange, bundlerepo
+from mercurial import templatefilters, exchange, bundlerepo, bundle2
 from mercurial import lock as lockmod
 from hgext import rebase
 import errno
@@ -96,9 +96,15 @@
         fp = self.opener()
         try:
             gen = exchange.readbundle(self.repo.ui, fp, self.fname, self.vfs)
-            gen.apply(self.repo, 'unshelve',
-                      'bundle:' + self.vfs.join(self.fname),
-                      targetphase=phases.secret)
+            if not isinstance(gen, bundle2.unbundle20):
+                gen.apply(self.repo, 'unshelve',
+                          'bundle:' + self.vfs.join(self.fname),
+                          targetphase=phases.secret)
+            if isinstance(gen, bundle2.unbundle20):
+                bundle2.applybundle(self.repo, gen,
+                                    self.repo.currenttransaction(),
+                                    source='unshelve',
+                                    url='bundle:' + self.vfs.join(self.fname))
         finally:
             fp.close()