mercurial/rewriteutil.py
author Pulkit Goyal <7895pulkit@gmail.com>
Fri, 24 Nov 2017 03:40:33 +0530
changeset 35242 27d5c2d2db2b
child 35243 490df753894d
permissions -rw-r--r--
rewriteutil: add utility function to check if we can create new unstable cset 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. Differential Revision: https://phab.mercurial-scm.org/D1502
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35242
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
     1
# rewriteutil.py - utility functions for rewriting changesets
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
     2
#
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
     3
# Copyright 2017 Octobus <contact@octobus.net>
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
     4
#
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
     5
# This software may be used and distributed according to the terms of the
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
     6
# GNU General Public License version 2 or any later version.
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
     7
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
     8
from __future__ import absolute_import
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
     9
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
    10
from . import (
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
    11
    obsolete,
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
    12
    revset,
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
    13
)
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
    14
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
    15
def disallowednewunstable(repo, revs):
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
    16
    """Checks whether editing the revs will create new unstable changesets and
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
    17
    are we allowed to create them.
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
    18
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
    19
    To allow new unstable changesets, set the config:
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
    20
        `experimental.evolution.allowunstable=True`
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
    21
    """
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
    22
    allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
    23
    if allowunstable:
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
    24
        return revset.baseset()
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
    25
    return repo.revs("(%ld::) - %ld", revs, revs)