diff -r 53dc4aada2d9 -r 59509c6724c7 mercurial/dispatch.py --- 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