Patchwork D1502: rewriteutil: add utility function to check if we can create new unstable cset

login
register
mail settings
Submitter phabricator
Date Nov. 28, 2017, 12:37 a.m.
Message ID <9fef41b5f8091e86ee56b151bc61b7bc@localhost.localdomain>
Download mbox | patch
Permalink /patch/25776/
State Not Applicable
Headers show

Comments

phabricator - Nov. 28, 2017, 12:37 a.m.
pulkit updated this revision to Diff 3899.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1502?vs=3809&id=3899

REVISION DETAIL
  https://phab.mercurial-scm.org/D1502

AFFECTED FILES
  mercurial/rewriteutil.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: dlax, mercurial-devel

Patch

diff --git a/mercurial/rewriteutil.py b/mercurial/rewriteutil.py
new file mode 100644
--- /dev/null
+++ b/mercurial/rewriteutil.py
@@ -0,0 +1,25 @@ 
+# rewriteutil.py - utility functions for rewriting changesets
+#
+# Copyright 2017 Octobus <contact@octobus.net>
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+
+from __future__ import absolute_import
+
+from . import (
+    obsolete,
+    revset,
+)
+
+def disallowednewunstable(repo, revs):
+    """Checks whether editing the revs will create new unstable changesets and
+    are we allowed to create them.
+
+    To allow new unstable changesets, set the config:
+        `experimental.evolution.allounstable=True`
+    """
+    allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
+    if allowunstable:
+        return revset.baseset()
+    return repo.revs("(%ld::) - %ld", revs, revs)