comparison hgext/largefiles/overrides.py @ 24206:13c1e66f9653

largefiles: teach log to handle patterns Adding the standin to the patterns list was (possibly) harmless before, but was wrong, because the pattern list was already updated above that code. Now that patterns are handled, it was actually harmful. For example, in this test: $ hg log -G glob:**another* the adjusted pattern list would have been: ['glob:**another*', '.hglf/.', 'glob:.hglf/**another*'] which causes every largefile in the root to be matched. I'm not sure why 'glob:a*' picks up the rename of a -> b commit in test-log.t, but a simple 'a' doesn't. But it doesn't appear to be caused by the largefiles extension.
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 28 Feb 2015 23:42:38 -0500
parents e0f06228bb66
children d90e3faf96a9
comparison
equal deleted inserted replaced
24205:abcb1ee3b20a 24206:13c1e66f9653
302 # We want to match everything anyway, so there's no benefit trying 302 # We want to match everything anyway, so there's no benefit trying
303 # to add standins. 303 # to add standins.
304 return matchandpats 304 return matchandpats
305 305
306 pats = set(p) 306 pats = set(p)
307 # TODO: handling of patterns in both cases below 307
308 def fixpats(pat, tostandin=lfutil.standin):
309 kindpat = match_._patsplit(pat, None)
310
311 if kindpat[0] is not None:
312 return kindpat[0] + ':' + tostandin(kindpat[1])
313 return tostandin(kindpat[1])
314
308 if m._cwd: 315 if m._cwd:
309 if os.path.isabs(m._cwd): 316 if os.path.isabs(m._cwd):
310 # TODO: handle largefile magic when invoked from other cwd 317 # TODO: handle largefile magic when invoked from other cwd
311 return matchandpats 318 return matchandpats
312 back = (m._cwd.count('/') + 1) * '../' 319 back = (m._cwd.count('/') + 1) * '../'
313 pats.update(back + lfutil.standin(m._cwd + '/' + f) for f in p) 320
321 def tostandin(f):
322 return back + lfutil.standin(m._cwd + '/' + f)
323
324 pats.update(fixpats(f, tostandin) for f in p)
314 else: 325 else:
315 pats.update(lfutil.standin(f) for f in p) 326 pats.update(fixpats(f) for f in p)
316 327
317 for i in range(0, len(m._files)): 328 for i in range(0, len(m._files)):
329 # Don't add '.hglf' to m.files, since that is already covered by '.'
330 if m._files[i] == '.':
331 continue
318 standin = lfutil.standin(m._files[i]) 332 standin = lfutil.standin(m._files[i])
319 # If the "standin" is a directory, append instead of replace to 333 # If the "standin" is a directory, append instead of replace to
320 # support naming a directory on the command line with only 334 # support naming a directory on the command line with only
321 # largefiles. The original directory is kept to support normal 335 # largefiles. The original directory is kept to support normal
322 # files. 336 # files.
323 if standin in repo[ctx.node()]: 337 if standin in repo[ctx.node()]:
324 m._files[i] = standin 338 m._files[i] = standin
325 elif m._files[i] not in repo[ctx.node()] \ 339 elif m._files[i] not in repo[ctx.node()] \
326 and repo.wvfs.isdir(standin): 340 and repo.wvfs.isdir(standin):
327 m._files.append(standin) 341 m._files.append(standin)
328 pats.add(standin)
329 342
330 m._fmap = set(m._files) 343 m._fmap = set(m._files)
331 m._always = False 344 m._always = False
332 origmatchfn = m.matchfn 345 origmatchfn = m.matchfn
333 def lfmatchfn(f): 346 def lfmatchfn(f):