Show More
@@ -1,53 +1,53 b'' | |||||
1 | # rewriteutil.py - utility functions for rewriting changesets |
|
1 | # rewriteutil.py - utility functions for rewriting changesets | |
2 | # |
|
2 | # | |
3 | # Copyright 2017 Octobus <contact@octobus.net> |
|
3 | # Copyright 2017 Octobus <contact@octobus.net> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | from __future__ import absolute_import |
|
8 | from __future__ import absolute_import | |
9 |
|
9 | |||
10 | from .i18n import _ |
|
10 | from .i18n import _ | |
11 |
|
11 | |||
12 | from . import ( |
|
12 | from . import ( | |
13 | error, |
|
13 | error, | |
14 | node, |
|
14 | node, | |
15 | obsolete, |
|
15 | obsolete, | |
16 | revset, |
|
16 | revset, | |
17 | ) |
|
17 | ) | |
18 |
|
18 | |||
19 | def precheck(repo, revs, action='rewrite'): |
|
19 | def precheck(repo, revs, action='rewrite'): | |
20 | """check if revs can be rewritten |
|
20 | """check if revs can be rewritten | |
21 | action is used to control the error message. |
|
21 | action is used to control the error message. | |
22 |
|
22 | |||
23 | Make sure this function is called after taking the lock. |
|
23 | Make sure this function is called after taking the lock. | |
24 | """ |
|
24 | """ | |
25 | if node.nullrev in revs: |
|
25 | if node.nullrev in revs: | |
26 | msg = _("cannot %s null changeset") % (action) |
|
26 | msg = _("cannot %s null changeset") % (action) | |
27 | hint = _("no changeset checked out") |
|
27 | hint = _("no changeset checked out") | |
28 | raise error.Abort(msg, hint=hint) |
|
28 | raise error.Abort(msg, hint=hint) | |
29 |
|
29 | |||
30 | publicrevs = repo.revs('%ld and public()', revs) |
|
|||
31 | if len(repo[None].parents()) > 1: |
|
30 | if len(repo[None].parents()) > 1: | |
32 | raise error.Abort(_("cannot %s while merging") % action) |
|
31 | raise error.Abort(_("cannot %s while merging") % action) | |
33 |
|
32 | |||
|
33 | publicrevs = repo.revs('%ld and public()', revs) | |||
34 | if publicrevs: |
|
34 | if publicrevs: | |
35 | msg = _("cannot %s public changesets") % (action) |
|
35 | msg = _("cannot %s public changesets") % (action) | |
36 | hint = _("see 'hg help phases' for details") |
|
36 | hint = _("see 'hg help phases' for details") | |
37 | raise error.Abort(msg, hint=hint) |
|
37 | raise error.Abort(msg, hint=hint) | |
38 |
|
38 | |||
39 | newunstable = disallowednewunstable(repo, revs) |
|
39 | newunstable = disallowednewunstable(repo, revs) | |
40 | if newunstable: |
|
40 | if newunstable: | |
41 | raise error.Abort(_("cannot %s changeset with children") % action) |
|
41 | raise error.Abort(_("cannot %s changeset with children") % action) | |
42 |
|
42 | |||
43 | def disallowednewunstable(repo, revs): |
|
43 | def disallowednewunstable(repo, revs): | |
44 | """Checks whether editing the revs will create new unstable changesets and |
|
44 | """Checks whether editing the revs will create new unstable changesets and | |
45 | are we allowed to create them. |
|
45 | are we allowed to create them. | |
46 |
|
46 | |||
47 | To allow new unstable changesets, set the config: |
|
47 | To allow new unstable changesets, set the config: | |
48 | `experimental.evolution.allowunstable=True` |
|
48 | `experimental.evolution.allowunstable=True` | |
49 | """ |
|
49 | """ | |
50 | allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt) |
|
50 | allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt) | |
51 | if allowunstable: |
|
51 | if allowunstable: | |
52 | return revset.baseset() |
|
52 | return revset.baseset() | |
53 | return repo.revs("(%ld::) - %ld", revs, revs) |
|
53 | return repo.revs("(%ld::) - %ld", revs, revs) |
General Comments 0
You need to be logged in to leave comments.
Login now