Mercurial > hg
comparison hgext/fix.py @ 48672:657e490756e6
fix: remove unnecessary and overly strict check for divergence
`rewriteutil.precheck()` checks for divergence these days, so we can
remove the redundant check in `hg fix`.
Differential Revision: https://phab.mercurial-scm.org/D12088
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 11 Feb 2021 22:52:43 -0800 |
parents | 2f7caef017d9 |
children | 6000f5b25c9b |
comparison
equal
deleted
inserted
replaced
48671:f1ed5c304f45 | 48672:657e490756e6 |
---|---|
147 logcmdutil, | 147 logcmdutil, |
148 match as matchmod, | 148 match as matchmod, |
149 mdiff, | 149 mdiff, |
150 merge, | 150 merge, |
151 mergestate as mergestatemod, | 151 mergestate as mergestatemod, |
152 obsolete, | |
153 pycompat, | 152 pycompat, |
154 registrar, | 153 registrar, |
155 rewriteutil, | 154 rewriteutil, |
156 scmutil, | 155 scmutil, |
157 util, | 156 util, |
461 revs.add(wdirrev) | 460 revs.add(wdirrev) |
462 else: | 461 else: |
463 revs = set(logcmdutil.revrange(repo, opts[b'rev'])) | 462 revs = set(logcmdutil.revrange(repo, opts[b'rev'])) |
464 if opts.get(b'working_dir'): | 463 if opts.get(b'working_dir'): |
465 revs.add(wdirrev) | 464 revs.add(wdirrev) |
466 for rev in revs: | |
467 checkfixablectx(ui, repo, repo[rev]) | |
468 # Allow fixing only wdir() even if there's an unfinished operation | 465 # Allow fixing only wdir() even if there's an unfinished operation |
469 if not (len(revs) == 1 and wdirrev in revs): | 466 if not (len(revs) == 1 and wdirrev in revs): |
470 cmdutil.checkunfinished(repo) | 467 cmdutil.checkunfinished(repo) |
471 rewriteutil.precheck(repo, revs, b'fix') | 468 rewriteutil.precheck(repo, revs, b'fix') |
472 if ( | 469 if ( |
477 if not revs: | 474 if not revs: |
478 raise error.Abort( | 475 raise error.Abort( |
479 b'no changesets specified', hint=b'use --source or --working-dir' | 476 b'no changesets specified', hint=b'use --source or --working-dir' |
480 ) | 477 ) |
481 return revs | 478 return revs |
482 | |
483 | |
484 def checkfixablectx(ui, repo, ctx): | |
485 """Aborts if the revision shouldn't be replaced with a fixed one.""" | |
486 if ctx.obsolete(): | |
487 # It would be better to actually check if the revision has a successor. | |
488 if not obsolete.isenabled(repo, obsolete.allowdivergenceopt): | |
489 raise error.Abort( | |
490 b'fixing obsolete revision could cause divergence' | |
491 ) | |
492 | 479 |
493 | 480 |
494 def pathstofix(ui, repo, pats, opts, match, basectxs, fixctx): | 481 def pathstofix(ui, repo, pats, opts, match, basectxs, fixctx): |
495 """Returns the set of files that should be fixed in a context | 482 """Returns the set of files that should be fixed in a context |
496 | 483 |