Mercurial > public > mercurial-scm > hg-stable
diff mercurial/cmdutil.py @ 44398:8be0c63535b5
copy: add option to unmark file as copied
To unmark a file as copied, the user currently has to do this:
hg forget <dest>
hg add <dest>
The new command simplifies that to:
hg copy --forget <dest>
That's not a very big improvement, but I'm planning to also teach `hg
copy [--forget]` a `--at-rev` argument for marking/unmarking copies
after commit (usually with `--at-rev .`).
Differential Revision: https://phab.mercurial-scm.org/D8029
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 20 Dec 2019 15:50:13 -0800 |
parents | 27a78ea30b48 |
children | 7c4b98a4e536 |
line wrap: on
line diff
--- 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)