[PATCH 4 of 5 modernize-streamclone] exchange: teach pull about requested stream clones
Gregory Szorc
gregory.szorc at gmail.com
Sat Oct 3 00:55:56 CDT 2015
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1443849394 25200
# Fri Oct 02 22:16:34 2015 -0700
# Node ID bbc29a9ce3dcbc0fdc721fe638f2329c5d578614
# Parent c12c6134a77f0afd2c48a3a0642199a6667a28a4
exchange: teach pull about requested stream clones
An upcoming patch will move the invocation of stream cloning logic to
the normal pull code path (from localrepository.clone). In preparation
for this, we teach pull() and pulloperation about whether a streaming
clone is requested.
The return logic in localrepository.clone() has been reformatted
slightly because of line length issues.
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -836,9 +836,9 @@ class pulloperation(object):
afterward.
"""
def __init__(self, repo, remote, heads=None, force=False, bookmarks=(),
- remotebookmarks=None):
+ remotebookmarks=None, streamclonerequested=None):
# repo we pull into
self.repo = repo
# repo we pull from
self.remote = remote
@@ -847,8 +847,10 @@ class pulloperation(object):
# bookmark pulled explicitly
self.explicitbookmarks = bookmarks
# do we force pull?
self.force = force
+ # whether a streaming clone was requested
+ self.streamclonerequested = streamclonerequested
# transaction manager
self.trmanager = None
# set of common changeset between local and remote before pull
self.common = None
@@ -914,9 +916,10 @@ class transactionmanager(object):
"""release transaction if created"""
if self._tr is not None:
self._tr.release()
-def pull(repo, remote, heads=None, force=False, bookmarks=(), opargs=None):
+def pull(repo, remote, heads=None, force=False, bookmarks=(), opargs=None,
+ streamclonerequested=None):
"""Fetch repository data from a remote.
This is the main function used to retrieve data from a remote repository.
@@ -927,15 +930,20 @@ def pull(repo, remote, heads=None, force
``bookmarks`` is an iterable of bookmarks requesting to be pulled. By
default, all remote bookmarks are pulled.
``opargs`` are additional keyword arguments to pass to ``pulloperation``
initialization.
+ ``streamclonerequested`` is a boolean indicating whether a "streaming
+ clone" is requested. A "streaming clone" is essentially a raw file copy
+ of revlogs from the server. This only works when the local repository is
+ empty. The default value of ``None`` means to respect the server
+ configuration for preferring stream clones.
Returns the ``pulloperation`` created for this pull.
"""
if opargs is None:
opargs = {}
pullop = pulloperation(repo, remote, heads, force, bookmarks=bookmarks,
- **opargs)
+ streamclonerequested=streamclonerequested, **opargs)
if pullop.remote.local():
missing = set(pullop.remote.requirements) - pullop.repo.supported
if missing:
msg = _("required features are not"
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1794,12 +1794,13 @@ class localrepository(object):
# internal config: ui.quietbookmarkmove
quiet = self.ui.backupconfig('ui', 'quietbookmarkmove')
try:
self.ui.setconfig('ui', 'quietbookmarkmove', True, 'clone')
- ret = exchange.pull(self, remote, heads).cgresult
+ pullop = exchange.pull(self, remote, heads,
+ streamclonerequested=stream)
+ return pullop.cgresult
finally:
self.ui.restoreconfig(quiet)
- return ret
def pushkey(self, namespace, key, old, new):
try:
tr = self.currenttransaction()
More information about the Mercurial-devel
mailing list