D4023: index: don't allow index[len(index)] to mean nullid

2018-08-04 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGa3dacabd476b: index: dont allow index[len(index)] to 
mean nullid (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4023?vs=9886=9893

REVISION DETAIL
  https://phab.mercurial-scm.org/D4023

AFFECTED FILES
  mercurial/cext/revlog.c
  mercurial/revlog.py
  tests/test-parseindex2.py

CHANGE DETAILS

diff --git a/tests/test-parseindex2.py b/tests/test-parseindex2.py
--- a/tests/test-parseindex2.py
+++ b/tests/test-parseindex2.py
@@ -61,9 +61,6 @@
 e[0] = offset_type(0, type)
 index[0] = tuple(e)
 
-# add the magic null revision at -1
-index.append((0, 0, 0, -1, -1, -1, -1, nullid))
-
 return index, cache
 
 data_inlined = (
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -792,7 +792,7 @@
 
 class revlogoldindex(list):
 def __getitem__(self, i):
-if i == -1 or i == len(self):
+if i == -1:
 return (0, 0, 0, -1, -1, -1, -1, nullid)
 return list.__getitem__(self, i)
 
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -158,12 +158,12 @@
Py_ssize_t length = index_length(self) + 1;
PyObject *entry;
 
-   if (pos == -1 || pos == length - 1) {
+   if (pos == -1) {
Py_INCREF(nullentry);
return nullentry;
}
 
-   if (pos < 0 || pos >= length) {
+   if (pos < 0 || pos >= length - 1) {
PyErr_SetString(PyExc_IndexError, "revlog index out of range");
return NULL;
}



To: martinvonz, indygreg, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4023: index: don't allow index[len(index)] to mean nullid

2018-08-03 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 9886.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4023?vs=9782=9886

REVISION DETAIL
  https://phab.mercurial-scm.org/D4023

AFFECTED FILES
  mercurial/cext/revlog.c
  mercurial/revlog.py
  tests/test-parseindex2.py

CHANGE DETAILS

diff --git a/tests/test-parseindex2.py b/tests/test-parseindex2.py
--- a/tests/test-parseindex2.py
+++ b/tests/test-parseindex2.py
@@ -61,9 +61,6 @@
 e[0] = offset_type(0, type)
 index[0] = tuple(e)
 
-# add the magic null revision at -1
-index.append((0, 0, 0, -1, -1, -1, -1, nullid))
-
 return index, cache
 
 data_inlined = (
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -792,7 +792,7 @@
 
 class revlogoldindex(list):
 def __getitem__(self, i):
-if i == -1 or i == len(self):
+if i == -1:
 return (0, 0, 0, -1, -1, -1, -1, nullid)
 return list.__getitem__(self, i)
 
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -158,12 +158,12 @@
Py_ssize_t length = index_length(self) + 1;
PyObject *entry;
 
-   if (pos == -1 || pos == length - 1) {
+   if (pos == -1) {
Py_INCREF(nullentry);
return nullentry;
}
 
-   if (pos < 0 || pos >= length) {
+   if (pos < 0 || pos >= length - 1) {
PyErr_SetString(PyExc_IndexError, "revlog index out of range");
return NULL;
}



To: martinvonz, indygreg, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4023: index: don't allow index[len(index)] to mean nullid

2018-08-01 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 9782.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4023?vs=9723=9782

REVISION DETAIL
  https://phab.mercurial-scm.org/D4023

AFFECTED FILES
  mercurial/cext/revlog.c
  mercurial/revlog.py
  tests/test-parseindex2.py

CHANGE DETAILS

diff --git a/tests/test-parseindex2.py b/tests/test-parseindex2.py
--- a/tests/test-parseindex2.py
+++ b/tests/test-parseindex2.py
@@ -61,9 +61,6 @@
 e[0] = offset_type(0, type)
 index[0] = tuple(e)
 
-# add the magic null revision at -1
-index.append((0, 0, 0, -1, -1, -1, -1, nullid))
-
 return index, cache
 
 data_inlined = (
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -791,7 +791,7 @@
 
 class revlogoldindex(list):
 def __getitem__(self, i):
-if i == -1 or i == len(self):
+if i == -1:
 return (0, 0, 0, -1, -1, -1, -1, nullid)
 return list.__getitem__(self, i)
 
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -158,12 +158,12 @@
Py_ssize_t length = index_length(self) + 1;
PyObject *entry;
 
-   if (pos == -1 || pos == length - 1) {
+   if (pos == -1) {
Py_INCREF(nullentry);
return nullentry;
}
 
-   if (pos < 0 || pos >= length) {
+   if (pos < 0 || pos >= length - 1) {
PyErr_SetString(PyExc_IndexError, "revlog index out of range");
return NULL;
}



To: martinvonz, indygreg, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4023: index: don't allow index[len(index)] to mean nullid

2018-08-01 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Now everything else has been cleaned up and we can drop support for
  getting the nullid from the end of the index (from *past* the end
  actually, since we reduced the length in the previous patch).

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D4023

AFFECTED FILES
  mercurial/cext/revlog.c
  mercurial/revlog.py
  tests/test-parseindex2.py

CHANGE DETAILS

diff --git a/tests/test-parseindex2.py b/tests/test-parseindex2.py
--- a/tests/test-parseindex2.py
+++ b/tests/test-parseindex2.py
@@ -61,9 +61,6 @@
 e[0] = offset_type(0, type)
 index[0] = tuple(e)
 
-# add the magic null revision at -1
-index.append((0, 0, 0, -1, -1, -1, -1, nullid))
-
 return index, cache
 
 data_inlined = (
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -791,7 +791,7 @@
 
 class revlogoldindex(list):
 def __getitem__(self, i):
-if i == -1 or i == len(self):
+if i == -1:
 return (0, 0, 0, -1, -1, -1, -1, nullid)
 return list.__getitem__(self, i)
 
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -158,12 +158,12 @@
Py_ssize_t length = index_length(self) + 1;
PyObject *entry;
 
-   if (pos == -1 || pos == length - 1) {
+   if (pos == -1) {
Py_INCREF(nullentry);
return nullentry;
}
 
-   if (pos < 0 || pos >= length) {
+   if (pos < 0 || pos >= length - 1) {
PyErr_SetString(PyExc_IndexError, "revlog index out of range");
return NULL;
}



To: martinvonz, indygreg, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel