##// END OF EJS Templates
remotefilelog: move most functions in onetimeclientsetup() to top level...
Martin von Zweigbergk -
r42459:651f325e default
parent child Browse files
Show More
@@ -405,29 +405,12 b' def setupclient(ui, repo):'
405 shallowrepo.wraprepo(repo)
405 shallowrepo.wraprepo(repo)
406 repo.store = shallowstore.wrapstore(repo.store)
406 repo.store = shallowstore.wrapstore(repo.store)
407
407
408 clientonetime = False
409 def onetimeclientsetup(ui):
410 global clientonetime
411 if clientonetime:
412 return
413 clientonetime = True
414
415 changegroup.cgpacker = shallowbundle.shallowcg1packer
416
417 extensions.wrapfunction(changegroup, '_addchangegroupfiles',
418 shallowbundle.addchangegroupfiles)
419 extensions.wrapfunction(
420 changegroup, 'makechangegroup', shallowbundle.makechangegroup)
421
422 def storewrapper(orig, requirements, path, vfstype):
408 def storewrapper(orig, requirements, path, vfstype):
423 s = orig(requirements, path, vfstype)
409 s = orig(requirements, path, vfstype)
424 if constants.SHALLOWREPO_REQUIREMENT in requirements:
410 if constants.SHALLOWREPO_REQUIREMENT in requirements:
425 s = shallowstore.wrapstore(s)
411 s = shallowstore.wrapstore(s)
426
412
427 return s
413 return s
428 extensions.wrapfunction(localrepo, 'makestore', storewrapper)
429
430 extensions.wrapfunction(exchange, 'pull', exchangepull)
431
414
432 # prefetch files before update
415 # prefetch files before update
433 def applyupdates(orig, repo, actions, wctx, mctx, overwrite, labels=None):
416 def applyupdates(orig, repo, actions, wctx, mctx, overwrite, labels=None):
@@ -439,7 +422,6 b' def onetimeclientsetup(ui):'
439 # batch fetch the needed files from the server
422 # batch fetch the needed files from the server
440 repo.fileservice.prefetch(files)
423 repo.fileservice.prefetch(files)
441 return orig(repo, actions, wctx, mctx, overwrite, labels=labels)
424 return orig(repo, actions, wctx, mctx, overwrite, labels=labels)
442 extensions.wrapfunction(merge, 'applyupdates', applyupdates)
443
425
444 # Prefetch merge checkunknownfiles
426 # Prefetch merge checkunknownfiles
445 def checkunknownfiles(orig, repo, wctx, mctx, force, actions,
427 def checkunknownfiles(orig, repo, wctx, mctx, force, actions,
@@ -458,7 +440,6 b' def onetimeclientsetup(ui):'
458 # batch fetch the needed files from the server
440 # batch fetch the needed files from the server
459 repo.fileservice.prefetch(files)
441 repo.fileservice.prefetch(files)
460 return orig(repo, wctx, mctx, force, actions, *args, **kwargs)
442 return orig(repo, wctx, mctx, force, actions, *args, **kwargs)
461 extensions.wrapfunction(merge, '_checkunknownfiles', checkunknownfiles)
462
443
463 # Prefetch files before status attempts to look at their size and contents
444 # Prefetch files before status attempts to look at their size and contents
464 def checklookup(orig, self, files):
445 def checklookup(orig, self, files):
@@ -472,7 +453,6 b' def onetimeclientsetup(ui):'
472 # batch fetch the needed files from the server
453 # batch fetch the needed files from the server
473 repo.fileservice.prefetch(prefetchfiles)
454 repo.fileservice.prefetch(prefetchfiles)
474 return orig(self, files)
455 return orig(self, files)
475 extensions.wrapfunction(context.workingctx, '_checklookup', checklookup)
476
456
477 # Prefetch the logic that compares added and removed files for renames
457 # Prefetch the logic that compares added and removed files for renames
478 def findrenames(orig, repo, matcher, added, removed, *args, **kwargs):
458 def findrenames(orig, repo, matcher, added, removed, *args, **kwargs):
@@ -485,7 +465,6 b' def onetimeclientsetup(ui):'
485 # batch fetch the needed files from the server
465 # batch fetch the needed files from the server
486 repo.fileservice.prefetch(files)
466 repo.fileservice.prefetch(files)
487 return orig(repo, matcher, added, removed, *args, **kwargs)
467 return orig(repo, matcher, added, removed, *args, **kwargs)
488 extensions.wrapfunction(scmutil, '_findrenames', findrenames)
489
468
490 # prefetch files before pathcopies check
469 # prefetch files before pathcopies check
491 def computeforwardmissing(orig, a, b, match=None):
470 def computeforwardmissing(orig, a, b, match=None):
@@ -507,8 +486,6 b' def onetimeclientsetup(ui):'
507 # batch fetch the needed files from the server
486 # batch fetch the needed files from the server
508 repo.fileservice.prefetch(files)
487 repo.fileservice.prefetch(files)
509 return missing
488 return missing
510 extensions.wrapfunction(copies, '_computeforwardmissing',
511 computeforwardmissing)
512
489
513 # close cache miss server connection after the command has finished
490 # close cache miss server connection after the command has finished
514 def runcommand(orig, lui, repo, *args, **kwargs):
491 def runcommand(orig, lui, repo, *args, **kwargs):
@@ -523,6 +500,90 b' def onetimeclientsetup(ui):'
523 finally:
500 finally:
524 if fileservice:
501 if fileservice:
525 fileservice.close()
502 fileservice.close()
503
504 # prevent strip from stripping remotefilelogs
505 def _collectbrokencsets(orig, repo, files, striprev):
506 if isenabled(repo):
507 files = list([f for f in files if not repo.shallowmatch(f)])
508 return orig(repo, files, striprev)
509
510 # changectx wrappers
511 def filectx(orig, self, path, fileid=None, filelog=None):
512 if fileid is None:
513 fileid = self.filenode(path)
514 if (isenabled(self._repo) and self._repo.shallowmatch(path)):
515 return remotefilectx.remotefilectx(self._repo, path, fileid=fileid,
516 changectx=self, filelog=filelog)
517 return orig(self, path, fileid=fileid, filelog=filelog)
518
519 def workingfilectx(orig, self, path, filelog=None):
520 if (isenabled(self._repo) and self._repo.shallowmatch(path)):
521 return remotefilectx.remoteworkingfilectx(self._repo, path,
522 workingctx=self,
523 filelog=filelog)
524 return orig(self, path, filelog=filelog)
525
526 # prefetch required revisions before a diff
527 def trydiff(orig, repo, revs, ctx1, ctx2, modified, added, removed,
528 copy, getfilectx, *args, **kwargs):
529 if isenabled(repo):
530 prefetch = []
531 mf1 = ctx1.manifest()
532 for fname in modified + added + removed:
533 if fname in mf1:
534 fnode = getfilectx(fname, ctx1).filenode()
535 # fnode can be None if it's a edited working ctx file
536 if fnode:
537 prefetch.append((fname, hex(fnode)))
538 if fname not in removed:
539 fnode = getfilectx(fname, ctx2).filenode()
540 if fnode:
541 prefetch.append((fname, hex(fnode)))
542
543 repo.fileservice.prefetch(prefetch)
544
545 return orig(repo, revs, ctx1, ctx2, modified, added, removed, copy,
546 getfilectx, *args, **kwargs)
547
548 # Prevent verify from processing files
549 # a stub for mercurial.hg.verify()
550 def _verify(orig, repo, level=None):
551 lock = repo.lock()
552 try:
553 return shallowverifier.shallowverifier(repo).verify()
554 finally:
555 lock.release()
556
557
558 clientonetime = False
559 def onetimeclientsetup(ui):
560 global clientonetime
561 if clientonetime:
562 return
563 clientonetime = True
564
565 changegroup.cgpacker = shallowbundle.shallowcg1packer
566
567 extensions.wrapfunction(changegroup, '_addchangegroupfiles',
568 shallowbundle.addchangegroupfiles)
569 extensions.wrapfunction(
570 changegroup, 'makechangegroup', shallowbundle.makechangegroup)
571
572 extensions.wrapfunction(localrepo, 'makestore', storewrapper)
573
574 extensions.wrapfunction(exchange, 'pull', exchangepull)
575
576 extensions.wrapfunction(merge, 'applyupdates', applyupdates)
577
578 extensions.wrapfunction(merge, '_checkunknownfiles', checkunknownfiles)
579
580 extensions.wrapfunction(context.workingctx, '_checklookup', checklookup)
581
582 extensions.wrapfunction(scmutil, '_findrenames', findrenames)
583
584 extensions.wrapfunction(copies, '_computeforwardmissing',
585 computeforwardmissing)
586
526 extensions.wrapfunction(dispatch, 'runcommand', runcommand)
587 extensions.wrapfunction(dispatch, 'runcommand', runcommand)
527
588
528 # disappointing hacks below
589 # disappointing hacks below
@@ -531,11 +592,6 b' def onetimeclientsetup(ui):'
531 revset.symbols['filelog'] = revset.filelog
592 revset.symbols['filelog'] = revset.filelog
532 extensions.wrapfunction(cmdutil, 'walkfilerevs', walkfilerevs)
593 extensions.wrapfunction(cmdutil, 'walkfilerevs', walkfilerevs)
533
594
534 # prevent strip from stripping remotefilelogs
535 def _collectbrokencsets(orig, repo, files, striprev):
536 if isenabled(repo):
537 files = list([f for f in files if not repo.shallowmatch(f)])
538 return orig(repo, files, striprev)
539 extensions.wrapfunction(repair, '_collectbrokencsets', _collectbrokencsets)
595 extensions.wrapfunction(repair, '_collectbrokencsets', _collectbrokencsets)
540
596
541 # Don't commit filelogs until we know the commit hash, since the hash
597 # Don't commit filelogs until we know the commit hash, since the hash
@@ -580,55 +636,12 b' def onetimeclientsetup(ui):'
580 return node
636 return node
581 extensions.wrapfunction(changelog.changelog, 'add', changelogadd)
637 extensions.wrapfunction(changelog.changelog, 'add', changelogadd)
582
638
583 # changectx wrappers
584 def filectx(orig, self, path, fileid=None, filelog=None):
585 if fileid is None:
586 fileid = self.filenode(path)
587 if (isenabled(self._repo) and self._repo.shallowmatch(path)):
588 return remotefilectx.remotefilectx(self._repo, path,
589 fileid=fileid, changectx=self, filelog=filelog)
590 return orig(self, path, fileid=fileid, filelog=filelog)
591 extensions.wrapfunction(context.changectx, 'filectx', filectx)
639 extensions.wrapfunction(context.changectx, 'filectx', filectx)
592
640
593 def workingfilectx(orig, self, path, filelog=None):
594 if (isenabled(self._repo) and self._repo.shallowmatch(path)):
595 return remotefilectx.remoteworkingfilectx(self._repo,
596 path, workingctx=self, filelog=filelog)
597 return orig(self, path, filelog=filelog)
598 extensions.wrapfunction(context.workingctx, 'filectx', workingfilectx)
641 extensions.wrapfunction(context.workingctx, 'filectx', workingfilectx)
599
642
600 # prefetch required revisions before a diff
601 def trydiff(orig, repo, revs, ctx1, ctx2, modified, added, removed,
602 copy, getfilectx, *args, **kwargs):
603 if isenabled(repo):
604 prefetch = []
605 mf1 = ctx1.manifest()
606 for fname in modified + added + removed:
607 if fname in mf1:
608 fnode = getfilectx(fname, ctx1).filenode()
609 # fnode can be None if it's a edited working ctx file
610 if fnode:
611 prefetch.append((fname, hex(fnode)))
612 if fname not in removed:
613 fnode = getfilectx(fname, ctx2).filenode()
614 if fnode:
615 prefetch.append((fname, hex(fnode)))
616
617 repo.fileservice.prefetch(prefetch)
618
619 return orig(repo, revs, ctx1, ctx2, modified, added, removed,
620 copy, getfilectx, *args, **kwargs)
621 extensions.wrapfunction(patch, 'trydiff', trydiff)
643 extensions.wrapfunction(patch, 'trydiff', trydiff)
622
644
623 # Prevent verify from processing files
624 # a stub for mercurial.hg.verify()
625 def _verify(orig, repo, level=None):
626 lock = repo.lock()
627 try:
628 return shallowverifier.shallowverifier(repo).verify()
629 finally:
630 lock.release()
631
632 extensions.wrapfunction(hg, 'verify', _verify)
645 extensions.wrapfunction(hg, 'verify', _verify)
633
646
634 scmutil.fileprefetchhooks.add('remotefilelog', _fileprefetchhook)
647 scmutil.fileprefetchhooks.add('remotefilelog', _fileprefetchhook)
General Comments 0
You need to be logged in to leave comments. Login now