/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: Canonical.com Patch Queue Manager
  • Date: 2006-06-20 06:38:49 UTC
  • mfrom: (1773.4.3 bzr.mbp.pyflakes)
  • Revision ID: pqm@pqm.ubuntu.com-20060620063849-400861427a3a9ff1
(mbp) pyflakes cleanups

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import time
22
22
from unittest import TestSuite
23
23
 
24
 
import bzrlib.bzrdir as bzrdir
 
24
from bzrlib import bzrdir, check, delta, gpg, errors, xml5, ui, transactions, osutils
25
25
from bzrlib.decorators import needs_read_lock, needs_write_lock
26
 
import bzrlib.errors as errors
27
26
from bzrlib.errors import InvalidRevisionId
28
 
import bzrlib.gpg as gpg
29
27
from bzrlib.graph import Graph
30
28
from bzrlib.inter import InterObject
31
29
from bzrlib.inventory import Inventory
37
35
from bzrlib.revision import NULL_REVISION, Revision
38
36
from bzrlib.store.versioned import VersionedFileStore, WeaveStore
39
37
from bzrlib.store.text import TextStore
40
 
from bzrlib.symbol_versioning import *
 
38
from bzrlib.symbol_versioning import (deprecated_method,
 
39
        zero_nine, 
 
40
        )
41
41
from bzrlib.trace import mutter, note
42
42
from bzrlib.tree import RevisionTree, EmptyTree
43
43
from bzrlib.tsort import topo_sort
44
44
from bzrlib.testament import Testament
45
45
from bzrlib.tree import EmptyTree
46
 
from bzrlib.delta import compare_trees
47
 
import bzrlib.ui
48
46
from bzrlib.weave import WeaveFile
49
 
import bzrlib.xml5
50
47
 
51
48
 
52
49
class Repository(object):
73
70
        assert inv.revision_id is None or inv.revision_id == revid, \
74
71
            "Mismatch between inventory revision" \
75
72
            " id and insertion revid (%r, %r)" % (inv.revision_id, revid)
76
 
        inv_text = bzrlib.xml5.serializer_v5.write_inventory_to_string(inv)
77
 
        inv_sha1 = bzrlib.osutils.sha_string(inv_text)
 
73
        inv_text = xml5.serializer_v5.write_inventory_to_string(inv)
 
74
        inv_sha1 = osutils.sha_string(inv_text)
78
75
        inv_vf = self.control_weaves.get_weave('inventory',
79
76
                                               self.get_transaction())
80
 
        self._inventory_add_lines(inv_vf, revid, parents, bzrlib.osutils.split_lines(inv_text))
 
77
        self._inventory_add_lines(inv_vf, revid, parents, osutils.split_lines(inv_text))
81
78
        return inv_sha1
82
79
 
83
80
    def _inventory_add_lines(self, inv_vf, revid, parents, lines):
120
117
        """Return all the possible revisions that we could find."""
121
118
        return self.get_inventory_weave().versions()
122
119
 
123
 
    @deprecated_method(zero_nine)
124
120
    def all_revision_ids(self):
125
121
        """Returns a list of all the revision ids in the repository. 
126
122
 
227
223
        For instance, if the repository is at URL/.bzr/repository,
228
224
        Repository.open(URL) -> a Repository instance.
229
225
        """
230
 
        control = bzrlib.bzrdir.BzrDir.open(base)
 
226
        control = bzrdir.BzrDir.open(base)
231
227
        return control.open_repository()
232
228
 
233
229
    def copy_content_into(self, destination, revision_id=None, basis=None):
278
274
            result = a_bzrdir.create_repository()
279
275
        # FIXME RBC 20060209 split out the repository type to avoid this check ?
280
276
        elif isinstance(a_bzrdir._format,
281
 
                      (bzrlib.bzrdir.BzrDirFormat4,
282
 
                       bzrlib.bzrdir.BzrDirFormat5,
283
 
                       bzrlib.bzrdir.BzrDirFormat6)):
 
277
                      (bzrdir.BzrDirFormat4,
 
278
                       bzrdir.BzrDirFormat5,
 
279
                       bzrdir.BzrDirFormat6)):
284
280
            result = a_bzrdir.open_repository()
285
281
        else:
286
282
            result = self._format.initialize(a_bzrdir, shared=self.is_shared())
347
343
            old_tree = EmptyTree()
348
344
        else:
349
345
            old_tree = self.revision_tree(revision.parent_ids[0])
350
 
        return compare_trees(old_tree, new_tree)
 
346
        return delta.compare_trees(old_tree, new_tree)
351
347
 
352
348
    def _check_revision_parents(self, revision, inventory):
353
349
        """Private to Repository and Fetch.
431
427
        :param revision_id: The expected revision id of the inventory.
432
428
        :param xml: A serialised inventory.
433
429
        """
434
 
        return bzrlib.xml5.serializer_v5.read_inventory_from_string(xml)
 
430
        return xml5.serializer_v5.read_inventory_from_string(xml)
435
431
 
436
432
    @needs_read_lock
437
433
    def get_inventory_xml(self, revision_id):
441
437
            iw = self.get_inventory_weave()
