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

login
register
mail settings
Submitter phabricator
Date Nov. 23, 2017, 10:39 p.m.
Message ID <differential-rev-PHID-DREV-2ilyrhhnfwgjv6nulmlt-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/25733/
State Superseded
Headers show

Comments

phabricator - Nov. 23, 2017, 10:39 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch adds a new file which will contain utility functions related to
  rewritting changesets. It also adds a utility function to check if the
  rewritting operation creates new unstable changesets and are we allowed to
  create them.
  
  This rewriteutil.py introduced in this patch and the utility functions added in
  the upcoming patches exists in the evolve extension are being ported from there.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/rewriteutil.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - Nov. 24, 2017, 9:35 a.m.
dlax added a comment.


  > This rewriteutil.py introduced in this patch and the utility functions added in the upcoming patches exists in the evolve extension are being ported from there.
  
  Is it worth porting this alone if nothing in core makes use of this module?
  Or is there a larger plan?

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers
Cc: dlax, mercurial-devel
phabricator - Nov. 28, 2017, 12:40 a.m.
pulkit added a comment.


  In https://phab.mercurial-scm.org/D1502#25341, @dlax wrote:
  
  > > This rewriteutil.py introduced in this patch and the utility functions added in the upcoming patches exists in the evolve extension are being ported from there.
  >
  > Is it worth porting this alone if nothing in core makes use of this module?
  >  Or is there a larger plan?
  
  
  I have updated the series with couple of usages. More functions will be introduced which will be used by both core and extensions.

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers
Cc: dlax, mercurial-devel
phabricator - Nov. 28, 2017, 9:18 a.m.
dlax requested changes to this revision.
dlax added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> rewriteutil.py:20
> +    To allow new unstable changesets, set the config:
> +        `experimental.evolution.allounstable=True`
> +    """

typo: allounstable

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers, dlax
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 mercurial import (
+    obsolete,
+    revset,
+)
+
+from mercurial.i18n import _
+
+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)