[PATCH 4 of 5 shelve-ext] shelve: move file-forgetting logic to a separate function
Kostia Balytskyi
ikostia at fb.com
Sun Nov 13 06:39:37 EST 2016
# HG changeset patch
# User Kostia Balytskyi <ikostia at 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.
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)
More information about the Mercurial-devel
mailing list