##// END OF EJS Templates
url: use open and not url.open for local files (issue3624)
Siddharth Agarwal -
r17887:0e2846b2 stable
parent child Browse files
Show More
@@ -36,7 +36,7 b' A few obvious properties that are not cu'
36 '''
36 '''
37
37
38 import bisect, collections, json, os, random, time
38 import bisect, collections, json, os, random, time
39 from mercurial import cmdutil, context, patch, scmutil, url, util
39 from mercurial import cmdutil, context, patch, scmutil, url, util, hg
40 from mercurial.i18n import _
40 from mercurial.i18n import _
41 from mercurial.node import nullrev, nullid
41 from mercurial.node import nullrev, nullid
42
42
@@ -224,7 +224,7 b' def synthesize(ui, repo, descpath, **opt'
224 path to an alternate dictionary to use.
224 path to an alternate dictionary to use.
225 '''
225 '''
226 try:
226 try:
227 fp = url.open(ui, descpath)
227 fp = hg.openpath(ui, descpath)
228 except Exception, err:
228 except Exception, err:
229 raise util.Abort('%s: %s' % (descpath, err[0].strerror))
229 raise util.Abort('%s: %s' % (descpath, err[0].strerror))
230 desc = json.load(fp)
230 desc = json.load(fp)
@@ -63,7 +63,7 b' from mercurial.i18n import _'
63 from mercurial.node import bin, hex, short, nullid, nullrev
63 from mercurial.node import bin, hex, short, nullid, nullrev
64 from mercurial.lock import release
64 from mercurial.lock import release
65 from mercurial import commands, cmdutil, hg, scmutil, util, revset
65 from mercurial import commands, cmdutil, hg, scmutil, util, revset
66 from mercurial import repair, extensions, url, error, phases, bookmarks
66 from mercurial import repair, extensions, error, phases, bookmarks
67 from mercurial import patch as patchmod
67 from mercurial import patch as patchmod
68 import os, re, errno, shutil
68 import os, re, errno, shutil
69
69
@@ -2004,7 +2004,7 b' class queue(object):'
2004 if filename == '-':
2004 if filename == '-':
2005 text = self.ui.fin.read()
2005 text = self.ui.fin.read()
2006 else:
2006 else:
2007 fp = url.open(self.ui, filename)
2007 fp = hg.openpath(self.ui, filename)
2008 text = fp.read()
2008 text = fp.read()
2009 fp.close()
2009 fp.close()
2010 except (OSError, IOError):
2010 except (OSError, IOError):
@@ -10,7 +10,7 b' from lock import release'
10 from i18n import _, gettext
10 from i18n import _, gettext
11 import os, re, difflib, time, tempfile, errno
11 import os, re, difflib, time, tempfile, errno
12 import hg, scmutil, util, revlog, extensions, copies, error, bookmarks
12 import hg, scmutil, util, revlog, extensions, copies, error, bookmarks
13 import patch, help, url, encoding, templatekw, discovery
13 import patch, help, encoding, templatekw, discovery
14 import archival, changegroup, cmdutil, hbisect
14 import archival, changegroup, cmdutil, hbisect
15 import sshserver, hgweb, hgweb.server, commandserver
15 import sshserver, hgweb, hgweb.server, commandserver
16 import merge as mergemod
16 import merge as mergemod
@@ -1590,7 +1590,7 b' def debugbuilddag(ui, repo, text=None,'
1590 @command('debugbundle', [('a', 'all', None, _('show all details'))], _('FILE'))
1590 @command('debugbundle', [('a', 'all', None, _('show all details'))], _('FILE'))
1591 def debugbundle(ui, bundlepath, all=None, **opts):
1591 def debugbundle(ui, bundlepath, all=None, **opts):
1592 """lists the contents of a bundle"""
1592 """lists the contents of a bundle"""
1593 f = url.open(ui, bundlepath)
1593 f = hg.openpath(ui, bundlepath)
1594 try:
1594 try:
1595 gen = changegroup.readbundle(f, bundlepath)
1595 gen = changegroup.readbundle(f, bundlepath)
1596 if all:
1596 if all:
@@ -3856,7 +3856,7 b' def import_(ui, repo, patch1=None, *patc'
3856 else:
3856 else:
3857 patchurl = os.path.join(base, patchurl)
3857 patchurl = os.path.join(base, patchurl)
3858 ui.status(_('applying %s\n') % patchurl)
3858 ui.status(_('applying %s\n') % patchurl)
3859 patchfile = url.open(ui, patchurl)
3859 patchfile = hg.openpath(ui, patchurl)
3860
3860
3861 haspatch = False
3861 haspatch = False
3862 for hunk in patch.split(patchfile):
3862 for hunk in patch.split(patchfile):
@@ -5804,7 +5804,7 b' def unbundle(ui, repo, fname1, *fnames, '
5804 wc = repo['.']
5804 wc = repo['.']
5805 try:
5805 try:
5806 for fname in fnames:
5806 for fname in fnames:
5807 f = url.open(ui, fname)
5807 f = hg.openpath(ui, fname)
5808 gen = changegroup.readbundle(f, fname)
5808 gen = changegroup.readbundle(f, fname)
5809 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
5809 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
5810 finally:
5810 finally:
@@ -10,7 +10,7 b' from i18n import _'
10 from lock import release
10 from lock import release
11 from node import hex, nullid
11 from node import hex, nullid
12 import localrepo, bundlerepo, httppeer, sshpeer, statichttprepo, bookmarks
12 import localrepo, bundlerepo, httppeer, sshpeer, statichttprepo, bookmarks
13 import lock, util, extensions, error, node, scmutil, phases
13 import lock, util, extensions, error, node, scmutil, phases, url
14 import cmdutil, discovery
14 import cmdutil, discovery
15 import merge as mergemod
15 import merge as mergemod
16 import verify as verifymod
16 import verify as verifymod
@@ -89,6 +89,13 b' def islocal(repo):'
89 return False
89 return False
90 return repo.local()
90 return repo.local()
91
91
92 def openpath(ui, path):
93 '''open path with open if local, url.open if remote'''
94 if islocal(path):
95 return open(util.urllocalpath(path))
96 else:
97 return url.open(ui, path)
98
92 def _peerorrepo(ui, path, create=False):
99 def _peerorrepo(ui, path, create=False):
93 """return a repository object for the specified path"""
100 """return a repository object for the specified path"""
94 obj = _peerlookup(path).instance(ui, path, create)
101 obj = _peerlookup(path).instance(ui, path, create)
General Comments 0
You need to be logged in to leave comments. Login now