share: stop using 'islocal' with repo instance
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 30 Nov 2022 11:12:48 +0100
changeset 49684 229e0ed88895
parent 49683 d9791643aab7
child 49686 b478e1b132e9
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.
mercurial/hg.py
--- 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)