diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -82,7 +82,7 @@ def _peerlookup(path): return thing def islocal(repo): - '''return true if repo or path is local''' + '''return true if repo (or path pointing to repo) is local''' if isinstance(repo, str): try: return _peerlookup(repo).islocal(repo) @@ -92,8 +92,9 @@ def islocal(repo): def openpath(ui, path): '''open path with open if local, url.open if remote''' - if islocal(path): - return util.posixfile(util.urllocalpath(path), 'rb') + pathurl = util.url(path, parsequery=False, parsefragment=False) + if pathurl.islocal(): + return util.posixfile(pathurl.localpath(), 'rb') else: return url.open(ui, path) diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1875,6 +1875,11 @@ class url(object): return path return self._origpath + def islocal(self): + '''whether localpath will return something that posixfile can open''' + return (not self.scheme or self.scheme == 'file' + or self.scheme == 'bundle') + def hasscheme(path): return bool(url(path).scheme)