Mercurial > evolve
changeset 3869:bbfbaf46f7b0
rewind: move revision selection into its own function
This will help making the logic more advanced.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 17 Jun 2018 03:07:53 +0200 |
parents | 1742254d1190 |
children | e0bf44befd6e |
files | hgext3rd/evolve/rewind.py |
diffstat | 1 files changed, 14 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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. """