hgext/fix.py
changeset 43936 699d6be3820a
parent 43897 dda49ec2b54a
child 43962 eebdd6709868
equal deleted inserted replaced
43935:2349a60f33db 43936:699d6be3820a
   142     copies,
   142     copies,
   143     error,
   143     error,
   144     match as matchmod,
   144     match as matchmod,
   145     mdiff,
   145     mdiff,
   146     merge,
   146     merge,
   147     obsolete,
       
   148     pycompat,
   147     pycompat,
   149     registrar,
   148     registrar,
       
   149     rewriteutil,
   150     scmutil,
   150     scmutil,
   151     util,
   151     util,
   152     worker,
   152     worker,
   153 )
   153 )
   154 
   154 
   401     revs = set(scmutil.revrange(repo, opts[b'rev']))
   401     revs = set(scmutil.revrange(repo, opts[b'rev']))
   402     for rev in revs:
   402     for rev in revs:
   403         checkfixablectx(ui, repo, repo[rev])
   403         checkfixablectx(ui, repo, repo[rev])
   404     if revs:
   404     if revs:
   405         cmdutil.checkunfinished(repo)
   405         cmdutil.checkunfinished(repo)
   406         checknodescendants(repo, revs)
   406         rewriteutil.precheck(repo, revs, b'fix')
   407     if opts.get(b'working_dir'):
   407     if opts.get(b'working_dir'):
   408         revs.add(wdirrev)
   408         revs.add(wdirrev)
   409         if list(merge.mergestate.read(repo).unresolved()):
   409         if list(merge.mergestate.read(repo).unresolved()):
   410             raise error.Abort(b'unresolved conflicts', hint=b"use 'hg resolve'")
   410             raise error.Abort(b'unresolved conflicts', hint=b"use 'hg resolve'")
   411     if not revs:
   411     if not revs:
   413             b'no changesets specified', hint=b'use --rev or --working-dir'
   413             b'no changesets specified', hint=b'use --rev or --working-dir'
   414         )
   414         )
   415     return revs
   415     return revs
   416 
   416 
   417 
   417 
   418 def checknodescendants(repo, revs):
       
   419     if not obsolete.isenabled(repo, obsolete.allowunstableopt) and repo.revs(
       
   420         b'(%ld::) - (%ld)', revs, revs
       
   421     ):
       
   422         raise error.Abort(
       
   423             _(b'can only fix a changeset together with all its descendants')
       
   424         )
       
   425 
       
   426 
       
   427 def checkfixablectx(ui, repo, ctx):
   418 def checkfixablectx(ui, repo, ctx):
   428     """Aborts if the revision shouldn't be replaced with a fixed one."""
   419     """Aborts if the revision shouldn't be replaced with a fixed one."""
   429     if not ctx.mutable():
       
   430         raise error.Abort(
       
   431             b'can\'t fix immutable changeset %s'
       
   432             % (scmutil.formatchangeid(ctx),)
       
   433         )
       
   434     if ctx.obsolete():
   420     if ctx.obsolete():
   435         # It would be better to actually check if the revision has a successor.
   421         # It would be better to actually check if the revision has a successor.
   436         allowdivergence = ui.configbool(
   422         allowdivergence = ui.configbool(
   437             b'experimental', b'evolution.allowdivergence'
   423             b'experimental', b'evolution.allowdivergence'
   438         )
   424         )