mercurial/dispatch.py
changeset 49420 3681a47611b8
parent 49304 48f1b314056b
child 49742 30eb36d93072
equal deleted inserted replaced
49419:2edb41ed6c49 49420:3681a47611b8
   950 def _getlocal(ui, rpath, wd=None):
   950 def _getlocal(ui, rpath, wd=None):
   951     """Return (path, local ui object) for the given target path.
   951     """Return (path, local ui object) for the given target path.
   952 
   952 
   953     Takes paths in [cwd]/.hg/hgrc into account."
   953     Takes paths in [cwd]/.hg/hgrc into account."
   954     """
   954     """
       
   955     try:
       
   956         cwd = encoding.getcwd()
       
   957     except OSError as e:
       
   958         raise error.Abort(
       
   959             _(b"error getting current working directory: %s")
       
   960             % encoding.strtolocal(e.strerror)
       
   961         )
       
   962 
       
   963     # If using an alternate wd, temporarily switch to it so that relative
       
   964     # paths are resolved correctly during config loading.
       
   965     oldcwd = None
   955     if wd is None:
   966     if wd is None:
   956         try:
   967         wd = cwd
   957             wd = encoding.getcwd()
   968     else:
   958         except OSError as e:
   969         oldcwd = cwd
   959             raise error.Abort(
   970         os.chdir(wd)
   960                 _(b"error getting current working directory: %s")
       
   961                 % encoding.strtolocal(e.strerror)
       
   962             )
       
   963 
   971 
   964     path = cmdutil.findrepo(wd) or b""
   972     path = cmdutil.findrepo(wd) or b""
   965     if not path:
   973     if not path:
   966         lui = ui
   974         lui = ui
   967     else:
   975     else:
   976         lui = ui.copy()
   984         lui = ui.copy()
   977         if rcutil.use_repo_hgrc():
   985         if rcutil.use_repo_hgrc():
   978             _readsharedsourceconfig(lui, path)
   986             _readsharedsourceconfig(lui, path)
   979             lui.readconfig(os.path.join(path, b".hg", b"hgrc"), path)
   987             lui.readconfig(os.path.join(path, b".hg", b"hgrc"), path)
   980             lui.readconfig(os.path.join(path, b".hg", b"hgrc-not-shared"), path)
   988             lui.readconfig(os.path.join(path, b".hg", b"hgrc-not-shared"), path)
       
   989 
       
   990     if oldcwd:
       
   991         os.chdir(oldcwd)
   981 
   992 
   982     return path, lui
   993     return path, lui
   983 
   994 
   984 
   995 
   985 def _checkshellalias(lui, ui, args):
   996 def _checkshellalias(lui, ui, args):