442
438
            return iw.get_text(revision_id)
443
439
        except IndexError:
444
 
            raise bzrlib.errors.HistoryMissing(self, 'inventory', revision_id)
 
440
            raise errors.HistoryMissing(self, 'inventory', revision_id)
445
441
 
446
442
    @needs_read_lock
447
443
    def get_inventory_sha1(self, revision_id):
643
639
        return self._check(revision_ids)
644
640
 
645
641
    def _check(self, revision_ids):
646
 
        result = bzrlib.check.Check(self)
 
642
        result = check.Check(self)
647
643
        result.check()
648
644
        return result
649
645
 
920
916
        reconciler.reconcile()
921
917
        return reconciler
922
918
    
923
 
    def revision_parents(self, revid):
924
 
        return self._get_revision_vf().get_parents(rev_id)
 
919
    def revision_parents(self, revision_id):
 
920
        return self._get_revision_vf().get_parents(revision_id)
 
921
 
925
922
 
926
923
class RepositoryFormat(object):
927
924
    """A repository format.
1090
1087
        
1091
1088
        # Create an empty weave
1092
1089
        sio = StringIO()
1093
 
        bzrlib.weavefile.write_weave_v5(Weave(), sio)
 
1090
        write_weave_v5(Weave(), sio)
1094
1091
        empty_weave = sio.getvalue()
1095
1092
 
1096
1093
        mutter('creating repository in %s.', a_bzrdir.transport.base)
1156
1153
 
1157
1154
    def __init__(self):
1158
1155
        super(RepositoryFormat4, self).__init__()
1159
 
        self._matchingbzrdir = bzrlib.bzrdir.BzrDirFormat4()
 
1156
        self._matchingbzrdir = bzrdir.BzrDirFormat4()
1160
1157
 
1161
1158
    def get_format_description(self):
1162
1159
        """See RepositoryFormat.get_format_description()."""
1205
1202
 
1206
1203
    def __init__(self):
1207
1204
        super(RepositoryFormat5, self).__init__()
1208
 
        self._matchingbzrdir = bzrlib.bzrdir.BzrDirFormat5()
 
1205
        self._matchingbzrdir = bzrdir.BzrDirFormat5()
1209
1206
 
1210
1207
    def get_format_description(self):
1211
1208
        """See RepositoryFormat.get_format_description()."""
1235
1232
 
1236
1233
    def __init__(self):
1237
1234
        super(RepositoryFormat6, self).__init__()
1238
 
        self._matchingbzrdir = bzrlib.bzrdir.BzrDirFormat6()
 
1235
        self._matchingbzrdir = bzrdir.BzrDirFormat6()
1239
1236
 
1240
1237
    def get_format_description(self):
1241
1238
        """See RepositoryFormat.get_format_description()."""
1259
1256
 
1260
1257
    def __init__(self):
1261
1258
        super(MetaDirRepositoryFormat, self).__init__()
1262
 
        self._matchingbzrdir = bzrlib.bzrdir.BzrDirMetaFormat1()
 
1259
        self._matchingbzrdir = bzrdir.BzrDirMetaFormat1()
1263
1260
 
1264
1261
    def _create_control_files(self, a_bzrdir):
1265
1262
        """Create the required files and the initial control_files object."""
1340
1337
 
1341
1338
        # Create an empty weave
1342
1339
        sio = StringIO()
1343
 
        bzrlib.weavefile.write_weave_v5(Weave(), sio)
 
1340
        write_weave_v5(Weave(), sio)
1344
1341
        empty_weave = sio.getvalue()
1345
1342
 
1346
1343
        mutter('creating repository in %s.', a_bzrdir.transport.base)
1451
1448
        repo_transport = a_bzrdir.get_repository_transport(None)
1452
1449
        control_files = LockableFiles(repo_transport, 'lock', LockDir)
1453
1450
        control_store = self._get_control_store(repo_transport, control_files)
1454
 
        transaction = bzrlib.transactions.WriteTransaction()
 
1451
        transaction = transactions.WriteTransaction()
1455
1452
        # trigger a write of the inventory store.
1456
1453
        control_store.get_weave_or_empty('inventory', transaction)
1457
1454
        _revision_store = self._get_revision_store(repo_transport, control_files)
1660
1657
                pass
1661
1658
            # FIXME do not peek!
1662
1659
            if self.source.control_files._transport.listable():
1663
 
                pb = bzrlib.ui.ui_factory.nested_progress_bar()
 
1660
                pb = ui.ui_factory.nested_progress_bar()
1664
1661
                try:
1665
1662
                    self.target.weave_store.copy_all_ids(
1666
1663
                        self.source.weave_store,
2089
2086
            # TODO: Rather than invoking sha_strings here, _add_text_to_weave
2090
2087
            # should return the SHA1 and size
2091
2088
            self._add_text_to_weave(file_id, new_lines, file_parents.keys())
2092
 
            return bzrlib.osutils.sha_strings(new_lines), \
 
2089
            return osutils.sha_strings(new_lines), \
2093
2090
                sum(map(len, new_lines))
2094
2091
 
2095
2092
    def modified_link(self, file_id, file_parents, link_target):