~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-05-29 11:26:30 UTC
  • mfrom: (4343.3.39 1.15-gc-stacking)
  • Revision ID: pqm@pqm.ubuntu.com-20090529112630-p1bfpivkz3igjzn2
(jam) Fix bug #373455, allow --dev6 repos to stack.

Show diffs side-by-side

added added

removed removed

Lines of Context:
268
268
 
269
269
    def __init__(self, name, revision_index, inventory_index, text_index,
270
270
        signature_index, upload_transport, pack_transport, index_transport,
271
 
        pack_collection):
 
271
        pack_collection, chk_index=None):
272
272
        """Create a ResumedPack object."""
273
273
        ExistingPack.__init__(self, pack_transport, name, revision_index,
274
 
            inventory_index, text_index, signature_index)
 
274
            inventory_index, text_index, signature_index,
 
275
            chk_index=chk_index)
275
276
        self.upload_transport = upload_transport
276
277
        self.index_transport = index_transport
277
278
        self.index_sizes = [None, None, None, None]
281
282
            ('text', text_index),
282
283
            ('signature', signature_index),
283
284
            ]
 
285
        if chk_index is not None:
 
286
            indices.append(('chk', chk_index))
 
287
            self.index_sizes.append(None)
284
288
        for index_type, index in indices:
285
289
            offset = self.index_offset(index_type)
286
290
            self.index_sizes[offset] = index._size
301
305
        self.upload_transport.delete(self.file_name())
302
306
        indices = [self.revision_index, self.inventory_index, self.text_index,
303
307
            self.signature_index]
 
308
        if self.chk_index is not None:
 
309
            indices.append(self.chk_index)
304
310
        for index in indices:
305
311
            index._transport.delete(index._name)
306
312
 
308
314
        self._check_references()
309
315
        new_name = '../packs/' + self.file_name()
310
316
        self.upload_transport.rename(self.file_name(), new_name)
311
 
        for index_type in ['revision', 'inventory', 'text', 'signature']:
 
317
        index_types = ['revision', 'inventory', 'text', 'signature']
 
318
        if self.chk_index is not None:
 
319
            index_types.append('chk')
 
320
        for index_type in index_types:
312
321
            old_name = self.index_name(index_type, self.name)
313
322
            new_name = '../indices/' + old_name
314
323
            self.upload_transport.rename(old_name, new_name)
316
325
        self._state = 'finished'
317
326
 
318
327
    def _get_external_refs(self, index):
 
328
        """Return compression parents for this index that are not present.
 
329
 
 
330
        This returns any compression parents that are referenced by this index,
 
331
        which are not contained *in* this index. They may be present elsewhere.
 
332
        """
319
333
        return index.external_references(1)
320
334
 
321
335
 
