Mercurial > evolve
changeset 1683:1b1c8c0ab20e
evolve: factor out sanity checks for folds
We're going to use the same checks in another context in an upcoming patch.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Mon, 25 Apr 2016 16:24:42 -0700 |
parents | fe4b41a2af4e |
children | 40d7b0c4abb1 |
files | hgext/evolve.py |
diffstat | 1 files changed, 21 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/evolve.py Thu Apr 21 06:12:20 2016 +0000 +++ b/hgext/evolve.py Mon Apr 25 16:24:42 2016 -0700 @@ -3122,23 +3122,8 @@ ui.write_err(_('single revision specified, nothing to fold\n')) return 1 - roots = repo.revs('roots(%ld)', revs) - if len(roots) > 1: - raise error.Abort(_("cannot fold non-linear revisions " - "(multiple roots given)")) - root = repo[roots.first()] - if root.phase() <= phases.public: - raise error.Abort(_("cannot fold public revisions")) - heads = repo.revs('heads(%ld)', revs) - if len(heads) > 1: - raise error.Abort(_("cannot fold non-linear revisions " - "(multiple heads given)")) - head = repo[heads.first()] - disallowunstable = not obsolete.isenabled(repo, obsolete.allowunstableopt) - if disallowunstable: - if repo.revs("(%ld::) - %ld", revs, revs): - raise error.Abort(_("cannot fold chain not ending with a head "\ - "or with branching")) + root, head = _foldcheck(repo, revs) + wlock = lock = None try: wlock = repo.wlock() @@ -3174,7 +3159,25 @@ finally: lockmod.release(lock, wlock) - +def _foldcheck(repo, revs): + roots = repo.revs('roots(%ld)', revs) + if len(roots) > 1: + raise error.Abort(_("cannot fold non-linear revisions " + "(multiple roots given)")) + root = repo[roots.first()] + if root.phase() <= phases.public: + raise error.Abort(_("cannot fold public revisions")) + heads = repo.revs('heads(%ld)', revs) + if len(heads) > 1: + raise error.Abort(_("cannot fold non-linear revisions " + "(multiple heads given)")) + head = repo[heads.first()] + disallowunstable = not obsolete.isenabled(repo, obsolete.allowunstableopt) + if disallowunstable: + if repo.revs("(%ld::) - %ld", revs, revs): + raise error.Abort(_("cannot fold chain not ending with a head "\ + "or with branching")) + return root, head @eh.wrapcommand('graft') def graftwrapper(orig, ui, repo, *revs, **kwargs):