unbundle: don't use urllib if it's a local file
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Tue, 30 Jan 2007 18:32:21 -0200
changeset 4056 f1622b4f467d
parent 4055 e37786b29bed
child 4057 3600b84656d3
unbundle: don't use urllib if it's a local file
mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2490,7 +2490,11 @@ def unbundle(ui, repo, fname, **opts):
     Apply a compressed changegroup file generated by the bundle
     command.
     """
-    gen = changegroup.readbundle(urllib.urlopen(fname), fname)
+    if os.path.exists(fname):
+        f = open(fname)
+    else:
+        f = urllib.urlopen(fname)
+    gen = changegroup.readbundle(f, fname)
     modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
     return postincoming(ui, repo, modheads, opts['update'])