Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 44805:02bf61bb4a70
copy: to find copy source, walk parent of revision we're marking copies in
As shown in the previous patch, `hg cp --after --at-rev . src dst`
fails if `src` is not in `.`. It seems obvious that you should always
walk the *parent* of the revision you're marking copies in, but that's
not how it was done for the working copy, and I didn't think to change
it when marking copies in a non-working-copy commit.
This patch fixes that by walking the parent commit instead, but only
if we're marking copies for a non-working-copy commit. We need to
leave the working-copy code unchanged because it depends on the weird
behavior of `workingctx.walk()`. With these changes, there's very
little overlap between the working-copy version and the
non-working-copy version of `walkpats()`, but I've refrained from
cleaning that up on the stable branch.
Differential Revision: https://phab.mercurial-scm.org/D8494
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 06 May 2020 10:33:56 -0700 |
parents | 9d2b2df2c2ba |
children | 16596f5e1afa |
comparison
equal
deleted
inserted
replaced
44804:5c49a4fdb238 | 44805:02bf61bb4a70 |
---|---|
1494 raise error.Abort(_(b'no destination specified')) | 1494 raise error.Abort(_(b'no destination specified')) |
1495 dest = pats.pop() | 1495 dest = pats.pop() |
1496 | 1496 |
1497 def walkpat(pat): | 1497 def walkpat(pat): |
1498 srcs = [] | 1498 srcs = [] |
1499 m = scmutil.match(ctx, [pat], opts, globbed=True) | 1499 # TODO: Inline and simplify the non-working-copy version of this code |
1500 for abs in ctx.walk(m): | 1500 # since it shares very little with the working-copy version of it. |
1501 ctx_to_walk = ctx if ctx.rev() is None else pctx | |
1502 m = scmutil.match(ctx_to_walk, [pat], opts, globbed=True) | |
1503 for abs in ctx_to_walk.walk(m): | |
1501 rel = uipathfn(abs) | 1504 rel = uipathfn(abs) |
1502 exact = m.exact(abs) | 1505 exact = m.exact(abs) |
1503 if abs not in ctx: | 1506 if abs not in ctx: |
1504 if abs in pctx: | 1507 if abs in pctx: |
1505 if not after: | 1508 if not after: |