[PATCH 1 of 2] commands: show also the hint other than ".hg not found" for "no Mercurial repository" failure

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Wed Aug 29 03:17:43 CDT 2012


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1346226786 -32400
# Node ID da5222276e629c7280d94972d55a8140e83117f4
# Parent  fc14953e8e34667181cd0d492825342b5e1e880b
commands: show also the hint other than ".hg not found" for "no Mercurial repository" failure

Before this patch, Mercurial shows the error message below, even if
there is ".hg" directory and the real reason of failure is mismatching
between features supported by "hg" command and ones required in target
repository:

    there is no Mercurial repository here (.hg not found)

The message explaining detail of failure like as below is shown at
some command invocations:

    unknown repository format: requires features 'xxxx' (upgrade
    Mercurial)

But this message is hidden at invocations of commands categorized as
"norepo" or "optionalrepo".

For example, "hg serve" is categorized as "optionalrepo", and invoked
on remote side for push, pull and so on. So, user can't see this
message on client side in such cases.

This patch changes this message to one below to show also the hint
other than ".hg not found":

    there is no available Mercurial repository here
    (.hg not found, or hg command can't support features required in it)

"hg init --mq" code path also shows same message, but it checks only
the existence of ".hg" directory, not features required in the
repository. So, this patch doesn't change the message shown in that
code path.

diff -r fc14953e8e34 -r da5222276e62 mercurial/commands.py
--- a/mercurial/commands.py	Tue Aug 28 17:59:08 2012 -0500
+++ b/mercurial/commands.py	Wed Aug 29 16:53:06 2012 +0900
@@ -1413,8 +1413,10 @@
         lookup = r.lookup
     elif len(args) == 2:
         if not repo:
-            raise util.Abort(_("there is no Mercurial repository here "
-                               "(.hg not found)"))
+            msg = _("there is no available Mercurial repository here")
+            hint = _(".hg not found, or hg command can't support"
+                     " features required in it")
+            raise util.Abort(msg, hint=hint)
         rev1, rev2 = args
         r = repo.changelog
         lookup = repo.lookup
@@ -3487,8 +3489,10 @@
     """
 
     if not repo and not source:
-        raise util.Abort(_("there is no Mercurial repository here "
-                           "(.hg not found)"))
+        msg = _("there is no available Mercurial repository here")
+        hint = _(".hg not found, or hg command can't support"
+                 " features required in it")
+        raise util.Abort(msg, hint=hint)
 
     hexfunc = ui.debugflag and hex or short
     default = not (num or id or branch or tags or bookmarks)
@@ -5152,8 +5156,10 @@
 
     def checkrepo():
         if repo is None:
-            raise error.RepoError(_("there is no Mercurial repository here"
-                              " (.hg not found)"))
+            msg = _("there is no available Mercurial repository here")
+            hint = _(".hg not found, or hg command can't support"
+                     " features required in it")
+            raise error.RepoError(msg, hint=hint)
 
     if opts["stdio"]:
         checkrepo()
@@ -5183,8 +5189,10 @@
     o = opts.get('web_conf') or opts.get('webdir_conf')
     if not o:
         if not repo:
-            raise error.RepoError(_("there is no Mercurial repository"
-                                    " here (.hg not found)"))
+            msg = _("there is no available Mercurial repository here")
+            hint = _(".hg not found, or hg command can't support"
+                     " features required in it")
+            raise error.RepoError(msg, hint=hint)
         o = repo.root
 
     app = hgweb.hgweb(o, baseui=ui)
diff -r fc14953e8e34 -r da5222276e62 tests/test-identify.t
--- a/tests/test-identify.t	Tue Aug 28 17:59:08 2012 -0500
+++ b/tests/test-identify.t	Wed Aug 29 16:53:06 2012 +0900
@@ -5,7 +5,8 @@
 no repo
 
   $ hg id
-  abort: there is no Mercurial repository here (.hg not found)
+  abort: there is no available Mercurial repository here
+  (.hg not found, or hg command can't support features required in it)
   [255]
 
 #endif
diff -r fc14953e8e34 -r da5222276e62 tests/test-ssh.t
--- a/tests/test-ssh.t	Tue Aug 28 17:59:08 2012 -0500
+++ b/tests/test-ssh.t	Wed Aug 29 16:53:06 2012 +0900
@@ -21,14 +21,16 @@
 repo not found error
 
   $ hg clone -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy/nonexistent local
-  remote: abort: there is no Mercurial repository here (.hg not found)!
+  remote: abort: there is no available Mercurial repository here!
+  remote: (.hg not found, or hg command can't support features required in it)
   abort: no suitable response from remote hg!
   [255]
 
 non-existent absolute path
 
   $ hg clone -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy//`pwd`/nonexistent local
-  remote: abort: there is no Mercurial repository here (.hg not found)!
+  remote: abort: there is no available Mercurial repository here!
+  remote: (.hg not found, or hg command can't support features required in it)
   abort: no suitable response from remote hg!
   [255]
 


More information about the Mercurial-devel mailing list