Mercurial > hg
comparison hgext/rebase.py @ 43934:71fee4564410
rebase: use rewriteutil.precheck() instead of reimplementing it
After this patch, there's still another place in `rebase.py`, in the
`--stop` code path, that reimplements `rewriteutil.precheck()`. I
couldn't fix that place because it `rewriteutil.precheck()` checks
that there is only one dirstate parent, which fails because we have
two parents at that point. I think it's incorrect that rebase leaves
the user with two parents during conflicts, but changing that is way
out of scope for this series.
Differential Revision: https://phab.mercurial-scm.org/D7685
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 18 Dec 2019 09:18:02 +0300 |
parents | 9fb9f3a5cad7 |
children | d77230743968 |
comparison
equal
deleted
inserted
replaced
43933:bde97bee321f | 43934:71fee4564410 |
---|---|
44 pycompat, | 44 pycompat, |
45 registrar, | 45 registrar, |
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, |
52 util, | 53 util, |
53 ) | 54 ) |
391 def _preparenewrebase(self, destmap): | 392 def _preparenewrebase(self, destmap): |
392 if not destmap: | 393 if not destmap: |
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 |
410 if not result: | 407 if not result: |
411 # Empty state built, nothing to rebase | 408 # Empty state built, nothing to rebase |
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 | |
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 | 411 |
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()) |
425 if len(dests) != 1: | 415 if len(dests) != 1: |