##// END OF EJS Templates
largefiles: rename match_ to matchmod import in reposetup
liscju -
r29319:cc497d28 default
parent child Browse files
Show More
@@ -1,385 +1,385 b''
1 # Copyright 2009-2010 Gregory P. Ward
1 # Copyright 2009-2010 Gregory P. Ward
2 # Copyright 2009-2010 Intelerad Medical Systems Incorporated
2 # Copyright 2009-2010 Intelerad Medical Systems Incorporated
3 # Copyright 2010-2011 Fog Creek Software
3 # Copyright 2010-2011 Fog Creek Software
4 # Copyright 2010-2011 Unity Technologies
4 # Copyright 2010-2011 Unity Technologies
5 #
5 #
6 # This software may be used and distributed according to the terms of the
6 # This software may be used and distributed according to the terms of the
7 # GNU General Public License version 2 or any later version.
7 # GNU General Public License version 2 or any later version.
8
8
9 '''setup for largefiles repositories: reposetup'''
9 '''setup for largefiles repositories: reposetup'''
10 from __future__ import absolute_import
10 from __future__ import absolute_import
11
11
12 import copy
12 import copy
13
13
14 from mercurial.i18n import _
14 from mercurial.i18n import _
15
15
16 from mercurial import (
16 from mercurial import (
17 error,
17 error,
18 localrepo,
18 localrepo,
19 match as match_,
19 match as matchmod,
20 scmutil,
20 scmutil,
21 )
21 )
22
22
23 from . import (
23 from . import (
24 lfcommands,
24 lfcommands,
25 lfutil,
25 lfutil,
26 )
26 )
27
27
28 def reposetup(ui, repo):
28 def reposetup(ui, repo):
29 # wire repositories should be given new wireproto functions
29 # wire repositories should be given new wireproto functions
30 # by "proto.wirereposetup()" via "hg.wirepeersetupfuncs"
30 # by "proto.wirereposetup()" via "hg.wirepeersetupfuncs"
31 if not repo.local():
31 if not repo.local():
32 return
32 return
33
33
34 class lfilesrepo(repo.__class__):
34 class lfilesrepo(repo.__class__):
35 # the mark to examine whether "repo" object enables largefiles or not
35 # the mark to examine whether "repo" object enables largefiles or not
36 _largefilesenabled = True
36 _largefilesenabled = True
37
37
38 lfstatus = False
38 lfstatus = False
39 def status_nolfiles(self, *args, **kwargs):
39 def status_nolfiles(self, *args, **kwargs):
40 return super(lfilesrepo, self).status(*args, **kwargs)
40 return super(lfilesrepo, self).status(*args, **kwargs)
41
41
42 # When lfstatus is set, return a context that gives the names
42 # When lfstatus is set, return a context that gives the names
43 # of largefiles instead of their corresponding standins and
43 # of largefiles instead of their corresponding standins and
44 # identifies the largefiles as always binary, regardless of
44 # identifies the largefiles as always binary, regardless of
45 # their actual contents.
45 # their actual contents.
46 def __getitem__(self, changeid):
46 def __getitem__(self, changeid):
47 ctx = super(lfilesrepo, self).__getitem__(changeid)
47 ctx = super(lfilesrepo, self).__getitem__(changeid)
48 if self.lfstatus:
48 if self.lfstatus:
49 class lfilesctx(ctx.__class__):
49 class lfilesctx(ctx.__class__):
50 def files(self):
50 def files(self):
51 filenames = super(lfilesctx, self).files()
51 filenames = super(lfilesctx, self).files()
52 return [lfutil.splitstandin(f) or f for f in filenames]
52 return [lfutil.splitstandin(f) or f for f in filenames]
53 def manifest(self):
53 def manifest(self):
54 man1 = super(lfilesctx, self).manifest()
54 man1 = super(lfilesctx, self).manifest()
55 class lfilesmanifest(man1.__class__):
55 class lfilesmanifest(man1.__class__):
56 def __contains__(self, filename):
56 def __contains__(self, filename):
57 orig = super(lfilesmanifest, self).__contains__
57 orig = super(lfilesmanifest, self).__contains__
58 return (orig(filename) or
58 return (orig(filename) or
59 orig(lfutil.standin(filename)))
59 orig(lfutil.standin(filename)))
60 man1.__class__ = lfilesmanifest
60 man1.__class__ = lfilesmanifest
61 return man1
61 return man1
62 def filectx(self, path, fileid=None, filelog=None):
62 def filectx(self, path, fileid=None, filelog=None):
63 orig = super(lfilesctx, self).filectx
63 orig = super(lfilesctx, self).filectx
64 try:
64 try:
65 if filelog is not None:
65 if filelog is not None:
66 result = orig(path, fileid, filelog)
66 result = orig(path, fileid, filelog)
67 else:
67 else:
68 result = orig(path, fileid)
68 result = orig(path, fileid)
69 except error.LookupError:
69 except error.LookupError:
70 # Adding a null character will cause Mercurial to
70 # Adding a null character will cause Mercurial to
71 # identify this as a binary file.
71 # identify this as a binary file.
72 if filelog is not None:
72 if filelog is not None:
73 result = orig(lfutil.standin(path), fileid,
73 result = orig(lfutil.standin(path), fileid,
74 filelog)
74 filelog)
75 else:
75 else:
76 result = orig(lfutil.standin(path), fileid)
76 result = orig(lfutil.standin(path), fileid)
77 olddata = result.data
77 olddata = result.data
78 result.data = lambda: olddata() + '\0'
78 result.data = lambda: olddata() + '\0'
79 return result
79 return result
80 ctx.__class__ = lfilesctx
80 ctx.__class__ = lfilesctx
81 return ctx
81 return ctx
82
82
83 # Figure out the status of big files and insert them into the
83 # Figure out the status of big files and insert them into the
84 # appropriate list in the result. Also removes standin files
84 # appropriate list in the result. Also removes standin files
85 # from the listing. Revert to the original status if
85 # from the listing. Revert to the original status if
86 # self.lfstatus is False.
86 # self.lfstatus is False.
87 # XXX large file status is buggy when used on repo proxy.
87 # XXX large file status is buggy when used on repo proxy.
88 # XXX this needs to be investigated.
88 # XXX this needs to be investigated.
89 @localrepo.unfilteredmethod
89 @localrepo.unfilteredmethod
90 def status(self, node1='.', node2=None, match=None, ignored=False,
90 def status(self, node1='.', node2=None, match=None, ignored=False,
91 clean=False, unknown=False, listsubrepos=False):
91 clean=False, unknown=False, listsubrepos=False):
92 listignored, listclean, listunknown = ignored, clean, unknown
92 listignored, listclean, listunknown = ignored, clean, unknown
93 orig = super(lfilesrepo, self).status
93 orig = super(lfilesrepo, self).status
94 if not self.lfstatus:
94 if not self.lfstatus:
95 return orig(node1, node2, match, listignored, listclean,
95 return orig(node1, node2, match, listignored, listclean,
96 listunknown, listsubrepos)
96 listunknown, listsubrepos)
97
97
98 # some calls in this function rely on the old version of status
98 # some calls in this function rely on the old version of status
99 self.lfstatus = False
99 self.lfstatus = False
100 ctx1 = self[node1]
100 ctx1 = self[node1]
101 ctx2 = self[node2]
101 ctx2 = self[node2]
102 working = ctx2.rev() is None
102 working = ctx2.rev() is None
103 parentworking = working and ctx1 == self['.']
103 parentworking = working and ctx1 == self['.']
104
104
105 if match is None:
105 if match is None:
106 match = match_.always(self.root, self.getcwd())
106 match = matchmod.always(self.root, self.getcwd())
107
107
108 wlock = None
108 wlock = None
109 try:
109 try:
110 try:
110 try:
111 # updating the dirstate is optional
111 # updating the dirstate is optional
112 # so we don't wait on the lock
112 # so we don't wait on the lock
113 wlock = self.wlock(False)
113 wlock = self.wlock(False)
114 except error.LockError:
114 except error.LockError:
115 pass
115 pass
116
116
117 # First check if paths or patterns were specified on the
117 # First check if paths or patterns were specified on the
118 # command line. If there were, and they don't match any
118 # command line. If there were, and they don't match any
119 # largefiles, we should just bail here and let super
119 # largefiles, we should just bail here and let super
120 # handle it -- thus gaining a big performance boost.
120 # handle it -- thus gaining a big performance boost.
121 lfdirstate = lfutil.openlfdirstate(ui, self)
121 lfdirstate = lfutil.openlfdirstate(ui, self)
122 if not match.always():
122 if not match.always():
123 for f in lfdirstate:
123 for f in lfdirstate:
124 if match(f):
124 if match(f):
125 break
125 break
126 else:
126 else:
127 return orig(node1, node2, match, listignored, listclean,
127 return orig(node1, node2, match, listignored, listclean,
128 listunknown, listsubrepos)
128 listunknown, listsubrepos)
129
129
130 # Create a copy of match that matches standins instead
130 # Create a copy of match that matches standins instead
131 # of largefiles.
131 # of largefiles.
132 def tostandins(files):
132 def tostandins(files):
133 if not working:
133 if not working:
134 return files
134 return files
135 newfiles = []
135 newfiles = []
136 dirstate = self.dirstate
136 dirstate = self.dirstate
137 for f in files:
137 for f in files:
138 sf = lfutil.standin(f)
138 sf = lfutil.standin(f)
139 if sf in dirstate:
139 if sf in dirstate:
140 newfiles.append(sf)
140 newfiles.append(sf)
141 elif sf in dirstate.dirs():
141 elif sf in dirstate.dirs():
142 # Directory entries could be regular or
142 # Directory entries could be regular or
143 # standin, check both
143 # standin, check both
144 newfiles.extend((f, sf))
144 newfiles.extend((f, sf))
145 else:
145 else:
146 newfiles.append(f)
146 newfiles.append(f)
147 return newfiles
147 return newfiles
148
148
149 m = copy.copy(match)
149 m = copy.copy(match)
150 m._files = tostandins(m._files)
150 m._files = tostandins(m._files)
151
151
152 result = orig(node1, node2, m, ignored, clean, unknown,
152 result = orig(node1, node2, m, ignored, clean, unknown,
153 listsubrepos)
153 listsubrepos)
154 if working:
154 if working:
155
155
156 def sfindirstate(f):
156 def sfindirstate(f):
157 sf = lfutil.standin(f)
157 sf = lfutil.standin(f)
158 dirstate = self.dirstate
158 dirstate = self.dirstate
159 return sf in dirstate or sf in dirstate.dirs()
159 return sf in dirstate or sf in dirstate.dirs()
160
160
161 match._files = [f for f in match._files
161 match._files = [f for f in match._files
162 if sfindirstate(f)]
162 if sfindirstate(f)]
163 # Don't waste time getting the ignored and unknown
163 # Don't waste time getting the ignored and unknown
164 # files from lfdirstate
164 # files from lfdirstate
165 unsure, s = lfdirstate.status(match, [], False, listclean,
165 unsure, s = lfdirstate.status(match, [], False, listclean,
166 False)
166 False)
167 (modified, added, removed, clean) = (s.modified, s.added,
167 (modified, added, removed, clean) = (s.modified, s.added,
168 s.removed, s.clean)
168 s.removed, s.clean)
169 if parentworking:
169 if parentworking:
170 for lfile in unsure:
170 for lfile in unsure:
171 standin = lfutil.standin(lfile)
171 standin = lfutil.standin(lfile)
172 if standin not in ctx1:
172 if standin not in ctx1:
173 # from second parent
173 # from second parent
174 modified.append(lfile)
174 modified.append(lfile)
175 elif ctx1[standin].data().strip() \
175 elif ctx1[standin].data().strip() \
176 != lfutil.hashfile(self.wjoin(lfile)):
176 != lfutil.hashfile(self.wjoin(lfile)):
177 modified.append(lfile)
177 modified.append(lfile)
178 else:
178 else:
179 if listclean:
179 if listclean:
180 clean.append(lfile)
180 clean.append(lfile)
181 lfdirstate.normal(lfile)
181 lfdirstate.normal(lfile)
182 else:
182 else:
183 tocheck = unsure + modified + added + clean
183 tocheck = unsure + modified + added + clean
184 modified, added, clean = [], [], []
184 modified, added, clean = [], [], []
185 checkexec = self.dirstate._checkexec
185 checkexec = self.dirstate._checkexec
186
186
187 for lfile in tocheck:
187 for lfile in tocheck:
188 standin = lfutil.standin(lfile)
188 standin = lfutil.standin(lfile)
189 if standin in ctx1:
189 if standin in ctx1:
190 abslfile = self.wjoin(lfile)
190 abslfile = self.wjoin(lfile)
191 if ((ctx1[standin].data().strip() !=
191 if ((ctx1[standin].data().strip() !=
192 lfutil.hashfile(abslfile)) or
192 lfutil.hashfile(abslfile)) or
193 (checkexec and
193 (checkexec and
194 ('x' in ctx1.flags(standin)) !=
194 ('x' in ctx1.flags(standin)) !=
195 bool(lfutil.getexecutable(abslfile)))):
195 bool(lfutil.getexecutable(abslfile)))):
196 modified.append(lfile)
196 modified.append(lfile)
197 elif listclean:
197 elif listclean:
198 clean.append(lfile)
198 clean.append(lfile)
199 else:
199 else:
200 added.append(lfile)
200 added.append(lfile)
201
201
202 # at this point, 'removed' contains largefiles
202 # at this point, 'removed' contains largefiles
203 # marked as 'R' in the working context.
203 # marked as 'R' in the working context.
204 # then, largefiles not managed also in the target
204 # then, largefiles not managed also in the target
205 # context should be excluded from 'removed'.
205 # context should be excluded from 'removed'.
206 removed = [lfile for lfile in removed
206 removed = [lfile for lfile in removed
207 if lfutil.standin(lfile) in ctx1]
207 if lfutil.standin(lfile) in ctx1]
208
208
209 # Standins no longer found in lfdirstate has been
209 # Standins no longer found in lfdirstate has been
210 # removed
210 # removed
211 for standin in ctx1.walk(lfutil.getstandinmatcher(self)):
211 for standin in ctx1.walk(lfutil.getstandinmatcher(self)):
212 lfile = lfutil.splitstandin(standin)
212 lfile = lfutil.splitstandin(standin)
213 if not match(lfile):
213 if not match(lfile):
214 continue
214 continue
215 if lfile not in lfdirstate:
215 if lfile not in lfdirstate:
216 removed.append(lfile)
216 removed.append(lfile)
217
217
218 # Filter result lists
218 # Filter result lists
219 result = list(result)
219 result = list(result)
220
220
221 # Largefiles are not really removed when they're
221 # Largefiles are not really removed when they're
222 # still in the normal dirstate. Likewise, normal
222 # still in the normal dirstate. Likewise, normal
223 # files are not really removed if they are still in
223 # files are not really removed if they are still in
224 # lfdirstate. This happens in merges where files
224 # lfdirstate. This happens in merges where files
225 # change type.
225 # change type.
226 removed = [f for f in removed
226 removed = [f for f in removed
227 if f not in self.dirstate]
227 if f not in self.dirstate]
228 result[2] = [f for f in result[2]
228 result[2] = [f for f in result[2]
229 if f not in lfdirstate]
229 if f not in lfdirstate]
230
230
231 lfiles = set(lfdirstate._map)
231 lfiles = set(lfdirstate._map)
232 # Unknown files
232 # Unknown files
233 result[4] = set(result[4]).difference(lfiles)
233 result[4] = set(result[4]).difference(lfiles)
234 # Ignored files
234 # Ignored files
235 result[5] = set(result[5]).difference(lfiles)
235 result[5] = set(result[5]).difference(lfiles)
236 # combine normal files and largefiles
236 # combine normal files and largefiles
237 normals = [[fn for fn in filelist
237 normals = [[fn for fn in filelist
238 if not lfutil.isstandin(fn)]
238 if not lfutil.isstandin(fn)]
239 for filelist in result]
239 for filelist in result]
240 lfstatus = (modified, added, removed, s.deleted, [], [],
240 lfstatus = (modified, added, removed, s.deleted, [], [],
241 clean)
241 clean)
242 result = [sorted(list1 + list2)
242 result = [sorted(list1 + list2)
243 for (list1, list2) in zip(normals, lfstatus)]
243 for (list1, list2) in zip(normals, lfstatus)]
244 else: # not against working directory
244 else: # not against working directory
245 result = [[lfutil.splitstandin(f) or f for f in items]
245 result = [[lfutil.splitstandin(f) or f for f in items]
246 for items in result]
246 for items in result]
247
247
248 if wlock:
248 if wlock:
249 lfdirstate.write()
249 lfdirstate.write()
250
250
251 finally:
251 finally:
252 if wlock:
252 if wlock:
253 wlock.release()
253 wlock.release()
254
254
255 self.lfstatus = True
255 self.lfstatus = True
256 return scmutil.status(*result)
256 return scmutil.status(*result)
257
257
258 def commitctx(self, ctx, *args, **kwargs):
258 def commitctx(self, ctx, *args, **kwargs):
259 node = super(lfilesrepo, self).commitctx(ctx, *args, **kwargs)
259 node = super(lfilesrepo, self).commitctx(ctx, *args, **kwargs)
260 class lfilesctx(ctx.__class__):
260 class lfilesctx(ctx.__class__):
261 def markcommitted(self, node):
261 def markcommitted(self, node):
262 orig = super(lfilesctx, self).markcommitted
262 orig = super(lfilesctx, self).markcommitted
263 return lfutil.markcommitted(orig, self, node)
263 return lfutil.markcommitted(orig, self, node)
264 ctx.__class__ = lfilesctx
264 ctx.__class__ = lfilesctx
265 return node
265 return node
266
266
267 # Before commit, largefile standins have not had their
267 # Before commit, largefile standins have not had their
268 # contents updated to reflect the hash of their largefile.
268 # contents updated to reflect the hash of their largefile.
269 # Do that here.
269 # Do that here.
270 def commit(self, text="", user=None, date=None, match=None,
270 def commit(self, text="", user=None, date=None, match=None,
271 force=False, editor=False, extra={}):
271 force=False, editor=False, extra={}):
272 orig = super(lfilesrepo, self).commit
272 orig = super(lfilesrepo, self).commit
273
273
274 with self.wlock():
274 with self.wlock():
275 lfcommithook = self._lfcommithooks[-1]
275 lfcommithook = self._lfcommithooks[-1]
276 match = lfcommithook(self, match)
276 match = lfcommithook(self, match)
277 result = orig(text=text, user=user, date=date, match=match,
277 result = orig(text=text, user=user, date=date, match=match,
278 force=force, editor=editor, extra=extra)
278 force=force, editor=editor, extra=extra)
279 return result
279 return result
280
280
281 def push(self, remote, force=False, revs=None, newbranch=False):
281 def push(self, remote, force=False, revs=None, newbranch=False):
282 if remote.local():
282 if remote.local():
283 missing = set(self.requirements) - remote.local().supported
283 missing = set(self.requirements) - remote.local().supported
284 if missing:
284 if missing:
285 msg = _("required features are not"
285 msg = _("required features are not"
286 " supported in the destination:"
286 " supported in the destination:"
287 " %s") % (', '.join(sorted(missing)))
287 " %s") % (', '.join(sorted(missing)))
288 raise error.Abort(msg)
288 raise error.Abort(msg)
289 return super(lfilesrepo, self).push(remote, force=force, revs=revs,
289 return super(lfilesrepo, self).push(remote, force=force, revs=revs,
290 newbranch=newbranch)
290 newbranch=newbranch)
291
291
292 # TODO: _subdirlfs should be moved into "lfutil.py", because
292 # TODO: _subdirlfs should be moved into "lfutil.py", because
293 # it is referred only from "lfutil.updatestandinsbymatch"
293 # it is referred only from "lfutil.updatestandinsbymatch"
294 def _subdirlfs(self, files, lfiles):
294 def _subdirlfs(self, files, lfiles):
295 '''
295 '''
296 Adjust matched file list
296 Adjust matched file list
297 If we pass a directory to commit whose only committable files
297 If we pass a directory to commit whose only committable files
298 are largefiles, the core commit code aborts before finding
298 are largefiles, the core commit code aborts before finding
299 the largefiles.
299 the largefiles.
300 So we do the following:
300 So we do the following:
301 For directories that only have largefiles as matches,
301 For directories that only have largefiles as matches,
302 we explicitly add the largefiles to the match list and remove
302 we explicitly add the largefiles to the match list and remove
303 the directory.
303 the directory.
304 In other cases, we leave the match list unmodified.
304 In other cases, we leave the match list unmodified.
305 '''
305 '''
306 actualfiles = []
306 actualfiles = []
307 dirs = []
307 dirs = []
308 regulars = []
308 regulars = []
309
309
310 for f in files:
310 for f in files:
311 if lfutil.isstandin(f + '/'):
311 if lfutil.isstandin(f + '/'):
312 raise error.Abort(
312 raise error.Abort(
313 _('file "%s" is a largefile standin') % f,
313 _('file "%s" is a largefile standin') % f,
314 hint=('commit the largefile itself instead'))
314 hint=('commit the largefile itself instead'))
315 # Scan directories
315 # Scan directories
316 if self.wvfs.isdir(f):
316 if self.wvfs.isdir(f):
317 dirs.append(f)
317 dirs.append(f)
318 else:
318 else:
319 regulars.append(f)
319 regulars.append(f)
320
320
321 for f in dirs:
321 for f in dirs:
322 matcheddir = False
322 matcheddir = False
323 d = self.dirstate.normalize(f) + '/'
323 d = self.dirstate.normalize(f) + '/'
324 # Check for matched normal files
324 # Check for matched normal files
325 for mf in regulars:
325 for mf in regulars:
326 if self.dirstate.normalize(mf).startswith(d):
326 if self.dirstate.normalize(mf).startswith(d):
327 actualfiles.append(f)
327 actualfiles.append(f)
328 matcheddir = True
328 matcheddir = True
329 break
329 break
330 if not matcheddir:
330 if not matcheddir:
331 # If no normal match, manually append
331 # If no normal match, manually append
332 # any matching largefiles
332 # any matching largefiles
333 for lf in lfiles:
333 for lf in lfiles:
334 if self.dirstate.normalize(lf).startswith(d):
334 if self.dirstate.normalize(lf).startswith(d):
335 actualfiles.append(lf)
335 actualfiles.append(lf)
336 if not matcheddir:
336 if not matcheddir:
337 # There may still be normal files in the dir, so
337 # There may still be normal files in the dir, so
338 # add a directory to the list, which
338 # add a directory to the list, which
339 # forces status/dirstate to walk all files and
339 # forces status/dirstate to walk all files and
340 # call the match function on the matcher, even
340 # call the match function on the matcher, even
341 # on case sensitive filesystems.
341 # on case sensitive filesystems.
342 actualfiles.append('.')
342 actualfiles.append('.')
343 matcheddir = True
343 matcheddir = True
344 # Nothing in dir, so readd it
344 # Nothing in dir, so readd it
345 # and let commit reject it
345 # and let commit reject it
346 if not matcheddir:
346 if not matcheddir:
347 actualfiles.append(f)
347 actualfiles.append(f)
348
348
349 # Always add normal files
349 # Always add normal files
350 actualfiles += regulars
350 actualfiles += regulars
351 return actualfiles
351 return actualfiles
352
352
353 repo.__class__ = lfilesrepo
353 repo.__class__ = lfilesrepo
354
354
355 # stack of hooks being executed before committing.
355 # stack of hooks being executed before committing.
356 # only last element ("_lfcommithooks[-1]") is used for each committing.
356 # only last element ("_lfcommithooks[-1]") is used for each committing.
357 repo._lfcommithooks = [lfutil.updatestandinsbymatch]
357 repo._lfcommithooks = [lfutil.updatestandinsbymatch]
358
358
359 # Stack of status writer functions taking "*msg, **opts" arguments
359 # Stack of status writer functions taking "*msg, **opts" arguments
360 # like "ui.status()". Only last element ("_lfstatuswriters[-1]")
360 # like "ui.status()". Only last element ("_lfstatuswriters[-1]")
361 # is used to write status out.
361 # is used to write status out.
362 repo._lfstatuswriters = [ui.status]
362 repo._lfstatuswriters = [ui.status]
363
363
364 def prepushoutgoinghook(pushop):
364 def prepushoutgoinghook(pushop):
365 """Push largefiles for pushop before pushing revisions."""
365 """Push largefiles for pushop before pushing revisions."""
366 lfrevs = pushop.lfrevs
366 lfrevs = pushop.lfrevs
367 if lfrevs is None:
367 if lfrevs is None:
368 lfrevs = pushop.outgoing.missing
368 lfrevs = pushop.outgoing.missing
369 if lfrevs:
369 if lfrevs:
370 toupload = set()
370 toupload = set()
371 addfunc = lambda fn, lfhash: toupload.add(lfhash)
371 addfunc = lambda fn, lfhash: toupload.add(lfhash)
372 lfutil.getlfilestoupload(pushop.repo, lfrevs,
372 lfutil.getlfilestoupload(pushop.repo, lfrevs,
373 addfunc)
373 addfunc)
374 lfcommands.uploadlfiles(ui, pushop.repo, pushop.remote, toupload)
374 lfcommands.uploadlfiles(ui, pushop.repo, pushop.remote, toupload)
375 repo.prepushoutgoinghooks.add("largefiles", prepushoutgoinghook)
375 repo.prepushoutgoinghooks.add("largefiles", prepushoutgoinghook)
376
376
377 def checkrequireslfiles(ui, repo, **kwargs):
377 def checkrequireslfiles(ui, repo, **kwargs):
378 if 'largefiles' not in repo.requirements and any(
378 if 'largefiles' not in repo.requirements and any(
379 lfutil.shortname+'/' in f[0] for f in repo.store.datafiles()):
379 lfutil.shortname+'/' in f[0] for f in repo.store.datafiles()):
380 repo.requirements.add('largefiles')
380 repo.requirements.add('largefiles')
381 repo._writerequirements()
381 repo._writerequirements()
382
382
383 ui.setconfig('hooks', 'changegroup.lfiles', checkrequireslfiles,
383 ui.setconfig('hooks', 'changegroup.lfiles', checkrequireslfiles,
384 'largefiles')
384 'largefiles')
385 ui.setconfig('hooks', 'commit.lfiles', checkrequireslfiles, 'largefiles')
385 ui.setconfig('hooks', 'commit.lfiles', checkrequireslfiles, 'largefiles')
General Comments 0
You need to be logged in to leave comments. Login now