This is an archive of the discontinued Mercurial Phabricator instance.

setdiscovery: don't use dagutil for parent resolution
ClosedPublic

Authored by indygreg on Aug 17 2018, 5:31 PM.

Details

Summary

_updatesample()'s one remaining use of revlogdag is for resolving
the parents of a revision.

In 2 cases, we actually resolve parents. In 1, we operate on the
inverted DAG and resolve children.

This commit teaches _updatesample() to receive an argument defining
the function to resolve "parent" revisions. Call sites pass in
changelog.parentrevs() or a wrapper around changelog.children()
accordingly.

The use of children() is semantically correct. But it is quadratic,
since revlog.children() does a range scan over all revisions starting
at its input and effectively calls parentrevs() to build up the list
of children. So calling it repeatedly in a loop is a recipe for
bad performance. I will be implementing something better in a
subsequent commit. I wanted to get the porting off of dagutil done
in a way that was simple and correct.

Like other patches in this series, this change is potentially impacted
but revlogdag's ignorance of filtered revisions. The new code is
filtering aware, since changelog's revs() (used by children() will
skip filtered revisions and therefore hidden children won't appear.
This is potentially backwards incompatible. But no tests fail and
I think this code should respect visibility.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

indygreg created this revision.Aug 17 2018, 5:31 PM
yuja added a subscriber: yuja.Aug 18 2018, 4:05 AM

+ # TODO this is quadratic
+ parentfn = lambda rev: repo.changelog.children(repo.changelog.node(rev))
+
+ _updatesample(revs, revsroots, sample, parentfn)

Here parentfn() returns a list of nodes, which is wrong. But I took this
since this code is completely rewritten.

Surprisingly, test-setdiscovery.t didn't fail at this revision.

This revision was automatically updated to reflect the committed changes.