/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/repository.py

  • Committer: Robert Collins
  • Date: 2006-02-23 04:08:56 UTC
  • mto: (1587.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1588.
  • Revision ID: robertc@robertcollins.net-20060223040856-8b476741783b6244
Import bzrtools' 'fix' command as 'bzr reconcile.'

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from bzrlib.decorators import needs_read_lock, needs_write_lock
24
24
import bzrlib.errors as errors
25
25
from bzrlib.errors import InvalidRevisionId
 
26
import bzrlib.gpg as gpg
26
27
from bzrlib.lockable_files import LockableFiles
27
28
from bzrlib.osutils import safe_unicode
28
29
from bzrlib.revision import NULL_REVISION
50
51
    remote) disk.
51
52
    """
52
53
 
 
54
    @needs_write_lock
 
55
    def add_inventory(self, revid, inv, parents):
 
56
        """Add the inventory inv to the repository as revid.
 
57
        
 
58
        :param parents: The revision ids of the parents that revid
 
59
                        is known to have and are in the repository already.
 
60
 
 
61
        returns the sha1 of the serialized inventory.
 
62
        """
 
63
        inv_text = bzrlib.xml5.serializer_v5.write_inventory_to_string(inv)
 
64
        inv_sha1 = bzrlib.osutils.sha_string(inv_text)
 
65
        self.control_weaves.add_text('inventory', revid,
 
66
                   bzrlib.osutils.split_lines(inv_text), parents,
 
67
                   self.get_transaction())
 
68
        return inv_sha1
 
69
 
 
70
    @needs_write_lock
 
71
    def add_revision(self, rev_id, rev, inv=None, config=None):
 
72
        """Add rev to the revision store as rev_id.
 
73
 
 
74
        :param rev_id: the revision id to use.
 
75
        :param rev: The revision object.
 
76
        :param inv: The inventory for the revision. if None, it will be looked
 
77
                    up in the inventory storer
 
78
        :param config: If None no digital signature will be created.
 
79
                       If supplied its signature_needed method will be used
 
80
                       to determine if a signature should be made.
 
81
        """
 
82
        if config is not None and config.signature_needed():
 
83
            if inv is None:
 
84
                inv = self.get_inventory(rev_id)
 
85
            plaintext = Testament(rev, inv).as_short_text()
 
86
            self.store_revision_signature(
 
87
                gpg.GPGStrategy(config), plaintext, rev_id)
 
88
        if not rev_id in self.get_inventory_weave():
 
89
            if inv is None:
 
90
                raise errors.WeaveRevisionNotPresent(rev_id,
 
91
                                                     self.get_inventory_weave())
 
92
            else:
 
93
                # yes, this is not suitable for adding with ghosts.
 
94
                self.add_inventory(rev_id, inv, rev.parent_ids)
 
95
            
 
96
        rev_tmp = StringIO()
 
97
        bzrlib.xml5.serializer_v5.write_revision(rev, rev_tmp)
 
98
        rev_tmp.seek(0)
 
99
        self.revision_store.add(rev_tmp, rev_id)
 
100
        mutter('added revision_id {%s}', rev_id)
 
101
 
53
102
    @needs_read_lock
54
103
    def _all_possible_ids(self):
55
104
        """Return all the possible revisions that we could find."""