[PATCH 1 of 3 RFC] changelog: handle obsolete and secret changesets more gracefully

Augie Fackler raf at durin42.com
Fri Aug 9 10:10:32 CDT 2013


On Thu, Aug 08, 2013 at 09:48:44AM +0200, Dan Villiom Podlaski Christiansen wrote:
> # HG changeset patch
> # User Dan Villiom Podlaski Christiansen  <danchr at gmail.com>
> # Date 1375817670 -7200
> #      Tue Aug 06 21:34:30 2013 +0200
> # Node ID 02c24ad6f4d2d954da11d128280978e25aaa48fd
> # Parent  df2155ebf502d14f7ef5276df806a35fc06dabd5
> changelog: handle obsolete and secret changesets more gracefully
>
> We now issue a 'changeset is hidden' message when the user attempts to
> access a hidden (i.e. secret or obsolete) changeset.
>
> Please notice that this introduces a slight information leak, as
> knowledge of a 'secret' hash may now be used to test whether it's
> present in a given repository.

I mean, on the one hand yes, but on the other, the user has that
change somehow, so it's only leaking information to themselves? They
could always run log --hidden and see these changes, right?

>
> diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
> --- a/mercurial/branchmap.py
> +++ b/mercurial/branchmap.py
> @@ -7,7 +7,7 @@

[...]

>
>      def delayupdate(self):
> diff --git a/mercurial/error.py b/mercurial/error.py
> --- a/mercurial/error.py
> +++ b/mercurial/error.py
> @@ -59,6 +59,14 @@ class RepoError(Exception):
>  class RepoLookupError(RepoError):
>      pass
>
> +class FilteredLookupError(RepoLookupError):
> +    """Exception raised on accessing filtered (i.e. hidden) changesets."""
> +
> +    def __init__(self, rev, message):
> +        self.rev = rev
> +
> +        RepoLookupError.__init__(self, message)

While it almost certainly doesn't matter in this case, please call the
superclass init before doing your own init work. Also, consider using
the super(type, self) construct here?

> +
>  class CapabilityError(RepoError):
>      pass
>
> diff --git a/mercurial/revlog.py b/mercurial/revlog.py
> --- a/mercurial/revlog.py
> +++ b/mercurial/revlog.py
> @@ -279,7 +279,7 @@ class revlog(object):
>          self.rev(self.node(0))
>          return self._nodecache
>
> -    def hasnode(self, node):
> +    def hasnode(self, node, hidden=False):
>          try:
>              self.rev(node)
>              return True
> @@ -752,7 +752,7 @@ class revlog(object):
>      def _partialmatch(self, id):
>          try:
>              n = self.index.partialmatch(id)
> -            if n and self.hasnode(n):
> +            if n and self.hasnode(n, hidden=True):
>                  return n
>              return None
>          except RevlogError:
> 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
> @@ -1390,7 +1390,7 @@ proper status for filtered revision
>    Content-Type: text/plain; charset=ascii\r (esc)
>    \r (esc)
>
> -  error: unknown revision '5'
> +  error: revision 5 is hidden
>
>
>
> @@ -1404,7 +1404,7 @@ proper status for filtered revision
>    Content-Type: text/plain; charset=ascii\r (esc)
>    \r (esc)
>
> -  error: unknown revision '4'
> +  error: revision 4 is hidden
>
>  filtered '0' changeset
>
> diff --git a/tests/test-log.t b/tests/test-log.t
> --- a/tests/test-log.t
> +++ b/tests/test-log.t
> @@ -1226,6 +1226,15 @@ enable obsolete to test hidden feature
>    $ hg log -r a
>    abort: unknown revision 'a'!
>    [255]
> +  $ hg log -r a7
> +  abort: unknown revision 'a7'!
> +  [255]
> +  $ hg log -r a76
> +  abort: unknown revision 'a76'!
> +  [255]
> +  $ hg log -r a765
> +  abort: changeset a765632148dc is hidden!
> +  [255]
>
>  test that parent prevent a changeset to be hidden
>
> diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
> --- a/tests/test-obsolete.t
> +++ b/tests/test-obsolete.t
> @@ -211,7 +211,7 @@ check that various commands work well wi
>    abort: unknown revision '6'!
>    [255]
>    $ hg log -r 4
> -  abort: unknown revision '4'!
> +  abort: revision 4 is hidden!
>    [255]
>
>  Check that public changeset are not accounted as obsolete:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list