Patchwork [4,of,5,shelve-ext] shelve: move file-forgetting logic to a separate function

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

Comments

Kostia Balytskyi - Nov. 13, 2016, 11:39 a.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@fb.com>
# Date 1478804559 28800
#      Thu Nov 10 11:02:39 2016 -0800
# Node ID dce4581dcae386c3d3b420911350d176c0423520
# Parent  36d052f32bf4efe1f17b8cf3cf022b1f032298f2
shelve: move file-forgetting logic to a separate function

This is just a readability improvement.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -697,6 +697,17 @@  def _rebaserestoredcommit(ui, repo, opts
         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')),
@@ -833,15 +844,7 @@  def _dounshelve(ui, repo, *shelved, **op
                                           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)