Patchwork [6,of,6] changectx: issue a FilteredRepoLookupError when applicable

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 16, 2014, 9:30 a.m.
Message ID <1f218b91a064f01a26d2.1413451811@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6324/
State Accepted
Headers show

Comments

Pierre-Yves David - Oct. 16, 2014, 9:30 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1413430664 25200
#      Wed Oct 15 20:37:44 2014 -0700
# Node ID 1f218b91a064f01a26d2839b5dfaf4873c036a09
# Parent  56cca5ebc3c92d9affecd349fd0b01c4dca9128e
changectx: issue a FilteredRepoLookupError when applicable

We capture FilteredxxxError and issue a FilteredRepoLookupError instead with a
sightly different messsge. The message will likely get more improvement in the
future.

    error: filtered revision '4'
Sean Farley - Oct. 17, 2014, 1:40 a.m.
Pierre-Yves David writes:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1413430664 25200
> #      Wed Oct 15 20:37:44 2014 -0700
> # Node ID 1f218b91a064f01a26d2839b5dfaf4873c036a09
> # Parent  56cca5ebc3c92d9affecd349fd0b01c4dca9128e
> changectx: issue a FilteredRepoLookupError when applicable
>
> We capture FilteredxxxError and issue a FilteredRepoLookupError instead with a
> sightly different messsge. The message will likely get more improvement in the
> future.
>
>     error: filtered revision '4'

It took me a while to get a good view of patch 1 but this series looks
good to me (and is much needed!).
Augie Fackler - Oct. 17, 2014, 2:33 p.m.
On Thu, Oct 16, 2014 at 02:30:11AM -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1413430664 25200
> #      Wed Oct 15 20:37:44 2014 -0700
> # Node ID 1f218b91a064f01a26d2839b5dfaf4873c036a09
> # Parent  56cca5ebc3c92d9affecd349fd0b01c4dca9128e
> changectx: issue a FilteredRepoLookupError when applicable

Looks like good incremental improvement. Queued.

