--- a/mercurial/cmdutil.py Tue Feb 11 11:18:52 2020 +0100
+++ b/mercurial/cmdutil.py Fri Dec 20 15:50:13 2019 -0800
@@ -1410,12 +1410,15 @@
def copy(ui, repo, pats, opts, rename=False):
+ check_incompatible_arguments(opts, b'forget', [b'dry_run'])
+
# called with the repo lock held
#
# hgsep => pathname that uses "/" to separate directories
# ossep => pathname that uses os.sep to separate directories
cwd = repo.getcwd()
targets = {}
+ forget = opts.get(b"forget")
after = opts.get(b"after")
dryrun = opts.get(b"dry_run")
ctx = repo[None]
@@ -1423,6 +1426,24 @@
uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
+ if forget:
+ match = scmutil.match(wctx, pats, opts)
+
+ current_copies = wctx.p1copies()
+ current_copies.update(wctx.p2copies())
+
+ for f in wctx.walk(match):
+ if f in current_copies:
+ wctx[f].markcopied(None)
+ elif match.exact(f):
+ ui.warn(
+ _(
+ b'%s: not unmarking as copy - file is not marked as copied\n'
+ )
+ % uipathfn(f)
+ )
+ return
+
def walkpat(pat):
srcs = []
m = scmutil.match(ctx, [pat], opts, globbed=True)