I don't know when this case happens and we don't seem to have tests
for it, but let's fix it anyway since I happened to notice it.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
I don't know when this case happens and we don't seem to have tests
for it, but let's fix it anyway since I happened to notice it.
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/copies.py (12 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Martin von Zweigbergk | Feb 19 2019, 1:31 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
manifest am, stopping after the first ancestor lower than limit""" | manifest am, stopping after the first ancestor lower than limit""" | ||||
for f in fctx.ancestors(): | for f in fctx.ancestors(): | ||||
if am.get(f.path(), None) == f.filenode(): | if am.get(f.path(), None) == f.filenode(): | ||||
return f | return f | ||||
if limit >= 0 and not f.isintroducedafter(limit): | if limit >= 0 and not f.isintroducedafter(limit): | ||||
return None | return None | ||||
def _dirstatecopies(d, match=None): | def _dirstatecopies(repo, match=None): | ||||
ds = d._repo.dirstate | ds = repo.dirstate | ||||
c = ds.copies().copy() | c = ds.copies().copy() | ||||
for k in list(c): | for k in list(c): | ||||
if ds[k] not in 'anm' or (match and not match(k)): | if ds[k] not in 'anm' or (match and not match(k)): | ||||
del c[k] | del c[k] | ||||
return c | return c | ||||
def _computeforwardmissing(a, b, match=None): | def _computeforwardmissing(a, b, match=None): | ||||
"""Computes which files are in b but not a. | """Computes which files are in b but not a. | ||||
def _forwardcopies(a, b, match=None): | def _forwardcopies(a, b, match=None): | ||||
"""find {dst@b: src@a} copy mapping where a is an ancestor of b""" | """find {dst@b: src@a} copy mapping where a is an ancestor of b""" | ||||
match = a.repo().narrowmatch(match) | match = a.repo().narrowmatch(match) | ||||
# check for working copy | # check for working copy | ||||
if b.rev() is None: | if b.rev() is None: | ||||
if a == b.p1(): | if a == b.p1(): | ||||
# short-circuit to avoid issues with merge states | # short-circuit to avoid issues with merge states | ||||
return _dirstatecopies(b, match) | return _dirstatecopies(b._repo, match) | ||||
cm = _committedforwardcopies(a, b.p1(), match) | cm = _committedforwardcopies(a, b.p1(), match) | ||||
# combine copies from dirstate if necessary | # combine copies from dirstate if necessary | ||||
return _chain(a, b, cm, _dirstatecopies(b, match)) | return _chain(a, b, cm, _dirstatecopies(b._repo, match)) | ||||
return _committedforwardcopies(a, b, match) | return _committedforwardcopies(a, b, match) | ||||
def _backwardrenames(a, b): | def _backwardrenames(a, b): | ||||
if a._repo.ui.config('experimental', 'copytrace') == 'off': | if a._repo.ui.config('experimental', 'copytrace') == 'off': | ||||
return {} | return {} | ||||
# Even though we're not taking copies into account, 1:n rename situations | # Even though we're not taking copies into account, 1:n rename situations | ||||
# can still exist (e.g. hg cp a b; hg mv a c). In those cases we | # can still exist (e.g. hg cp a b; hg mv a c). In those cases we | ||||
"dirmove" is a mapping of detected source dir -> destination dir renames. | "dirmove" is a mapping of detected source dir -> destination dir renames. | ||||
This is needed for handling changes to new files previously grafted into | This is needed for handling changes to new files previously grafted into | ||||
renamed directories. | renamed directories. | ||||
""" | """ | ||||
# avoid silly behavior for update from empty dir | # avoid silly behavior for update from empty dir | ||||
if not c1 or not c2 or c1 == c2: | if not c1 or not c2 or c1 == c2: | ||||
return {}, {}, {}, {}, {} | return {}, {}, {}, {}, {} | ||||
narrowmatch = c1.repo().narrowmatch() | |||||
# avoid silly behavior for parent -> working dir | # avoid silly behavior for parent -> working dir | ||||
if c2.node() is None and c1.node() == repo.dirstate.p1(): | if c2.node() is None and c1.node() == repo.dirstate.p1(): | ||||
return repo.dirstate.copies(), {}, {}, {}, {} | return _dirstatecopies(repo, narrowmatch), {}, {}, {}, {} | ||||
copytracing = repo.ui.config('experimental', 'copytrace') | copytracing = repo.ui.config('experimental', 'copytrace') | ||||
boolctrace = stringutil.parsebool(copytracing) | boolctrace = stringutil.parsebool(copytracing) | ||||
# Copy trace disabling is explicitly below the node == p1 logic above | # Copy trace disabling is explicitly below the node == p1 logic above | ||||
# because the logic above is required for a simple copy to be kept across a | # because the logic above is required for a simple copy to be kept across a | ||||
# rebase. | # rebase. | ||||
if copytracing == 'heuristics': | if copytracing == 'heuristics': |