/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: Alexander Belchenko
  • Date: 2007-09-05 08:18:57 UTC
  • mfrom: (2799 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2800.
  • Revision ID: bialix@ukr.net-20070905081857-me1osc2lpuzq6ur1
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
2184
2184
        if self._new_revision_id is None:
2185
2185
            self._new_revision_id = self._gen_revision_id()
2186
2186
 
2187
 
    def record_entry_contents(self, ie, parent_invs, path, tree):
2188
 
        """Record the content of ie from tree into the commit if needed.
2189
 
 
2190
 
        Side effect: sets ie.revision when unchanged
2191
 
 
2192
 
        :param ie: An inventory entry present in the commit.
 
2187
    def _check_root(self, ie, parent_invs, tree):
 
2188
        """Helper for record_entry_contents.
 
2189
 
 
2190
        :param ie: An entry being added.
2193
2191
        :param parent_invs: The inventories of the parent revisions of the
2194
2192
            commit.
2195
 
        :param path: The path the entry is at in the tree.
2196
 
        :param tree: The tree which contains this entry and should be used to 
2197
 
        obtain content.
 
2193
        :param tree: The tree that is being committed.
2198
2194
        """
2199
 
        if self.new_inventory.root is None and ie.parent_id is not None:
 
2195
        if ie.parent_id is not None:
 
2196
            # if ie is not root, add a root automatically.
2200
2197
            symbol_versioning.warn('Root entry should be supplied to'
2201
2198
                ' record_entry_contents, as of bzr 0.10.',
2202
2199
                 DeprecationWarning, stacklevel=2)
2203
2200
            self.record_entry_contents(tree.inventory.root.copy(), parent_invs,
2204
2201
                                       '', tree)
2205
 
        self.new_inventory.add(ie)
2206
 
 
2207
 
        # ie.revision is always None if the InventoryEntry is considered
2208
 
        # for committing. ie.snapshot will record the correct revision 
2209
 
        # which may be the sole parent if it is untouched.
2210
 
        if ie.revision is not None:
2211
 
            return
2212
 
 
2213
 
        # In this revision format, root entries have no knit or weave
2214
 
        if ie is self.new_inventory.root:
2215
 
            # When serializing out to disk and back in
2216
 
            # root.revision is always _new_revision_id
 
2202
        else:
 
2203
            # In this revision format, root entries have no knit or weave When
 
2204
            # serializing out to disk and back in root.revision is always
 
2205
            # _new_revision_id
2217
2206
            ie.revision = self._new_revision_id
 
2207
 
 
2208
    def record_entry_contents(self, ie, parent_invs, path, tree):
 
2209
        """Record the content of ie from tree into the commit if needed.
 
2210
 
 
2211
        Side effect: sets ie.revision when unchanged
 
2212
 
 
2213
        :param ie: An inventory entry present in the commit.
 
2214
        :param parent_invs: The inventories of the parent revisions of the
 
2215
            commit.
 
2216
        :param path: The path the entry is at in the tree.
 
2217
        :param tree: The tree which contains this entry and should be used to 
 
2218
        obtain content.
 
2219
        """
 
2220
        if self.new_inventory.root is None:
 
2221
            self._check_root(ie, parent_invs, tree)
 
2222
        self.new_inventory.add(ie)
 
2223
 
 
2224
        # ie.revision is always None if the InventoryEntry is considered
 
2225
        # for committing. ie.snapshot will record the correct revision 
 
2226
        # which may be the sole parent if it is untouched.
 
2227
        if ie.revision is not None:
2218
2228
            return
2219
 
        previous_entries = ie.find_previous_heads(
2220
 
            parent_invs,
2221
 
            self.repository.weave_store,
2222
 
            self.repository.get_transaction())
2223
 
        # we are creating a new revision for ie in the history store
2224
 
        # and inventory.
 
2229
 
 
2230
        parent_candiate_entries = ie.parent_candidates(parent_invs)
 
2231
        heads = self.repository.get_graph().heads(parent_candiate_entries.keys())
 
2232
        # XXX: Note that this is unordered - and this is tolerable because 
 
2233
        # the previous code was also unordered.
 
2234
        previous_entries = dict((head, parent_candiate_entries[head]) for head
 
2235
            in heads)
 
2236
        # we are creating a new revision for ie in the history store and
 
2237
        # inventory.
2225
2238
        ie.snapshot(self._new_revision_id, path, previous_entries, tree, self)
2226
2239
 
2227
2240
    def modified_directory(self, file_id, file_parents):
2260
2273
            and text_sha1 == file_parents.values()[0].text_sha1
2261
2274
            and text_size == file_parents.values()[0].text_size):
2262
2275
            previous_ie = file_parents.values()[0]
2263
 
            versionedfile = self.repository.weave_store.get_weave(file_id, 
 
2276
            versionedfile = self.repository.weave_store.get_weave(file_id,
2264
2277
                self.repository.get_transaction())
2265
 
            versionedfile.clone_text(self._new_revision_id, 
 
2278
            versionedfile.clone_text(self._new_revision_id,
2266
2279
                previous_ie.revision, file_parents.keys())
2267
2280
            return text_sha1, text_size
2268
2281
        else:
2269
2282
            new_lines = get_content_byte_lines()
2270
 
            # TODO: Rather than invoking sha_strings here, _add_text_to_weave
2271
 
            # should return the SHA1 and size
2272
 
            self._add_text_to_weave(file_id, new_lines, file_parents.keys())
2273
 
            return osutils.sha_strings(new_lines), \
2274
 
                sum(map(len, new_lines))
 
2283
            return self._add_text_to_weave(file_id, new_lines,
 
2284
                file_parents.keys())
2275
2285
 
2276
2286
    def modified_link(self, file_id, file_parents, link_target):
2277
2287
        """Record the presence of a symbolic link.
2285
2295
    def _add_text_to_weave(self, file_id, new_lines, parents):
2286
2296
        versionedfile = self.repository.weave_store.get_weave_or_empty(
2287
2297
            file_id, self.repository.get_transaction())
2288
 
        versionedfile.add_lines(self._new_revision_id, parents, new_lines)
 
2298
        result = versionedfile.add_lines(
 
2299
            self._new_revision_id, parents, new_lines)[0:2]
2289
2300
        versionedfile.clear_cache()
 
2301
        return result
2290
2302
 
2291
2303
 
2292
2304
class _CommitBuilder(CommitBuilder):
2303
2315
    
2304
2316
    record_root_entry = True
2305
2317
 
2306
 
    def record_entry_contents(self, ie, parent_invs, path, tree):
2307
 
        """Record the content of ie from tree into the commit if needed.
2308
 
 
2309
 
        Side effect: sets ie.revision when unchanged
2310
 
 
2311
 
        :param ie: An inventory entry present in the commit.
 
2318
    def _check_root(self, ie, parent_invs, tree):
 
2319
        """Helper for record_entry_contents.
 
2320
 
 
2321
        :param ie: An entry being added.
2312
2322
        :param parent_invs: The inventories of the parent revisions of the
2313
2323
            commit.
2314
 
        :param path: The path the entry is at in the tree.
2315
 
        :param tree: The tree which contains this entry and should be used to 
2316
 
        obtain content.
 
2324
        :param tree: The tree that is being committed.
2317
2325
        """
2318
 
        assert self.new_inventory.root is not None or ie.parent_id is None
2319
 
        self.new_inventory.add(ie)
2320
 
 
2321
 
        # ie.revision is always None if the InventoryEntry is considered
2322
 
        # for committing. ie.snapshot will record the correct revision 
2323
 
        # which may be the sole parent if it is untouched.
2324
 
        if ie.revision is not None:
2325
 
            return
2326
 
 
2327
 
        previous_entries = ie.find_previous_heads(
2328
 
            parent_invs,
2329
 
            self.repository.weave_store,
2330
 
            self.repository.get_transaction())
2331
 
        # we are creating a new revision for ie in the history store
2332
 
        # and inventory.
2333
 
        ie.snapshot(self._new_revision_id, path, previous_entries, tree, self)
 
2326
        # ie must be root for this builder
 
2327
        assert ie.parent_id is None
2334
2328
 
2335
2329
 
2336
2330
_unescape_map = {