diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -576,6 +576,8 @@ def _dispatch(ui, args): 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 diff --git a/mercurial/error.py b/mercurial/error.py --- a/mercurial/error.py +++ b/mercurial/error.py @@ -51,6 +51,10 @@ class RepoLookupError(RepoError): 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) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -75,7 +75,8 @@ class localrepository(repo.repository): 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: diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py --- a/mercurial/statichttprepo.py +++ b/mercurial/statichttprepo.py @@ -112,7 +112,8 @@ class statichttprepository(localrepo.loc # 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) diff --git a/tests/test-commit.t b/tests/test-commit.t --- a/tests/test-commit.t +++ b/tests/test-commit.t @@ -92,6 +92,15 @@ An empty date was interpreted as epoch o $ 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 .. diff --git a/tests/test-identify.t b/tests/test-identify.t --- a/tests/test-identify.t +++ b/tests/test-identify.t @@ -67,3 +67,16 @@ remote with tags? $ 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] +