##// END OF EJS Templates
rebase: use rewriteutil.precheck() instead of reimplementing it...
Martin von Zweigbergk -
r44771:71fee456 default
parent child Browse files
Show More
@@ -46,6 +46,7 b' from mercurial import ('
46 repair,
46 repair,
47 revset,
47 revset,
48 revsetlang,
48 revsetlang,
49 rewriteutil,
49 scmutil,
50 scmutil,
50 smartset,
51 smartset,
51 state as statemod,
52 state as statemod,
@@ -393,17 +394,13 b' class rebaseruntime(object):'
393 return _nothingtorebase()
394 return _nothingtorebase()
394
395
395 rebaseset = destmap.keys()
396 rebaseset = destmap.keys()
396 allowunstable = obsolete.isenabled(self.repo, obsolete.allowunstableopt)
397 if not self.keepf:
397 if not (self.keepf or allowunstable) and self.repo.revs(
398 try:
398 b'first(children(%ld) - %ld)', rebaseset, rebaseset
399 rewriteutil.precheck(self.repo, rebaseset, action=b'rebase')
399 ):
400 except error.Abort as e:
400 raise error.Abort(
401 if e.hint is None:
401 _(
402 e.hint = b'use --keep to keep original changesets'
402 b"can't remove original changesets with"
403 raise e
403 b" unrebased descendants"
404 ),
405 hint=_(b'use --keep to keep original changesets'),
406 )
407
404
408 result = buildstate(self.repo, destmap, self.collapsef)
405 result = buildstate(self.repo, destmap, self.collapsef)
409
406
@@ -412,13 +409,6 b' class rebaseruntime(object):'
412 self.ui.status(_(b'nothing to rebase\n'))
409 self.ui.status(_(b'nothing to rebase\n'))
413 return _nothingtorebase()
410 return _nothingtorebase()
414
411
415 for root in self.repo.set(b'roots(%ld)', rebaseset):
416 if not self.keepf and not root.mutable():
417 raise error.Abort(
418 _(b"can't rebase public changeset %s") % root,
419 hint=_(b"see 'hg help phases' for details"),
420 )
421
422 (self.originalwd, self.destmap, self.state) = result
412 (self.originalwd, self.destmap, self.state) = result
423 if self.collapsef:
413 if self.collapsef:
424 dests = set(self.destmap.values())
414 dests = set(self.destmap.values())
@@ -592,7 +592,7 b' Test collapsing a middle revision in-pla'
592 o 0: f447d5abf5ea 'add'
592 o 0: f447d5abf5ea 'add'
593
593
594 $ hg rebase --collapse -r 1 -d 0
594 $ hg rebase --collapse -r 1 -d 0
595 abort: can't remove original changesets with unrebased descendants
595 abort: cannot rebase changeset with children
596 (use --keep to keep original changesets)
596 (use --keep to keep original changesets)
597 [255]
597 [255]
598
598
@@ -325,14 +325,15 b' Check rebasing public changeset'
325
325
326 $ hg pull --config phases.publish=True -q -r 6 . # update phase of 6
326 $ hg pull --config phases.publish=True -q -r 6 . # update phase of 6
327 $ hg rebase -d 0 -b 6
327 $ hg rebase -d 0 -b 6
328 nothing to rebase
328 abort: cannot rebase public changesets
329 [1]
329 (see 'hg help phases' for details)
330 [255]
330 $ hg rebase -d 5 -b 6
331 $ hg rebase -d 5 -b 6
331 abort: can't rebase public changeset e1c4361dd923
332 abort: cannot rebase public changesets
332 (see 'hg help phases' for details)
333 (see 'hg help phases' for details)
333 [255]
334 [255]
334 $ hg rebase -d 5 -r '1 + (6::)'
335 $ hg rebase -d 5 -r '1 + (6::)'
335 abort: can't rebase public changeset e1c4361dd923
336 abort: cannot rebase public changesets
336 (see 'hg help phases' for details)
337 (see 'hg help phases' for details)
337 [255]
338 [255]
338
339
@@ -452,7 +453,7 b' Source on have two descendant heads but '
452 $ hg clone -q -u . ah ah1
453 $ hg clone -q -u . ah ah1
453 $ cd ah1
454 $ cd ah1
454 $ hg rebase -r '2::8' -d 1
455 $ hg rebase -r '2::8' -d 1
455 abort: can't remove original changesets with unrebased descendants
456 abort: cannot rebase changeset with children
456 (use --keep to keep original changesets)
457 (use --keep to keep original changesets)
457 [255]
458 [255]
458 $ hg rebase -r '2::8' -d 1 -k
459 $ hg rebase -r '2::8' -d 1 -k
@@ -498,7 +499,7 b' Base on have one descendant heads we ask'
498 $ hg clone -q -u . ah ah2
499 $ hg clone -q -u . ah ah2
499 $ cd ah2
500 $ cd ah2
500 $ hg rebase -r '3::8' -d 1
501 $ hg rebase -r '3::8' -d 1
501 abort: can't remove original changesets with unrebased descendants
502 abort: cannot rebase changeset with children
502 (use --keep to keep original changesets)
503 (use --keep to keep original changesets)
503 [255]
504 [255]
504 $ hg rebase -r '3::8' -d 1 --keep
505 $ hg rebase -r '3::8' -d 1 --keep
@@ -541,7 +542,7 b' rebase subset'
541 $ hg clone -q -u . ah ah3
542 $ hg clone -q -u . ah ah3
542 $ cd ah3
543 $ cd ah3
543 $ hg rebase -r '3::7' -d 1
544 $ hg rebase -r '3::7' -d 1
544 abort: can't remove original changesets with unrebased descendants
545 abort: cannot rebase changeset with children
545 (use --keep to keep original changesets)
546 (use --keep to keep original changesets)
546 [255]
547 [255]
547 $ hg rebase -r '3::7' -d 1 --keep
548 $ hg rebase -r '3::7' -d 1 --keep
@@ -581,7 +582,7 b' rebase subset with multiple head'
581 $ hg clone -q -u . ah ah4
582 $ hg clone -q -u . ah ah4
582 $ cd ah4
583 $ cd ah4
583 $ hg rebase -r '3::(7+5)' -d 1
584 $ hg rebase -r '3::(7+5)' -d 1
584 abort: can't remove original changesets with unrebased descendants
585 abort: cannot rebase changeset with children
585 (use --keep to keep original changesets)
586 (use --keep to keep original changesets)
586 [255]
587 [255]
587 $ hg rebase -r '3::(7+5)' -d 1 --keep
588 $ hg rebase -r '3::(7+5)' -d 1 --keep
General Comments 0
You need to be logged in to leave comments. Login now