hgext/largefiles/overrides.py
branchstable
changeset 15306 94527d67f3da
parent 15305 683f417fa538
child 15323 19368c54a774
equal deleted inserted replaced
15305:683f417fa538 15306:94527d67f3da
    22 
    22 
    23 def installnormalfilesmatchfn(manifest):
    23 def installnormalfilesmatchfn(manifest):
    24     '''overrides scmutil.match so that the matcher it returns will ignore all
    24     '''overrides scmutil.match so that the matcher it returns will ignore all
    25     largefiles'''
    25     largefiles'''
    26     oldmatch = None # for the closure
    26     oldmatch = None # for the closure
    27     def override_match(repo, pats=[], opts={}, globbed=False,
    27     def override_match(ctx, pats=[], opts={}, globbed=False,
    28             default='relpath'):
    28             default='relpath'):
    29         match = oldmatch(repo, pats, opts, globbed, default)
    29         match = oldmatch(ctx, pats, opts, globbed, default)
    30         m = copy.copy(match)
    30         m = copy.copy(match)
    31         notlfile = lambda f: not (lfutil.isstandin(f) or lfutil.standin(f) in
    31         notlfile = lambda f: not (lfutil.isstandin(f) or lfutil.standin(f) in
    32                 manifest)
    32                 manifest)
    33         m._files = filter(notlfile, m._files)
    33         m._files = filter(notlfile, m._files)
    34         m._fmap = set(m._files)
    34         m._fmap = set(m._files)
   339             # to the dir state until later so lock during that time.
   339             # to the dir state until later so lock during that time.
   340             wlock = repo.wlock()
   340             wlock = repo.wlock()
   341 
   341 
   342             manifest = repo[None].manifest()
   342             manifest = repo[None].manifest()
   343             oldmatch = None # for the closure
   343             oldmatch = None # for the closure
   344             def override_match(repo, pats=[], opts={}, globbed=False,
   344             def override_match(ctx, pats=[], opts={}, globbed=False,
   345                     default='relpath'):
   345                     default='relpath'):
   346                 newpats = []
   346                 newpats = []
   347                 # The patterns were previously mangled to add the standin
   347                 # The patterns were previously mangled to add the standin
   348                 # directory; we need to remove that now
   348                 # directory; we need to remove that now
   349                 for pat in pats:
   349                 for pat in pats:
   350                     if match_.patkind(pat) is None and lfutil.shortname in pat:
   350                     if match_.patkind(pat) is None and lfutil.shortname in pat:
   351                         newpats.append(pat.replace(lfutil.shortname, ''))
   351                         newpats.append(pat.replace(lfutil.shortname, ''))
   352                     else:
   352                     else:
   353                         newpats.append(pat)
   353                         newpats.append(pat)
   354                 match = oldmatch(repo, newpats, opts, globbed, default)
   354                 match = oldmatch(ctx, newpats, opts, globbed, default)
   355                 m = copy.copy(match)
   355                 m = copy.copy(match)
   356                 lfile = lambda f: lfutil.standin(f) in manifest
   356                 lfile = lambda f: lfutil.standin(f) in manifest
   357                 m._files = [lfutil.standin(f) for f in m._files if lfile(f)]
   357                 m._files = [lfutil.standin(f) for f in m._files if lfile(f)]
   358                 m._fmap = set(m._files)
   358                 m._fmap = set(m._files)
   359                 orig_matchfn = m.matchfn
   359                 orig_matchfn = m.matchfn
   441             lfutil.updatestandin(repo, lfutil.standin(lfile))
   441             lfutil.updatestandin(repo, lfutil.standin(lfile))
   442 
   442 
   443         try:
   443         try:
   444             ctx = repo[opts.get('rev')]
   444             ctx = repo[opts.get('rev')]
   445             oldmatch = None # for the closure
   445             oldmatch = None # for the closure
   446             def override_match(ctxorrepo, pats=[], opts={}, globbed=False,
   446             def override_match(ctx, pats=[], opts={}, globbed=False,
   447                     default='relpath'):
   447                     default='relpath'):
   448                 if util.safehasattr(ctxorrepo, 'match'):
   448                 match = oldmatch(ctx, pats, opts, globbed, default)
   449                     ctx0 = ctxorrepo
       
   450                 else:
       
   451                     ctx0 = ctxorrepo[None]
       
   452                 match = oldmatch(ctxorrepo, pats, opts, globbed, default)
       
   453                 m = copy.copy(match)
   449                 m = copy.copy(match)
   454                 def tostandin(f):
   450                 def tostandin(f):
   455                     if lfutil.standin(f) in ctx0 or lfutil.standin(f) in ctx:
   451                     if lfutil.standin(f) in ctx or lfutil.standin(f) in ctx:
   456                         return lfutil.standin(f)
   452                         return lfutil.standin(f)
   457                     elif lfutil.standin(f) in repo[None]:
   453                     elif lfutil.standin(f) in repo[None]:
   458                         return None
   454                         return None
   459                     return f
   455                     return f
   460                 m._files = [tostandin(f) for f in m._files]
   456                 m._files = [tostandin(f) for f in m._files]