Mercurial > hg
annotate mercurial/rewriteutil.py @ 42136:10a6725dca6e
compression: introduce an official `zstd-revlog` requirement
This requirement supersedes `exp-compression-zstd`. However, we keep support for
the old requirement.
Strictly speaking, we do not need to add a new requirement, there are no logic
change making "new" repo incompatible with mercurial client using a version
that support `exp-compression-zstd`.
The choice to introduce a new requirement is motivated by the following:
* The previous requirement was explicitly "experimental". Using it by default
could confuse users.
* adding support for a hypothetical third compression engine will requires new
code, and will comes with its own requirement tool.
* We won't use it as the default for a while since I do not think we support
zstd on all platform. I can imagine we'll gain another (unrelated but on my
default) requirement by the time we turn this zstd by default.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 27 Mar 2019 18:27:03 +0100 |
parents | 8c6329fa6038 |
children | 57875cf423c9 |
rev | line source |
---|---|
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 |
35243
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
10 from .i18n import _ |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
11 |
35242
27d5c2d2db2b
rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
12 from . import ( |
35243
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
13 error, |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
14 node, |
35242
27d5c2d2db2b
rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
15 obsolete, |
27d5c2d2db2b
rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
16 revset, |
27d5c2d2db2b
rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
17 ) |
27d5c2d2db2b
rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
18 |
35243
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
19 def precheck(repo, revs, action='rewrite'): |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
20 """check if revs can be rewritten |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
21 action is used to control the error message. |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
22 |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
23 Make sure this function is called after taking the lock. |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
24 """ |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
25 if node.nullrev in revs: |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
26 msg = _("cannot %s null changeset") % (action) |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
27 hint = _("no changeset checked out") |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
28 raise error.Abort(msg, hint=hint) |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
29 |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
30 if len(repo[None].parents()) > 1: |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
31 raise error.Abort(_("cannot %s while merging") % action) |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
32 |
40636
8c6329fa6038
rewriteutil: move publicrevs closer to where it's used
Anton Shestakov <av6@dwimlabs.net>
parents:
35243
diff
changeset
|
33 publicrevs = repo.revs('%ld and public()', revs) |
35243
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
34 if publicrevs: |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
35 msg = _("cannot %s public changesets") % (action) |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
36 hint = _("see 'hg help phases' for details") |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
37 raise error.Abort(msg, hint=hint) |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
38 |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
39 newunstable = disallowednewunstable(repo, revs) |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
40 if newunstable: |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
41 raise error.Abort(_("cannot %s changeset with children") % action) |
490df753894d
rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35242
diff
changeset
|
42 |
35242
27d5c2d2db2b
rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
43 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
|
44 """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
|
45 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
|
46 |
27d5c2d2db2b
rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
47 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
|
48 `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
|
49 """ |
27d5c2d2db2b
rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
50 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
|
51 if allowunstable: |
27d5c2d2db2b
rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
52 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
|
53 return repo.revs("(%ld::) - %ld", revs, revs) |