~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-06-25 10:36:36 UTC
  • mfrom: (3350.6.12 versionedfiles)
  • Revision ID: pqm@pqm.ubuntu.com-20080625103636-6kxh4e1gmyn82f50
(mbp for robertc) VersionedFiles refactoring

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
    graph,
44
44
    lockable_files,
45
45
    lockdir,
 
46
    osutils,
46
47
    registry,
47
48
    remote,
48
49
    revision as _mod_revision,
49
50
    symbol_versioning,
50
51
    ui,
51
52
    urlutils,
 
53
    versionedfile,
52
54
    win32utils,
53
55
    workingtree,
54
56
    workingtree_4,
61
63
    )
62
64
from bzrlib.smart.client import _SmartClient
63
65
from bzrlib.smart import protocol
64
 
from bzrlib.store.revision.text import TextRevisionStore
65
 
from bzrlib.store.text import TextStore
66
66
from bzrlib.store.versioned import WeaveStore
67
67
from bzrlib.transactions import WriteTransaction
68
68
from bzrlib.transport import (
2055
2055
        self.bzrdir.transport.mkdir('revision-store')
2056
2056
        revision_transport = self.bzrdir.transport.clone('revision-store')
2057
2057
        # TODO permissions
2058
 
        _revision_store = TextRevisionStore(TextStore(revision_transport,
2059
 
                                                      prefixed=False,
2060
 
                                                      compressed=True))
 
2058
        from bzrlib.xml5 import serializer_v5
 
2059
        from bzrlib.repofmt.weaverepo import RevisionTextStore
 
2060
        revision_store = RevisionTextStore(revision_transport,
 
2061
            serializer_v5, False, versionedfile.PrefixMapper(),
 
2062
            lambda:True, lambda:True)
2061
2063
        try:
2062
 
            transaction = WriteTransaction()
2063
2064
            for i, rev_id in enumerate(self.converted_revs):
2064
2065
                self.pb.update('write revision', i, len(self.converted_revs))
2065
 
                _revision_store.add_revision(self.revisions[rev_id], transaction)
 
2066
                text = serializer_v5.write_revision_to_string(
 
2067
                    self.revisions[rev_id])
 
2068
                key = (rev_id,)
 
2069
                revision_store.add_lines(key, None, osutils.split_lines(text))
2066
2070
        finally:
2067
2071
            self.pb.clear()
2068
2072
            
2081
2085
                         rev_id)
2082
2086
            self.absent_revisions.add(rev_id)
2083
2087
        else:
2084
 
            rev = self.branch.repository._revision_store.get_revision(rev_id,
2085
 
                self.branch.repository.get_transaction())
 
2088
            rev = self.branch.repository.get_revision(rev_id)
2086
2089
            for parent_id in rev.parent_ids:
2087
2090
                self.known_revisions.add(parent_id)
2088
2091
                self.to_read.append(parent_id)
2178
2181
                ie.revision = previous_ie.revision
2179
2182
                return
2180
2183
        if ie.has_text():
2181
 
            text = self.branch.repository.weave_store.get(ie.text_id)
 
2184
            text = self.branch.repository._text_store.get(ie.text_id)
2182
2185
            file_lines = text.readlines()
2183
2186
            w.add_lines(rev_id, previous_revisions, file_lines)
2184
2187
            self.text_count += 1
2232
2235
                if (filename.endswith(".weave") or
2233
2236
                    filename.endswith(".gz") or
2234
2237
                    filename.endswith(".sig")):
2235
 
                    file_id = os.path.splitext(filename)[0]
 
2238
                    file_id, suffix = os.path.splitext(filename)
2236
2239
                else:
2237
2240
                    file_id = filename
2238
 
                prefix_dir = store.hash_prefix(file_id)
 
2241
                    suffix = ''
 
2242
                new_name = store._mapper.map((file_id,)) + suffix
2239
2243
                # FIXME keep track of the dirs made RBC 20060121
2240
2244
                try:
2241
 
                    store_transport.move(filename, prefix_dir + '/' + filename)
 
2245
                    store_transport.move(filename, new_name)
2242
2246
                except errors.NoSuchFile: # catches missing dirs strangely enough
2243
 
                    store_transport.mkdir(prefix_dir)
2244
 
                    store_transport.move(filename, prefix_dir + '/' + filename)
 
2247
                    store_transport.mkdir(osutils.dirname(new_name))
 
2248
                    store_transport.move(filename, new_name)
2245
2249
        self.bzrdir.transport.put_bytes(
2246
2250
            'branch-format',
2247
2251
            BzrDirFormat6().get_format_string(),