##// 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 18 from . import (
19 19 error,
20 node,
20 21 obsolete,
21 22 obsutil,
22 23 revset,
@@ -28,6 +29,26 b' from . import ('
28 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 52 def precheck(repo, revs, action=b'rewrite'):
32 53 """check if revs can be rewritten
33 54 action is used to control the error message.
@@ -50,7 +71,8 b" def precheck(repo, revs, action=b'rewrit"
50 71
51 72 publicrevs = repo.revs(b'%ld and public()', revs)
52 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 76 hint = _(b"see 'hg help phases' for details")
55 77 raise error.InputError(msg, hint=hint)
56 78
@@ -250,7 +250,7 b' Cannot amend public changeset'
250 250 $ hg phase -r A --public
251 251 $ hg update -C -q A
252 252 $ hg amend -m AMEND
253 abort: cannot amend public changesets
253 abort: cannot amend public changesets: 426bada5c675
254 254 (see 'hg help phases' for details)
255 255 [10]
256 256
@@ -369,7 +369,7 b' Changing branch on public changeset'
369 369
370 370 $ hg phase -r . -p
371 371 $ hg branch -r . def
372 abort: cannot change branch of public changesets
372 abort: cannot change branch of public changesets: d1c2addda4a2
373 373 (see 'hg help phases' for details)
374 374 [10]
375 375
@@ -10,7 +10,7 b' Refuse to amend public csets:'
10 10
11 11 $ hg phase -r . -p
12 12 $ hg ci --amend
13 abort: cannot amend public changesets
13 abort: cannot amend public changesets: ad120869acf0
14 14 (see 'hg help phases' for details)
15 15 [10]
16 16 $ hg phase -r . -f -d
@@ -264,11 +264,11 b' nothing happens, even to the working dir'
264 264 $ hg commit -Aqm "hello"
265 265 $ hg phase -r 0 --public
266 266 $ hg fix -r 0
267 abort: cannot fix public changesets
267 abort: cannot fix public changesets: 6470986d2e7b
268 268 (see 'hg help phases' for details)
269 269 [10]
270 270 $ hg fix -r 0 --working-dir
271 abort: cannot fix public changesets
271 abort: cannot fix public changesets: 6470986d2e7b
272 272 (see 'hg help phases' for details)
273 273 [10]
274 274 $ hg cat -r tip hello.whole
@@ -307,7 +307,7 b' Check that histedit respect immutability'
307 307 o 0:cb9a9f314b8b (public) a
308 308
309 309 $ hg histedit -r '.~2'
310 abort: cannot edit public changesets
310 abort: cannot edit public changesets: cb9a9f314b8b, 40db8afa467b
311 311 (see 'hg help phases' for details)
312 312 [10]
313 313
@@ -328,11 +328,11 b' Check rebasing public changeset'
328 328 nothing to rebase
329 329 [1]
330 330 $ hg rebase -d 5 -b 6
331 abort: cannot rebase public changesets
331 abort: cannot rebase public changesets: e1c4361dd923
332 332 (see 'hg help phases' for details)
333 333 [10]
334 334 $ hg rebase -d 5 -r '1 + (6::)'
335 abort: cannot rebase public changesets
335 abort: cannot rebase public changesets: e1c4361dd923
336 336 (see 'hg help phases' for details)
337 337 [10]
338 338
@@ -77,7 +77,7 b' Cannot split a public changeset'
77 77
78 78 $ hg phase --public -r 'all()'
79 79 $ hg split .
80 abort: cannot split public changesets
80 abort: cannot split public changesets: 1df0d5c5a3ab
81 81 (see 'hg help phases' for details)
82 82 [10]
83 83
@@ -298,7 +298,7 b' Trying to unamend a public changeset'
298 298 $ hg phase -r . -p
299 299 1 new phase-divergent changesets
300 300 $ hg unamend
301 abort: cannot unamend public changesets
301 abort: cannot unamend public changesets: 03ddd6fc5af1
302 302 (see 'hg help phases' for details)
303 303 [10]
304 304
General Comments 0
You need to be logged in to leave comments. Login now