Patchwork [2,of,5,shelve-ext] shelve: move commit restoration logic to a separate function

login
register
mail settings
Submitter Kostia Balytskyi
Date Nov. 13, 2016, 11:39 a.m.
Message ID <bce5daba05f23d87b323.1479037175@dev1902.lla1.facebook.com>
Download mbox | patch
Permalink /patch/17543/
State Accepted
Headers show

Comments

Kostia Balytskyi - Nov. 13, 2016, 11:39 a.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@fb.com>
# Date 1478803866 28800
#      Thu Nov 10 10:51:06 2016 -0800
# Node ID bce5daba05f23d87b3231c7dd28014f881b4de32
# Parent  45dbc9a803375958310bced301227b02802372b0
shelve: move commit restoration logic to a separate function

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -651,6 +651,14 @@  def _commitworkingcopychanges(ui, repo, 
     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')),
@@ -776,12 +784,7 @@  def _dounshelve(ui, repo, *shelved, **op
         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():