/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/multiparent.py

  • Committer: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
from bzrlib.lazy_import import lazy_import
18
18
 
28
28
    trace,
29
29
    ui,
30
30
    )
31
 
from bzrlib.util import bencode
 
31
from bzrlib import bencode
32
32
""")
33
33
from bzrlib.tuned_gzip import GzipFile
34
34
 
35
35
 
 
36
def topo_iter_keys(vf, keys=None):
 
37
    if keys is None:
 
38
        keys = vf.keys()
 
39
    parents = vf.get_parent_map(keys)
 
40
    return _topo_iter(parents, keys)
 
41
 
36
42
def topo_iter(vf, versions=None):
37
 
    seen = set()
38
 
    descendants = {}
39
43
    if versions is None:
40
44
        versions = vf.versions()
41
45
    parents = vf.get_parent_map(versions)
 
46
    return _topo_iter(parents, versions)
 
47
 
 
48
def _topo_iter(parents, versions):
 
49
    seen = set()
 
50
    descendants = {}
42
51
    def pending_parents(version):
 
52
        if parents[version] is None:
 
53
            return []
43
54
        return [v for v in parents[version] if v in versions and
44
55
                v not in seen]
45
56
    for version_id in versions:
 
57
        if parents[version_id] is None:
 
58
            # parentless
 
59
            continue
46
60
        for parent_id in parents[version_id]:
47
61
            descendants.setdefault(parent_id, []).append(version_id)
48
62
    cur = [v for v in versions if len(pending_parents(v)) == 0]
57
71
            yield version_id
58
72
            seen.add(version_id)
59
73
        cur = next
60
 
    assert len(seen) == len(versions)
61
74
 
62
75
 
63
76
class MultiParent(object):
195
208
            elif cur_line[0] == '\n':
196
209
                hunks[-1].lines[-1] += '\n'
197
210
            else:
198
 
                assert cur_line[0] == 'c', cur_line[0]
 
211
                if not (cur_line[0] == 'c'):
 
212
                    raise AssertionError(cur_line[0])
199
213
                parent, parent_pos, child_pos, num_lines =\
200
214
                    [int(v) for v in cur_line.split(' ')[1:]]
201
215
                hunks.append(ParentText(parent, parent_pos, child_pos,
276
290
            ' %(num_lines)r)' % self.__dict__
277
291
 
278
292
    def __eq__(self, other):
279
 
        if self.__class__ != other.__class__:
 
293
        if self.__class__ is not other.__class__:
280
294
            return False
281
295
        return (self.__dict__ == other.__dict__)
282
296
 
302
316
        return version in self._parents
303
317
 
304
318
    def do_snapshot(self, version_id, parent_ids):
305
 
        """Determine whether to perform a a snapshot for this version"""
 
319
        """Determine whether to perform a snapshot for this version"""
306
320
        if self.snapshot_interval is None:
307
321
            return False
308
322
        if self.max_snapshots is not None and\
370
384
        :param single_parent: If true, omit all but one parent text, (but
371
385
            retain parent metadata).
372
386
        """
373
 
        assert no_cache or not verify
 
387
        if not (no_cache or not verify):
 
388
            raise ValueError()
374
389
        revisions = set(vf.versions())
375
390
        total = len(revisions)
376
391
        pb = ui.ui_factory.nested_progress_bar()
382
397
                    if [p for p in parents if p not in self._parents] != []:
383
398
                        continue
384
399
                    lines = [a + ' ' + l for a, l in
385
 
                             vf.annotate_iter(revision)]
 
400
                             vf.annotate(revision)]
386
401
                    if snapshots is None:
387
402
                        force_snapshot = None
388
403
                    else:
394
409
                        self.clear_cache()
395
410
                        vf.clear_cache()
396
411
                        if verify:
397
 
                            assert lines == self.get_line_list([revision])[0]
 
412
                            if not (lines == self.get_line_list([revision])[0]):
 
413
                                raise AssertionError()
398
414
                            self.clear_cache()
399
415
                    pb.update('Importing revisions',
400
416
                              (total - len(revisions)) + len(added), total)