shelve: add "applybundle()" to invoke "readbundle()" with relative path and vfs
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Sun, 09 Mar 2014 01:03:28 +0900
changeset 20982 1df99f1ea28d
parent 20981 4fdd1172d37e
child 20983 2778616de7ce
shelve: add "applybundle()" to invoke "readbundle()" with relative path and vfs "applybundle()" also includes "addchangegroup()" invocation to encapsulate "vfs.join()" inside it.
hgext/shelve.py
--- a/hgext/shelve.py	Sun Mar 09 01:03:28 2014 +0900
+++ b/hgext/shelve.py	Sun Mar 09 01:03:28 2014 +0900
@@ -68,6 +68,15 @@
                 raise
             raise util.Abort(_("shelved change '%s' not found") % self.name)
 
+    def applybundle(self):
+        fp = self.opener()
+        try:
+            gen = changegroup.readbundle(fp, self.fname, self.vfs)
+            changegroup.addchangegroup(self.repo, gen, 'unshelve',
+                                       'bundle:' + self.vfs.join(self.fname))
+        finally:
+            fp.close()
+
 class shelvedstate(object):
     """Handle persistence during unshelving operations.
 
@@ -560,16 +569,10 @@
             node = cmdutil.commit(ui, repo, commitfunc, [], tempopts)
             tmpwctx = repo[node]
 
-        try:
-            ui.quiet = True
-            fp = shelvedfile(repo, basename, 'hg').opener()
-            gen = changegroup.readbundle(fp, fp.name)
-            changegroup.addchangegroup(repo, gen, 'unshelve',
-                                       'bundle:' + fp.name)
-            nodes = [ctx.node() for ctx in repo.set('%d:', oldtiprev)]
-            phases.retractboundary(repo, phases.secret, nodes)
-        finally:
-            fp.close()
+        ui.quiet = True
+        shelvedfile(repo, basename, 'hg').applybundle()
+        nodes = [ctx.node() for ctx in repo.set('%d:', oldtiprev)]
+        phases.retractboundary(repo, phases.secret, nodes)
 
         ui.quiet = oldquiet