shelve: move file-forgetting logic to a separate function
This is just a readability improvement.
--- 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)