clone: disable pull during hgsql streaming clones

Summary:
hgsql depends on repositories being byte for byte identical, but the
current pull after a streaming clone can cause the repository to be different
(like if different delta decisions were made, or the commits were ordered
slightly differently). Let's disable that pull when the repository is an hgsql
repo.

Reviewed By: ryanmce

Differential Revision: D7925300

fbshipit-source-id: 6eba7ad4ccdd37f6d7c5090522867d1a54f722b7
This commit is contained in:
Durham Goode 2018-05-09 05:58:03 -07:00 committed by Facebook Github Bot
parent 6596190811
commit a25ff90a5e
4 changed files with 36 additions and 10 deletions

View File

@ -121,6 +121,7 @@ def uisetup(ui):
wrapcommand(commands.table, 'bookmark', bookmarkcommand)
wrapfunction(exchange, '_localphasemove', _localphasemove)
wrapfunction(exchange.pulloperation, '__init__', pullop_init)
wrapfunction(exchange, 'push', push)
# Enable SQL for remote commands that write to the repository
@ -252,6 +253,11 @@ def pull(orig, *args, **kwargs):
else:
return orig(*args, **kwargs)
def pullop_init(orig, self, repo, *args, **kwargs):
if issqlrepo(repo) or 'hgsql' in repo.requirements:
kwargs['exactbyteclone'] = True
return orig(self, repo, *args, **kwargs)
def push(orig, *args, **kwargs):
repo = args[0]
if issqlrepo(repo):

View File

@ -1194,7 +1194,8 @@ class pulloperation(object):
"""
def __init__(self, repo, remote, heads=None, force=False, bookmarks=(),
remotebookmarks=None, streamclonerequested=None):
remotebookmarks=None, streamclonerequested=None,
exactbyteclone=False):
# repo we pull into
self.repo = repo
# repo we pull from
@ -1224,6 +1225,9 @@ class pulloperation(object):
self.stepsdone = set()
# Whether we attempted a clone from pre-generated bundles.
self.clonebundleattempted = False
# Whether clones should do an exact byte clone. This is used for hgsql
# to avoid the extra semantic pull after a streaming clone.
self.exactbyteclone = exactbyteclone
@util.propertycache
def pulledsubset(self):
@ -1336,14 +1340,19 @@ def pull(repo, remote, heads=None, force=False, bookmarks=(), opargs=None,
# This should ideally be in _pullbundle2(). However, it needs to run
# before discovery to avoid extra work.
_maybeapplyclonebundle(pullop)
streamclone.maybeperformlegacystreamclone(pullop)
_pulldiscovery(pullop)
if pullop.canusebundle2:
_pullbundle2(pullop)
_pullchangeset(pullop)
_pullphase(pullop)
_pullbookmarks(pullop)
_pullobsolete(pullop)
cloned = streamclone.maybeperformlegacystreamclone(pullop)
# hgsql needs byte-for-byte identical clones, so let's skip the semantic
# pull stage since it can result in different bytes (different deltas,
# etc).
if not (cloned and pullop.exactbyteclone):
_pulldiscovery(pullop)
if pullop.canusebundle2:
_pullbundle2(pullop)
_pullchangeset(pullop)
_pullphase(pullop)
_pullbookmarks(pullop)
_pullobsolete(pullop)
pullop.trmanager.close()
finally:
lockmod.release(pullop.trmanager, lock, wlock)

View File

@ -115,11 +115,13 @@ def maybeperformlegacystreamclone(pullop):
A legacy stream clone will not be performed if a bundle2 stream clone is
supported.
Returns True if a clone was performed.
"""
supported, requirements = canperformstreamclone(pullop)
if not supported:
return
return False
repo = pullop.repo
remote = pullop.remote
@ -169,6 +171,8 @@ def maybeperformlegacystreamclone(pullop):
repo.invalidate()
return True
def allowservergeneration(repo):
"""Whether streaming clones are allowed from the server."""
if not repo.ui.configbool('server', 'uncompressed', untrusted=True):

View File

@ -41,3 +41,10 @@ Ensure streaming clones to non-hgsql repos work
$ hg clone --config extensions.hgsql=! --config ui.ssh='python "$TESTDIR/dummyssh"' --uncompressed ssh://user@dummy/master client2 | grep "streaming all changes"
streaming all changes
Ensure streaming clones to hgsql repos work
$ hg clone --config extensions.hgsql= --config ui.ssh='python "$TESTDIR/dummyssh"' --uncompressed ssh://user@dummy/master client3
streaming all changes
3 files to transfer, 294 bytes of data
transferred 294 bytes in * seconds (*) (glob)
updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved