--- a/mercurial/commands.py Mon Oct 27 21:50:01 2008 +0100
+++ b/mercurial/commands.py Mon Oct 27 21:50:16 2008 +0100
@@ -8,7 +8,7 @@
from node import hex, nullid, nullrev, short
from repo import RepoError, NoCapability
from i18n import _, gettext
-import os, re, sys, urllib
+import os, re, sys
import hg, util, revlog, bundlerepo, extensions, copies
import difflib, patch, time, help, mdiff, tempfile, url
import version, socket
@@ -1590,13 +1590,11 @@
if pf == '-':
ui.status(_("applying patch from stdin\n"))
- data = patch.extract(ui, sys.stdin)
+ pf = sys.stdin
else:
ui.status(_("applying %s\n") % p)
- if os.path.exists(pf):
- data = patch.extract(ui, file(pf, 'rb'))
- else:
- data = patch.extract(ui, urllib.urlopen(pf))
+ pf = url.open(ui, pf)
+ data = patch.extract(ui, pf)
tmpname, message, user, date, branch, nodeid, p1, p2 = data
if tmpname is None:
@@ -2844,10 +2842,7 @@
try:
lock = repo.lock()
for fname in fnames:
- if os.path.exists(fname):
- f = open(fname, "rb")
- else:
- f = urllib.urlopen(fname)
+ f = url.open(ui, fname)
gen = changegroup.readbundle(f, fname)
modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
finally: