~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/knitrepo.py

  • Committer: Andrew Bennetts
  • Date: 2010-01-15 05:30:30 UTC
  • mto: (4973.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4975.
  • Revision ID: andrew.bennetts@canonical.com-20100115053030-1d6qd89pnj8hmb55
Pass kinds (not pairs) to MergeHookParams.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
from bzrlib.lazy_import import lazy_import
18
18
lazy_import(globals(), """
53
53
    def __repr__(self):
54
54
        return 'KnitParentsProvider(%r)' % self._knit
55
55
 
56
 
    @symbol_versioning.deprecated_method(symbol_versioning.one_one)
57
 
    def get_parents(self, revision_ids):
58
 
        """See graph._StackedParentsProvider.get_parents"""
59
 
        parent_map = self.get_parent_map(revision_ids)
60
 
        return [parent_map.get(r, None) for r in revision_ids]
61
 
 
62
56
    def get_parent_map(self, keys):
63
 
        """See graph._StackedParentsProvider.get_parent_map"""
 
57
        """See graph.StackedParentsProvider.get_parent_map"""
64
58
        parent_map = {}
65
59
        for revision_id in keys:
66
60
            if revision_id is None:
91
85
        return 'KnitsParentsProvider(%r)' % self._knit
92
86
 
93
87
    def get_parent_map(self, keys):
94
 
        """See graph._StackedParentsProvider.get_parent_map"""
 
88
        """See graph.StackedParentsProvider.get_parent_map"""
95
89
        parent_map = self._knit.get_parent_map(
96
90
            [self._prefix + (key,) for key in keys])
97
91
        result = {}
124
118
        self._commit_builder_class = _commit_builder_class
125
119
        self._serializer = _serializer
126
120
        self._reconcile_fixes_text_parents = True
127
 
        self._fetch_uses_deltas = True
128
 
        self._fetch_order = 'topological'
129
121
 
130
122
    @needs_read_lock
131
123
    def _all_revision_ids(self):
215
207
        revision_id = osutils.safe_revision_id(revision_id)
216
208
        return self.get_revision_reconcile(revision_id)
217
209
 
 
210
    def _refresh_data(self):
 
211
        if not self.is_locked():
 
212
            return
 
213
        # Create a new transaction to force all knits to see the scope change.
 
214
        # This is safe because we're outside a write group.
 
215
        self.control_files._finish_transaction()
 
216
        if self.is_write_locked():
 
217
            self.control_files._set_write_transaction()
 
218
        else:
 
219
            self.control_files._set_read_transaction()
 
220
 
218
221
    @needs_write_lock
219
222
    def reconcile(self, other=None, thorough=False):
220
223
        """Reconcile this repository."""
222
225
        reconciler = KnitReconciler(self, thorough=thorough)
223
226
        reconciler.reconcile()
224
227
        return reconciler
225
 
    
 
228
 
226
229
    def _make_parents_provider(self):
227
230
        return _KnitsParentsProvider(self.revisions)
228
231
 
229
 
    def _find_inconsistent_revision_parents(self):
 
232
    def _find_inconsistent_revision_parents(self, revisions_iterator=None):
230
233
        """Find revisions with different parent lists in the revision object
231
234
        and in the index graph.
232
235
 
 
236
        :param revisions_iterator: None, or an iterator of (revid,
 
237
            Revision-or-None). This iterator controls the revisions checked.
233
238
        :returns: an iterator yielding tuples of (revison-id, parents-in-index,
234
239
            parents-in-revision).
235
240
        """
236
241
        if not self.is_locked():
237
242
            raise AssertionError()
238
243
        vf = self.revisions
239
 
        for index_version in vf.keys():
240
 
            parent_map = vf.get_parent_map([index_version])
 
244
        if revisions_iterator is None:
 
245
            revisions_iterator = self._iter_revisions(None)
 
246
        for revid, revision in revisions_iterator:
 
247
            if revision is None:
 
248
                pass
 
249
            parent_map = vf.get_parent_map([(revid,)])
241
250
            parents_according_to_index = tuple(parent[-1] for parent in
242
 
                parent_map[index_version])
243
 
            revision = self.get_revision(index_version[-1])
 
251
                parent_map[(revid,)])
244
252
            parents_according_to_revision = tuple(revision.parent_ids)
245
253
            if parents_according_to_index != parents_according_to_revision:
246
 
                yield (index_version[-1], parents_according_to_index,
 
254
                yield (revid, parents_according_to_index,
247
255
                    parents_according_to_revision)
248
256
 
249
257
    def _check_for_inconsistent_revision_parents(self):
259
267
 
260
268
 
261
269
class RepositoryFormatKnit(MetaDirRepositoryFormat):
262
 
    """Bzr repository knit format (generalized). 
 
270
    """Bzr repository knit format (generalized).
263
271
 
264
272
    This repository format has:
265
273
     - knits for file texts and inventory
288
296
    supports_ghosts = True
289
297
    # External lookups are not supported in this format.
290
298
    supports_external_lookups = False
 
299
    # No CHK support.
 
300
    supports_chks = False
 
301
    _fetch_order = 'topological'
 
302
    _fetch_uses_deltas = True
 
303
    fast_deltas = False
291
304
 
292
305
    def _get_inventories(self, repo_transport, repo, name='inventory'):
293
306
        mapper = versionedfile.ConstantMapper(name)
333
346
        dirs = ['knits']
334
347
        files = []
335
348
        utf8_files = [('format', self.get_format_string())]
336
 
        
 
349
 
337
350
        self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
338
351
        repo_transport = a_bzrdir.get_repository_transport(None)
339
352
        control_files = lockable_files.LockableFiles(repo_transport,
351
364
 
352
365
    def open(self, a_bzrdir, _found=False, _override_transport=None):
353
366
        """See RepositoryFormat.open().
354
 
        
 
367
 
355
368
        :param _override_transport: INTERNAL USE ONLY. Allows opening the
356
369
                                    repository at a slightly different url
357
370
                                    than normal. I.e. during 'upgrade'.
373
386
        repo.signatures = self._get_signatures(repo_transport, repo)
374
387
        repo.inventories = self._get_inventories(repo_transport, repo)
375
388
        repo.texts = self._get_texts(repo_transport, repo)
 
389
        repo.chk_bytes = None
376
390
        repo._transport = repo_transport
377
391
        return repo
378
392
 
410
424
        """See RepositoryFormat.get_format_description()."""
411
425
        return "Knit repository format 1"
412
426
 
413
 
    def check_conversion_target(self, target_format):
414
 
        pass
415
 
 
416
427
 
417
428
class RepositoryFormatKnit3(RepositoryFormatKnit):
418
429
    """Bzr repository knit format 3.
446
457
 
447
458
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
448
459
 
449
 
    def check_conversion_target(self, target_format):
450
 
        if not target_format.rich_root_data:
451
 
            raise errors.BadConversionTarget(
452
 
                'Does not support rich root data.', target_format)
453
 
        if not getattr(target_format, 'supports_tree_reference', False):
454
 
            raise errors.BadConversionTarget(
455
 
                'Does not support nested trees', target_format)
456
 
            
457
460
    def get_format_string(self):
458
461
        """See RepositoryFormat.get_format_string()."""
459
462
        return "Bazaar Knit Repository Format 3 (bzr 0.15)\n"
495
498
 
496
499
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
497
500
 
498
 
    def check_conversion_target(self, target_format):
499
 
        if not target_format.rich_root_data:
500
 
            raise errors.BadConversionTarget(
501
 
                'Does not support rich root data.', target_format)
502
 
 
503
501
    def get_format_string(self):
504
502
        """See RepositoryFormat.get_format_string()."""
505
503
        return 'Bazaar Knit Repository Format 4 (bzr 1.0)\n'