rewind: move revision selection into its own function
This will help making the logic more advanced.
--- a/hgext3rd/evolve/rewind.py Sun Jun 17 02:32:29 2018 +0200
+++ b/hgext3rd/evolve/rewind.py Sun Jun 17 03:07:53 2018 +0200
@@ -56,18 +56,12 @@
"""
unfi = repo.unfiltered()
- if not opts.get('to'):
- raise error.Abort('no revision to rewind to')
-
successorsmap = collections.defaultdict(set)
rewindmap = {}
sscache = {}
with repo.wlock(), repo.lock():
- rewinded = scmutil.revrange(repo, opts.get('to'))
-
- if not opts['exact']:
- rewinded = repo.revs('obsolete() and ::%ld', rewinded)
+ rewinded = _select_rewinded(repo, opts)
if not opts['as_divergence']:
for rev in rewinded:
@@ -107,6 +101,19 @@
if update_target is not None:
ui.status(_('working directory is now at %s\n') % repo['.'])
+def _select_rewinded(repo, opts):
+ """select the revision we shoudl rewind to
+ """
+ if not opts.get('to'):
+ raise error.Abort('no revision to rewind to')
+
+ rewinded = scmutil.revrange(repo, opts.get('to'))
+
+ if not opts['exact']:
+ rewinded = repo.revs('obsolete() and ::%ld', rewinded)
+
+ return rewinded
+
def _revive_revision(unfi, rev, rewindmap):
"""rewind a single revision rev.
"""