[PATCH 2 of 2] repoview: issue a special message when filtering hidden changeset

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Oct 17 18:07:49 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1413584732 25200
#      Fri Oct 17 15:25:32 2014 -0700
# Node ID e7bb8c8e4ec37c1401de08463b01ccc292eed898
# Parent  eee5d61eb2fcc6dc71105ebc641be69ddbc67173
repoview: issue a special message when filtering hidden changeset

Hidden changesets are by far the most common error case and is the only one[1]
that can reach the user. We move to a friendlier message with an hint about how
to access the data anyway. We should probably point to a help topic instead but
we do not have such topic yet.

exemple of the new output

  abort: hidden revision '4'!
  (use --hidden to access hidden revisions)


[1] Actually, filtering from "served" can also reach the user during certain
exchange operations.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -467,10 +467,14 @@ class changectx(basectx):
                     changeid = hex(changeid)
             except TypeError:
                 pass
         except (error.FilteredIndexError, error.FilteredLookupError,
                 error.FilteredRepoLookupError):
+            if repo.filtername == 'visible':
+                msg = _("hidden revision '%s'") % changeid
+                hint = _('use --hidden to access hidden revisions')
+                raise error.FilteredRepoLookupError(msg, hint=hint)
             msg = _("filtered revision '%s' (not in '%s' subset)")
             msg %= (changeid, repo.filtername)
             raise error.FilteredRepoLookupError(msg)
         except IndexError:
             pass
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -1391,11 +1391,12 @@ enable obsolete to test hidden feature
   0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
   $ hg log --template='{rev}:{node}\n' --hidden
   1:a765632148dc55d38c35c4f247c618701886cb2f
   0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
   $ hg log -r a
-  abort: filtered revision 'a' (not in 'visible' subset)!
+  abort: hidden revision 'a'!
+  (use --hidden to access hidden revisions)
   [255]
 
 test that parent prevent a changeset to be hidden
 
   $ hg up 1 -q --hidden
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -180,11 +180,12 @@ check that various commands work well wi
   5:5601fb93a350 (draft) [tip ] add new_3_c
   $ hg log -r 6
   abort: unknown revision '6'!
   [255]
   $ hg log -r 4
-  abort: filtered revision '4' (not in 'visible' subset)!
+  abort: hidden revision '4'!
+  (use --hidden to access hidden revisions)
   [255]
 
 Check that public changeset are not accounted as obsolete:
 
   $ hg --hidden phase --public 2


More information about the Mercurial-devel mailing list