introduce new RequirementError (
issue2649)
This improves the misleading error message
$ hg identify
abort: there is no Mercurial repository here (.hg not found)!
to the more explicit
$ hg identify
abort: requirement 'fake' not supported!
for all commands in commands.optionalrepo, which includes the identify
and serve commands in particular.
This is for the case when a new entry in .hg/requires will be defined
in a future Mercurial release.
--- a/mercurial/dispatch.py Thu Feb 10 09:03:06 2011 +0100
+++ b/mercurial/dispatch.py Fri Feb 18 20:25:25 2011 +0100
@@ -576,6 +576,8 @@
if not repo.local():
raise util.Abort(_("repository '%s' is not local") % path)
ui.setconfig("bundle", "mainreporoot", repo.root)
+ except error.RequirementError:
+ raise
except error.RepoError:
if cmd not in commands.optionalrepo.split():
if args and not path: # try to infer -R from command args
--- a/mercurial/error.py Thu Feb 10 09:03:06 2011 +0100
+++ b/mercurial/error.py Fri Feb 18 20:25:25 2011 +0100
@@ -51,6 +51,10 @@
class CapabilityError(RepoError):
pass
+class RequirementError(RepoError):
+ """Exception raised if .hg/requires has an unknown entry."""
+ pass
+
class LockError(IOError):
def __init__(self, errno, strerror, filename, desc):
IOError.__init__(self, errno, strerror, filename)
--- a/mercurial/localrepo.py Thu Feb 10 09:03:06 2011 +0100
+++ b/mercurial/localrepo.py Fri Feb 18 20:25:25 2011 +0100
@@ -75,7 +75,8 @@
if inst.errno != errno.ENOENT:
raise
for r in requirements - self.supported:
- raise error.RepoError(_("requirement '%s' not supported") % r)
+ raise error.RequirementError(
+ _("requirement '%s' not supported") % r)
self.sharedpath = self.path
try:
--- a/mercurial/statichttprepo.py Thu Feb 10 09:03:06 2011 +0100
+++ b/mercurial/statichttprepo.py Fri Feb 18 20:25:25 2011 +0100
@@ -112,7 +112,8 @@
# check them
for r in requirements:
if r not in self.supported:
- raise error.RepoError(_("requirement '%s' not supported") % r)
+ raise error.RequirementError(
+ _("requirement '%s' not supported") % r)
# setup store
self.store = store.store(requirements, self.path, opener)
--- a/tests/test-commit.t Thu Feb 10 09:03:06 2011 +0100
+++ b/tests/test-commit.t Fri Feb 18 20:25:25 2011 +0100
@@ -92,6 +92,15 @@
$ hg commit -d '' -m commit-no-date
$ hg tip --template '{date|isodate}\n' | grep '1970'
[1]
+
+Make sure we do not obscure unknown requires file entries (issue2649)
+
+ $ echo foo >> foo
+ $ echo fake >> .hg/requires
+ $ hg commit -m bla
+ abort: requirement 'fake' not supported!
+ [255]
+
$ cd ..
--- a/tests/test-identify.t Thu Feb 10 09:03:06 2011 +0100
+++ b/tests/test-identify.t Fri Feb 18 20:25:25 2011 +0100
@@ -67,3 +67,16 @@
$ hg id -t http://localhost:$HGPORT1/
abort: can't query remote revision number, branch, or tags
[255]
+
+Make sure we do not obscure unknown requires file entries (issue2649)
+
+ $ echo fake >> .hg/requires
+ $ hg id
+ abort: requirement 'fake' not supported!
+ [255]
+
+ $ cd ..
+ $ hg id test
+ abort: requirement 'fake' not supported!
+ [255]
+