[PATCH 4 of 5 V2] obsolete: add allowunstable option
Durham Goode
durham at fb.com
Wed Oct 15 15:03:24 CDT 2014
# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1413318313 25200
# Tue Oct 14 13:25:13 2014 -0700
# Node ID 8fcbb951b20a5d0612a57f4970f398991f21b774
# Parent a3a31152f8570dc6e83ff0ab8298673923f32226
obsolete: add allowunstable option
This option allows the creation of unstable commits. This allows things like
amending in the middle of a stack of commits, etc.
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -738,7 +738,7 @@ def between(repo, old, new, keep):
When keep is false, the specified set can't have children."""
ctxs = list(repo.set('%n::%n', old, new))
if ctxs and not keep:
- if (not obsolete._enabled and
+ if (not obsolete.isenabled(repo, obsolete.allowunstableopt) and
repo.revs('(%ld::) - (%ld)', ctxs, ctxs)):
raise util.Abort(_('cannot edit history that would orphan nodes'))
if repo.revs('(%ld) and merge()', ctxs):
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -303,7 +303,8 @@ def rebase(ui, repo, **opts):
('+'.join(str(repo[r]) for r in base), dest))
return 1
- if (not (keepf or obsolete._enabled)
+ allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
+ if (not (keepf or allowunstable)
and repo.revs('first(children(%ld) - %ld)',
rebaseset, rebaseset)):
raise util.Abort(
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1450,7 +1450,8 @@ def commit(ui, repo, *pats, **opts):
raise util.Abort(_('cannot amend public changesets'))
if len(repo[None].parents()) > 1:
raise util.Abort(_('cannot amend while merging'))
- if (not obsolete._enabled) and old.children():
+ allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
+ if not allowunstable and old.children():
raise util.Abort(_('cannot amend changeset with children'))
# commitfunc is used only for temporary amend commit by cmdutil.amend
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -82,6 +82,7 @@ from i18n import _
_enabled = False
# Enablable options for obsolesence
createmarkersopt = 'createmarkers'
+allowunstableopt = 'allowunstable'
### obsolescence marker flag
More information about the Mercurial-devel
mailing list