1352
1366
    """
1353
1367
 
1354
1368
    pack_factory = NewPack
 
1369
    resumed_pack_factory = ResumedPack
1355
1370
 
1356
1371
    def __init__(self, repo, transport, index_transport, upload_transport,
1357
1372
                 pack_transport, index_builder_class, index_class,
1680
1695
            inv_index = self._make_index(name, '.iix', resume=True)
1681
1696
            txt_index = self._make_index(name, '.tix', resume=True)
1682
1697
            sig_index = self._make_index(name, '.six', resume=True)
1683
 
            result = ResumedPack(name, rev_index, inv_index, txt_index,
1684
 
                sig_index, self._upload_transport, self._pack_transport,
1685
 
                self._index_transport, self)
 
1698
            if self.chk_index is not None:
 
1699
                chk_index = self._make_index(name, '.cix', resume=True)
 
1700
            else:
 
1701
                chk_index = None
 
1702
            result = self.resumed_pack_factory(name, rev_index, inv_index,
 
1703
                txt_index, sig_index, self._upload_transport,
 
1704
                self._pack_transport, self._index_transport, self,
 
1705
                chk_index=chk_index)
1686
1706
        except errors.NoSuchFile, e:
1687
1707
            raise errors.UnresumableWriteGroup(self.repo, [name], str(e))
1688
1708
        self.add_pack_to_memory(result)
1809
1829
    def reset(self):
1810
1830
        """Clear all cached data."""
1811
1831
        # cached revision data
1812
 
        self.repo._revision_knit = None
1813
1832
        self.revision_index.clear()
1814
1833
        # cached signature data
1815
 
        self.repo._signature_knit = None
1816
1834
        self.signature_index.clear()
1817
1835
        # cached file text data
1818
1836
        self.text_index.clear()
1819
 
        self.repo._text_knit = None
1820
1837
        # cached inventory data
1821
1838
        self.inventory_index.clear()
1822
1839
        # cached chk data
2035
2052
                except KeyError:
2036
2053
                    pass
2037
2054
        del self._resumed_packs[:]
2038
 
        self.repo._text_knit = None
2039
2055
 
2040
2056
    def _remove_resumed_pack_indices(self):
2041
2057
        for resumed_pack in self._resumed_packs:
2081
2097
                # when autopack takes no steps, the names list is still
2082
2098
                # unsaved.
2083
2099
                self._save_pack_names()
2084
 
        self.repo._text_knit = None
2085
2100
 
2086
2101
    def _suspend_write_group(self):
2087
2102
        tokens = [pack.name for pack in self._resumed_packs]
2095
2110
            self._new_pack.abort()
2096
2111
            self._new_pack = None
2097
2112
        self._remove_resumed_pack_indices()
2098
 
        self.repo._text_knit = None
2099
2113
        return tokens
2100
2114
 
2101
2115
    def _resume_write_group(self, tokens):
2202
2216
                    % (self._format, self.bzrdir.transport.base))
2203
2217
 
2204
2218
    def _abort_write_group(self):
 
2219
        self.revisions._index._key_dependencies.refs.clear()
2205
2220
        self._pack_collection._abort_write_group()
2206
2221
 
2207
2222
    def _find_inconsistent_revision_parents(self):
2262
2277
        self._pack_collection._start_write_group()
2263
2278
 
2264
2279
    def _commit_write_group(self):
 
2280
        self.revisions._index._key_dependencies.refs.clear()
2265
2281
        return self._pack_collection._commit_write_group()
2266
2282
 
2267
2283
    def suspend_write_group(self):
2268
2284
        # XXX check self._write_group is self.get_transaction()?
2269
2285
        tokens = self._pack_collection._suspend_write_group()
 
2286
        self.revisions._index._key_dependencies.refs.clear()
2270
2287
        self._write_group = None
2271
2288
        return tokens
2272
2289
 
2295
2312
        self._write_lock_count += 1
2296
2313
        if self._write_lock_count == 1:
2297
2314
            self._transaction = transactions.WriteTransaction()
 
2315
        if not locked:
2298
2316
            for repo in self._fallback_repositories:
2299
2317
                # Writes don't affect fallback repos
2300
2318
                repo.lock_read()
2301
 
        if not locked:
2302
2319
            self._refresh_data()
2303
2320
 
2304
2321
    def lock_read(self):
2307
2324
            self._write_lock_count += 1
2308
2325
        else:
2309
2326
            self.control_files.lock_read()
 
2327
        if not locked:
2310
2328
            for repo in self._fallback_repositories:
2311
 
                # Writes don't affect fallback repos
2312
2329
                repo.lock_read()
2313
 
        if not locked:
2314
2330
            self._refresh_data()
2315
2331
 
2316
2332
    def leave_lock_in_place(self):
2356
2372
                transaction = self._transaction
2357
2373
                self._transaction = None
2358
2374
                transaction.finish()
2359
 
                for repo in self._fallback_repositories:
2360
 
                    repo.unlock()
2361
2375
        else:
2362
2376
            self.control_files.unlock()
 
2377
 
 
2378
        if not self.is_locked():
2363
2379
            for repo in self._fallback_repositories:
2364
2380
                repo.unlock()
2365
2381