Patchwork [3,of,5,modernize-streamclone] streamclone: add explicit check for empty local repo

login
register
mail settings
Submitter Gregory Szorc
Date Oct. 3, 2015, 5:55 a.m.
Message ID <c12c6134a77f0afd2c48.1443851755@126.1.168.192.in-addr.arpa>
Download mbox | patch
Permalink /patch/10755/
State Accepted
Headers show

Comments

Gregory Szorc - Oct. 3, 2015, 5:55 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1443848005 25200
#      Fri Oct 02 21:53:25 2015 -0700
# Node ID c12c6134a77f0afd2c48a3a0642199a6667a28a4
# Parent  3b07d689eb21b1bae0baa38fa708fd339f3521af
streamclone: add explicit check for empty local repo

Stream clone doesn't work with non-empty local repositories. In upcoming
patches, we'll move stream cloning to the regular pull code path. Add an
explicit check on the repository being empty to prevent streaming clones
to non-empty repos.
Pierre-Yves David - Oct. 3, 2015, 11:16 p.m.
On 10/02/2015 10:55 PM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1443848005 25200
> #      Fri Oct 02 21:53:25 2015 -0700
> # Node ID c12c6134a77f0afd2c48a3a0642199a6667a28a4
> # Parent  3b07d689eb21b1bae0baa38fa708fd339f3521af
> streamclone: add explicit check for empty local repo

This is not entirely correct as other data can be contained (bookmark, 
obsmarkers etc) but let's move forward.

Patch

diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -24,8 +24,12 @@  def canperformstreamclone(repo, remote, 
     streaming clone is supported and False otherwise. ``requirements`` is
     a set of repo requirements from the remote, or ``None`` if stream clone
     isn't supported.
     """
+    # Streaming clone only works on empty repositories.
+    if len(repo):
+        return False, None
+
     # Streaming clone only works if all data is being requested.
     if heads:
         return False, None