Patchwork [2,of,3,stable] hg.openpath: use url.islocal to tell if the path is local (issue3624)

login
register
mail settings
Submitter Siddharth Agarwal
Date Feb. 3, 2014, 11:12 p.m.
Message ID <a2661fa3b83547321cdd.1391469132@dev998.prn1.facebook.com>
Download mbox | patch
Permalink /patch/3451/
State Accepted
Commit b433b43364e4059797637a5cf298f24e7209f95c
Headers show

Comments

Siddharth Agarwal - Feb. 3, 2014, 11:12 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1391468024 28800
#      Mon Feb 03 14:53:44 2014 -0800
# Branch stable
# Node ID a2661fa3b83547321cdd07bb7b24210b35870198
# Parent  8ab8a85a22c2f5a0e23e86f2041ef7d348fab857
hg.openpath: use url.islocal to tell if the path is local (issue3624)

Previously we used hg.islocal, which doesn't work for paths pointing to
non-repos, such as patch files.

Patch

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -92,8 +92,9 @@ 
 
 def openpath(ui, path):
     '''open path with open if local, url.open if remote'''
-    if islocal(path):
-        return util.posixfile(util.urllocalpath(path), 'rb')
+    pathurl = util.url(path, parsequery=False, parsefragment=False)
+    if pathurl.islocal():
+        return util.posixfile(pathurl.localpath(), 'rb')
     else:
         return url.open(ui, path)