D4021: index: replace insert(-1, e) method by append(e) method

2018-08-04 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG6104b203bec8: index: replace insert(-1, e) method by 
append(e) method (authored by martinvonz, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D4021?vs=9884=9891#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4021?vs=9884=9891

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

AFFECTED FILES
  mercurial/bundlerepo.py
  mercurial/cext/parsers.c
  mercurial/cext/revlog.c
  mercurial/policy.py
  mercurial/pure/parsers.py
  mercurial/revlog.py
  mercurial/unionrepo.py

CHANGE DETAILS

diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py
--- a/mercurial/unionrepo.py
+++ b/mercurial/unionrepo.py
@@ -73,7 +73,7 @@
 # I have no idea if csize is valid in the base revlog context.
 e = (flags, None, rsize, base,
  link, self.rev(p1node), self.rev(p2node), node)
-self.index.insert(-1, e)
+self.index.append(e)
 self.nodemap[node] = n
 self.bundlerevs.add(n)
 n += 1
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2549,7 +2549,7 @@
 
 e = (offset_type(offset, flags), l, textlen,
  base, link, p1r, p2r, node)
-self.index.insert(-1, e)
+self.index.append(e)
 self.nodemap[node] = curr
 
 entry = self._io.packentry(e, self.node, self.version, curr)
diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -41,8 +41,7 @@
 def __len__(self):
 return self._lgt + len(self._extra) + 1
 
-def insert(self, i, tup):
-assert i == -1
+def append(self, tup):
 self._extra.append(tup)
 
 def _fix_index(self, i):
diff --git a/mercurial/policy.py b/mercurial/policy.py
--- a/mercurial/policy.py
+++ b/mercurial/policy.py
@@ -69,7 +69,7 @@
 (r'cext', r'bdiff'): 3,
 (r'cext', r'mpatch'): 1,
 (r'cext', r'osutil'): 4,
-(r'cext', r'parsers'): 5,
+(r'cext', r'parsers'): 6,
 }
 
 # map import request to other package or module
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -272,16 +272,11 @@
return -1;
 }
 
