diff --git a/contrib/synthrepo.py b/contrib/synthrepo.py --- a/contrib/synthrepo.py +++ b/contrib/synthrepo.py @@ -36,7 +36,7 @@ A few obvious properties that are not cu ''' import bisect, collections, json, os, random, time -from mercurial import cmdutil, context, patch, scmutil, url, util +from mercurial import cmdutil, context, patch, scmutil, url, util, hg from mercurial.i18n import _ from mercurial.node import nullrev, nullid @@ -224,7 +224,7 @@ def synthesize(ui, repo, descpath, **opt path to an alternate dictionary to use. ''' try: - fp = url.open(ui, descpath) + fp = hg.openpath(ui, descpath) except Exception, err: raise util.Abort('%s: %s' % (descpath, err[0].strerror)) desc = json.load(fp) diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -63,7 +63,7 @@ from mercurial.i18n import _ from mercurial.node import bin, hex, short, nullid, nullrev from mercurial.lock import release from mercurial import commands, cmdutil, hg, scmutil, util, revset -from mercurial import repair, extensions, url, error, phases, bookmarks +from mercurial import repair, extensions, error, phases, bookmarks from mercurial import patch as patchmod import os, re, errno, shutil @@ -2004,7 +2004,7 @@ class queue(object): if filename == '-': text = self.ui.fin.read() else: - fp = url.open(self.ui, filename) + fp = hg.openpath(self.ui, filename) text = fp.read() fp.close() except (OSError, IOError): diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -10,7 +10,7 @@ from lock import release from i18n import _, gettext import os, re, difflib, time, tempfile, errno import hg, scmutil, util, revlog, extensions, copies, error, bookmarks -import patch, help, url, encoding, templatekw, discovery +import patch, help, encoding, templatekw, discovery import archival, changegroup, cmdutil, hbisect import sshserver, hgweb, hgweb.server, commandserver import merge as mergemod @@ -1590,7 +1590,7 @@ def debugbuilddag(ui, repo, text=None, @command('debugbundle', [('a', 'all', None, _('show all details'))], _('FILE')) def debugbundle(ui, bundlepath, all=None, **opts): """lists the contents of a bundle""" - f = url.open(ui, bundlepath) + f = hg.openpath(ui, bundlepath) try: gen = changegroup.readbundle(f, bundlepath) if all: @@ -3856,7 +3856,7 @@ def import_(ui, repo, patch1=None, *patc else: patchurl = os.path.join(base, patchurl) ui.status(_('applying %s\n') % patchurl) - patchfile = url.open(ui, patchurl) + patchfile = hg.openpath(ui, patchurl) haspatch = False for hunk in patch.split(patchfile): @@ -5804,7 +5804,7 @@ def unbundle(ui, repo, fname1, *fnames, wc = repo['.'] try: for fname in fnames: - f = url.open(ui, fname) + f = hg.openpath(ui, fname) gen = changegroup.readbundle(f, fname) modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname) finally: diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -10,7 +10,7 @@ from i18n import _ from lock import release from node import hex, nullid import localrepo, bundlerepo, httppeer, sshpeer, statichttprepo, bookmarks -import lock, util, extensions, error, node, scmutil, phases +import lock, util, extensions, error, node, scmutil, phases, url import cmdutil, discovery import merge as mergemod import verify as verifymod @@ -89,6 +89,13 @@ def islocal(repo): return False return repo.local() +def openpath(ui, path): + '''open path with open if local, url.open if remote''' + if islocal(path): + return open(util.urllocalpath(path)) + else: + return url.open(ui, path) + def _peerorrepo(ui, path, create=False): """return a repository object for the specified path""" obj = _peerlookup(path).instance(ui, path, create)