~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store/revision/knit.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-10-10 07:23:07 UTC
  • mfrom: (2067.1.1 urandom-56883)
  • Revision ID: pqm@pqm.ubuntu.com-20061010072307-037a6f63da8a1bdd
(John Arbash Meinel) Handle exceptions while opening /dev/urandom

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006 by Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License as published by
5
 
# the Free Software Foundation; either version 2 of the License, or
6
 
# (at your option) any later version.
 
4
# it under the terms of the GNU General Public License version 2 as published by
 
5
# the Free Software Foundation.
7
6
#
8
7
# This program is distributed in the hope that it will be useful,
9
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21
20
"""
22
21
 
23
22
 
24
 
from bzrlib import (
25
 
    errors,
26
 
    osutils,
27
 
    revision as _mod_revision,
28
 
    )
 
23
import bzrlib
 
24
import bzrlib.errors as errors
29
25
from bzrlib.knit import KnitVersionedFile, KnitPlainFactory
30
26
from bzrlib.store.revision import RevisionStore
31
27
from bzrlib.store.versioned import VersionedFileStore
62
58
        super(KnitRevisionStore, self).__init__()
63
59
        self.versioned_file_store = versioned_file_store
64
60
 
65
 
    def __repr__(self):
66
 
        return "%s(%s)" % (self.__class__.__name__,
67
 
                           self.versioned_file_store)
68
 
 
69
61
    def _add_revision(self, revision, revision_as_file, transaction):
70
62
        """Template method helper to store revision in this store."""
 
63
        # FIXME: make this ghost aware at the knit level
 
64
        rf = self.get_revision_file(transaction)
71
65
        self.get_revision_file(transaction).add_lines_with_ghosts(
72
66
            revision.revision_id,
73
67
            revision.parent_ids,
74
 
            osutils.split_lines(revision_as_file.read()))
 
68
            bzrlib.osutils.split_lines(revision_as_file.read()))
75
69
 
76
70
    def add_revision_signature_text(self, revision_id, signature_text, transaction):
77
71
        """See RevisionStore.add_revision_signature_text()."""
78
72
        self.get_signature_file(transaction).add_lines(
79
 
            revision_id, [], osutils.split_lines(signature_text))
 
73
            revision_id, [], bzrlib.osutils.split_lines(signature_text))
80
74
 
81
75
    def all_revision_ids(self, transaction):
82
76
        """See RevisionStore.all_revision_ids()."""
93
87
                assert r.revision_id == revision_id
94
88
                revisions.append(r)
95
89
        except SyntaxError, e:
96
 
            raise errors.BzrError('failed to unpack revision_xml for %s: %s' %
97
 
                                   (revision_id, str(e)))
98
 
        return revisions
 
90
            raise errors.BzrError('failed to unpack revision_xml',
 
91
                                   [revision_id,
 
92
                                   str(e)])
 
93
        return revisions 
99
94
 
100
95
    def _get_serialized_revisions(self, revision_ids, transaction):
101
96
        texts = []
128
123
 
129
124
    def has_revision_id(self, revision_id, transaction):
130
125
        """True if the store contains revision_id."""
131
 
        return (_mod_revision.is_null(revision_id)
 
126
        return (revision_id is None
132
127
                or self.get_revision_file(transaction).has_version(revision_id))
133
 
 
 
128
        
134
129
    def _has_signature(self, revision_id, transaction):
135
130
        """See RevisionStore._has_signature()."""
136
131
        return self.get_signature_file(transaction).has_version(revision_id)