-static PyObject *index_insert(indexObject *self, PyObject *args)
+static PyObject *index_append(indexObject *self, PyObject *obj)
 {
-   PyObject *obj;
char *node;
-   int index;
Py_ssize_t len;
 
-   if (!PyArg_ParseTuple(args, "iO", , ))
-   return NULL;
-
if (!PyTuple_Check(obj) || PyTuple_GET_SIZE(obj) != 8) {
PyErr_SetString(PyExc_TypeError, "8-tuple required");
return NULL;
@@ -292,15 +287,6 @@
 
len = index_length(self);
 
-   if (index < 0)
-   index += len;
-
-   if (index != len - 1) {
-   PyErr_SetString(PyExc_IndexError,
-   "insert only supported at index -1");
-   return NULL;
-   }
-
if (self->added == NULL) {
self->added = PyList_New(0);
if (self->added == NULL)
@@ -311,7 +297,7 @@
return NULL;
 
if (self->nt)
-   nt_insert(self, node, index);
+   nt_insert(self, node, len - 1);
 
Py_CLEAR(self->headrevs);
Py_RETURN_NONE;
@@ -2065,8 +2051,8 @@
 "get filtered head revisions"}, /* Can always do filtering */
{"deltachain", (PyCFunction)index_deltachain, METH_VARARGS,
 "determine revisions with deltas to reconstruct fulltext"},
-   {"insert", (PyCFunction)index_insert, METH_VARARGS,
-"insert an index entry"},
+   {"append", (PyCFunction)index_append, METH_O,
+"append an index entry"},
{"partialmatch", (PyCFunction)index_partialmatch, METH_VARARGS,
 "match a potentially ambiguous node ID"},
{"shortest", (PyCFunction)index_shortest, METH_VARARGS,
diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c
--- a/mercurial/cext/parsers.c
+++ b/mercurial/cext/parsers.c
@@ -713,7 +713,7 @@
 void manifest_module_init(PyObject *mod);
 void revlog_module_init(PyObject *mod);
 
-static const int version = 5;
+static const int version = 6;
 
 static void module_init(PyObject *mod)
 {
diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -80,7 +80,7 @@
 # start, size, full unc. size, base (unused), link, p1, p2, node
 e = (revlog.offset_type(start, flags), size, -1, baserev, link,
  self.rev(p1), self.rev(p2), node)
-self.index.insert(-1, e)
+self.index.append(e)
 self.nodemap[node] = n
 self.bundlerevs.add(n)
 n += 1



To: 

Re: D4021: index: replace insert(-1, e) method by append(e) method

2018-08-04 Thread Yuya Nishihara
Bumped cext version and queued, thanks.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4021: index: replace insert(-1, e) method by append(e) method

2018-08-04 Thread yuja (Yuya Nishihara)
yuja added a comment.


  Bumped cext version and queued, thanks.

REPOSITORY
  rHG Mercurial

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

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


D4021: index: replace insert(-1, e) method by append(e) method

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4021?vs=9780=9884

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

AFFECTED FILES
  mercurial/bundlerepo.py
  mercurial/cext/revlog.c
  mercurial/pure/parsers.py
  mercurial/revlog.py
  mercurial/unionrepo.py

CHANGE DETAILS

diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py
--- a/mercurial/unionrepo.py
+++ b/mercurial/unionrepo.py
@@ -73,7 +73,7 @@
 # I have no idea if csize is valid in the base revlog context.
 e = (flags, None, rsize, base,
  link, self.rev(p1node), self.rev(p2node), node)
-self.index.insert(-1, e)
+self.index.append(e)
 self.nodemap[node] = n
 self.bundlerevs.add(n)
 n += 1
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2549,7 +2549,7 @@
 
 e = (offset_type(offset, flags), l, textlen,
  base, link, p1r, p2r, node)
-self.index.insert(-1, e)
+self.index.append(e)
 self.nodemap[node] = curr
 
 entry = self._io.packentry(e, self.node, self.version, curr)
diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -41,8 +41,7 @@
 def __len__(self):
 return self._lgt + len(self._extra) + 1
 
-def insert(self, i, tup):
-assert i == -1
+def append(self, tup):
 self._extra.append(tup)
 
 def _fix_index(self, i):
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -272,16 +272,12 @@
return -1;
 }
 
-static PyObject *index_insert(indexObject *self, PyObject *args)
+
+static PyObject *index_append(indexObject *self, PyObject *obj)
 {
-   PyObject *obj;
char *node;
-   int index;
Py_ssize_t len;
 
-   if (!PyArg_ParseTuple(args, "iO", , ))
-   return NULL;
-
if (!PyTuple_Check(obj) || PyTuple_GET_SIZE(obj) != 8) {
PyErr_SetString(PyExc_TypeError, "8-tuple required");
return NULL;
@@ -292,15 +288,6 @@
 
len = index_length(self);
 
-   if (index < 0)
-   index += len;
-
-   if (index != len - 1) {
-   PyErr_SetString(PyExc_IndexError,
-   "insert only supported at index -1");
-   return NULL;
-   }
-
if (self->added == NULL) {
self->added = PyList_New(0);
if (self->added == NULL)
@@ -311,7 +298,7 @@
return NULL;
 
if (self->nt)
-   nt_insert(self, node, index);
+   nt_insert(self, node, len - 1);
 
Py_CLEAR(self->headrevs);
Py_RETURN_NONE;
@@ -2065,8 +2052,8 @@
 "get filtered head revisions"}, /* Can always do filtering */
{"deltachain", (PyCFunction)index_deltachain, METH_VARARGS,
 "determine revisions with deltas to reconstruct fulltext"},
-   {"insert", (PyCFunction)index_insert, METH_VARARGS,
-"insert an index entry"},
+   {"append", (PyCFunction)index_append, METH_O,
+"append an index entry"},
{"partialmatch", (PyCFunction)index_partialmatch, METH_VARARGS,
 "match a potentially ambiguous node ID"},
{"shortest", (PyCFunction)index_shortest, METH_VARARGS,
diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -80,7 +80,7 @@
 # start, size, full unc. size, base (unused), link, p1, p2, node
 e = (revlog.offset_type(start, flags), size, -1, baserev, link,
  self.rev(p1), self.rev(p2), node)
-self.index.insert(-1, e)
+self.index.append(e)
 self.nodemap[node] = n
 self.bundlerevs.add(n)
 n += 1



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


D4021: index: replace insert(-1, e) method by append(e) method

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4021?vs=9721=9780

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

AFFECTED FILES
  mercurial/bundlerepo.py
  mercurial/cext/revlog.c
  mercurial/pure/parsers.py
  mercurial/revlog.py
  mercurial/unionrepo.py

CHANGE DETAILS

diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py
--- a/mercurial/unionrepo.py
+++ b/mercurial/unionrepo.py
@@ -73,7 +73,7 @@
 # I have no idea if csize is valid in the base revlog context.
 e = (flags, None, rsize, base,
  link, self.rev(p1node), self.rev(p2node), node)
-self.index.insert(-1, e)
+self.index.append(e)
 self.nodemap[node] = n
 self.bundlerevs.add(n)
 n += 1
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2548,7 +2548,7 @@
 
 e = (offset_type(offset, flags), l, textlen,
  base, link, p1r, p2r, node)
-self.index.insert(-1, e)
+self.index.append(e)
 self.nodemap[node] = curr
 
 entry = self._io.packentry(e, self.node, self.version, curr)
diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -41,8 +41,7 @@
 def __len__(self):
 return self._lgt + len(self._extra) + 1
 
-def insert(self, i, tup):
-assert i == -1
+def append(self, tup):
 self._extra.append(tup)
 
 def _fix_index(self, i):
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -271,16 +271,12 @@
return -1;
 }
 
-static PyObject *index_insert(indexObject *self, PyObject *args)
+
+static PyObject *index_append(indexObject *self, PyObject *obj)
 {
-   PyObject *obj;
char *node;
-   int index;
Py_ssize_t len, nodelen;
 
-   if (!PyArg_ParseTuple(args, "iO", , ))
-   return NULL;
-
if (!PyTuple_Check(obj) || PyTuple_GET_SIZE(obj) != 8) {
PyErr_SetString(PyExc_TypeError, "8-tuple required");
return NULL;
@@ -291,15 +287,6 @@
 
len = index_length(self);
 
-   if (index < 0)
-   index += len;
-
-   if (index != len - 1) {
-   PyErr_SetString(PyExc_IndexError,
-   "insert only supported at index -1");
-   return NULL;
-   }
-
if (self->added == NULL) {
self->added = PyList_New(0);
if (self->added == NULL)
@@ -310,7 +297,7 @@
return NULL;
 
if (self->nt)
-   nt_insert(self, node, index);
+   nt_insert(self, node, len - 1);
 
Py_CLEAR(self->headrevs);
Py_RETURN_NONE;
@@ -2063,8 +2050,8 @@
 "get filtered head revisions"}, /* Can always do filtering */
{"deltachain", (PyCFunction)index_deltachain, METH_VARARGS,
 "determine revisions with deltas to reconstruct fulltext"},
-   {"insert", (PyCFunction)index_insert, METH_VARARGS,
-"insert an index entry"},
+   {"append", (PyCFunction)index_append, METH_O,
+"append an index entry"},
{"partialmatch", (PyCFunction)index_partialmatch, METH_VARARGS,
 "match a potentially ambiguous node ID"},
{"shortest", (PyCFunction)index_shortest, METH_VARARGS,
diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -80,7 +80,7 @@
 # start, size, full unc. size, base (unused), link, p1, p2, node
 e = (revlog.offset_type(start, flags), size, -1, baserev, link,
  self.rev(p1), self.rev(p2), node)
-self.index.insert(-1, e)
+self.index.append(e)
 self.nodemap[node] = n
 self.bundlerevs.add(n)
 n += 1



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


D4021: index: replace insert(-1, e) method by append(e) method

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
  I want to make index[len(index) - 1] be the tip revision, not null
  revision as it is today. insert(-1, e) will then make little
  sense. Since insert() currently requires the first argument to be -1,
  it seems simpler to replace it by a method that allows insertion only
  at the end.
  
  Note that revlogoldindex already has this method (by virtue of
  extending list).

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/bundlerepo.py
  mercurial/cext/revlog.c
  mercurial/pure/parsers.py
  mercurial/revlog.py
  mercurial/unionrepo.py

CHANGE DETAILS

diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py
--- a/mercurial/unionrepo.py
+++ b/mercurial/unionrepo.py
@@ -73,7 +73,7 @@
 # I have no idea if csize is valid in the base revlog context.
 e = (flags, None, rsize, base,
  link, self.rev(p1node), self.rev(p2node), node)
-self.index.insert(-1, e)
+self.index.append(e)
 self.nodemap[node] = n
 self.bundlerevs.add(n)
 n += 1
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2548,7 +2548,7 @@
 
 e = (offset_type(offset, flags), l, textlen,
  base, link, p1r, p2r, node)
-self.index.insert(-1, e)
+self.index.append(e)
 self.nodemap[node] = curr
 
 entry = self._io.packentry(e, self.node, self.version, curr)
diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -41,8 +41,7 @@
 def __len__(self):
 return self._lgt + len(self._extra) + 1
 
-def insert(self, i, tup):
-assert i == -1
+def append(self, tup):
 self._extra.append(tup)
 
 def _fix_index(self, i):
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -271,16 +271,12 @@
return -1;
 }
 
-static PyObject *index_insert(indexObject *self, PyObject *args)
+
+static PyObject *index_append(indexObject *self, PyObject *obj)
 {
-   PyObject *obj;
char *node;
-   int index;
Py_ssize_t len, nodelen;
 
-   if (!PyArg_ParseTuple(args, "iO", , ))
-   return NULL;
-
if (!PyTuple_Check(obj) || PyTuple_GET_SIZE(obj) != 8) {
PyErr_SetString(PyExc_TypeError, "8-tuple required");
return NULL;
@@ -291,15 +287,6 @@
 
len = index_length(self);
 
-   if (index < 0)
-   index += len;
-
-   if (index != len - 1) {
-   PyErr_SetString(PyExc_IndexError,
-   "insert only supported at index -1");
-   return NULL;
-   }
-
if (self->added == NULL) {
self->added = PyList_New(0);
if (self->added == NULL)
@@ -310,7 +297,7 @@
return NULL;
 
if (self->nt)
-   nt_insert(self, node, index);
+   nt_insert(self, node, len - 1);
 
Py_CLEAR(self->headrevs);
Py_RETURN_NONE;
@@ -2063,8 +2050,8 @@
 "get filtered head revisions"}, /* Can always do filtering */
{"deltachain", (PyCFunction)index_deltachain, METH_VARARGS,
 "determine revisions with deltas to reconstruct fulltext"},
-   {"insert", (PyCFunction)index_insert, METH_VARARGS,
-"insert an index entry"},
+   {"append", (PyCFunction)index_append, METH_O,
+"append an index entry"},
{"partialmatch", (PyCFunction)index_partialmatch, METH_VARARGS,
 "match a potentially ambiguous node ID"},
{"shortest", (PyCFunction)index_shortest, METH_VARARGS,
diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -80,7 +80,7 @@
 # start, size, full unc. size, base (unused), link, p1, p2, node
 e = (revlog.offset_type(start, flags), size, -1, baserev, link,
  self.rev(p1), self.rev(p2), node)
-self.index.insert(-1, e)
+self.index.append(e)
 self.nodemap[node] = n
 self.bundlerevs.add(n)
 n += 1



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