Mercurial > hg-stable
changeset 17887:0e2846b2482c stable
url: use open and not url.open for local files (issue3624)
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Wed, 17 Oct 2012 21:30:08 -0700 |
parents | d8905e2c1301 |
children | 39b7052b217b |
files | contrib/synthrepo.py hgext/mq.py mercurial/commands.py mercurial/hg.py |
diffstat | 4 files changed, 16 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/synthrepo.py Tue Oct 30 18:48:44 2012 -0500 +++ b/contrib/synthrepo.py Wed Oct 17 21:30:08 2012 -0700 @@ -36,7 +36,7 @@ ''' 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 @@ 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)
--- a/hgext/mq.py Tue Oct 30 18:48:44 2012 -0500 +++ b/hgext/mq.py Wed Oct 17 21:30:08 2012 -0700 @@ -63,7 +63,7 @@ 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 @@ 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):
--- a/mercurial/commands.py Tue Oct 30 18:48:44 2012 -0500 +++ b/mercurial/commands.py Wed Oct 17 21:30:08 2012 -0700 @@ -10,7 +10,7 @@ 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 @@ @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 @@ 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 @@ 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:
--- a/mercurial/hg.py Tue Oct 30 18:48:44 2012 -0500 +++ b/mercurial/hg.py Wed Oct 17 21:30:08 2012 -0700 @@ -10,7 +10,7 @@ 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 @@ 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)