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