Sat, 05 May 2018 00:16:43 -0700 shortest: don't keep checking for longer prefix if node doesn't exist (API)
Martin von Zweigbergk <martinvonz@google.com> [Sat, 05 May 2018 00:16:43 -0700] rev 37909
shortest: don't keep checking for longer prefix if node doesn't exist (API) If revlog.shortest() is called with an invalid nodeid, we keep checking if longer and longer prefixes are valid. We call revlog._partialmatch() for each prefix. That function will give us None if the node doesn't exist (and a RevlogError if it's ambiguous), so there's no need to keep checking. This patch instead makes revlog.shortest() raise a LookupError is the node does not exist, and updates the caller to handle it. Before this patch, revlog.shortest() would return the full hexnode for nonexistent nodeids. By the same reasoning as in 7b2955624777 (scmutil: make shortesthexnodeidprefix() take a full binary nodeid, 2018-04-14), it's not revlog.shortest() that should decide how to present nonexistent nodeids, so that's now moved to the template function. This should speed up cases where {shortest()} is applied to an invalid nodeid, but I couldn't think of a reasonable case where that would happen. Differential Revision: https://phab.mercurial-scm.org/D3461
Wed, 02 May 2018 22:56:10 -0700 shortest: extract function for checking if a prefix is a revnum
Martin von Zweigbergk <martinvonz@google.com> [Wed, 02 May 2018 22:56:10 -0700] rev 37908
shortest: extract function for checking if a prefix is a revnum Much of isvalid() was about testing if a prefix is a valid revnum. I want to reuse that soon, so let's move it out. There is no significant slowdown from the function call overhead. Differential Revision: https://phab.mercurial-scm.org/D3460
Thu, 03 May 2018 10:12:47 -0700 shortest: rename "test" variable to "prefix"
Martin von Zweigbergk <martinvonz@google.com> [Thu, 03 May 2018 10:12:47 -0700] rev 37907
shortest: rename "test" variable to "prefix" Sorry if this is considered churn, but "prefix" just seems much clearer to me. Differential Revision: https://phab.mercurial-scm.org/D3459
(0) -30000 -10000 -3000 -1000 -300 -100 -30 -10 -3 +3 +10 +30 +100 +300 +1000 +3000 +10000 tip