[PATCH 5 of 5 shelve-ext] shelve: move unshelve-finishing logic to a separate function
Kostia Balytskyi
ikostia at fb.com
Sun Nov 13 11:39:38 UTC 2016
# HG changeset patch
# User Kostia Balytskyi <ikostia at fb.com>
# Date 1478876487 28800
# Fri Nov 11 07:01:27 2016 -0800
# Node ID c34ee36f4e7fe6b04ea1b4e2f032e995fe65d6c5
# Parent dce4581dcae386c3d3b420911350d176c0423520
shelve: move unshelve-finishing logic to a separate function
Finishing unshelve involves two steps now:
- stripping a changelog
- aborting a transaction
Obs-based shelve will not require these things, so isolating this logic
into a separate function where the normal/obs-shelve branching is
going to be implemented seems to be like a nice idea.
Behavior-wise this change moves 'unshelvecleanup' from being between
changelog stripping and transaction abortion to being after them.
I don't think this has any negative effects.
diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -708,6 +708,14 @@ def _forgetunknownfiles(repo, shelvectx,
toforget = (addedafter & shelveunknown) - addedbefore
repo[None].forget(toforget)
+def _finishunshelve(repo, oldtiprev, tr):
+ # The transaction aborting will strip all the commits for us,
+ # but it doesn't update the inmemory structures, so addchangegroup
+ # hooks still fire and try to operate on the missing commits.
+ # Clean up manually to prevent this.
+ repo.unfiltered().changelog.strip(oldtiprev, tr)
+ _aborttransaction(repo)
+
@command('unshelve',
[('a', 'abort', None,
_('abort an incomplete unshelve operation')),
@@ -847,16 +855,8 @@ def _dounshelve(ui, repo, *shelved, **op
_forgetunknownfiles(repo, shelvectx, addedbefore)
shelvedstate.clear(repo)
-
- # The transaction aborting will strip all the commits for us,
- # but it doesn't update the inmemory structures, so addchangegroup
- # hooks still fire and try to operate on the missing commits.
- # Clean up manually to prevent this.
- repo.unfiltered().changelog.strip(oldtiprev, tr)
-
+ _finishunshelve(repo, oldtiprev, tr)
unshelvecleanup(ui, repo, basename, opts)
-
- _aborttransaction(repo)
finally:
ui.quiet = oldquiet
if tr:
More information about the Mercurial-devel
mailing list