Mercurial > public > mercurial-scm > hg
comparison mercurial/graphmod.py @ 32903:27932a76a88d
dagop: split module hosting DAG-related algorithms from revset
This module hosts the following functions. They are somewhat similar (e.g.
scanning revisions using heap queue or stack) and seem non-trivial in
algorithmic point of view.
- _revancestors()
- _revdescendants()
- reachableroots()
- _toposort()
I was thinking of adding revset._fileancestors() generator for better follow()
implementation, but it would be called from context.py as well. So I decided
to create new module.
Naming is hard. I couldn't come up with any better module name, so it's called
"dag operation" now. I rejected the following candidates:
- ancestor.py - existing, revlog-level DAG algorithm
- ancestorset.py - doesn't always return a set
- dagalgorithm.py - hard to type
- dagutil.py - existing
- revancestor.py - I want to add fileancestors()
% wc -l mercurial/dagop.py mercurial/revset.py
339 mercurial/dagop.py
2020 mercurial/revset.py
2359 total
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 16 Oct 2016 18:03:24 +0900 |
parents | 906da89821ce |
children | 6f6c87888b22 |
comparison
equal
deleted
inserted
replaced
32902:642feee29d70 | 32903:27932a76a88d |
---|---|
19 | 19 |
20 from __future__ import absolute_import | 20 from __future__ import absolute_import |
21 | 21 |
22 from .node import nullrev | 22 from .node import nullrev |
23 from . import ( | 23 from . import ( |
24 revset, | 24 dagop, |
25 smartset, | 25 smartset, |
26 util, | 26 util, |
27 ) | 27 ) |
28 | 28 |
29 CHANGESET = 'C' | 29 CHANGESET = 'C' |
68 if gp is None: | 68 if gp is None: |
69 # precompute slow query as we know reachableroots() goes | 69 # precompute slow query as we know reachableroots() goes |
70 # through all revs (issue4782) | 70 # through all revs (issue4782) |
71 if not isinstance(revs, smartset.baseset): | 71 if not isinstance(revs, smartset.baseset): |
72 revs = smartset.baseset(revs) | 72 revs = smartset.baseset(revs) |
73 gp = gpcache[mpar] = sorted(set(revset.reachableroots( | 73 gp = gpcache[mpar] = sorted(set(dagop.reachableroots( |
74 repo, revs, [mpar]))) | 74 repo, revs, [mpar]))) |
75 if not gp: | 75 if not gp: |
76 parents.append((MISSINGPARENT, mpar)) | 76 parents.append((MISSINGPARENT, mpar)) |
77 pset.add(mpar) | 77 pset.add(mpar) |
78 else: | 78 else: |