comparison mercurial/copies.py @ 41752:012f695546aa

copies: respect narrowmatcher in "parent -> working dir" case 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. Differential Revision: https://phab.mercurial-scm.org/D5987
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 19 Feb 2019 10:31:06 -0800
parents 35158796f52f
children 3158cb74fbca
comparison
equal deleted inserted replaced
41751:4ec0ce0fb929 41752:012f695546aa
139 if am.get(f.path(), None) == f.filenode(): 139 if am.get(f.path(), None) == f.filenode():
140 return f 140 return f
141 if limit >= 0 and not f.isintroducedafter(limit): 141 if limit >= 0 and not f.isintroducedafter(limit):
142 return None 142 return None
143 143
144 def _dirstatecopies(d, match=None): 144 def _dirstatecopies(repo, match=None):
145 ds = d._repo.dirstate 145 ds = repo.dirstate
146 c = ds.copies().copy() 146 c = ds.copies().copy()
147 for k in list(c): 147 for k in list(c):
148 if ds[k] not in 'anm' or (match and not match(k)): 148 if ds[k] not in 'anm' or (match and not match(k)):
149 del c[k] 149 del c[k]
150 return c 150 return c
219 match = a.repo().narrowmatch(match) 219 match = a.repo().narrowmatch(match)
220 # check for working copy 220 # check for working copy
221 if b.rev() is None: 221 if b.rev() is None:
222 if a == b.p1(): 222 if a == b.p1():
223 # short-circuit to avoid issues with merge states 223 # short-circuit to avoid issues with merge states
224 return _dirstatecopies(b, match) 224 return _dirstatecopies(b._repo, match)
225 225
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, 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):
232 if a._repo.ui.config('experimental', 'copytrace') == 'off': 232 if a._repo.ui.config('experimental', 'copytrace') == 'off':
233 return {} 233 return {}
389 """ 389 """
390 # avoid silly behavior for update from empty dir 390 # avoid silly behavior for update from empty dir
391 if not c1 or not c2 or c1 == c2: 391 if not c1 or not c2 or c1 == c2:
392 return {}, {}, {}, {}, {} 392 return {}, {}, {}, {}, {}
393 393
394 narrowmatch = c1.repo().narrowmatch()
395
394 # avoid silly behavior for parent -> working dir 396 # avoid silly behavior for parent -> working dir
395 if c2.node() is None and c1.node() == repo.dirstate.p1(): 397 if c2.node() is None and c1.node() == repo.dirstate.p1():
396 return repo.dirstate.copies(), {}, {}, {}, {} 398 return _dirstatecopies(repo, narrowmatch), {}, {}, {}, {}
397 399
398 copytracing = repo.ui.config('experimental', 'copytrace') 400 copytracing = repo.ui.config('experimental', 'copytrace')
399 boolctrace = stringutil.parsebool(copytracing) 401 boolctrace = stringutil.parsebool(copytracing)
400 402
401 # Copy trace disabling is explicitly below the node == p1 logic above 403 # Copy trace disabling is explicitly below the node == p1 logic above