Mercurial > hg
comparison hgext/largefiles/overrides.py @ 24208:e6b0de02a02e
largefiles: handle logging from outside the repo
It's probably possible to refactor so that the 'if m._cwd' check isn't
necessary, but the False case is the typical case (i.e. run from the root of the
repo), and simpler to read.
An exact path to a largefile from outside the repo was previously ignored.
match.rel('.hglf') will handle figuring out both the correct '../' length to the
standin directory if inside the repo, or path/to/repo from outside, at the cost
of a pconvert() to keep the patterns using '/' on Windows.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 01 Mar 2015 18:35:29 -0500 |
parents | d90e3faf96a9 |
children | 23438bceba04 |
comparison
equal
deleted
inserted
replaced
24207:d90e3faf96a9 | 24208:e6b0de02a02e |
---|---|
311 if kindpat[0] is not None: | 311 if kindpat[0] is not None: |
312 return kindpat[0] + ':' + tostandin(kindpat[1]) | 312 return kindpat[0] + ':' + tostandin(kindpat[1]) |
313 return tostandin(kindpat[1]) | 313 return tostandin(kindpat[1]) |
314 | 314 |
315 if m._cwd: | 315 if m._cwd: |
316 if os.path.isabs(m._cwd): | 316 hglf = lfutil.shortname |
317 # TODO: handle largefile magic when invoked from other cwd | 317 back = util.pconvert(m.rel(hglf)[:-len(hglf)]) |
318 return matchandpats | |
319 back = (m._cwd.count('/') + 1) * '../' | |
320 | 318 |
321 def tostandin(f): | 319 def tostandin(f): |
322 # The file may already be a standin, so trucate the back | 320 # The file may already be a standin, so trucate the back |
323 # escaping and test before mangling it. This avoids turning | 321 # prefix and test before mangling it. This avoids turning |
324 # 'glob:../.hglf/foo*' into 'glob:../.hglf/../.hglf/foo*'. | 322 # 'glob:../.hglf/foo*' into 'glob:../.hglf/../.hglf/foo*'. |
325 if f.startswith(back) and lfutil.splitstandin(f[len(back):]): | 323 if f.startswith(back) and lfutil.splitstandin(f[len(back):]): |
326 return f | 324 return f |
327 | 325 |
328 return back + lfutil.standin(m._cwd + '/' + f) | 326 # An absolute path is from outside the repo, so truncate the |
327 # path to the root before building the standin. Otherwise cwd | |
328 # is somewhere in the repo, relative to root, and needs to be | |
329 # prepended before building the standin. | |
330 if os.path.isabs(m._cwd): | |
331 f = f[len(back):] | |
332 else: | |
333 f = m._cwd + '/' + f | |
334 return back + lfutil.standin(f) | |
329 | 335 |
330 pats.update(fixpats(f, tostandin) for f in p) | 336 pats.update(fixpats(f, tostandin) for f in p) |
331 else: | 337 else: |
332 def tostandin(f): | 338 def tostandin(f): |
333 if lfutil.splitstandin(f): | 339 if lfutil.splitstandin(f): |