mercurial/cmdutil.py
changeset 44365 7c4b98a4e536
parent 44364 8be0c63535b5
child 44366 d8b49bf6cfec
equal deleted inserted replaced
44364:8be0c63535b5 44365:7c4b98a4e536
  1425     pctx = ctx.p1()
  1425     pctx = ctx.p1()
  1426 
  1426 
  1427     uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
  1427     uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
  1428 
  1428 
  1429     if forget:
  1429     if forget:
  1430         match = scmutil.match(wctx, pats, opts)
  1430         rev = opts[b'at_rev']
  1431 
  1431         if rev:
  1432         current_copies = wctx.p1copies()
  1432             ctx = scmutil.revsingle(repo, rev)
  1433         current_copies.update(wctx.p2copies())
  1433         else:
  1434 
  1434             ctx = repo[None]
  1435         for f in wctx.walk(match):
  1435         if ctx.rev() is None:
       
  1436             new_ctx = ctx
       
  1437         else:
       
  1438             if len(ctx.parents()) > 1:
       
  1439                 raise error.Abort(_(b'cannot unmark copy in merge commit'))
       
  1440             # avoid cycle context -> subrepo -> cmdutil
       
  1441             from . import context
       
  1442 
       
  1443             rewriteutil.precheck(repo, [ctx.rev()], b'uncopy')
       
  1444             new_ctx = context.overlayworkingctx(repo)
       
  1445             new_ctx.setbase(ctx.p1())
       
  1446             mergemod.graft(repo, ctx, wctx=new_ctx)
       
  1447 
       
  1448         match = scmutil.match(ctx, pats, opts)
       
  1449 
       
  1450         current_copies = ctx.p1copies()
       
  1451         current_copies.update(ctx.p2copies())
       
  1452 
       
  1453         uipathfn = scmutil.getuipathfn(repo)
       
  1454         for f in ctx.walk(match):
  1436             if f in current_copies:
  1455             if f in current_copies:
  1437                 wctx[f].markcopied(None)
  1456                 new_ctx[f].markcopied(None)
  1438             elif match.exact(f):
  1457             elif match.exact(f):
  1439                 ui.warn(
  1458                 ui.warn(
  1440                     _(
  1459                     _(
  1441                         b'%s: not unmarking as copy - file is not marked as copied\n'
  1460                         b'%s: not unmarking as copy - file is not marked as copied\n'
  1442                     )
  1461                     )
  1443                     % uipathfn(f)
  1462                     % uipathfn(f)
  1444                 )
  1463                 )
       
  1464 
       
  1465         if ctx.rev() is not None:
       
  1466             with repo.lock():
       
  1467                 mem_ctx = new_ctx.tomemctx_for_amend(ctx)
       
  1468                 new_node = mem_ctx.commit()
       
  1469 
       
  1470                 if repo.dirstate.p1() == ctx.node():
       
  1471                     with repo.dirstate.parentchange():
       
  1472                         scmutil.movedirstate(repo, repo[new_node])
       
  1473                 replacements = {ctx.node(): [new_node]}
       
  1474                 scmutil.cleanupnodes(
       
  1475                     repo, replacements, b'uncopy', fixphase=True
       
  1476                 )
       
  1477 
  1445         return
  1478         return
       
  1479 
       
  1480     if opts.get(b'at_rev'):
       
  1481         raise error.Abort(_("--at-rev is only supported with --forget"))
  1446 
  1482 
  1447     def walkpat(pat):
  1483     def walkpat(pat):
  1448         srcs = []
  1484         srcs = []
  1449         m = scmutil.match(ctx, [pat], opts, globbed=True)
  1485         m = scmutil.match(ctx, [pat], opts, globbed=True)
  1450         for abs in ctx.walk(m):
  1486         for abs in ctx.walk(m):