Mercurial > hg
comparison mercurial/copies.py @ 41753:3158cb74fbca
copies: make _backwardrenames() filter out copies by destination
As shown by the test case, _backwardrenames() doesn't filter by the
matcher. It doesn't show up in `hg status --copies` because that only
prints files changed between the two commits. I wouldn't be surprised
if some other command that replies on pathcopies() was broken before
this patch, but I haven't bothered to check other commands.
Differential Revision: https://phab.mercurial-scm.org/D5988
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 19 Feb 2019 10:45:22 -0800 |
parents | 012f695546aa |
children | d5edb5d3a337 |
comparison
equal
deleted
inserted
replaced
41752:012f695546aa | 41753:3158cb74fbca |
---|---|
226 cm = _committedforwardcopies(a, b.p1(), match) | 226 cm = _committedforwardcopies(a, b.p1(), match) |
227 # combine copies from dirstate if necessary | 227 # combine copies from dirstate if necessary |
228 return _chain(a, b, cm, _dirstatecopies(b._repo, match)) | 228 return _chain(a, b, cm, _dirstatecopies(b._repo, match)) |
229 return _committedforwardcopies(a, b, match) | 229 return _committedforwardcopies(a, b, match) |
230 | 230 |
231 def _backwardrenames(a, b): | 231 def _backwardrenames(a, b, match): |
232 if a._repo.ui.config('experimental', 'copytrace') == 'off': | 232 if a._repo.ui.config('experimental', 'copytrace') == 'off': |
233 return {} | 233 return {} |
234 | 234 |
235 # Even though we're not taking copies into account, 1:n rename situations | 235 # Even though we're not taking copies into account, 1:n rename situations |
236 # can still exist (e.g. hg cp a b; hg mv a c). In those cases we | 236 # can still exist (e.g. hg cp a b; hg mv a c). In those cases we |
237 # arbitrarily pick one of the renames. | 237 # arbitrarily pick one of the renames. |
238 # We don't want to pass in "match" here, since that would filter | |
239 # the destination by it. Since we're reversing the copies, we want | |
240 # to filter the source instead. | |
238 f = _forwardcopies(b, a) | 241 f = _forwardcopies(b, a) |
239 r = {} | 242 r = {} |
240 for k, v in sorted(f.iteritems()): | 243 for k, v in sorted(f.iteritems()): |
244 if match and not match(v): | |
245 continue | |
241 # remove copies | 246 # remove copies |
242 if v in a: | 247 if v in a: |
243 continue | 248 continue |
244 r[v] = k | 249 r[v] = k |
245 return r | 250 return r |
259 repo.ui.debug('debug.copies: search mode: forward\n') | 264 repo.ui.debug('debug.copies: search mode: forward\n') |
260 return _forwardcopies(x, y, match=match) | 265 return _forwardcopies(x, y, match=match) |
261 if a == y: | 266 if a == y: |
262 if debug: | 267 if debug: |
263 repo.ui.debug('debug.copies: search mode: backward\n') | 268 repo.ui.debug('debug.copies: search mode: backward\n') |
264 return _backwardrenames(x, y) | 269 return _backwardrenames(x, y, match=match) |
265 if debug: | 270 if debug: |
266 repo.ui.debug('debug.copies: search mode: combined\n') | 271 repo.ui.debug('debug.copies: search mode: combined\n') |
267 return _chain(x, y, _backwardrenames(x, a), | 272 return _chain(x, y, _backwardrenames(x, a, match=match), |
268 _forwardcopies(a, y, match=match)) | 273 _forwardcopies(a, y, match=match)) |
269 | 274 |
270 def _computenonoverlap(repo, c1, c2, addedinm1, addedinm2, baselabel=''): | 275 def _computenonoverlap(repo, c1, c2, addedinm1, addedinm2, baselabel=''): |
271 """Computes, based on addedinm1 and addedinm2, the files exclusive to c1 | 276 """Computes, based on addedinm1 and addedinm2, the files exclusive to c1 |
272 and c2. This is its own function so extensions can easily wrap this call | 277 and c2. This is its own function so extensions can easily wrap this call |