changeset 49798:229e0ed88895

share: stop using 'islocal' with repo instance Having this level of polymorphism of the `islocal` function is weird, and we already have a way to know if the repo is local from the object itself. We are about to deprecate passing a non-bytes object to `islocal`, so clean this up beforehand. We might want to clean up this function too in the future, however this is another adventure.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 30 Nov 2022 11:12:48 +0100
parents d9791643aab7
children b478e1b132e9
files mercurial/hg.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hg.py	Tue Nov 29 19:54:55 2022 +0100
+++ b/mercurial/hg.py	Wed Nov 30 11:12:48 2022 +0100
@@ -299,8 +299,13 @@
 ):
     '''create a shared repository'''
 
-    if not islocal(source):
-        raise error.Abort(_(b'can only share local repositories'))
+    not_local_msg = _(b'can only share local repositories')
+    if util.safehasattr(source, 'local'):
+        if source.local() is None:
+            raise error.Abort(not_local_msg)
+    elif not islocal(source):
+        # XXX why are we getting bytes here ?
+        raise error.Abort(not_local_msg)
 
     if not dest:
         dest = defaultdest(source)