Mercurial > hg
comparison hgext/lfs/__init__.py @ 35664:3c838bdc57b6
lfs: move the tracked file function creation to a method
Once a commitable file format for tracked config is agreed upon, I can't see any
reason to have a config based way to control this. (Other than convert. That
will be necessary to override the file when converting to normal files. Also,
converting to lfs needs this if not splicing the file in at the beginning. So
maybe the existing config option should be `convert` specific.) Looking to
hgeol for precedent, it looks like policy that affects how items are stored are
handled only by the tracked file, while policy that affects the checkout can be
handled by either a user config or the tracked file (but the latter takes
precedence).
We probably need a transition period, so this transition policy can be
controlled by the function. Additionally, it provides a place for convert to
wrap to override the file based config.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 14 Jan 2018 01:04:45 -0500 |
parents | a985834961f7 |
children | 1ad1e59b405e |
comparison
equal
deleted
inserted
replaced
35663:a985834961f7 | 35664:3c838bdc57b6 |
---|---|
122 def reposetup(ui, repo): | 122 def reposetup(ui, repo): |
123 # Nothing to do with a remote repo | 123 # Nothing to do with a remote repo |
124 if not repo.local(): | 124 if not repo.local(): |
125 return | 125 return |
126 | 126 |
127 trackspec = repo.ui.config('lfs', 'track') | 127 repo.svfs.options['lfstrack'] = _trackedmatcher(repo) |
128 | |
129 # deprecated config: lfs.threshold | |
130 threshold = repo.ui.configbytes('lfs', 'threshold') | |
131 if threshold: | |
132 fileset.parse(trackspec) # make sure syntax errors are confined | |
133 trackspec = "(%s) | size('>%d')" % (trackspec, threshold) | |
134 | |
135 repo.svfs.options['lfstrack'] = minifileset.compile(trackspec) | |
136 repo.svfs.lfslocalblobstore = blobstore.local(repo) | 128 repo.svfs.lfslocalblobstore = blobstore.local(repo) |
137 repo.svfs.lfsremoteblobstore = blobstore.remote(repo) | 129 repo.svfs.lfsremoteblobstore = blobstore.remote(repo) |
138 | 130 |
139 # Push hook | 131 # Push hook |
140 repo.prepushoutgoinghooks.add('lfs', wrapper.prepush) | 132 repo.prepushoutgoinghooks.add('lfs', wrapper.prepush) |
156 break | 148 break |
157 | 149 |
158 ui.setconfig('hooks', 'commit.lfs', checkrequireslfs, 'lfs') | 150 ui.setconfig('hooks', 'commit.lfs', checkrequireslfs, 'lfs') |
159 ui.setconfig('hooks', 'pretxnchangegroup.lfs', checkrequireslfs, 'lfs') | 151 ui.setconfig('hooks', 'pretxnchangegroup.lfs', checkrequireslfs, 'lfs') |
160 | 152 |
153 def _trackedmatcher(repo): | |
154 """Return a function (path, size) -> bool indicating whether or not to | |
155 track a given file with lfs.""" | |
156 trackspec = repo.ui.config('lfs', 'track') | |
157 | |
158 # deprecated config: lfs.threshold | |
159 threshold = repo.ui.configbytes('lfs', 'threshold') | |
160 if threshold: | |
161 fileset.parse(trackspec) # make sure syntax errors are confined | |
162 trackspec = "(%s) | size('>%d')" % (trackspec, threshold) | |
163 | |
164 return minifileset.compile(trackspec) | |
165 | |
161 def wrapfilelog(filelog): | 166 def wrapfilelog(filelog): |
162 wrapfunction = extensions.wrapfunction | 167 wrapfunction = extensions.wrapfunction |
163 | 168 |
164 wrapfunction(filelog, 'addrevision', wrapper.filelogaddrevision) | 169 wrapfunction(filelog, 'addrevision', wrapper.filelogaddrevision) |
165 wrapfunction(filelog, 'renamed', wrapper.filelogrenamed) | 170 wrapfunction(filelog, 'renamed', wrapper.filelogrenamed) |