mercurial/dispatch.py
branchstable
changeset 35033 d3d35a55e03b
parent 35032 cd235d6f851b
child 35034 02845f7441af
--- a/mercurial/dispatch.py	Sat Nov 11 16:46:41 2017 +0900
+++ b/mercurial/dispatch.py	Sat Nov 11 17:55:15 2017 +0900
@@ -787,8 +787,8 @@
         lui = ui.copy()
         lui.readconfig(os.path.join(path, ".hg", "hgrc"), path)
 
-    if rpath and rpath[-1]:
-        path = lui.expandpath(rpath[-1])
+    if rpath:
+        path = lui.expandpath(rpath)
         lui = ui.copy()
         lui.readconfig(os.path.join(path, ".hg", "hgrc"), path)
 
@@ -829,10 +829,12 @@
 
     # check for cwd
     cwd = _earlygetopt(['--cwd'], args)
+    cwd = cwd and cwd[-1] or ''
     if cwd:
-        os.chdir(cwd[-1])
+        os.chdir(cwd)
 
     rpath = _earlygetopt(["-R", "--repository", "--repo"], args)
+    rpath = rpath and rpath[-1] or ''
     path, lui = _getlocal(ui, rpath)
 
     uis = {ui, lui}
@@ -971,7 +973,7 @@
                 except error.RequirementError:
                     raise
                 except error.RepoError:
-                    if rpath and rpath[-1]: # invalid -R path
+                    if rpath: # invalid -R path
                         raise
                     if not func.optionalrepo:
                         if func.inferrepo and args and not path: