Re: [PATCH 2 of 4 V2] sparse-revlog: handle nullrev in index_get_start

2018-12-15 Thread Yuya Nishihara
On Sat, 15 Dec 2018 15:10:54 +, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1544804621 -3600
> #  Fri Dec 14 17:23:41 2018 +0100
> # Node ID 216e6d5c773cd51c18e351b11a8105165d2ad2d7
> # Parent  c1e47daaab82e7d9340b0bd179d022fdd21062fc
> # EXP-Topic sparse-followup
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> 216e6d5c773c
> sparse-revlog: handle nullrev in index_get_start
> 
> The more generic index_get method handle nullrev fine, we apply the same logic
> here.
> 
> diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
> --- a/mercurial/cext/revlog.c
> +++ b/mercurial/cext/revlog.c
> @@ -190,6 +190,9 @@ static inline int index_get_parents(inde
>  
>  static inline int64_t index_get_start(indexObject *self, Py_ssize_t rev)
>  {
> + if (rev == nullrev) {
> + return 0;
> + }
>   uint64_t offset;

Moved the declaration to top.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 4 V2] sparse-revlog: handle nullrev in index_get_start

2018-12-15 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1544804621 -3600
#  Fri Dec 14 17:23:41 2018 +0100
# Node ID 216e6d5c773cd51c18e351b11a8105165d2ad2d7
# Parent  c1e47daaab82e7d9340b0bd179d022fdd21062fc
# EXP-Topic sparse-followup
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
216e6d5c773c
sparse-revlog: handle nullrev in index_get_start

The more generic index_get method handle nullrev fine, we apply the same logic
here.

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -190,6 +190,9 @@ static inline int index_get_parents(inde
 
 static inline int64_t index_get_start(indexObject *self, Py_ssize_t rev)
 {
+   if (rev == nullrev) {
+   return 0;
+   }
uint64_t offset;
if (rev >= self->length) {
PyObject *tuple;
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel