Patchwork [8,of,9] shelve: add "applybundle()" to invoke "readbundle()" with relative path and vfs

login
register
mail settings
Submitter Katsunori FUJIWARA
Date March 8, 2014, 4:07 p.m.
Message ID <8db5796fef8c9d7d4e53.1394294833@juju>
Download mbox | patch
Permalink /patch/3898/
State Accepted
Commit 1df99f1ea28df18a217ff1e15f30dda3ce57a51f
Headers show

Comments

Katsunori FUJIWARA - March 8, 2014, 4:07 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1394294608 -32400
#      Sun Mar 09 01:03:28 2014 +0900
# Node ID 8db5796fef8c9d7d4e5329c96c6e7c692d91922e
# Parent  29bb3f593d2ed2f8eadd724db31d26509f5a99db
shelve: add "applybundle()" to invoke "readbundle()" with relative path and vfs

"applybundle()" also includes "addchangegroup()" invocation to
encapsulate "vfs.join()" inside it.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -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)
+            self.repo.addchangegroup(gen, 'unshelve',
+                                     'bundle:' + self.vfs.join(self.fname))
+        finally:
+            fp.close()
+
 class shelvedstate(object):
     """Handle persistence during unshelving operations.
 
@@ -557,15 +566,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)
-            repo.addchangegroup(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