##// END OF EJS Templates
rewriteutil: give examples of public changesets that can't be rewritten...
Martin von Zweigbergk -
r47835:5b6dd0d9 default
parent child Browse files
Show More
@@ -17,6 +17,7 b' from .node import ('
17
17
18 from . import (
18 from . import (
19 error,
19 error,
20 node,
20 obsolete,
21 obsolete,
21 obsutil,
22 obsutil,
22 revset,
23 revset,
@@ -28,6 +29,26 b' from . import ('
28 NODE_RE = re.compile(br'\b[0-9a-f]{6,64}\b')
29 NODE_RE = re.compile(br'\b[0-9a-f]{6,64}\b')
29
30
30
31
32 def _formatrevs(repo, revs, maxrevs=4):
33 """returns a string summarizing revisions in a decent size
34
35 If there are few enough revisions, we list them all. Otherwise we display a
36 summary of the form:
37
38 1ea73414a91b and 5 others
39 """
40 tonode = repo.changelog.node
41 numrevs = len(revs)
42 if numrevs < maxrevs:
43 shorts = [node.short(tonode(r)) for r in revs]
44 summary = b', '.join(shorts)
45 else:
46 first = revs.first()
47 summary = _(b'%s and %d others')
48 summary %= (node.short(tonode(first)), numrevs - 1)
49 return summary
50
51
31 def precheck(repo, revs, action=b'rewrite'):
52 def precheck(repo, revs, action=b'rewrite'):
32 """check if revs can be rewritten
53 """check if revs can be rewritten
33 action is used to control the error message.
54 action is used to control the error message.
@@ -50,7 +71,8 b" def precheck(repo, revs, action=b'rewrit"
50
71
51 publicrevs = repo.revs(b'%ld and public()', revs)
72 publicrevs = repo.revs(b'%ld and public()', revs)
52 if publicrevs:
73 if publicrevs:
53 msg = _(b"cannot %s public changesets") % action
74 summary = _formatrevs(repo, publicrevs)
75 msg = _(b"cannot %s public changesets: %s") % (action, summary)
54 hint = _(b"see 'hg help phases' for details")
76 hint = _(b"see 'hg help phases' for details")
55 raise error.InputError(msg, hint=hint)
77 raise error.InputError(msg, hint=hint)
56
78
@@ -250,7 +250,7 b' Cannot amend public changeset'
250 $ hg phase -r A --public
250 $ hg phase -r A --public
251 $ hg update -C -q A
251 $ hg update -C -q A
252 $ hg amend -m AMEND
252 $ hg amend -m AMEND
253 abort: cannot amend public changesets
253 abort: cannot amend public changesets: 426bada5c675
254 (see 'hg help phases' for details)
254 (see 'hg help phases' for details)
255 [10]
255 [10]
256
256
@@ -369,7 +369,7 b' Changing branch on public changeset'
369
369
370 $ hg phase -r . -p
370 $ hg phase -r . -p
371 $ hg branch -r . def
371 $ hg branch -r . def
372 abort: cannot change branch of public changesets
372 abort: cannot change branch of public changesets: d1c2addda4a2
373 (see 'hg help phases' for details)
373 (see 'hg help phases' for details)
374 [10]
374 [10]
375
375
@@ -10,7 +10,7 b' Refuse to amend public csets:'
10
10
11 $ hg phase -r . -p
11 $ hg phase -r . -p
12 $ hg ci --amend
12 $ hg ci --amend
13 abort: cannot amend public changesets
13 abort: cannot amend public changesets: ad120869acf0
14 (see 'hg help phases' for details)
14 (see 'hg help phases' for details)
15 [10]
15 [10]
16 $ hg phase -r . -f -d
16 $ hg phase -r . -f -d
@@ -264,11 +264,11 b' nothing happens, even to the working dir'
264 $ hg commit -Aqm "hello"
264 $ hg commit -Aqm "hello"
265 $ hg phase -r 0 --public
265 $ hg phase -r 0 --public
266 $ hg fix -r 0
266 $ hg fix -r 0
267 abort: cannot fix public changesets
267 abort: cannot fix public changesets: 6470986d2e7b
268 (see 'hg help phases' for details)
268 (see 'hg help phases' for details)
269 [10]
269 [10]
270 $ hg fix -r 0 --working-dir
270 $ hg fix -r 0 --working-dir
271 abort: cannot fix public changesets
271 abort: cannot fix public changesets: 6470986d2e7b
272 (see 'hg help phases' for details)
272 (see 'hg help phases' for details)
273 [10]
273 [10]
274 $ hg cat -r tip hello.whole
274 $ hg cat -r tip hello.whole
@@ -307,7 +307,7 b' Check that histedit respect immutability'
307 o 0:cb9a9f314b8b (public) a
307 o 0:cb9a9f314b8b (public) a
308
308
309 $ hg histedit -r '.~2'
309 $ hg histedit -r '.~2'
310 abort: cannot edit public changesets
310 abort: cannot edit public changesets: cb9a9f314b8b, 40db8afa467b
311 (see 'hg help phases' for details)
311 (see 'hg help phases' for details)
312 [10]
312 [10]
313
313
@@ -328,11 +328,11 b' Check rebasing public changeset'
328 nothing to rebase
328 nothing to rebase
329 [1]
329 [1]
330 $ hg rebase -d 5 -b 6
330 $ hg rebase -d 5 -b 6
331 abort: cannot rebase public changesets
331 abort: cannot rebase public changesets: e1c4361dd923
332 (see 'hg help phases' for details)
332 (see 'hg help phases' for details)
333 [10]
333 [10]
334 $ hg rebase -d 5 -r '1 + (6::)'
334 $ hg rebase -d 5 -r '1 + (6::)'
335 abort: cannot rebase public changesets
335 abort: cannot rebase public changesets: e1c4361dd923
336 (see 'hg help phases' for details)
336 (see 'hg help phases' for details)
337 [10]
337 [10]
338
338
@@ -77,7 +77,7 b' Cannot split a public changeset'
77
77
78 $ hg phase --public -r 'all()'
78 $ hg phase --public -r 'all()'
79 $ hg split .
79 $ hg split .
80 abort: cannot split public changesets
80 abort: cannot split public changesets: 1df0d5c5a3ab
81 (see 'hg help phases' for details)
81 (see 'hg help phases' for details)
82 [10]
82 [10]
83
83
@@ -298,7 +298,7 b' Trying to unamend a public changeset'
298 $ hg phase -r . -p
298 $ hg phase -r . -p
299 1 new phase-divergent changesets
299 1 new phase-divergent changesets
300 $ hg unamend
300 $ hg unamend
301 abort: cannot unamend public changesets
301 abort: cannot unamend public changesets: 03ddd6fc5af1
302 (see 'hg help phases' for details)
302 (see 'hg help phases' for details)
303 [10]
303 [10]
304
304
General Comments 0
You need to be logged in to leave comments. Login now