Mercurial > public > mercurial-scm > hg
comparison mercurial/pathutil.py @ 25011:7d6a507a4c53
pathutil: hint if a path is root relative instead of cwd relative (issue4663)
Given that this path is going to abort, it seems OK to spend the time to do an
alternate lookup to better inform the user. The path returned by util.pathto()
ends with '/' at least in some cases, so os.path.relpath() is used instead,
which requires python 2.6.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 11 May 2015 21:26:13 -0400 |
parents | a4679a74df14 |
children | 10bbdcd89164 |
comparison
equal
deleted
inserted
replaced
25010:ded7302e1c83 | 25011:7d6a507a4c53 |
---|---|
150 rel.append(basename) | 150 rel.append(basename) |
151 if dirname == name: | 151 if dirname == name: |
152 break | 152 break |
153 name = dirname | 153 name = dirname |
154 | 154 |
155 raise util.Abort(_("%s not under root '%s'") % (myname, root)) | 155 # A common mistake is to use -R, but specify a file relative to the repo |
156 # instead of cwd. Detect that case, and provide a hint to the user. | |
157 hint = None | |
158 try: | |
159 canonpath(root, root, myname, auditor) | |
160 hint = _("consider using '--cwd %s'") % os.path.relpath(root, cwd) | |
161 except util.Abort: | |
162 pass | |
163 | |
164 raise util.Abort(_("%s not under root '%s'") % (myname, root), | |
165 hint=hint) | |
156 | 166 |
157 def normasprefix(path): | 167 def normasprefix(path): |
158 '''normalize the specified path as path prefix | 168 '''normalize the specified path as path prefix |
159 | 169 |
160 Returned value can be used safely for "p.startswith(prefix)", | 170 Returned value can be used safely for "p.startswith(prefix)", |