shelve: move file-forgetting logic to a separate function
authorKostia Balytskyi <ikostia@fb.com>
Thu, 10 Nov 2016 11:02:39 -0800
changeset 30456 b924375cce3a
parent 30455 10684a298973
child 30457 893be22cdb38
shelve: move file-forgetting logic to a separate function This is just a readability improvement.
hgext/shelve.py
--- a/hgext/shelve.py	Thu Nov 10 10:57:10 2016 -0800
+++ b/hgext/shelve.py	Thu Nov 10 11:02:39 2016 -0800
@@ -696,6 +696,17 @@
         shelvectx = tmpwctx
     return shelvectx
 
+def _forgetunknownfiles(repo, shelvectx, addedbefore):
+    # Forget any files that were unknown before the shelve, unknown before
+    # unshelve started, but are now added.
+    shelveunknown = shelvectx.extra().get('shelve_unknown')
+    if not shelveunknown:
+        return
+    shelveunknown = frozenset(shelveunknown.split('\0'))
+    addedafter = frozenset(repo.status().added)
+    toforget = (addedafter & shelveunknown) - addedbefore
+    repo[None].forget(toforget)
+
 @command('unshelve',
          [('a', 'abort', None,
            _('abort an incomplete unshelve operation')),
@@ -832,15 +843,7 @@
                                           branchtorestore)
         mergefiles(ui, repo, pctx, shelvectx)
         restorebranch(ui, repo, branchtorestore)
-
-        # Forget any files that were unknown before the shelve, unknown before
-        # unshelve started, but are now added.
-        shelveunknown = shelvectx.extra().get('shelve_unknown')
-        if shelveunknown:
-            shelveunknown = frozenset(shelveunknown.split('\0'))
-            addedafter = frozenset(repo.status().added)
-            toforget = (addedafter & shelveunknown) - addedbefore
-            repo[None].forget(toforget)
+        _forgetunknownfiles(repo, shelvectx, addedbefore)
 
         shelvedstate.clear(repo)