Martin von Zweigbergk <martinvonz@google.com> [Fri, 20 Jul 2018 09:53:54 -0700] rev 38847
index: handle index[-1] as nullid more explicitly
I find it more intuitive to check if "pos == -1" than to first add the
index length (which includes one extra item for the nullid) and
compare that to "length - 1". However, because test-parseindex2.py
compares the whole index (up to len(index)-1), we need to also
preserve that other check for a little while more. I'll remove it
soon.
Differential Revision: https://phab.mercurial-scm.org/D4018
Martin von Zweigbergk <martinvonz@google.com> [Fri, 20 Jul 2018 22:26:28 -0700] rev 38846
index: store nullrev as -1 in nodetree
Nothing important, it just seems more natural to not map nullrev to
INT_MAX. We just need to change the revision encoding a little to make
space for the -1.
Differential Revision: https://phab.mercurial-scm.org/D4005
Martin von Zweigbergk <martinvonz@google.com> [Fri, 20 Jul 2018 23:24:14 -0700] rev 38845
index: create function for deleting node from nodetree
A node is marked deleted by nt_insert(self, node, -1), but "-1" could
mean so many things (notably nullrev), so let's hide it in a
function. The function could possibly also remove nodes from the tree
in the future (it currently only marks them deleted).
Differential Revision: https://phab.mercurial-scm.org/D4004
Martin von Zweigbergk <martinvonz@google.com> [Fri, 20 Jul 2018 09:58:09 -0700] rev 38844
revlog: remove some knowledge of sentinel nullid in index
I think the "-2" to mean "last position in index, not counting the
null revision at the end" is an implementation detail of the index
that we should avoid spreading knowledge of. I hope we can even remove
support for index[-2].
Differential Revision: https://phab.mercurial-scm.org/D4016
Martin von Zweigbergk <martinvonz@google.com> [Fri, 13 Apr 2018 23:23:47 -0700] rev 38843
scmutil: make shortest() respect disambiguation revset
The previous patch would let you use a shorter prefix if the prefix is
unique within a configured revset. However, that's not very useful if
there's no simple way of knowing what that shorter prefix is. This
patch adapts the shortest() template function to use the shorter
prefixes for nodes in the configured revset.
This is currently extremely slow, because it calculates the revset for
each call to shortest(). To make this faster, the next patch will
start caching the revset instance. Ideally we'd cache a prefix tree
instance instead.
Differential Revision: https://phab.mercurial-scm.org/D4038
Martin von Zweigbergk <martinvonz@google.com> [Wed, 28 Mar 2018 09:36:02 -0700] rev 38842
lookup: add option to disambiguate prefix within revset
When resolving a nodeid prefix that is not unique within the repo and
the user has configured a revset that they want to disambiguate
within, we now try to look up within that revset before we fail. If
there is a unique match within the revset, we use that.
This is of course most effective at allowing a short prefix if the
revset contains few nodes. For most of our internal users at Google,
"not public()" is sufficiently small that a hex digit or two is
enough.
The implementation is currently pretty slow, but good enough for small
revsets (which is the expected use case). The scan in the revset is
linear. We may want to use a prefix tree if we want to allow users to
use a larger revset.
Credit for the idea goes to Kyle Lippincott.
Differential Revision: https://phab.mercurial-scm.org/D4037
Martin von Zweigbergk <martinvonz@google.com> [Fri, 13 Apr 2018 23:37:53 -0700] rev 38841
revlog: use specialized exception for ambiguous prefix lookup
It's useful to be able to catch a specific exception for this
case. We'll use it soon.
Differential Revision: https://phab.mercurial-scm.org/D4036