hgext/largefiles/overrides.py
changeset 31618 5c1d3f1b8f44
parent 31318 8908f985570c
child 31619 d5d0e6ca62ad
equal deleted inserted replaced
31617:c93cdfa131a8 31618:5c1d3f1b8f44
   647             m = copy.copy(match)
   647             m = copy.copy(match)
   648             lfile = lambda f: lfutil.standin(f) in manifest
   648             lfile = lambda f: lfutil.standin(f) in manifest
   649             m._files = [lfutil.standin(f) for f in m._files if lfile(f)]
   649             m._files = [lfutil.standin(f) for f in m._files if lfile(f)]
   650             m._fileroots = set(m._files)
   650             m._fileroots = set(m._files)
   651             origmatchfn = m.matchfn
   651             origmatchfn = m.matchfn
   652             m.matchfn = lambda f: (lfutil.isstandin(f) and
   652             def matchfn(f):
   653                                 (f in manifest) and
   653                 lfile = lfutil.splitstandin(f)
   654                                 origmatchfn(lfutil.splitstandin(f)) or
   654                 return (lfile is not None and
   655                                 None)
   655                         (f in manifest) and
       
   656                         origmatchfn(lfile) or
       
   657                         None)
       
   658             m.matchfn = matchfn
   656             return m
   659             return m
   657         oldmatch = installmatchfn(overridematch)
   660         oldmatch = installmatchfn(overridematch)
   658         listpats = []
   661         listpats = []
   659         for pat in pats:
   662         for pat in pats:
   660             if matchmod.patkind(pat) is not None:
   663             if matchmod.patkind(pat) is not None:
   765             m._files = [tostandin(f) for f in m._files]
   768             m._files = [tostandin(f) for f in m._files]
   766             m._files = [f for f in m._files if f is not None]
   769             m._files = [f for f in m._files if f is not None]
   767             m._fileroots = set(m._files)
   770             m._fileroots = set(m._files)
   768             origmatchfn = m.matchfn
   771             origmatchfn = m.matchfn
   769             def matchfn(f):
   772             def matchfn(f):
   770                 if lfutil.isstandin(f):
   773                 lfile = lfutil.splitstandin(f)
   771                     return (origmatchfn(lfutil.splitstandin(f)) and
   774                 if lfile is not None:
       
   775                     return (origmatchfn(lfile) and
   772                             (f in ctx or f in mctx))
   776                             (f in ctx or f in mctx))
   773                 return origmatchfn(f)
   777                 return origmatchfn(f)
   774             m.matchfn = matchfn
   778             m.matchfn = matchfn
   775             return m
   779             return m
   776         oldmatch = installmatchfn(overridematch)
   780         oldmatch = installmatchfn(overridematch)
   966               lambda: archival.buildmetadata(ctx))
   970               lambda: archival.buildmetadata(ctx))
   967 
   971 
   968     for f in ctx:
   972     for f in ctx:
   969         ff = ctx.flags(f)
   973         ff = ctx.flags(f)
   970         getdata = ctx[f].data
   974         getdata = ctx[f].data
   971         if lfutil.isstandin(f):
   975         lfile = lfutil.splitstandin(f)
       
   976         if lfile is not None:
   972             if node is not None:
   977             if node is not None:
   973                 path = lfutil.findfile(repo, getdata().strip())
   978                 path = lfutil.findfile(repo, getdata().strip())
   974 
   979 
   975                 if path is None:
   980                 if path is None:
   976                     raise error.Abort(
   981                     raise error.Abort(
   977                        _('largefile %s not found in repo store or system cache')
   982                        _('largefile %s not found in repo store or system cache')
   978                        % lfutil.splitstandin(f))
   983                        % lfile)
   979             else:
   984             else:
   980                 path = lfutil.splitstandin(f)
   985                 path = lfile
   981 
   986 
   982             f = lfutil.splitstandin(f)
   987             f = lfile
   983 
   988 
   984             getdata = lambda: util.readfile(path)
   989             getdata = lambda: util.readfile(path)
   985         write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, getdata)
   990         write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, getdata)
   986 
   991 
   987     if subrepos:
   992     if subrepos:
  1016         archiver.addfile(prefix + repo._path + '/' + name, mode, islink, data)
  1021         archiver.addfile(prefix + repo._path + '/' + name, mode, islink, data)
  1017 
  1022 
  1018     for f in ctx:
  1023     for f in ctx:
  1019         ff = ctx.flags(f)
  1024         ff = ctx.flags(f)
  1020         getdata = ctx[f].data
  1025         getdata = ctx[f].data
  1021         if lfutil.isstandin(f):
  1026         lfile = lfutil.splitstandin(f)
       
  1027         if lfile is not None:
  1022             if ctx.node() is not None:
  1028             if ctx.node() is not None:
  1023                 path = lfutil.findfile(repo._repo, getdata().strip())
  1029                 path = lfutil.findfile(repo._repo, getdata().strip())
  1024 
  1030 
  1025                 if path is None:
  1031                 if path is None:
  1026                     raise error.Abort(
  1032                     raise error.Abort(
  1027                        _('largefile %s not found in repo store or system cache')
  1033                        _('largefile %s not found in repo store or system cache')
  1028                        % lfutil.splitstandin(f))
  1034                        % lfile)
  1029             else:
  1035             else:
  1030                 path = lfutil.splitstandin(f)
  1036                 path = lfile
  1031 
  1037 
  1032             f = lfutil.splitstandin(f)
  1038             f = lfile
  1033 
  1039 
  1034             getdata = lambda: util.readfile(os.path.join(prefix, path))
  1040             getdata = lambda: util.readfile(os.path.join(prefix, path))
  1035 
  1041 
  1036         write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, getdata)
  1042         write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, getdata)
  1037 
  1043 
  1431         return result
  1437         return result
  1432 
  1438 
  1433 def scmutilmarktouched(orig, repo, files, *args, **kwargs):
  1439 def scmutilmarktouched(orig, repo, files, *args, **kwargs):
  1434     result = orig(repo, files, *args, **kwargs)
  1440     result = orig(repo, files, *args, **kwargs)
  1435 
  1441 
  1436     filelist = [lfutil.splitstandin(f) for f in files if lfutil.isstandin(f)]
  1442     filelist = []
       
  1443     for f in files:
       
  1444         lf = lfutil.splitstandin(f)
       
  1445         if lf is not None:
       
  1446             filelist.append(lf)
  1437     if filelist:
  1447     if filelist:
  1438         lfcommands.updatelfiles(repo.ui, repo, filelist=filelist,
  1448         lfcommands.updatelfiles(repo.ui, repo, filelist=filelist,
  1439                                 printmessage=False, normallookup=True)
  1449                                 printmessage=False, normallookup=True)
  1440 
  1450 
  1441     return result
  1451     return result