--- a/hgext3rd/evolve/__init__.py Sun Jul 23 04:46:33 2017 +0200
+++ b/hgext3rd/evolve/__init__.py Sun Jul 23 04:54:42 2017 +0200
@@ -2751,7 +2751,7 @@
wlock = repo.wlock()
lock = repo.lock()
- root, head = _foldcheck(repo, revs)
+ root, head = rewriteutil.foldcheck(repo, revs)
tr = repo.transaction('fold')
try:
@@ -2845,7 +2845,7 @@
'not currently supported'))
if opts['fold']:
- root, head = _foldcheck(repo, revs)
+ root, head = rewriteutil.foldcheck(repo, revs)
else:
if repo.revs("%ld and public()", revs):
raise error.Abort(_('cannot edit commit information for public '
@@ -2906,25 +2906,6 @@
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()]
- if rewriteutil.disallowednewunstable(repo, revs):
- msg = _("cannot fold chain not ending with a head or with branching")
- hint = _("new unstable changesets are not allowed")
- raise error.Abort(msg, hint=hint)
- return root, head
-
@eh.wrapcommand('graft')
def graftwrapper(orig, ui, repo, *revs, **kwargs):
kwargs = dict(kwargs)
--- a/hgext3rd/evolve/rewriteutil.py Sun Jul 23 04:46:33 2017 +0200
+++ b/hgext3rd/evolve/rewriteutil.py Sun Jul 23 04:54:42 2017 +0200
@@ -12,10 +12,14 @@
# commands).
from mercurial import (
+ error,
obsolete,
+ phases,
revset,
)
+from mercurial.i18n import _
+
from . import (
compat,
)
@@ -40,3 +44,23 @@
if allowunstable:
return revset.baseset()
return repo.revs("(%ld::) - %ld", revs, revs)
+
+def foldcheck(repo, revs):
+ """check that <revs> can be folded"""
+ 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()]
+ if disallowednewunstable(repo, revs):
+ msg = _("cannot fold chain not ending with a head or with branching")
+ hint = _("new unstable changesets are not allowed")
+ raise error.Abort(msg, hint=hint)
+ return root, head