mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
Fix pull wrapping to match upstream
Upstream Mercurial has moved localrepo.pull into exchange.pull. This moves our wrapping of that command out of shallowrepo and into __init__. Exchange is becoming an increasingly important class, so we may want to think about moving all exchange wrapper logic out to a separate module in remotefilelog.
This commit is contained in:
parent
65503211ed
commit
37798a0827
@ -17,7 +17,7 @@ from mercurial import repair, extensions, filelog, revlog, wireproto, cmdutil
|
||||
from mercurial import copies, store, context, changegroup, localrepo
|
||||
from mercurial import commands, sshpeer, scmutil, dispatch, merge, context, changelog
|
||||
from mercurial import templatekw, repoview, bundlerepo, revset, hg, patch, verify
|
||||
from mercurial import match
|
||||
from mercurial import match, exchange
|
||||
import struct, zlib, errno, collections, time, os, socket, subprocess, lz4
|
||||
import stat
|
||||
|
||||
@ -148,6 +148,8 @@ def onetimeclientsetup(ui):
|
||||
return s
|
||||
wrapfunction(store, 'store', storewrapper)
|
||||
|
||||
extensions.wrapfunction(exchange, 'pull', exchangepull)
|
||||
|
||||
# prefetch files before update
|
||||
def applyupdates(orig, repo, actions, wctx, mctx, overwrite, labels=None):
|
||||
if shallowrepo.requirement in repo.requirements:
|
||||
@ -537,6 +539,37 @@ def pull(orig, ui, repo, *pats, **opts):
|
||||
|
||||
return result
|
||||
|
||||
def exchangepull(orig, repo, remote, *args, **kwargs):
|
||||
# Hook into the callstream/getbundle to insert bundle capabilities
|
||||
# during a pull.
|
||||
def remotecallstream(orig, command, **opts):
|
||||
if command == 'getbundle' and 'remotefilelog' in remote._capabilities():
|
||||
bundlecaps = opts.get('bundlecaps')
|
||||
if bundlecaps:
|
||||
bundlecaps = [bundlecaps]
|
||||
else:
|
||||
bundlecaps = []
|
||||
bundlecaps.append('remotefilelog')
|
||||
if repo.includepattern:
|
||||
bundlecaps.append("includepattern=" + '\0'.join(repo.includepattern))
|
||||
if repo.excludepattern:
|
||||
bundlecaps.append("excludepattern=" + '\0'.join(repo.excludepattern))
|
||||
opts['bundlecaps'] = ','.join(bundlecaps)
|
||||
return orig(command, **opts)
|
||||
|
||||
def localgetbundle(orig, source, heads=None, common=None, bundlecaps=None):
|
||||
if not bundlecaps:
|
||||
bundlecaps = []
|
||||
bundlecaps.append('remotefilelog')
|
||||
return orig(source, heads=heads, common=common, bundlecaps=bundlecaps)
|
||||
|
||||
if hasattr(remote, '_callstream'):
|
||||
wrapfunction(remote, '_callstream', remotecallstream)
|
||||
elif hasattr(remote, 'getbundle'):
|
||||
wrapfunction(remote, 'getbundle', localgetbundle)
|
||||
|
||||
return orig(repo, remote, *args, **kwargs)
|
||||
|
||||
def revert(orig, ui, repo, ctx, parents, *pats, **opts):
|
||||
# prefetch prior to reverting
|
||||
# used for old mercurial version
|
||||
|
@ -41,37 +41,6 @@ def wraprepo(repo):
|
||||
else:
|
||||
return super(shallowrepository, self).filectx(path, changeid, fileid)
|
||||
|
||||
def pull(self, remote, *args, **kwargs):
|
||||
# Hook into the callstream/getbundle to insert bundle capabilities
|
||||
# during a pull.
|
||||
def remotecallstream(orig, command, **opts):
|
||||
if command == 'getbundle' and 'remotefilelog' in remote._capabilities():
|
||||
bundlecaps = opts.get('bundlecaps')
|
||||
if bundlecaps:
|
||||
bundlecaps = [bundlecaps]
|
||||
else:
|
||||
bundlecaps = []
|
||||
bundlecaps.append('remotefilelog')
|
||||
if self.includepattern:
|
||||
bundlecaps.append("includepattern=" + '\0'.join(self.includepattern))
|
||||
if self.excludepattern:
|
||||
bundlecaps.append("excludepattern=" + '\0'.join(self.excludepattern))
|
||||
opts['bundlecaps'] = ','.join(bundlecaps)
|
||||
return orig(command, **opts)
|
||||
|
||||
def localgetbundle(orig, source, heads=None, common=None, bundlecaps=None):
|
||||
if not bundlecaps:
|
||||
bundlecaps = []
|
||||
bundlecaps.append('remotefilelog')
|
||||
return orig(source, heads=heads, common=common, bundlecaps=bundlecaps)
|
||||
|
||||
if hasattr(remote, '_callstream'):
|
||||
wrapfunction(remote, '_callstream', remotecallstream)
|
||||
elif hasattr(remote, 'getbundle'):
|
||||
wrapfunction(remote, 'getbundle', localgetbundle)
|
||||
|
||||
return super(shallowrepository, self).pull(remote, *args, **kwargs)
|
||||
|
||||
def prefetch(self, revs, base=None, pats=None, opts=None):
|
||||
"""Prefetches all the necessary file revisions for the given revs
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user