Mercurial > public > mercurial-scm > hg-stable
diff mercurial/copies.py @ 18136:f23dea2b296e
copies: do not track backward copies, only renames (issue3739)
The inverse of a rename is a rename, but the inverse of a copy is not a copy.
Presenting it as such -- in particular, stuffing it into the same dict as real
copies -- causes bugs because other code starts believing the inverse copies
are real.
The only test whose output changes is test-mv-cp-st-diff.t. When a backwards
status -C command is run where a copy is involved, the inverse copy (which was
hitherto presented as a real copy) is no longer displayed.
Keeping track of inverse copies is useful in some situations -- composability
of diffs, for example, since adding "a" followed by an inverse copy "b" to "a"
is equivalent to a rename "b" to "a". However, representing them would require
a more complex data structure than the same dict in which real copies are also
stored.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Wed, 26 Dec 2012 15:04:07 -0800 |
parents | a6fe1b9cc68f |
children | 2330d97e7707 |
line wrap: on
line diff
--- a/mercurial/copies.py Wed Dec 26 15:03:58 2012 -0800 +++ b/mercurial/copies.py Wed Dec 26 15:04:07 2012 -0800 @@ -145,12 +145,16 @@ return cm -def _backwardcopies(a, b): - # because the forward mapping is 1:n, we can lose renames here - # in particular, we find renames better than copies +def _backwardrenames(a, b): + # 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 + # arbitrarily pick one of the renames. f = _forwardcopies(b, a) r = {} for k, v in f.iteritems(): + # remove copies + if v in a: + continue r[v] = k return r @@ -162,8 +166,8 @@ if a == x: return _forwardcopies(x, y) if a == y: - return _backwardcopies(x, y) - return _chain(x, y, _backwardcopies(x, a), _forwardcopies(a, y)) + return _backwardrenames(x, y) + return _chain(x, y, _backwardrenames(x, a), _forwardcopies(a, y)) def mergecopies(repo, c1, c2, ca): """