changeset 51798:187d7c859be7 stable

largefiles: fix check that ensures that --all-largefiles is only used locally Previously, the command added in the test failed with “abort: --all-largefiles is incompatible with non-local destination existing_destination”. The reason for the buggy behavior was the use of hg.islocal(), which does “return true if repo (or path pointing to repo) is local” and, for local paths, assumes that the path is actually pointing to an existing repository and returns whether the path is not a regular file (in which case it assumes that it is a bundlerepo, which are considered non-local).
author Manuel Jacob <me@manueljacob.de>
date Fri, 09 Aug 2024 22:45:32 +0200
parents 8f629783b8ae
children 23116aefe786
files hgext/largefiles/overrides.py tests/test-largefiles.t
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py	Fri Aug 09 14:26:13 2024 +0200
+++ b/hgext/largefiles/overrides.py	Fri Aug 09 22:45:32 2024 +0200
@@ -46,6 +46,8 @@
     actions as upgrade_actions,
 )
 
+from mercurial.utils import urlutil
+
 from . import (
     lfcommands,
     lfutil,
@@ -1136,7 +1138,10 @@
     d = dest
     if d is None:
         d = hg.defaultdest(source)
-    if opts.get('all_largefiles') and not hg.islocal(d):
+    if opts.get('all_largefiles') and urlutil.url(d).scheme not in (
+        b'file',
+        None,
+    ):
         raise error.Abort(
             _(b'--all-largefiles is incompatible with non-local destination %s')
             % d
--- a/tests/test-largefiles.t	Fri Aug 09 14:26:13 2024 +0200
+++ b/tests/test-largefiles.t	Fri Aug 09 22:45:32 2024 +0200
@@ -1076,6 +1076,11 @@
   abort: --all-largefiles is incompatible with non-local destination ssh://localhost/a
   [255]
 
+  $ touch existing_destination
+  $ hg clone --all-largefiles a existing_destination
+  abort: destination 'existing_destination' already exists
+  [10]
+
 Test pulling with --all-largefiles flag.  Also test that the largefiles are
 downloaded from 'default' instead of 'default-push' when no source is specified
 (issue3584)