shelve: move commit restoration logic to a separate function
authorKostia Balytskyi <ikostia@fb.com>
Thu, 10 Nov 2016 10:51:06 -0800
changeset 30463 672026aece64
parent 30462 2e736f01a710
child 30464 10684a298973
shelve: move commit restoration logic to a separate function
hgext/shelve.py
--- a/hgext/shelve.py	Sun Nov 13 03:35:52 2016 -0800
+++ b/hgext/shelve.py	Thu Nov 10 10:51:06 2016 -0800
@@ -650,6 +650,14 @@
     tmpwctx = repo[node]
     return tmpwctx, addedbefore
 
+def _unshelverestorecommit(ui, repo, basename, oldquiet):
+    """Recreate commit in the repository during the unshelve"""
+    ui.quiet = True
+    shelvedfile(repo, basename, 'hg').applybundle()
+    shelvectx = repo['tip']
+    ui.quiet = oldquiet
+    return repo, shelvectx
+
 @command('unshelve',
          [('a', 'abort', None,
            _('abort an incomplete unshelve operation')),
@@ -775,12 +783,7 @@
         tmpwctx, addedbefore = _commitworkingcopychanges(ui, repo, opts,
                                                          tmpwctx)
 
-        ui.quiet = True
-        shelvedfile(repo, basename, 'hg').applybundle()
-
-        ui.quiet = oldquiet
-
-        shelvectx = repo['tip']
+        repo, shelvectx = _unshelverestorecommit(ui, repo, basename, oldquiet)
 
         branchtorestore = ''
         if shelvectx.branch() != shelvectx.p1().branch():