~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to weave.py

  • Committer: Martin Pool
  • Date: 2005-06-30 08:17:18 UTC
  • mto: This revision was merged to the branch mainline in revision 852.
  • Revision ID: mbp@sourcefrog.net-20050630081718-ad66591972dde48d
New Weave.get_included() does transitive expansion

Show diffs side-by-side

added added

removed removed

Lines of Context:
140
140
    _v
141
141
        List of versions, indexed by index number.
142
142
 
143
 
        For each version we store the tuple (included_versions), which
144
 
        lists the previous versions also considered active.
 
143
        For each version we store the set (included_versions), which
 
144
        lists the previous versions also considered active; the
 
145
        versions included in those versions are included transitively.
 
146
        So new versions created from nothing list []; most versions
 
147
        have a single entry; some have more.
145
148
    """
146
149
    def __init__(self):
147
150
        self._l = []
221
224
        return idx
222
225
 
223
226
 
 
227
    def get_included(self, version):
 
228
        """Return a set with all included versions for version."""
 
229
        i = set()
 
230
        x = [version]
 
231
        while x:
 
232
            v = x.pop()
 
233
            if v in i:
 
234
                continue
 
235
            i.add(v)
 
236
            for u in self._v[v]:
 
237
                x.append(u)
 
238
        return i
 
239
 
 
240
 
224
241
    def _addversion(self, parents):
225
242
        if parents:
226
243
            self._v.append(frozenset(parents))