[PATCH 1 of 3 stable] util.url: add an 'islocal' method

Siddharth Agarwal sid0 at fb.com
Mon Feb 3 17:12:11 CST 2014


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1391467661 28800
#      Mon Feb 03 14:47:41 2014 -0800
# Branch stable
# Node ID 8ab8a85a22c2f5a0e23e86f2041ef7d348fab857
# Parent  9139dedeffa6d54367fcf410d583d401e8fd1318
util.url: add an 'islocal' method

This returns True if the URL represents a path that can be opened locally,
without needing to go through the entire URL open mechanism.

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1875,6 +1875,11 @@
             return path
         return self._origpath
 
+    def islocal(self):
+        '''whether localpath will return something that posixfile can open'''
+        return (not self.scheme or self.scheme == 'file'
+                or self.scheme == 'bundle')
+
 def hasscheme(path):
     return bool(url(path).scheme)
 


More information about the Mercurial-devel mailing list