comparison mercurial/dispatch.py @ 28263:59509c6724c7

dispatch: add wd parameter to _getlocal Before this patch, _getlocal uses os.getcwd() to locate repo in current dir. chgserver needs it to load repo config and has to do chdir twice: the first is to set current directory and the second is to redo the side effect (in case hg --cwd some/relative/path, chdir will be called again in dispatch later), which is not pretty. This patch adds an optional wd parameter to make it possible to specify wd without chdir (and its side effect).
author Jun Wu <quark@fb.com>
date Fri, 26 Feb 2016 15:07:58 +0000
parents a6344df5108e
children aa73d6a5d9ea
comparison
equal deleted inserted replaced
28262:53dc4aada2d9 28263:59509c6724c7
683 # run post-hook, passing command result 683 # run post-hook, passing command result
684 hook.hook(lui, repo, "post-%s" % cmd, False, args=" ".join(fullargs), 684 hook.hook(lui, repo, "post-%s" % cmd, False, args=" ".join(fullargs),
685 result=ret, pats=cmdpats, opts=cmdoptions) 685 result=ret, pats=cmdpats, opts=cmdoptions)
686 return ret 686 return ret
687 687
688 def _getlocal(ui, rpath): 688 def _getlocal(ui, rpath, wd=None):
689 """Return (path, local ui object) for the given target path. 689 """Return (path, local ui object) for the given target path.
690 690
691 Takes paths in [cwd]/.hg/hgrc into account." 691 Takes paths in [cwd]/.hg/hgrc into account."
692 """ 692 """
693 try: 693 if wd is None:
694 wd = os.getcwd() 694 try:
695 except OSError as e: 695 wd = os.getcwd()
696 raise error.Abort(_("error getting current working directory: %s") % 696 except OSError as e:
697 e.strerror) 697 raise error.Abort(_("error getting current working directory: %s") %
698 e.strerror)
698 path = cmdutil.findrepo(wd) or "" 699 path = cmdutil.findrepo(wd) or ""
699 if not path: 700 if not path:
700 lui = ui 701 lui = ui
701 else: 702 else:
702 lui = ui.copy() 703 lui = ui.copy()