>
> We capture FilteredxxxError and issue a FilteredRepoLookupError instead with a
> sightly different messsge. The message will likely get more improvement in the
> future.
>
>     error: filtered revision '4'
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -398,10 +398,12 @@ class changectx(basectx):
>              if len(changeid) == 20:
>                  try:
>                      self._node = changeid
>                      self._rev = repo.changelog.rev(changeid)
>                      return
> +                except error.FilteredRepoLookupError:
> +                    raise
>                  except LookupError:
>                      pass
>
>              try:
>                  r = int(changeid)
> @@ -413,18 +415,22 @@ class changectx(basectx):
>                  if r < 0 or r >= l:
>                      raise ValueError
>                  self._rev = r
>                  self._node = repo.changelog.node(r)
>                  return
> +            except error.FilteredIndexError:
> +                raise
>              except (ValueError, OverflowError, IndexError):
>                  pass
>
>              if len(changeid) == 40:
>                  try:
>                      self._node = bin(changeid)
>                      self._rev = repo.changelog.rev(self._node)
>                      return
> +                except error.FilteredLookupError:
> +                    raise
>                  except (TypeError, LookupError):
>                      pass
>
>              if changeid in repo._bookmarks:
>                  self._node = repo._bookmarks[changeid]
> @@ -436,14 +442,16 @@ class changectx(basectx):
>                  return
>              try:
>                  self._node = repo.branchtip(changeid)
>                  self._rev = repo.changelog.rev(self._node)
>                  return
> +            except error.FilteredRepoLookupError:
> +                raise
>              except error.RepoLookupError:
>                  pass
>
> -            self._node = repo.changelog._partialmatch(changeid)
> +            self._node = repo.unfiltered().changelog._partialmatch(changeid)
>              if self._node is not None:
>                  self._rev = repo.changelog.rev(self._node)
>                  return
>
>              # lookup failed
> @@ -457,10 +465,14 @@ class changectx(basectx):
>              try:
>                  if len(changeid) == 20:
>                      changeid = hex(changeid)
>              except TypeError:
>                  pass
> +        except (error.FilteredIndexError, error.FilteredLookupError,
> +                error.FilteredRepoLookupError):
> +            raise error.FilteredRepoLookupError(_("filtered revision '%s'")
> +                                                % changeid)
>          except IndexError:
>              pass
>          raise error.RepoLookupError(
>              _("unknown revision '%s'") % changeid)
>
> diff --git a/tests/test-hgweb-commands.t b/tests/test-hgweb-commands.t
> --- a/tests/test-hgweb-commands.t
> +++ b/tests/test-hgweb-commands.t
> @@ -2173,11 +2173,11 @@ proper status for filtered revision
>    Status: 404 Not Found\r (esc)
>    ETag: *\r (glob) (esc)
>    Content-Type: text/plain; charset=ascii\r (esc)
>    \r (esc)
>
> -  error: unknown revision '5'
> +  error: filtered revision '5'
>
>
>
>  (filtered rev)
>
> @@ -2187,11 +2187,11 @@ proper status for filtered revision
>    Status: 404 Not Found\r (esc)
>    ETag: *\r (glob) (esc)
>    Content-Type: text/plain; charset=ascii\r (esc)
>    \r (esc)
>
> -  error: unknown revision '4'
> +  error: filtered revision '4'
>
>  filtered '0' changeset
>
>  (create new root)
>    $ hg up null
> diff --git a/tests/test-log.t b/tests/test-log.t
> --- a/tests/test-log.t
> +++ b/tests/test-log.t
> @@ -1393,11 +1393,11 @@ enable obsolete to test hidden feature
>    0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
>    $ hg log --template='{rev}:{node}\n' --hidden
>    1:a765632148dc55d38c35c4f247c618701886cb2f
>    0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
>    $ hg log -r a
> -  abort: unknown revision 'a'!
> +  abort: filtered revision 'a'!
>    [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
> @@ -182,11 +182,11 @@ 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: unknown revision '4'!
> +  abort: filtered revision '4'!
>    [255]
>
>  Check that public changeset are not accounted as obsolete:
>
>    $ hg --hidden phase --public 2
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -398,10 +398,12 @@  class changectx(basectx):
             if len(changeid) == 20:
                 try:
                     self._node = changeid
                     self._rev = repo.changelog.rev(changeid)
                     return
+                except error.FilteredRepoLookupError:
+                    raise
                 except LookupError:
                     pass
 
             try:
                 r = int(changeid)
@@ -413,18 +415,22 @@  class changectx(basectx):
                 if r < 0 or r >= l:
                     raise ValueError
                 self._rev = r
                 self._node = repo.changelog.node(r)
                 return
+            except error.FilteredIndexError:
+                raise
             except (ValueError, OverflowError, IndexError):
                 pass
 
             if len(changeid) == 40:
                 try:
                     self._node = bin(changeid)
                     self._rev = repo.changelog.rev(self._node)
                     return
+                except error.FilteredLookupError:
+                    raise
                 except (TypeError, LookupError):
                     pass
 
             if changeid in repo._bookmarks:
                 self._node = repo._bookmarks[changeid]
@@ -436,14 +442,16 @@  class changectx(basectx):
                 return
             try:
                 self._node = repo.branchtip(changeid)
                 self._rev = repo.changelog.rev(self._node)
                 return
+            except error.FilteredRepoLookupError:
+                raise
             except error.RepoLookupError:
                 pass
 
-            self._node = repo.changelog._partialmatch(changeid)
+            self._node = repo.unfiltered().changelog._partialmatch(changeid)
             if self._node is not None:
                 self._rev = repo.changelog.rev(self._node)
                 return
 
             # lookup failed
@@ -457,10 +465,14 @@  class changectx(basectx):
             try:
                 if len(changeid) == 20:
                     changeid = hex(changeid)
             except TypeError:
                 pass
+        except (error.FilteredIndexError, error.FilteredLookupError,
+                error.FilteredRepoLookupError):
+            raise error.FilteredRepoLookupError(_("filtered revision '%s'")
+                                                % changeid)
         except IndexError:
             pass
         raise error.RepoLookupError(
             _("unknown revision '%s'") % changeid)
 
diff --git a/tests/test-hgweb-commands.t b/tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t
+++ b/tests/test-hgweb-commands.t
@@ -2173,11 +2173,11 @@  proper status for filtered revision
   Status: 404 Not Found\r (esc)
   ETag: *\r (glob) (esc)
   Content-Type: text/plain; charset=ascii\r (esc)
   \r (esc)
   
-  error: unknown revision '5'
+  error: filtered revision '5'
 
 
 
 (filtered rev)
 
@@ -2187,11 +2187,11 @@  proper status for filtered revision
   Status: 404 Not Found\r (esc)
   ETag: *\r (glob) (esc)
   Content-Type: text/plain; charset=ascii\r (esc)
   \r (esc)
   
-  error: unknown revision '4'
+  error: filtered revision '4'
 
 filtered '0' changeset
 
 (create new root)
   $ hg up null
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -1393,11 +1393,11 @@  enable obsolete to test hidden feature
   0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
   $ hg log --template='{rev}:{node}\n' --hidden
   1:a765632148dc55d38c35c4f247c618701886cb2f
   0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
   $ hg log -r a
-  abort: unknown revision 'a'!
+  abort: filtered revision 'a'!
   [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
@@ -182,11 +182,11 @@  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: unknown revision '4'!
+  abort: filtered revision '4'!
   [255]
 
 Check that public changeset are not accounted as obsolete:
 
   $ hg --hidden phase --public 2