mercurial/pathutil.py
changeset 25011 7d6a507a4c53
parent 23602 a4679a74df14
child 25022 10bbdcd89164
--- a/mercurial/pathutil.py	Mon May 11 22:47:01 2015 -0400
+++ b/mercurial/pathutil.py	Mon May 11 21:26:13 2015 -0400
@@ -152,7 +152,17 @@
                 break
             name = dirname
 
-        raise util.Abort(_("%s not under root '%s'") % (myname, root))
+        # A common mistake is to use -R, but specify a file relative to the repo
+        # instead of cwd.  Detect that case, and provide a hint to the user.
+        hint = None
+        try:
+            canonpath(root, root, myname, auditor)
+            hint = _("consider using '--cwd %s'") % os.path.relpath(root, cwd)
+        except util.Abort:
+            pass
+
+        raise util.Abort(_("%s not under root '%s'") % (myname, root),
+                         hint=hint)
 
 def normasprefix(path):
     '''normalize the specified path as path prefix