Patchwork [STABLE] largefiles: don't crash when cloning to a remote repo

login
register
mail settings
Submitter Matt Harbison
Date April 18, 2015, 4:47 p.m.
Message ID <e4e69cebeedd99813947.1429375645@Envy>
Download mbox | patch
Permalink /patch/8740/
State Accepted
Headers show

Comments

Matt Harbison - April 18, 2015, 4:47 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1429331678 14400
#      Sat Apr 18 00:34:38 2015 -0400
# Branch stable
# Node ID e4e69cebeedd9981394786bd25b8fee14a6b89ba
# Parent  a2dcf460e141fa5979d3b29cce76b958d5b68b94
largefiles: don't crash when cloning to a remote repo

The immediate crash was when checking for requirements immediately after this,
but lfcommands.downloadlfiles() will also crash if --all-largefiles is
specified.  That has been in place since atleast 5884812686f7 (2.3-rc) without
anyone noticing.

I can't tell from the peer classes if there's a way to make the custom largefile
functionality work in this case, but atleast it doesn't crash.
Matt Mackall - April 19, 2015, 6:01 p.m.
On Sat, 2015-04-18 at 12:47 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1429331678 14400
> #      Sat Apr 18 00:34:38 2015 -0400
> # Branch stable
> # Node ID e4e69cebeedd9981394786bd25b8fee14a6b89ba
> # Parent  a2dcf460e141fa5979d3b29cce76b958d5b68b94
> largefiles: don't crash when cloning to a remote repo

Seems ok, queued for stable, thanks.

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -838,6 +838,12 @@ 
         sourcerepo, destrepo = result
         repo = destrepo.local()
 
+        # When cloning to a remote repo (like through SSH), no repo is available
+        # from the peer.   Therefore the largefiles can't be downloaded and the
+        # hgrc can't be updated.
+        if not repo:
+            return result
+
         # If largefiles is required for this repo, permanently enable it locally
         if 'largefiles' in repo.requirements:
             fp = repo.vfs('hgrc', 'a', text=True)
diff --git a/tests/test-init.t b/tests/test-init.t
--- a/tests/test-init.t
+++ b/tests/test-init.t
@@ -111,6 +111,14 @@ 
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
 
+The largefiles extension doesn't crash
+  $ hg clone -e "python \"$TESTDIR/dummyssh\"" local ssh://user@dummy/remotelf --config extensions.largefiles=
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 1 changes to 1 files
+
 init to existing repo
 
   $ hg init -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote1
@@ -133,6 +141,8 @@ 
   Got arguments 1:user@dummy 2:hg -R remote2 serve --stdio
   Got arguments 1:user@dummy 2:hg init remote1
   Got arguments 1:user@dummy 2:hg -R remote1 serve --stdio
+  Got arguments 1:user@dummy 2:hg init remotelf
+  Got arguments 1:user@dummy 2:hg -R remotelf serve --stdio
   Got arguments 1:user@dummy 2:hg init remote1
   Got arguments 1:user@dummy 2:hg init remote1