Show More
@@ -114,14 +114,14 b' class basestore(object):' | |||||
114 | failed = util.any(self._verifyfile( |
|
114 | failed = util.any(self._verifyfile( | |
115 | cctx, cset, contents, standin, verified) for standin in cctx) |
|
115 | cctx, cset, contents, standin, verified) for standin in cctx) | |
116 |
|
116 | |||
117 |
num |
|
117 | numrevs = len(verified) | |
118 |
num |
|
118 | numlfiles = len(set([fname for (fname, fnode) in verified])) | |
119 | if contents: |
|
119 | if contents: | |
120 | write(_('verified contents of %d revisions of %d largefiles\n') |
|
120 | write(_('verified contents of %d revisions of %d largefiles\n') | |
121 |
% (num |
|
121 | % (numrevs, numlfiles)) | |
122 | else: |
|
122 | else: | |
123 | write(_('verified existence of %d revisions of %d largefiles\n') |
|
123 | write(_('verified existence of %d revisions of %d largefiles\n') | |
124 |
% (num |
|
124 | % (numrevs, numlfiles)) | |
125 |
|
125 | |||
126 | return int(failed) |
|
126 | return int(failed) | |
127 |
|
127 | |||
@@ -186,9 +186,9 b' def _openstore(repo, remote=None, put=Fa' | |||||
186 | except KeyError: |
|
186 | except KeyError: | |
187 | raise util.Abort(_('unsupported URL scheme %r') % scheme) |
|
187 | raise util.Abort(_('unsupported URL scheme %r') % scheme) | |
188 |
|
188 | |||
189 |
for class |
|
189 | for classobj in storeproviders: | |
190 | try: |
|
190 | try: | |
191 |
return class |
|
191 | return classobj(ui, repo, remote) | |
192 | except lfutil.storeprotonotcapable: |
|
192 | except lfutil.storeprotonotcapable: | |
193 | pass |
|
193 | pass | |
194 |
|
194 |
@@ -58,7 +58,7 b' def lfconvert(ui, src, dest, *pats, **op' | |||||
58 | # Lock destination to prevent modification while it is converted to. |
|
58 | # Lock destination to prevent modification while it is converted to. | |
59 | # Don't need to lock src because we are just reading from its history |
|
59 | # Don't need to lock src because we are just reading from its history | |
60 | # which can't change. |
|
60 | # which can't change. | |
61 |
dst |
|
61 | dstlock = rdst.lock() | |
62 |
|
62 | |||
63 | # Get a list of all changesets in the source. The easy way to do this |
|
63 | # Get a list of all changesets in the source. The easy way to do this | |
64 | # is to simply walk the changelog, using changelog.nodesbewteen(). |
|
64 | # is to simply walk the changelog, using changelog.nodesbewteen(). | |
@@ -113,7 +113,7 b' def lfconvert(ui, src, dest, *pats, **op' | |||||
113 | if not success: |
|
113 | if not success: | |
114 | # we failed, remove the new directory |
|
114 | # we failed, remove the new directory | |
115 | shutil.rmtree(rdst.root) |
|
115 | shutil.rmtree(rdst.root) | |
116 |
dst |
|
116 | dstlock.release() | |
117 |
|
117 | |||
118 | def _addchangeset(ui, rsrc, rdst, ctx, revmap): |
|
118 | def _addchangeset(ui, rsrc, rdst, ctx, revmap): | |
119 | # Convert src parents to dst parents |
|
119 | # Convert src parents to dst parents | |
@@ -451,7 +451,7 b' def _updatelfile(repo, lfdirstate, lfile' | |||||
451 | expecthash != lfutil.hashfile(abslfile))): |
|
451 | expecthash != lfutil.hashfile(abslfile))): | |
452 | if not lfutil.copyfromcache(repo, expecthash, lfile): |
|
452 | if not lfutil.copyfromcache(repo, expecthash, lfile): | |
453 | # use normallookup() to allocate entry in largefiles dirstate, |
|
453 | # use normallookup() to allocate entry in largefiles dirstate, | |
454 |
# because lack of it misleads lfiles |
|
454 | # because lack of it misleads lfilesrepo.status() into | |
455 | # recognition that such cache missing files are REMOVED. |
|
455 | # recognition that such cache missing files are REMOVED. | |
456 | lfdirstate.normallookup(lfile) |
|
456 | lfdirstate.normallookup(lfile) | |
457 | return None # don't try to set the mode |
|
457 | return None # don't try to set the mode |
@@ -23,14 +23,14 b" longname = 'largefiles'" | |||||
23 |
|
23 | |||
24 | # -- Portability wrappers ---------------------------------------------- |
|
24 | # -- Portability wrappers ---------------------------------------------- | |
25 |
|
25 | |||
26 |
def dirstate |
|
26 | def dirstatewalk(dirstate, matcher, unknown=False, ignored=False): | |
27 | return dirstate.walk(matcher, [], unknown, ignored) |
|
27 | return dirstate.walk(matcher, [], unknown, ignored) | |
28 |
|
28 | |||
29 |
def repo |
|
29 | def repoadd(repo, list): | |
30 | add = repo[None].add |
|
30 | add = repo[None].add | |
31 | return add(list) |
|
31 | return add(list) | |
32 |
|
32 | |||
33 |
def repo |
|
33 | def reporemove(repo, list, unlink=False): | |
34 | def remove(list, unlink): |
|
34 | def remove(list, unlink): | |
35 | wlock = repo.wlock() |
|
35 | wlock = repo.wlock() | |
36 | try: |
|
36 | try: | |
@@ -46,7 +46,7 b' def repo_remove(repo, list, unlink=False' | |||||
46 | wlock.release() |
|
46 | wlock.release() | |
47 | return remove(list, unlink=unlink) |
|
47 | return remove(list, unlink=unlink) | |
48 |
|
48 | |||
49 |
def repo |
|
49 | def repoforget(repo, list): | |
50 | forget = repo[None].forget |
|
50 | forget = repo[None].forget | |
51 | return forget(list) |
|
51 | return forget(list) | |
52 |
|
52 | |||
@@ -125,21 +125,21 b' def findfile(repo, hash):' | |||||
125 | return path |
|
125 | return path | |
126 | return None |
|
126 | return None | |
127 |
|
127 | |||
128 |
class largefiles |
|
128 | class largefilesdirstate(dirstate.dirstate): | |
129 | def __getitem__(self, key): |
|
129 | def __getitem__(self, key): | |
130 |
return super(largefiles |
|
130 | return super(largefilesdirstate, self).__getitem__(unixpath(key)) | |
131 | def normal(self, f): |
|
131 | def normal(self, f): | |
132 |
return super(largefiles |
|
132 | return super(largefilesdirstate, self).normal(unixpath(f)) | |
133 | def remove(self, f): |
|
133 | def remove(self, f): | |
134 |
return super(largefiles |
|
134 | return super(largefilesdirstate, self).remove(unixpath(f)) | |
135 | def add(self, f): |
|
135 | def add(self, f): | |
136 |
return super(largefiles |
|
136 | return super(largefilesdirstate, self).add(unixpath(f)) | |
137 | def drop(self, f): |
|
137 | def drop(self, f): | |
138 |
return super(largefiles |
|
138 | return super(largefilesdirstate, self).drop(unixpath(f)) | |
139 | def forget(self, f): |
|
139 | def forget(self, f): | |
140 |
return super(largefiles |
|
140 | return super(largefilesdirstate, self).forget(unixpath(f)) | |
141 | def normallookup(self, f): |
|
141 | def normallookup(self, f): | |
142 |
return super(largefiles |
|
142 | return super(largefilesdirstate, self).normallookup(unixpath(f)) | |
143 |
|
143 | |||
144 | def openlfdirstate(ui, repo): |
|
144 | def openlfdirstate(ui, repo): | |
145 | ''' |
|
145 | ''' | |
@@ -148,7 +148,7 b' def openlfdirstate(ui, repo):' | |||||
148 | ''' |
|
148 | ''' | |
149 | admin = repo.join(longname) |
|
149 | admin = repo.join(longname) | |
150 | opener = scmutil.opener(admin) |
|
150 | opener = scmutil.opener(admin) | |
151 |
lfdirstate = largefiles |
|
151 | lfdirstate = largefilesdirstate(opener, ui, repo.root, | |
152 | repo.dirstate._validate) |
|
152 | repo.dirstate._validate) | |
153 |
|
153 | |||
154 | # If the largefiles dirstate does not exist, populate and create |
|
154 | # If the largefiles dirstate does not exist, populate and create | |
@@ -157,7 +157,7 b' def openlfdirstate(ui, repo):' | |||||
157 | if not os.path.exists(os.path.join(admin, 'dirstate')): |
|
157 | if not os.path.exists(os.path.join(admin, 'dirstate')): | |
158 | util.makedirs(admin) |
|
158 | util.makedirs(admin) | |
159 | matcher = getstandinmatcher(repo) |
|
159 | matcher = getstandinmatcher(repo) | |
160 |
for standin in dirstate |
|
160 | for standin in dirstatewalk(repo.dirstate, matcher): | |
161 | lfile = splitstandin(standin) |
|
161 | lfile = splitstandin(standin) | |
162 | hash = readstandin(repo, lfile) |
|
162 | hash = readstandin(repo, lfile) | |
163 | lfdirstate.normallookup(lfile) |
|
163 | lfdirstate.normallookup(lfile) | |
@@ -169,7 +169,7 b' def openlfdirstate(ui, repo):' | |||||
169 | raise |
|
169 | raise | |
170 | return lfdirstate |
|
170 | return lfdirstate | |
171 |
|
171 | |||
172 |
def lfdirstate |
|
172 | def lfdirstatestatus(lfdirstate, repo, rev): | |
173 | match = match_.always(repo.root, repo.getcwd()) |
|
173 | match = match_.always(repo.root, repo.getcwd()) | |
174 | s = lfdirstate.status(match, [], False, False, False) |
|
174 | s = lfdirstate.status(match, [], False, False, False) | |
175 | unsure, modified, added, removed, missing, unknown, ignored, clean = s |
|
175 | unsure, modified, added, removed, missing, unknown, ignored, clean = s | |
@@ -286,9 +286,9 b' def composestandinmatcher(repo, rmatcher' | |||||
286 | as the paths specified by the user.''' |
|
286 | as the paths specified by the user.''' | |
287 | smatcher = getstandinmatcher(repo, rmatcher.files()) |
|
287 | smatcher = getstandinmatcher(repo, rmatcher.files()) | |
288 | isstandin = smatcher.matchfn |
|
288 | isstandin = smatcher.matchfn | |
289 |
def composed |
|
289 | def composedmatchfn(f): | |
290 | return isstandin(f) and rmatcher.matchfn(splitstandin(f)) |
|
290 | return isstandin(f) and rmatcher.matchfn(splitstandin(f)) | |
291 |
smatcher.matchfn = composed |
|
291 | smatcher.matchfn = composedmatchfn | |
292 |
|
292 | |||
293 | return smatcher |
|
293 | return smatcher | |
294 |
|
294 | |||
@@ -296,8 +296,8 b' def standin(filename):' | |||||
296 | '''Return the repo-relative path to the standin for the specified big |
|
296 | '''Return the repo-relative path to the standin for the specified big | |
297 | file.''' |
|
297 | file.''' | |
298 | # Notes: |
|
298 | # Notes: | |
299 |
# 1) Most callers want an absolute path, but _create |
|
299 | # 1) Most callers want an absolute path, but _createstandin() needs | |
300 |
# it repo-relative so lfadd() can pass it to repo |
|
300 | # it repo-relative so lfadd() can pass it to repoadd(). So leave | |
301 | # it up to the caller to use repo.wjoin() to get an absolute path. |
|
301 | # it up to the caller to use repo.wjoin() to get an absolute path. | |
302 | # 2) Join with '/' because that's what dirstate always uses, even on |
|
302 | # 2) Join with '/' because that's what dirstate always uses, even on | |
303 | # Windows. Change existing separator to '/' first in case we are |
|
303 | # Windows. Change existing separator to '/' first in case we are | |
@@ -453,7 +453,7 b' def getcurrentheads(repo):' | |||||
453 | def getstandinsstate(repo): |
|
453 | def getstandinsstate(repo): | |
454 | standins = [] |
|
454 | standins = [] | |
455 | matcher = getstandinmatcher(repo) |
|
455 | matcher = getstandinmatcher(repo) | |
456 |
for standin in dirstate |
|
456 | for standin in dirstatewalk(repo.dirstate, matcher): | |
457 | lfile = splitstandin(standin) |
|
457 | lfile = splitstandin(standin) | |
458 | standins.append((lfile, readstandin(repo, lfile))) |
|
458 | standins.append((lfile, readstandin(repo, lfile))) | |
459 | return standins |
|
459 | return standins |
@@ -26,7 +26,7 b' def installnormalfilesmatchfn(manifest):' | |||||
26 | '''overrides scmutil.match so that the matcher it returns will ignore all |
|
26 | '''overrides scmutil.match so that the matcher it returns will ignore all | |
27 | largefiles''' |
|
27 | largefiles''' | |
28 | oldmatch = None # for the closure |
|
28 | oldmatch = None # for the closure | |
29 |
def override |
|
29 | def overridematch(ctx, pats=[], opts={}, globbed=False, | |
30 | default='relpath'): |
|
30 | default='relpath'): | |
31 | match = oldmatch(ctx, pats, opts, globbed, default) |
|
31 | match = oldmatch(ctx, pats, opts, globbed, default) | |
32 | m = copy.copy(match) |
|
32 | m = copy.copy(match) | |
@@ -34,10 +34,10 b' def installnormalfilesmatchfn(manifest):' | |||||
34 | manifest) |
|
34 | manifest) | |
35 | m._files = filter(notlfile, m._files) |
|
35 | m._files = filter(notlfile, m._files) | |
36 | m._fmap = set(m._files) |
|
36 | m._fmap = set(m._files) | |
37 |
orig |
|
37 | origmatchfn = m.matchfn | |
38 |
m.matchfn = lambda f: notlfile(f) and orig |
|
38 | m.matchfn = lambda f: notlfile(f) and origmatchfn(f) or None | |
39 | return m |
|
39 | return m | |
40 |
oldmatch = installmatchfn(override |
|
40 | oldmatch = installmatchfn(overridematch) | |
41 |
|
41 | |||
42 | def installmatchfn(f): |
|
42 | def installmatchfn(f): | |
43 | oldmatch = scmutil.match |
|
43 | oldmatch = scmutil.match | |
@@ -53,7 +53,7 b' def restorematchfn():' | |||||
53 | restore matchfn to reverse''' |
|
53 | restore matchfn to reverse''' | |
54 | scmutil.match = getattr(scmutil.match, 'oldmatch', scmutil.match) |
|
54 | scmutil.match = getattr(scmutil.match, 'oldmatch', scmutil.match) | |
55 |
|
55 | |||
56 |
def add |
|
56 | def addlargefiles(ui, repo, *pats, **opts): | |
57 | large = opts.pop('large', None) |
|
57 | large = opts.pop('large', None) | |
58 | lfsize = lfutil.getminsize( |
|
58 | lfsize = lfutil.getminsize( | |
59 | ui, lfutil.islfilesrepo(repo), opts.pop('lfsize', None)) |
|
59 | ui, lfutil.islfilesrepo(repo), opts.pop('lfsize', None)) | |
@@ -109,13 +109,13 b' def add_largefiles(ui, repo, *pats, **op' | |||||
109 | lfdirstate.add(f) |
|
109 | lfdirstate.add(f) | |
110 | lfdirstate.write() |
|
110 | lfdirstate.write() | |
111 | bad += [lfutil.splitstandin(f) |
|
111 | bad += [lfutil.splitstandin(f) | |
112 |
for f in lfutil.repo |
|
112 | for f in lfutil.repoadd(repo, standins) | |
113 | if f in m.files()] |
|
113 | if f in m.files()] | |
114 | finally: |
|
114 | finally: | |
115 | wlock.release() |
|
115 | wlock.release() | |
116 | return bad |
|
116 | return bad | |
117 |
|
117 | |||
118 |
def remove |
|
118 | def removelargefiles(ui, repo, *pats, **opts): | |
119 | after = opts.get('after') |
|
119 | after = opts.get('after') | |
120 | if not pats and not after: |
|
120 | if not pats and not after: | |
121 | raise util.Abort(_('no files specified')) |
|
121 | raise util.Abort(_('no files specified')) | |
@@ -164,11 +164,11 b' def remove_largefiles(ui, repo, *pats, *' | |||||
164 | lfdirstate.write() |
|
164 | lfdirstate.write() | |
165 | forget = [lfutil.standin(f) for f in forget] |
|
165 | forget = [lfutil.standin(f) for f in forget] | |
166 | remove = [lfutil.standin(f) for f in remove] |
|
166 | remove = [lfutil.standin(f) for f in remove] | |
167 |
lfutil.repo |
|
167 | lfutil.repoforget(repo, forget) | |
168 | # If this is being called by addremove, let the original addremove |
|
168 | # If this is being called by addremove, let the original addremove | |
169 | # function handle this. |
|
169 | # function handle this. | |
170 | if not getattr(repo, "_isaddremove", False): |
|
170 | if not getattr(repo, "_isaddremove", False): | |
171 |
lfutil.repo |
|
171 | lfutil.reporemove(repo, remove, unlink=True) | |
172 | finally: |
|
172 | finally: | |
173 | wlock.release() |
|
173 | wlock.release() | |
174 |
|
174 | |||
@@ -178,40 +178,40 b' def remove_largefiles(ui, repo, *pats, *' | |||||
178 | # checking if they should be added as largefiles. Then it makes a new |
|
178 | # checking if they should be added as largefiles. Then it makes a new | |
179 | # matcher which matches only the normal files and runs the original |
|
179 | # matcher which matches only the normal files and runs the original | |
180 | # version of add. |
|
180 | # version of add. | |
181 |
def override |
|
181 | def overrideadd(orig, ui, repo, *pats, **opts): | |
182 | normal = opts.pop('normal') |
|
182 | normal = opts.pop('normal') | |
183 | if normal: |
|
183 | if normal: | |
184 | if opts.get('large'): |
|
184 | if opts.get('large'): | |
185 | raise util.Abort(_('--normal cannot be used with --large')) |
|
185 | raise util.Abort(_('--normal cannot be used with --large')) | |
186 | return orig(ui, repo, *pats, **opts) |
|
186 | return orig(ui, repo, *pats, **opts) | |
187 |
bad = add |
|
187 | bad = addlargefiles(ui, repo, *pats, **opts) | |
188 | installnormalfilesmatchfn(repo[None].manifest()) |
|
188 | installnormalfilesmatchfn(repo[None].manifest()) | |
189 | result = orig(ui, repo, *pats, **opts) |
|
189 | result = orig(ui, repo, *pats, **opts) | |
190 | restorematchfn() |
|
190 | restorematchfn() | |
191 |
|
191 | |||
192 | return (result == 1 or bad) and 1 or 0 |
|
192 | return (result == 1 or bad) and 1 or 0 | |
193 |
|
193 | |||
194 |
def override |
|
194 | def overrideremove(orig, ui, repo, *pats, **opts): | |
195 | installnormalfilesmatchfn(repo[None].manifest()) |
|
195 | installnormalfilesmatchfn(repo[None].manifest()) | |
196 | orig(ui, repo, *pats, **opts) |
|
196 | orig(ui, repo, *pats, **opts) | |
197 | restorematchfn() |
|
197 | restorematchfn() | |
198 |
remove |
|
198 | removelargefiles(ui, repo, *pats, **opts) | |
199 |
|
199 | |||
200 |
def override |
|
200 | def overridestatus(orig, ui, repo, *pats, **opts): | |
201 | try: |
|
201 | try: | |
202 | repo.lfstatus = True |
|
202 | repo.lfstatus = True | |
203 | return orig(ui, repo, *pats, **opts) |
|
203 | return orig(ui, repo, *pats, **opts) | |
204 | finally: |
|
204 | finally: | |
205 | repo.lfstatus = False |
|
205 | repo.lfstatus = False | |
206 |
|
206 | |||
207 |
def override |
|
207 | def overridelog(orig, ui, repo, *pats, **opts): | |
208 | try: |
|
208 | try: | |
209 | repo.lfstatus = True |
|
209 | repo.lfstatus = True | |
210 | orig(ui, repo, *pats, **opts) |
|
210 | orig(ui, repo, *pats, **opts) | |
211 | finally: |
|
211 | finally: | |
212 | repo.lfstatus = False |
|
212 | repo.lfstatus = False | |
213 |
|
213 | |||
214 |
def override |
|
214 | def overrideverify(orig, ui, repo, *pats, **opts): | |
215 | large = opts.pop('large', False) |
|
215 | large = opts.pop('large', False) | |
216 | all = opts.pop('lfa', False) |
|
216 | all = opts.pop('lfa', False) | |
217 | contents = opts.pop('lfc', False) |
|
217 | contents = opts.pop('lfc', False) | |
@@ -225,7 +225,7 b' def override_verify(orig, ui, repo, *pat' | |||||
225 | # will go through properly. Then the other update hook (overriding repo.update) |
|
225 | # will go through properly. Then the other update hook (overriding repo.update) | |
226 | # will get the new files. Filemerge is also overriden so that the merge |
|
226 | # will get the new files. Filemerge is also overriden so that the merge | |
227 | # will merge standins correctly. |
|
227 | # will merge standins correctly. | |
228 |
def override |
|
228 | def overrideupdate(orig, ui, repo, *pats, **opts): | |
229 | lfdirstate = lfutil.openlfdirstate(ui, repo) |
|
229 | lfdirstate = lfutil.openlfdirstate(ui, repo) | |
230 | s = lfdirstate.status(match_.always(repo.root, repo.getcwd()), [], False, |
|
230 | s = lfdirstate.status(match_.always(repo.root, repo.getcwd()), [], False, | |
231 | False, False) |
|
231 | False, False) | |
@@ -265,7 +265,7 b' def override_update(orig, ui, repo, *pat' | |||||
265 | # The overridden function filters the unknown files by removing any |
|
265 | # The overridden function filters the unknown files by removing any | |
266 | # largefiles. This makes the merge proceed and we can then handle this |
|
266 | # largefiles. This makes the merge proceed and we can then handle this | |
267 | # case further in the overridden manifestmerge function below. |
|
267 | # case further in the overridden manifestmerge function below. | |
268 |
def override |
|
268 | def overridecheckunknownfile(origfn, repo, wctx, mctx, f): | |
269 | if lfutil.standin(f) in wctx: |
|
269 | if lfutil.standin(f) in wctx: | |
270 | return False |
|
270 | return False | |
271 | return origfn(repo, wctx, mctx, f) |
|
271 | return origfn(repo, wctx, mctx, f) | |
@@ -296,7 +296,7 b' def override_checkunknownfile(origfn, re' | |||||
296 | # Finally, the merge.applyupdates function will then take care of |
|
296 | # Finally, the merge.applyupdates function will then take care of | |
297 | # writing the files into the working copy and lfcommands.updatelfiles |
|
297 | # writing the files into the working copy and lfcommands.updatelfiles | |
298 | # will update the largefiles. |
|
298 | # will update the largefiles. | |
299 |
def override |
|
299 | def overridemanifestmerge(origfn, repo, p1, p2, pa, overwrite, partial): | |
300 | actions = origfn(repo, p1, p2, pa, overwrite, partial) |
|
300 | actions = origfn(repo, p1, p2, pa, overwrite, partial) | |
301 | processed = [] |
|
301 | processed = [] | |
302 |
|
302 | |||
@@ -339,7 +339,7 b' def override_manifestmerge(origfn, repo,' | |||||
339 | # Override filemerge to prompt the user about how they wish to merge |
|
339 | # Override filemerge to prompt the user about how they wish to merge | |
340 | # largefiles. This will handle identical edits, and copy/rename + |
|
340 | # largefiles. This will handle identical edits, and copy/rename + | |
341 | # edit without prompting the user. |
|
341 | # edit without prompting the user. | |
342 |
def override |
|
342 | def overridefilemerge(origfn, repo, mynode, orig, fcd, fco, fca): | |
343 | # Use better variable names here. Because this is a wrapper we cannot |
|
343 | # Use better variable names here. Because this is a wrapper we cannot | |
344 | # change the variable names in the function declaration. |
|
344 | # change the variable names in the function declaration. | |
345 | fcdest, fcother, fcancestor = fcd, fco, fca |
|
345 | fcdest, fcother, fcancestor = fcd, fco, fca | |
@@ -384,7 +384,7 b' def override_filemerge(origfn, repo, myn' | |||||
384 | # checks if the destination largefile already exists. It also keeps a |
|
384 | # checks if the destination largefile already exists. It also keeps a | |
385 | # list of copied files so that the largefiles can be copied and the |
|
385 | # list of copied files so that the largefiles can be copied and the | |
386 | # dirstate updated. |
|
386 | # dirstate updated. | |
387 |
def override |
|
387 | def overridecopy(orig, ui, repo, pats, opts, rename=False): | |
388 | # doesn't remove largefile on rename |
|
388 | # doesn't remove largefile on rename | |
389 | if len(pats) < 2: |
|
389 | if len(pats) < 2: | |
390 | # this isn't legal, let the original function deal with it |
|
390 | # this isn't legal, let the original function deal with it | |
@@ -434,7 +434,7 b' def override_copy(orig, ui, repo, pats, ' | |||||
434 |
|
434 | |||
435 | manifest = repo[None].manifest() |
|
435 | manifest = repo[None].manifest() | |
436 | oldmatch = None # for the closure |
|
436 | oldmatch = None # for the closure | |
437 |
def override |
|
437 | def overridematch(ctx, pats=[], opts={}, globbed=False, | |
438 | default='relpath'): |
|
438 | default='relpath'): | |
439 | newpats = [] |
|
439 | newpats = [] | |
440 | # The patterns were previously mangled to add the standin |
|
440 | # The patterns were previously mangled to add the standin | |
@@ -449,13 +449,13 b' def override_copy(orig, ui, repo, pats, ' | |||||
449 | lfile = lambda f: lfutil.standin(f) in manifest |
|
449 | lfile = lambda f: lfutil.standin(f) in manifest | |
450 | m._files = [lfutil.standin(f) for f in m._files if lfile(f)] |
|
450 | m._files = [lfutil.standin(f) for f in m._files if lfile(f)] | |
451 | m._fmap = set(m._files) |
|
451 | m._fmap = set(m._files) | |
452 |
orig |
|
452 | origmatchfn = m.matchfn | |
453 | m.matchfn = lambda f: (lfutil.isstandin(f) and |
|
453 | m.matchfn = lambda f: (lfutil.isstandin(f) and | |
454 | (f in manifest) and |
|
454 | (f in manifest) and | |
455 |
orig |
|
455 | origmatchfn(lfutil.splitstandin(f)) or | |
456 | None) |
|
456 | None) | |
457 | return m |
|
457 | return m | |
458 |
oldmatch = installmatchfn(override |
|
458 | oldmatch = installmatchfn(overridematch) | |
459 | listpats = [] |
|
459 | listpats = [] | |
460 | for pat in pats: |
|
460 | for pat in pats: | |
461 | if match_.patkind(pat) is not None: |
|
461 | if match_.patkind(pat) is not None: | |
@@ -466,7 +466,7 b' def override_copy(orig, ui, repo, pats, ' | |||||
466 | try: |
|
466 | try: | |
467 | origcopyfile = util.copyfile |
|
467 | origcopyfile = util.copyfile | |
468 | copiedfiles = [] |
|
468 | copiedfiles = [] | |
469 |
def override |
|
469 | def overridecopyfile(src, dest): | |
470 | if (lfutil.shortname in src and |
|
470 | if (lfutil.shortname in src and | |
471 | dest.startswith(repo.wjoin(lfutil.shortname))): |
|
471 | dest.startswith(repo.wjoin(lfutil.shortname))): | |
472 | destlfile = dest.replace(lfutil.shortname, '') |
|
472 | destlfile = dest.replace(lfutil.shortname, '') | |
@@ -476,7 +476,7 b' def override_copy(orig, ui, repo, pats, ' | |||||
476 | copiedfiles.append((src, dest)) |
|
476 | copiedfiles.append((src, dest)) | |
477 | origcopyfile(src, dest) |
|
477 | origcopyfile(src, dest) | |
478 |
|
478 | |||
479 |
util.copyfile = override |
|
479 | util.copyfile = overridecopyfile | |
480 | result += orig(ui, repo, listpats, opts, rename) |
|
480 | result += orig(ui, repo, listpats, opts, rename) | |
481 | finally: |
|
481 | finally: | |
482 | util.copyfile = origcopyfile |
|
482 | util.copyfile = origcopyfile | |
@@ -521,7 +521,7 b' def override_copy(orig, ui, repo, pats, ' | |||||
521 | # the matcher to hit standins instead of largefiles. Based on the |
|
521 | # the matcher to hit standins instead of largefiles. Based on the | |
522 | # resulting standins update the largefiles. Then return the standins |
|
522 | # resulting standins update the largefiles. Then return the standins | |
523 | # to their proper state |
|
523 | # to their proper state | |
524 |
def override |
|
524 | def overriderevert(orig, ui, repo, *pats, **opts): | |
525 | # Because we put the standins in a bad state (by updating them) |
|
525 | # Because we put the standins in a bad state (by updating them) | |
526 | # and then return them to a correct state we need to lock to |
|
526 | # and then return them to a correct state we need to lock to | |
527 | # prevent others from changing them in their incorrect state. |
|
527 | # prevent others from changing them in their incorrect state. | |
@@ -529,7 +529,7 b' def override_revert(orig, ui, repo, *pat' | |||||
529 | try: |
|
529 | try: | |
530 | lfdirstate = lfutil.openlfdirstate(ui, repo) |
|
530 | lfdirstate = lfutil.openlfdirstate(ui, repo) | |
531 | (modified, added, removed, missing, unknown, ignored, clean) = \ |
|
531 | (modified, added, removed, missing, unknown, ignored, clean) = \ | |
532 |
lfutil.lfdirstate |
|
532 | lfutil.lfdirstatestatus(lfdirstate, repo, repo['.'].rev()) | |
533 | for lfile in modified: |
|
533 | for lfile in modified: | |
534 | lfutil.updatestandin(repo, lfutil.standin(lfile)) |
|
534 | lfutil.updatestandin(repo, lfutil.standin(lfile)) | |
535 | for lfile in missing: |
|
535 | for lfile in missing: | |
@@ -538,7 +538,7 b' def override_revert(orig, ui, repo, *pat' | |||||
538 | try: |
|
538 | try: | |
539 | ctx = repo[opts.get('rev')] |
|
539 | ctx = repo[opts.get('rev')] | |
540 | oldmatch = None # for the closure |
|
540 | oldmatch = None # for the closure | |
541 |
def override |
|
541 | def overridematch(ctx, pats=[], opts={}, globbed=False, | |
542 | default='relpath'): |
|
542 | default='relpath'): | |
543 | match = oldmatch(ctx, pats, opts, globbed, default) |
|
543 | match = oldmatch(ctx, pats, opts, globbed, default) | |
544 | m = copy.copy(match) |
|
544 | m = copy.copy(match) | |
@@ -551,7 +551,7 b' def override_revert(orig, ui, repo, *pat' | |||||
551 | m._files = [tostandin(f) for f in m._files] |
|
551 | m._files = [tostandin(f) for f in m._files] | |
552 | m._files = [f for f in m._files if f is not None] |
|
552 | m._files = [f for f in m._files if f is not None] | |
553 | m._fmap = set(m._files) |
|
553 | m._fmap = set(m._files) | |
554 |
orig |
|
554 | origmatchfn = m.matchfn | |
555 | def matchfn(f): |
|
555 | def matchfn(f): | |
556 | if lfutil.isstandin(f): |
|
556 | if lfutil.isstandin(f): | |
557 | # We need to keep track of what largefiles are being |
|
557 | # We need to keep track of what largefiles are being | |
@@ -560,7 +560,7 b' def override_revert(orig, ui, repo, *pat' | |||||
560 | # largefiles. This is repo-specific, so duckpunch the |
|
560 | # largefiles. This is repo-specific, so duckpunch the | |
561 | # repo object to keep the list of largefiles for us |
|
561 | # repo object to keep the list of largefiles for us | |
562 | # later. |
|
562 | # later. | |
563 |
if orig |
|
563 | if origmatchfn(lfutil.splitstandin(f)) and \ | |
564 | (f in repo[None] or f in ctx): |
|
564 | (f in repo[None] or f in ctx): | |
565 | lfileslist = getattr(repo, '_lfilestoupdate', []) |
|
565 | lfileslist = getattr(repo, '_lfilestoupdate', []) | |
566 | lfileslist.append(lfutil.splitstandin(f)) |
|
566 | lfileslist.append(lfutil.splitstandin(f)) | |
@@ -568,12 +568,12 b' def override_revert(orig, ui, repo, *pat' | |||||
568 | return True |
|
568 | return True | |
569 | else: |
|
569 | else: | |
570 | return False |
|
570 | return False | |
571 |
return orig |
|
571 | return origmatchfn(f) | |
572 | m.matchfn = matchfn |
|
572 | m.matchfn = matchfn | |
573 | return m |
|
573 | return m | |
574 |
oldmatch = installmatchfn(override |
|
574 | oldmatch = installmatchfn(overridematch) | |
575 | scmutil.match |
|
575 | scmutil.match | |
576 |
matches = override |
|
576 | matches = overridematch(repo[None], pats, opts) | |
577 | orig(ui, repo, *pats, **opts) |
|
577 | orig(ui, repo, *pats, **opts) | |
578 | finally: |
|
578 | finally: | |
579 | restorematchfn() |
|
579 | restorematchfn() | |
@@ -601,7 +601,7 b' def override_revert(orig, ui, repo, *pat' | |||||
601 | finally: |
|
601 | finally: | |
602 | wlock.release() |
|
602 | wlock.release() | |
603 |
|
603 | |||
604 |
def hg |
|
604 | def hgupdate(orig, repo, node): | |
605 | # Only call updatelfiles the standins that have changed to save time |
|
605 | # Only call updatelfiles the standins that have changed to save time | |
606 | oldstandins = lfutil.getstandinsstate(repo) |
|
606 | oldstandins = lfutil.getstandinsstate(repo) | |
607 | result = orig(repo, node) |
|
607 | result = orig(repo, node) | |
@@ -610,12 +610,12 b' def hg_update(orig, repo, node):' | |||||
610 | lfcommands.updatelfiles(repo.ui, repo, filelist=filelist, printmessage=True) |
|
610 | lfcommands.updatelfiles(repo.ui, repo, filelist=filelist, printmessage=True) | |
611 | return result |
|
611 | return result | |
612 |
|
612 | |||
613 |
def hg |
|
613 | def hgclean(orig, repo, node, show_stats=True): | |
614 | result = orig(repo, node, show_stats) |
|
614 | result = orig(repo, node, show_stats) | |
615 | lfcommands.updatelfiles(repo.ui, repo) |
|
615 | lfcommands.updatelfiles(repo.ui, repo) | |
616 | return result |
|
616 | return result | |
617 |
|
617 | |||
618 |
def hg |
|
618 | def hgmerge(orig, repo, node, force=None, remind=True): | |
619 | # Mark the repo as being in the middle of a merge, so that |
|
619 | # Mark the repo as being in the middle of a merge, so that | |
620 | # updatelfiles() will know that it needs to trust the standins in |
|
620 | # updatelfiles() will know that it needs to trust the standins in | |
621 | # the working copy, not in the standins in the current node |
|
621 | # the working copy, not in the standins in the current node | |
@@ -630,7 +630,7 b' def hg_merge(orig, repo, node, force=Non' | |||||
630 | # When we rebase a repository with remotely changed largefiles, we need to |
|
630 | # When we rebase a repository with remotely changed largefiles, we need to | |
631 | # take some extra care so that the largefiles are correctly updated in the |
|
631 | # take some extra care so that the largefiles are correctly updated in the | |
632 | # working copy |
|
632 | # working copy | |
633 |
def override |
|
633 | def overridepull(orig, ui, repo, source=None, **opts): | |
634 | if opts.get('rebase', False): |
|
634 | if opts.get('rebase', False): | |
635 | repo._isrebasing = True |
|
635 | repo._isrebasing = True | |
636 | try: |
|
636 | try: | |
@@ -677,14 +677,14 b' def override_pull(orig, ui, repo, source' | |||||
677 | ui.status(_("%d largefiles cached\n") % numcached) |
|
677 | ui.status(_("%d largefiles cached\n") % numcached) | |
678 | return result |
|
678 | return result | |
679 |
|
679 | |||
680 |
def override |
|
680 | def overriderebase(orig, ui, repo, **opts): | |
681 | repo._isrebasing = True |
|
681 | repo._isrebasing = True | |
682 | try: |
|
682 | try: | |
683 | orig(ui, repo, **opts) |
|
683 | orig(ui, repo, **opts) | |
684 | finally: |
|
684 | finally: | |
685 | repo._isrebasing = False |
|
685 | repo._isrebasing = False | |
686 |
|
686 | |||
687 |
def override |
|
687 | def overridearchive(orig, repo, dest, node, kind, decode=True, matchfn=None, | |
688 | prefix=None, mtime=None, subrepos=None): |
|
688 | prefix=None, mtime=None, subrepos=None): | |
689 | # No need to lock because we are only reading history and |
|
689 | # No need to lock because we are only reading history and | |
690 | # largefile caches, neither of which are modified. |
|
690 | # largefile caches, neither of which are modified. | |
@@ -766,7 +766,7 b' def override_archive(orig, repo, dest, n' | |||||
766 | # standin until a commit. cmdutil.bailifchanged() raises an exception |
|
766 | # standin until a commit. cmdutil.bailifchanged() raises an exception | |
767 | # if the repo has uncommitted changes. Wrap it to also check if |
|
767 | # if the repo has uncommitted changes. Wrap it to also check if | |
768 | # largefiles were changed. This is used by bisect and backout. |
|
768 | # largefiles were changed. This is used by bisect and backout. | |
769 |
def override |
|
769 | def overridebailifchanged(orig, repo): | |
770 | orig(repo) |
|
770 | orig(repo) | |
771 | repo.lfstatus = True |
|
771 | repo.lfstatus = True | |
772 | modified, added, removed, deleted = repo.status()[:4] |
|
772 | modified, added, removed, deleted = repo.status()[:4] | |
@@ -774,8 +774,8 b' def override_bailifchanged(orig, repo):' | |||||
774 | if modified or added or removed or deleted: |
|
774 | if modified or added or removed or deleted: | |
775 | raise util.Abort(_('outstanding uncommitted changes')) |
|
775 | raise util.Abort(_('outstanding uncommitted changes')) | |
776 |
|
776 | |||
777 |
# Fetch doesn't use cmdutil.bail |
|
777 | # Fetch doesn't use cmdutil.bailifchanged so override it to add the check | |
778 |
def override |
|
778 | def overridefetch(orig, ui, repo, *pats, **opts): | |
779 | repo.lfstatus = True |
|
779 | repo.lfstatus = True | |
780 | modified, added, removed, deleted = repo.status()[:4] |
|
780 | modified, added, removed, deleted = repo.status()[:4] | |
781 | repo.lfstatus = False |
|
781 | repo.lfstatus = False | |
@@ -783,7 +783,7 b' def override_fetch(orig, ui, repo, *pats' | |||||
783 | raise util.Abort(_('outstanding uncommitted changes')) |
|
783 | raise util.Abort(_('outstanding uncommitted changes')) | |
784 | return orig(ui, repo, *pats, **opts) |
|
784 | return orig(ui, repo, *pats, **opts) | |
785 |
|
785 | |||
786 |
def override |
|
786 | def overrideforget(orig, ui, repo, *pats, **opts): | |
787 | installnormalfilesmatchfn(repo[None].manifest()) |
|
787 | installnormalfilesmatchfn(repo[None].manifest()) | |
788 | orig(ui, repo, *pats, **opts) |
|
788 | orig(ui, repo, *pats, **opts) | |
789 | restorematchfn() |
|
789 | restorematchfn() | |
@@ -818,7 +818,7 b' def override_forget(orig, ui, repo, *pat' | |||||
818 | else: |
|
818 | else: | |
819 | lfdirstate.remove(f) |
|
819 | lfdirstate.remove(f) | |
820 | lfdirstate.write() |
|
820 | lfdirstate.write() | |
821 |
lfutil.repo |
|
821 | lfutil.reporemove(repo, [lfutil.standin(f) for f in forget], | |
822 | unlink=True) |
|
822 | unlink=True) | |
823 | finally: |
|
823 | finally: | |
824 | wlock.release() |
|
824 | wlock.release() | |
@@ -865,7 +865,7 b' def getoutgoinglfiles(ui, repo, dest=Non' | |||||
865 | set([f for f in files if lfutil.isstandin(f) and f in ctx])) |
|
865 | set([f for f in files if lfutil.isstandin(f) and f in ctx])) | |
866 | return toupload |
|
866 | return toupload | |
867 |
|
867 | |||
868 |
def override |
|
868 | def overrideoutgoing(orig, ui, repo, dest=None, **opts): | |
869 | orig(ui, repo, dest, **opts) |
|
869 | orig(ui, repo, dest, **opts) | |
870 |
|
870 | |||
871 | if opts.pop('large', None): |
|
871 | if opts.pop('large', None): | |
@@ -878,7 +878,7 b' def override_outgoing(orig, ui, repo, de' | |||||
878 | ui.status(lfutil.splitstandin(file) + '\n') |
|
878 | ui.status(lfutil.splitstandin(file) + '\n') | |
879 | ui.status('\n') |
|
879 | ui.status('\n') | |
880 |
|
880 | |||
881 |
def override |
|
881 | def overridesummary(orig, ui, repo, *pats, **opts): | |
882 | try: |
|
882 | try: | |
883 | repo.lfstatus = True |
|
883 | repo.lfstatus = True | |
884 | orig(ui, repo, *pats, **opts) |
|
884 | orig(ui, repo, *pats, **opts) | |
@@ -892,7 +892,7 b' def override_summary(orig, ui, repo, *pa' | |||||
892 | else: |
|
892 | else: | |
893 | ui.status(_('largefiles: %d to upload\n') % len(toupload)) |
|
893 | ui.status(_('largefiles: %d to upload\n') % len(toupload)) | |
894 |
|
894 | |||
895 |
def override |
|
895 | def overrideaddremove(orig, ui, repo, *pats, **opts): | |
896 | # Get the list of missing largefiles so we can remove them |
|
896 | # Get the list of missing largefiles so we can remove them | |
897 | lfdirstate = lfutil.openlfdirstate(ui, repo) |
|
897 | lfdirstate = lfutil.openlfdirstate(ui, repo) | |
898 | s = lfdirstate.status(match_.always(repo.root, repo.getcwd()), [], False, |
|
898 | s = lfdirstate.status(match_.always(repo.root, repo.getcwd()), [], False, | |
@@ -905,11 +905,11 b' def override_addremove(orig, ui, repo, *' | |||||
905 | # confused state later. |
|
905 | # confused state later. | |
906 | if missing: |
|
906 | if missing: | |
907 | repo._isaddremove = True |
|
907 | repo._isaddremove = True | |
908 |
remove |
|
908 | removelargefiles(ui, repo, *missing, **opts) | |
909 | repo._isaddremove = False |
|
909 | repo._isaddremove = False | |
910 | # Call into the normal add code, and any files that *should* be added as |
|
910 | # Call into the normal add code, and any files that *should* be added as | |
911 | # largefiles will be |
|
911 | # largefiles will be | |
912 |
add |
|
912 | addlargefiles(ui, repo, *pats, **opts) | |
913 | # Now that we've handled largefiles, hand off to the original addremove |
|
913 | # Now that we've handled largefiles, hand off to the original addremove | |
914 | # function to take care of the rest. Make sure it doesn't do anything with |
|
914 | # function to take care of the rest. Make sure it doesn't do anything with | |
915 | # largefiles by installing a matcher that will ignore them. |
|
915 | # largefiles by installing a matcher that will ignore them. | |
@@ -920,9 +920,9 b' def override_addremove(orig, ui, repo, *' | |||||
920 |
|
920 | |||
921 | # Calling purge with --all will cause the largefiles to be deleted. |
|
921 | # Calling purge with --all will cause the largefiles to be deleted. | |
922 | # Override repo.status to prevent this from happening. |
|
922 | # Override repo.status to prevent this from happening. | |
923 |
def override |
|
923 | def overridepurge(orig, ui, repo, *dirs, **opts): | |
924 | oldstatus = repo.status |
|
924 | oldstatus = repo.status | |
925 |
def override |
|
925 | def overridestatus(node1='.', node2=None, match=None, ignored=False, | |
926 | clean=False, unknown=False, listsubrepos=False): |
|
926 | clean=False, unknown=False, listsubrepos=False): | |
927 | r = oldstatus(node1, node2, match, ignored, clean, unknown, |
|
927 | r = oldstatus(node1, node2, match, ignored, clean, unknown, | |
928 | listsubrepos) |
|
928 | listsubrepos) | |
@@ -931,11 +931,11 b' def override_purge(orig, ui, repo, *dirs' | |||||
931 | unknown = [f for f in unknown if lfdirstate[f] == '?'] |
|
931 | unknown = [f for f in unknown if lfdirstate[f] == '?'] | |
932 | ignored = [f for f in ignored if lfdirstate[f] == '?'] |
|
932 | ignored = [f for f in ignored if lfdirstate[f] == '?'] | |
933 | return modified, added, removed, deleted, unknown, ignored, clean |
|
933 | return modified, added, removed, deleted, unknown, ignored, clean | |
934 |
repo.status = override |
|
934 | repo.status = overridestatus | |
935 | orig(ui, repo, *dirs, **opts) |
|
935 | orig(ui, repo, *dirs, **opts) | |
936 | repo.status = oldstatus |
|
936 | repo.status = oldstatus | |
937 |
|
937 | |||
938 |
def override |
|
938 | def overriderollback(orig, ui, repo, **opts): | |
939 | result = orig(ui, repo, **opts) |
|
939 | result = orig(ui, repo, **opts) | |
940 | merge.update(repo, node=None, branchmerge=False, force=True, |
|
940 | merge.update(repo, node=None, branchmerge=False, force=True, | |
941 | partial=lfutil.isstandin) |
|
941 | partial=lfutil.isstandin) | |
@@ -954,7 +954,7 b' def override_rollback(orig, ui, repo, **' | |||||
954 | wlock.release() |
|
954 | wlock.release() | |
955 | return result |
|
955 | return result | |
956 |
|
956 | |||
957 |
def override |
|
957 | def overridetransplant(orig, ui, repo, *revs, **opts): | |
958 | try: |
|
958 | try: | |
959 | oldstandins = lfutil.getstandinsstate(repo) |
|
959 | oldstandins = lfutil.getstandinsstate(repo) | |
960 | repo._istransplanting = True |
|
960 | repo._istransplanting = True |
@@ -131,15 +131,15 b' def wirereposetup(ui, repo):' | |||||
131 |
|
131 | |||
132 | # advertise the largefiles=serve capability |
|
132 | # advertise the largefiles=serve capability | |
133 | def capabilities(repo, proto): |
|
133 | def capabilities(repo, proto): | |
134 |
return capabilities |
|
134 | return capabilitiesorig(repo, proto) + ' largefiles=serve' | |
135 |
|
135 | |||
136 | # duplicate what Mercurial's new out-of-band errors mechanism does, because |
|
136 | # duplicate what Mercurial's new out-of-band errors mechanism does, because | |
137 | # clients old and new alike both handle it well |
|
137 | # clients old and new alike both handle it well | |
138 |
def webproto |
|
138 | def webprotorefuseclient(self, message): | |
139 | self.req.header([('Content-Type', 'application/hg-error')]) |
|
139 | self.req.header([('Content-Type', 'application/hg-error')]) | |
140 | return message |
|
140 | return message | |
141 |
|
141 | |||
142 |
def sshproto |
|
142 | def sshprotorefuseclient(self, message): | |
143 | self.ui.write_err('%s\n-\n' % message) |
|
143 | self.ui.write_err('%s\n-\n' % message) | |
144 | self.fout.write('\n') |
|
144 | self.fout.write('\n') | |
145 | self.fout.flush() |
|
145 | self.fout.flush() | |
@@ -151,16 +151,16 b' def heads(repo, proto):' | |||||
151 | return wireproto.ooberror(LARGEFILES_REQUIRED_MSG) |
|
151 | return wireproto.ooberror(LARGEFILES_REQUIRED_MSG) | |
152 | return wireproto.heads(repo, proto) |
|
152 | return wireproto.heads(repo, proto) | |
153 |
|
153 | |||
154 |
def sshrepo |
|
154 | def sshrepocallstream(self, cmd, **args): | |
155 | if cmd == 'heads' and self.capable('largefiles'): |
|
155 | if cmd == 'heads' and self.capable('largefiles'): | |
156 | cmd = 'lheads' |
|
156 | cmd = 'lheads' | |
157 | if cmd == 'batch' and self.capable('largefiles'): |
|
157 | if cmd == 'batch' and self.capable('largefiles'): | |
158 | args['cmds'] = args['cmds'].replace('heads ', 'lheads ') |
|
158 | args['cmds'] = args['cmds'].replace('heads ', 'lheads ') | |
159 |
return ssh |
|
159 | return ssholdcallstream(self, cmd, **args) | |
160 |
|
160 | |||
161 |
def httprepo |
|
161 | def httprepocallstream(self, cmd, **args): | |
162 | if cmd == 'heads' and self.capable('largefiles'): |
|
162 | if cmd == 'heads' and self.capable('largefiles'): | |
163 | cmd = 'lheads' |
|
163 | cmd = 'lheads' | |
164 | if cmd == 'batch' and self.capable('largefiles'): |
|
164 | if cmd == 'batch' and self.capable('largefiles'): | |
165 | args['cmds'] = args['cmds'].replace('heads ', 'lheads ') |
|
165 | args['cmds'] = args['cmds'].replace('heads ', 'lheads ') | |
166 |
return http |
|
166 | return httpoldcallstream(self, cmd, **args) |
@@ -34,54 +34,54 b' def reposetup(ui, repo):' | |||||
34 | 'largefiles may behave incorrectly\n') |
|
34 | 'largefiles may behave incorrectly\n') | |
35 | % name) |
|
35 | % name) | |
36 |
|
36 | |||
37 |
class lfiles |
|
37 | class lfilesrepo(repo.__class__): | |
38 | lfstatus = False |
|
38 | lfstatus = False | |
39 | def status_nolfiles(self, *args, **kwargs): |
|
39 | def status_nolfiles(self, *args, **kwargs): | |
40 |
return super(lfiles |
|
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(lfiles |
|
47 | ctx = super(lfilesrepo, self).__getitem__(changeid) | |
48 | if self.lfstatus: |
|
48 | if self.lfstatus: | |
49 |
class lfiles |
|
49 | class lfilesmanifestdict(manifest.manifestdict): | |
50 | def __contains__(self, filename): |
|
50 | def __contains__(self, filename): | |
51 |
if super(lfiles |
|
51 | if super(lfilesmanifestdict, | |
52 | self).__contains__(filename): |
|
52 | self).__contains__(filename): | |
53 | return True |
|
53 | return True | |
54 |
return super(lfiles |
|
54 | return super(lfilesmanifestdict, | |
55 | self).__contains__(lfutil.standin(filename)) |
|
55 | self).__contains__(lfutil.standin(filename)) | |
56 |
class lfiles |
|
56 | class lfilesctx(ctx.__class__): | |
57 | def files(self): |
|
57 | def files(self): | |
58 |
filenames = super(lfiles |
|
58 | filenames = super(lfilesctx, self).files() | |
59 | return [lfutil.splitstandin(f) or f for f in filenames] |
|
59 | return [lfutil.splitstandin(f) or f for f in filenames] | |
60 | def manifest(self): |
|
60 | def manifest(self): | |
61 |
man1 = super(lfiles |
|
61 | man1 = super(lfilesctx, self).manifest() | |
62 |
man1.__class__ = lfiles |
|
62 | man1.__class__ = lfilesmanifestdict | |
63 | return man1 |
|
63 | return man1 | |
64 | def filectx(self, path, fileid=None, filelog=None): |
|
64 | def filectx(self, path, fileid=None, filelog=None): | |
65 | try: |
|
65 | try: | |
66 | if filelog is not None: |
|
66 | if filelog is not None: | |
67 |
result = super(lfiles |
|
67 | result = super(lfilesctx, self).filectx( | |
68 | path, fileid, filelog) |
|
68 | path, fileid, filelog) | |
69 | else: |
|
69 | else: | |
70 |
result = super(lfiles |
|
70 | result = super(lfilesctx, self).filectx( | |
71 | path, fileid) |
|
71 | path, fileid) | |
72 | except error.LookupError: |
|
72 | except error.LookupError: | |
73 | # Adding a null character will cause Mercurial to |
|
73 | # Adding a null character will cause Mercurial to | |
74 | # identify this as a binary file. |
|
74 | # identify this as a binary file. | |
75 | if filelog is not None: |
|
75 | if filelog is not None: | |
76 |
result = super(lfiles |
|
76 | result = super(lfilesctx, self).filectx( | |
77 | lfutil.standin(path), fileid, filelog) |
|
77 | lfutil.standin(path), fileid, filelog) | |
78 | else: |
|
78 | else: | |
79 |
result = super(lfiles |
|
79 | result = super(lfilesctx, self).filectx( | |
80 | lfutil.standin(path), fileid) |
|
80 | lfutil.standin(path), fileid) | |
81 | olddata = result.data |
|
81 | olddata = result.data | |
82 | result.data = lambda: olddata() + '\0' |
|
82 | result.data = lambda: olddata() + '\0' | |
83 | return result |
|
83 | return result | |
84 |
ctx.__class__ = lfiles |
|
84 | ctx.__class__ = lfilesctx | |
85 | return ctx |
|
85 | return ctx | |
86 |
|
86 | |||
87 | # Figure out the status of big files and insert them into the |
|
87 | # Figure out the status of big files and insert them into the | |
@@ -92,7 +92,7 b' def reposetup(ui, repo):' | |||||
92 | clean=False, unknown=False, listsubrepos=False): |
|
92 | clean=False, unknown=False, listsubrepos=False): | |
93 | listignored, listclean, listunknown = ignored, clean, unknown |
|
93 | listignored, listclean, listunknown = ignored, clean, unknown | |
94 | if not self.lfstatus: |
|
94 | if not self.lfstatus: | |
95 |
return super(lfiles |
|
95 | return super(lfilesrepo, self).status(node1, node2, match, | |
96 | listignored, listclean, listunknown, listsubrepos) |
|
96 | listignored, listclean, listunknown, listsubrepos) | |
97 | else: |
|
97 | else: | |
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 | |
@@ -130,7 +130,7 b' def reposetup(ui, repo):' | |||||
130 | if match(f): |
|
130 | if match(f): | |
131 | break |
|
131 | break | |
132 | else: |
|
132 | else: | |
133 |
return super(lfiles |
|
133 | return super(lfilesrepo, self).status(node1, node2, | |
134 | match, listignored, listclean, |
|
134 | match, listignored, listclean, | |
135 | listunknown, listsubrepos) |
|
135 | listunknown, listsubrepos) | |
136 |
|
136 | |||
@@ -154,7 +154,7 b' def reposetup(ui, repo):' | |||||
154 |
|
154 | |||
155 | # Get ignored files here even if we weren't asked for them; we |
|
155 | # Get ignored files here even if we weren't asked for them; we | |
156 | # must use the result here for filtering later |
|
156 | # must use the result here for filtering later | |
157 |
result = super(lfiles |
|
157 | result = super(lfilesrepo, self).status(node1, node2, m, | |
158 | True, clean, unknown, listsubrepos) |
|
158 | True, clean, unknown, listsubrepos) | |
159 | if working: |
|
159 | if working: | |
160 | try: |
|
160 | try: | |
@@ -164,7 +164,7 b' def reposetup(ui, repo):' | |||||
164 | # super's status. |
|
164 | # super's status. | |
165 | # Override lfdirstate's ignore matcher to not do |
|
165 | # Override lfdirstate's ignore matcher to not do | |
166 | # anything |
|
166 | # anything | |
167 |
orig |
|
167 | origignore = lfdirstate._ignore | |
168 | lfdirstate._ignore = _ignoreoverride |
|
168 | lfdirstate._ignore = _ignoreoverride | |
169 |
|
169 | |||
170 | match._files = [f for f in match._files if f in |
|
170 | match._files = [f for f in match._files if f in | |
@@ -209,7 +209,7 b' def reposetup(ui, repo):' | |||||
209 | added.append(lfile) |
|
209 | added.append(lfile) | |
210 | finally: |
|
210 | finally: | |
211 | # Replace the original ignore function |
|
211 | # Replace the original ignore function | |
212 |
lfdirstate._ignore = orig |
|
212 | lfdirstate._ignore = origignore | |
213 |
|
213 | |||
214 | for standin in ctx1.manifest(): |
|
214 | for standin in ctx1.manifest(): | |
215 | if not lfutil.isstandin(standin): |
|
215 | if not lfutil.isstandin(standin): | |
@@ -265,7 +265,7 b' def reposetup(ui, repo):' | |||||
265 | # As part of committing, copy all of the largefiles into the |
|
265 | # As part of committing, copy all of the largefiles into the | |
266 | # cache. |
|
266 | # cache. | |
267 | def commitctx(self, *args, **kwargs): |
|
267 | def commitctx(self, *args, **kwargs): | |
268 |
node = super(lfiles |
|
268 | node = super(lfilesrepo, self).commitctx(*args, **kwargs) | |
269 | lfutil.copyalltostore(self, node) |
|
269 | lfutil.copyalltostore(self, node) | |
270 | return node |
|
270 | return node | |
271 |
|
271 | |||
@@ -274,7 +274,7 b' def reposetup(ui, repo):' | |||||
274 | # Do that here. |
|
274 | # Do that here. | |
275 | def commit(self, text="", user=None, date=None, match=None, |
|
275 | def commit(self, text="", user=None, date=None, match=None, | |
276 | force=False, editor=False, extra={}): |
|
276 | force=False, editor=False, extra={}): | |
277 |
orig = super(lfiles |
|
277 | orig = super(lfilesrepo, self).commit | |
278 |
|
278 | |||
279 | wlock = repo.wlock() |
|
279 | wlock = repo.wlock() | |
280 | try: |
|
280 | try: | |
@@ -343,7 +343,7 b' def reposetup(ui, repo):' | |||||
343 | # Case 2: user calls commit with specified patterns: refresh |
|
343 | # Case 2: user calls commit with specified patterns: refresh | |
344 | # any matching big files. |
|
344 | # any matching big files. | |
345 | smatcher = lfutil.composestandinmatcher(self, match) |
|
345 | smatcher = lfutil.composestandinmatcher(self, match) | |
346 |
standins = lfutil.dirstate |
|
346 | standins = lfutil.dirstatewalk(self.dirstate, smatcher) | |
347 |
|
347 | |||
348 | # No matching big files: get out of the way and pass control to |
|
348 | # No matching big files: get out of the way and pass control to | |
349 | # the usual commit() method. |
|
349 | # the usual commit() method. | |
@@ -371,7 +371,7 b' def reposetup(ui, repo):' | |||||
371 | # complaining "not tracked" for big files. |
|
371 | # complaining "not tracked" for big files. | |
372 | lfiles = lfutil.listlfiles(repo) |
|
372 | lfiles = lfutil.listlfiles(repo) | |
373 | match = copy.copy(match) |
|
373 | match = copy.copy(match) | |
374 |
orig |
|
374 | origmatchfn = match.matchfn | |
375 |
|
375 | |||
376 | # Check both the list of largefiles and the list of |
|
376 | # Check both the list of largefiles and the list of | |
377 | # standins because if a largefile was removed, it |
|
377 | # standins because if a largefile was removed, it | |
@@ -398,7 +398,7 b' def reposetup(ui, repo):' | |||||
398 | match._files = actualfiles |
|
398 | match._files = actualfiles | |
399 |
|
399 | |||
400 | def matchfn(f): |
|
400 | def matchfn(f): | |
401 |
if orig |
|
401 | if origmatchfn(f): | |
402 | return f not in lfiles |
|
402 | return f not in lfiles | |
403 | else: |
|
403 | else: | |
404 | return f in standins |
|
404 | return f in standins | |
@@ -443,10 +443,10 b' def reposetup(ui, repo):' | |||||
443 | for f in files |
|
443 | for f in files | |
444 | if lfutil.isstandin(f) and f in ctx])) |
|
444 | if lfutil.isstandin(f) and f in ctx])) | |
445 | lfcommands.uploadlfiles(ui, self, remote, toupload) |
|
445 | lfcommands.uploadlfiles(ui, self, remote, toupload) | |
446 |
return super(lfiles |
|
446 | return super(lfilesrepo, self).push(remote, force, revs, | |
447 | newbranch) |
|
447 | newbranch) | |
448 |
|
448 | |||
449 |
repo.__class__ = lfiles |
|
449 | repo.__class__ = lfilesrepo | |
450 |
|
450 | |||
451 | def checkrequireslfiles(ui, repo, **kwargs): |
|
451 | def checkrequireslfiles(ui, repo, **kwargs): | |
452 | if 'largefiles' not in repo.requirements and util.any( |
|
452 | if 'largefiles' not in repo.requirements and util.any( |
@@ -21,7 +21,7 b' def uisetup(ui):' | |||||
21 | # files in the result are under Mercurial's control |
|
21 | # files in the result are under Mercurial's control | |
22 |
|
22 | |||
23 | entry = extensions.wrapcommand(commands.table, 'add', |
|
23 | entry = extensions.wrapcommand(commands.table, 'add', | |
24 |
overrides.override |
|
24 | overrides.overrideadd) | |
25 | addopt = [('', 'large', None, _('add as largefile')), |
|
25 | addopt = [('', 'large', None, _('add as largefile')), | |
26 | ('', 'normal', None, _('add as normal file')), |
|
26 | ('', 'normal', None, _('add as normal file')), | |
27 | ('', 'lfsize', '', _('add all files above this size ' |
|
27 | ('', 'lfsize', '', _('add all files above this size ' | |
@@ -30,19 +30,19 b' def uisetup(ui):' | |||||
30 | entry[1].extend(addopt) |
|
30 | entry[1].extend(addopt) | |
31 |
|
31 | |||
32 | entry = extensions.wrapcommand(commands.table, 'addremove', |
|
32 | entry = extensions.wrapcommand(commands.table, 'addremove', | |
33 |
overrides.override |
|
33 | overrides.overrideaddremove) | |
34 | entry = extensions.wrapcommand(commands.table, 'remove', |
|
34 | entry = extensions.wrapcommand(commands.table, 'remove', | |
35 |
overrides.override |
|
35 | overrides.overrideremove) | |
36 | entry = extensions.wrapcommand(commands.table, 'forget', |
|
36 | entry = extensions.wrapcommand(commands.table, 'forget', | |
37 |
overrides.override |
|
37 | overrides.overrideforget) | |
38 | entry = extensions.wrapcommand(commands.table, 'status', |
|
38 | entry = extensions.wrapcommand(commands.table, 'status', | |
39 |
overrides.override |
|
39 | overrides.overridestatus) | |
40 | entry = extensions.wrapcommand(commands.table, 'log', |
|
40 | entry = extensions.wrapcommand(commands.table, 'log', | |
41 |
overrides.override |
|
41 | overrides.overridelog) | |
42 | entry = extensions.wrapcommand(commands.table, 'rollback', |
|
42 | entry = extensions.wrapcommand(commands.table, 'rollback', | |
43 |
overrides.override |
|
43 | overrides.overriderollback) | |
44 | entry = extensions.wrapcommand(commands.table, 'verify', |
|
44 | entry = extensions.wrapcommand(commands.table, 'verify', | |
45 |
overrides.override |
|
45 | overrides.overrideverify) | |
46 |
|
46 | |||
47 | verifyopt = [('', 'large', None, _('verify largefiles')), |
|
47 | verifyopt = [('', 'large', None, _('verify largefiles')), | |
48 | ('', 'lfa', None, |
|
48 | ('', 'lfa', None, | |
@@ -52,44 +52,44 b' def uisetup(ui):' | |||||
52 | entry[1].extend(verifyopt) |
|
52 | entry[1].extend(verifyopt) | |
53 |
|
53 | |||
54 | entry = extensions.wrapcommand(commands.table, 'outgoing', |
|
54 | entry = extensions.wrapcommand(commands.table, 'outgoing', | |
55 |
overrides.override |
|
55 | overrides.overrideoutgoing) | |
56 | outgoingopt = [('', 'large', None, _('display outgoing largefiles'))] |
|
56 | outgoingopt = [('', 'large', None, _('display outgoing largefiles'))] | |
57 | entry[1].extend(outgoingopt) |
|
57 | entry[1].extend(outgoingopt) | |
58 | entry = extensions.wrapcommand(commands.table, 'summary', |
|
58 | entry = extensions.wrapcommand(commands.table, 'summary', | |
59 |
overrides.override |
|
59 | overrides.overridesummary) | |
60 | summaryopt = [('', 'large', None, _('display outgoing largefiles'))] |
|
60 | summaryopt = [('', 'large', None, _('display outgoing largefiles'))] | |
61 | entry[1].extend(summaryopt) |
|
61 | entry[1].extend(summaryopt) | |
62 |
|
62 | |||
63 | entry = extensions.wrapcommand(commands.table, 'update', |
|
63 | entry = extensions.wrapcommand(commands.table, 'update', | |
64 |
overrides.override |
|
64 | overrides.overrideupdate) | |
65 | entry = extensions.wrapcommand(commands.table, 'pull', |
|
65 | entry = extensions.wrapcommand(commands.table, 'pull', | |
66 |
overrides.override |
|
66 | overrides.overridepull) | |
67 | entry = extensions.wrapfunction(merge, '_checkunknownfile', |
|
67 | entry = extensions.wrapfunction(merge, '_checkunknownfile', | |
68 |
overrides.override |
|
68 | overrides.overridecheckunknownfile) | |
69 | entry = extensions.wrapfunction(merge, 'manifestmerge', |
|
69 | entry = extensions.wrapfunction(merge, 'manifestmerge', | |
70 |
overrides.override |
|
70 | overrides.overridemanifestmerge) | |
71 | entry = extensions.wrapfunction(filemerge, 'filemerge', |
|
71 | entry = extensions.wrapfunction(filemerge, 'filemerge', | |
72 |
overrides.override |
|
72 | overrides.overridefilemerge) | |
73 | entry = extensions.wrapfunction(cmdutil, 'copy', |
|
73 | entry = extensions.wrapfunction(cmdutil, 'copy', | |
74 |
overrides.override |
|
74 | overrides.overridecopy) | |
75 |
|
75 | |||
76 | # Backout calls revert so we need to override both the command and the |
|
76 | # Backout calls revert so we need to override both the command and the | |
77 | # function |
|
77 | # function | |
78 | entry = extensions.wrapcommand(commands.table, 'revert', |
|
78 | entry = extensions.wrapcommand(commands.table, 'revert', | |
79 |
overrides.override |
|
79 | overrides.overriderevert) | |
80 | entry = extensions.wrapfunction(commands, 'revert', |
|
80 | entry = extensions.wrapfunction(commands, 'revert', | |
81 |
overrides.override |
|
81 | overrides.overriderevert) | |
82 |
|
82 | |||
83 | # clone uses hg._update instead of hg.update even though they are the |
|
83 | # clone uses hg._update instead of hg.update even though they are the | |
84 | # same function... so wrap both of them) |
|
84 | # same function... so wrap both of them) | |
85 |
extensions.wrapfunction(hg, 'update', overrides.hg |
|
85 | extensions.wrapfunction(hg, 'update', overrides.hgupdate) | |
86 |
extensions.wrapfunction(hg, '_update', overrides.hg |
|
86 | extensions.wrapfunction(hg, '_update', overrides.hgupdate) | |
87 |
extensions.wrapfunction(hg, 'clean', overrides.hg |
|
87 | extensions.wrapfunction(hg, 'clean', overrides.hgclean) | |
88 |
extensions.wrapfunction(hg, 'merge', overrides.hg |
|
88 | extensions.wrapfunction(hg, 'merge', overrides.hgmerge) | |
89 |
|
89 | |||
90 |
extensions.wrapfunction(archival, 'archive', overrides.override |
|
90 | extensions.wrapfunction(archival, 'archive', overrides.overridearchive) | |
91 | extensions.wrapfunction(cmdutil, 'bailifchanged', |
|
91 | extensions.wrapfunction(cmdutil, 'bailifchanged', | |
92 |
overrides.override |
|
92 | overrides.overridebailifchanged) | |
93 |
|
93 | |||
94 | # create the new wireproto commands ... |
|
94 | # create the new wireproto commands ... | |
95 | wireproto.commands['putlfile'] = (proto.putlfile, 'sha') |
|
95 | wireproto.commands['putlfile'] = (proto.putlfile, 'sha') | |
@@ -109,20 +109,20 b' def uisetup(ui):' | |||||
109 |
|
109 | |||
110 | # the hello wireproto command uses wireproto.capabilities, so it won't see |
|
110 | # the hello wireproto command uses wireproto.capabilities, so it won't see | |
111 | # our largefiles capability unless we replace the actual function as well. |
|
111 | # our largefiles capability unless we replace the actual function as well. | |
112 |
proto.capabilities |
|
112 | proto.capabilitiesorig = wireproto.capabilities | |
113 | wireproto.capabilities = proto.capabilities |
|
113 | wireproto.capabilities = proto.capabilities | |
114 |
|
114 | |||
115 | # these let us reject non-largefiles clients and make them display |
|
115 | # these let us reject non-largefiles clients and make them display | |
116 | # our error messages |
|
116 | # our error messages | |
117 |
protocol.webproto.refuseclient = proto.webproto |
|
117 | protocol.webproto.refuseclient = proto.webprotorefuseclient | |
118 |
sshserver.sshserver.refuseclient = proto.sshproto |
|
118 | sshserver.sshserver.refuseclient = proto.sshprotorefuseclient | |
119 |
|
119 | |||
120 | # can't do this in reposetup because it needs to have happened before |
|
120 | # can't do this in reposetup because it needs to have happened before | |
121 | # wirerepo.__init__ is called |
|
121 | # wirerepo.__init__ is called | |
122 |
proto.ssh |
|
122 | proto.ssholdcallstream = sshrepo.sshrepository._callstream | |
123 |
proto.http |
|
123 | proto.httpoldcallstream = httprepo.httprepository._callstream | |
124 |
sshrepo.sshrepository._callstream = proto.sshrepo |
|
124 | sshrepo.sshrepository._callstream = proto.sshrepocallstream | |
125 |
httprepo.httprepository._callstream = proto.httprepo |
|
125 | httprepo.httprepository._callstream = proto.httprepocallstream | |
126 |
|
126 | |||
127 | # don't die on seeing a repo with the largefiles requirement |
|
127 | # don't die on seeing a repo with the largefiles requirement | |
128 | localrepo.localrepository.supported |= set(['largefiles']) |
|
128 | localrepo.localrepository.supported |= set(['largefiles']) | |
@@ -131,13 +131,13 b' def uisetup(ui):' | |||||
131 | for name, module in extensions.extensions(): |
|
131 | for name, module in extensions.extensions(): | |
132 | if name == 'fetch': |
|
132 | if name == 'fetch': | |
133 | extensions.wrapcommand(getattr(module, 'cmdtable'), 'fetch', |
|
133 | extensions.wrapcommand(getattr(module, 'cmdtable'), 'fetch', | |
134 |
overrides.override |
|
134 | overrides.overridefetch) | |
135 | if name == 'purge': |
|
135 | if name == 'purge': | |
136 | extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge', |
|
136 | extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge', | |
137 |
overrides.override |
|
137 | overrides.overridepurge) | |
138 | if name == 'rebase': |
|
138 | if name == 'rebase': | |
139 | extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase', |
|
139 | extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase', | |
140 |
overrides.override |
|
140 | overrides.overriderebase) | |
141 | if name == 'transplant': |
|
141 | if name == 'transplant': | |
142 | extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant', |
|
142 | extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant', | |
143 |
overrides.override |
|
143 | overrides.overridetransplant) |
General Comments 0
You need to be logged in to leave comments.
Login now