Show More
@@ -10,56 +10,11 from __future__ import absolute_import | |||
|
10 | 10 | |
|
11 | 11 | from .node import nullrev |
|
12 | 12 | |
|
13 |
class |
|
|
14 | '''generic interface for DAGs | |
|
15 | ||
|
16 | terms: | |
|
17 | "ix" (short for index) identifies a nodes internally, | |
|
18 | "id" identifies one externally. | |
|
19 | ||
|
20 | All params are ixs unless explicitly suffixed otherwise. | |
|
21 | Pluralized params are lists or sets. | |
|
22 | ''' | |
|
23 | ||
|
24 | def parents(self, ix): | |
|
25 | '''list of parents ixs of ix''' | |
|
26 | raise NotImplementedError | |
|
27 | ||
|
28 | def headsetofconnecteds(self, ixs): | |
|
29 | ''' | |
|
30 | subset of connected list of ixs so that no node has a descendant in it | |
|
31 | ||
|
32 | By "connected list" we mean that if an ancestor and a descendant are in | |
|
33 | the list, then so is at least one path connecting them. | |
|
34 | ''' | |
|
35 | raise NotImplementedError | |
|
36 | ||
|
37 | class genericdag(basedag): | |
|
38 | '''generic implementations for DAGs''' | |
|
39 | ||
|
40 | def headsetofconnecteds(self, ixs): | |
|
41 | hds = set(ixs) | |
|
42 | if not hds: | |
|
43 | return hds | |
|
44 | for n in ixs: | |
|
45 | for p in self.parents(n): | |
|
46 | hds.discard(p) | |
|
47 | assert hds | |
|
48 | return hds | |
|
49 | ||
|
50 | ||
|
51 | class revlogbaseddag(basedag): | |
|
52 | '''generic dag interface to a revlog''' | |
|
53 | ||
|
54 | def __init__(self, revlog): | |
|
55 | basedag.__init__(self) | |
|
56 | self._revlog = revlog | |
|
57 | ||
|
58 | class revlogdag(revlogbaseddag): | |
|
13 | class revlogdag(object): | |
|
59 | 14 | '''dag interface to a revlog''' |
|
60 | 15 | |
|
61 | 16 | def __init__(self, revlog): |
|
62 | revlogbaseddag.__init__(self, revlog) | |
|
17 | self._revlog = revlog | |
|
63 | 18 | |
|
64 | 19 | def parents(self, ix): |
|
65 | 20 | rlog = self._revlog |
General Comments 0
You need to be logged in to leave comments.
Login now