mercurial/dispatch.py
changeset 28263 59509c6724c7
parent 28081 a6344df5108e
child 28313 aa73d6a5d9ea
--- a/mercurial/dispatch.py	Fri Feb 26 14:50:04 2016 +0000
+++ b/mercurial/dispatch.py	Fri Feb 26 15:07:58 2016 +0000
@@ -685,16 +685,17 @@
               result=ret, pats=cmdpats, opts=cmdoptions)
     return ret
 
-def _getlocal(ui, rpath):
+def _getlocal(ui, rpath, wd=None):
     """Return (path, local ui object) for the given target path.
 
     Takes paths in [cwd]/.hg/hgrc into account."
     """
-    try:
-        wd = os.getcwd()
-    except OSError as e:
-        raise error.Abort(_("error getting current working directory: %s") %
-                         e.strerror)
+    if wd is None:
+        try:
+            wd = os.getcwd()
+        except OSError as e:
+            raise error.Abort(_("error getting current working directory: %s") %
+                              e.strerror)
     path = cmdutil.findrepo(wd) or ""
     if not path:
         lui = ui