~ubuntu-branches/ubuntu/raring/bzr-svn/raring

« back to all changes in this revision

Viewing changes to revmeta.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2010-07-30 23:14:36 UTC
  • mfrom: (1.1.28 upstream) (3.3.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100730231436-po8j0ibgjn2d6hy0
Tags: 1.0.3-1
* New upstream release.
 + Provides BranchConfig._get_change_editor. Closes: #572109
 + Supports more trunk layout levels. Closes: #573988
* Bump standards version to 3.9.1.
* Mark as supporting bzr 2.2.
* Suggest bzr-rewrite rather than bzr-rebase. LP: #481730

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    imap,
31
31
    )
32
32
from subvertpy import (
 
33
    NODE_DIR,
33
34
    properties,
34
35
    )
35
36
 
67
68
    svk_features_merged_since,
68
69
    SVN_PROP_SVK_MERGE,
69
70
    )
 
71
from bzrlib.plugins.svn.util import (
 
72
    ListBuildingIterator,
 
73
    )
70
74
 
71
75
# Maximum number of revisions to browse for a cached copy of the branch
72
76
# file properties
106
110
    from other known data before contacting the Subversions server.
107
111
    """
108
112
 
 
113
    __slots__ = ('repository', 'check_revprops', '_get_fileprops_fn',
 
114
                 '_log', 'branch_path', '_paths', 'revnum', '_revprops',
 
115
                 '_changed_fileprops', '_fileprops',
 
116
                 '_direct_lhs_parent_known', '_consider_bzr_fileprops',
 
117
                 '_consider_bzr_revprops', '_estimated_fileprop_ancestors',
 
118
                 'metaiterators', 'uuid', 'children',
 
119
                 '_direct_lhs_parent_revmeta', '_revprop_redirect_revnum')
 
120
 
109
121
    def __init__(self, repository, check_revprops, get_fileprops_fn, logwalker,
110
122
                 uuid, branch_path, revnum, paths, revprops,
111
123
                 changed_fileprops=None, fileprops=None,
218
230
            while (not lm.changes_branch_root() and lm._fileprops is None and
219
231
                   len(todo) < MAX_FILEPROP_SHARED):
220
232
                todo.add(lm)
221
 
                lm = lm.get_direct_lhs_parent_revmeta()
 
233
                nlm = lm.get_direct_lhs_parent_revmeta()
 
234
                assert nlm is not None, \
 
235
                        "no lhs parent revmeta found for %r" % lm
 
236
                lm = nlm
222
237
            if lm._fileprops is None:
223
238
                lm._fileprops = self._get_fileprops_fn(lm.branch_path,
224
 
                                                       lm.revnum)
 
239
                    lm.revnum)
225
240
            for r in todo:
226
241
                r._fileprops = lm._fileprops
227
242
        return self._fileprops
230
245
        """Get the revision properties set on the revision."""
231
246
        if self._revprops is None:
232
247
            self._revprops = self._log.revprop_list(self.revnum)
233
 
 
234
248
        return self._revprops
235
249
 
236
250
    def knows_changed_fileprops(self):
238
252
        if self._changed_fileprops is None:
239
253
            return False
240
254
        changed_fileprops = self.get_changed_fileprops()
241
 
        return isinstance(changed_fileprops, dict) or changed_fileprops.is_loaded
 
255
        return (isinstance(changed_fileprops, dict) or
 
256
                changed_fileprops.is_loaded)
242
257
 
243
258
    def knows_fileprops(self):
244
259
        """Check whether the file properties can be cheaply retrieved."""
305
320
                return self._direct_lhs_parent_revmeta
306
321
            except MetaHistoryIncomplete:
307
322
                pass
308
 
        iterator = self.repository._revmeta_provider.iter_reverse_branch_changes(self.branch_path,
309
 
            self.revnum, to_revnum=0, limit=0)
 
323
        iterator = self.repository._revmeta_provider.iter_reverse_branch_changes(
 
324
                self.branch_path, self.revnum, to_revnum=0, limit=0)
310
325
        firstrevmeta = iterator.next()
311
326
        assert self == firstrevmeta, "Expected %r got %r" % (self, firstrevmeta)
312
327
        try:
462
477
 
463
478
    def estimate_bzr_fileprop_ancestors(self):
464
479
        """Estimate how many ancestors with bzr fileprops this revision has.
465
 
 
466
480
        """
467
481
        return self._estimate_fileprop_ancestors("bzr:", estimate_bzr_ancestors)
468
482
 
519
533
        """Determine the Bazaar revision number for this revision.
520
534
 
521
535
        :param mapping: Mapping to use
 
536
        :return: Bazaar revision number
522
537
        """
523
538
        extra = 0
524
539
        total_hidden = None
544
559
    def get_rhs_parents(self, mapping):
545
560
        """Determine the right hand side parent ids for this revision.
546
561
 
 
562
        :param mapping:
547
563
        """
548
564
        return self._get_rhs_parents(mapping)
549
565
 
714
730
            mapping.import_text_revisions_revprops, {},
715
731
            self.consider_bzr_fileprops)
716
732
 
717
 
    def get_text_parents(self, mapping):
718
 
        """Return text revision override map for this revision."""
719
 
        return self._import_from_props(mapping,
720
 
            mapping.import_text_parents_fileprops,
721
 
            mapping.import_text_parents_revprops, {},
722
 
            self.consider_bzr_fileprops)
723
 
 
724
733
    def consider_bzr_revprops(self):
725
734
        """See if bzr revision properties should be checked at all.
726
735
 
797
806
class CachingRevisionMetadata(RevisionMetadata):
798
807
    """Wrapper around RevisionMetadata that stores some results in a cache."""
799
808
 
 
809
    __slots__ = ('base', '_revid_cache', '_revinfo_cache', '_revision_info',
 
810
                 '_original_mapping', '_original_mapping_set',
 
811
                 '_stored_lhs_parent_revid', '_parents_cache', 'paths')
 
812
 
800
813
    def __init__(self, repository, *args, **kwargs):
801
814
        self.base = super(CachingRevisionMetadata, self)
802
815
        self.base.__init__(repository, *args,
835
848
    def get_original_mapping(self):
836
849
        if self._original_mapping_set:
837
850
            return self._original_mapping
838
 
 
839
851
        try:
840
852
            self._original_mapping = self._revinfo_cache.get_original_mapping(
841
853
                self.get_foreign_revid())
913
925
    return mapping.revision_id_foreign_to_bzr((uuid, bp, revnum))
914
926
 
915
927
 
916
 
class ListBuildingIterator(object):
917
 
    """Simple iterator that iterates over a list, and calling an iterator
918
 
    once all items in the list have been iterated.
919
 
 
920
 
    The list may be updated while the iterator is running.
921
 
    """
922
 
 
923
 
    def __init__(self, base_list, it):
924
 
        self.base_list = base_list
925
 
        self.i = -1
926
 
        self.it = it
927
 
 
928
 
    def next(self):
929
 
        """Return the next item."""
930
 
        self.i+=1
931
 
        try:
932
 
            return self.base_list[self.i]
933
 
        except IndexError:
934
 
            return self.it()
935
 
 
936
 
 
937
928
class RevisionMetadataBranch(object):
938
929
    """Describes a Bazaar-like branch in a Subversion repository."""
939
930
 
 
931
    __slots__ = ('_revs', '_revnums', '_history_limit', '_revmeta_provider',
 
932
                 '_get_next')
 
933
 
940
934
    def __init__(self, revmeta_provider=None, history_limit=None):
941
935
        self._revs = []
942
936
        self._revnums = []
1160
1154
            deletes = []
1161
1155
 
1162
1156
            if paths == {}:
1163
 
                paths = {"": ("M", None, -1)}
 
1157
                paths = {"": ("M", None, -1, NODE_DIR)}
1164
1158
 
1165
1159
            # Find out what branches have changed
1166
1160
            for p in sorted(paths):
1205
1199
                yield "revision", revmeta
1206
1200
 
1207
1201
            # Apply reverse renames and the like for the next round
1208
 
            for new_name, old_name, old_rev in changes.apply_reverse_changes(
 
1202
            for new_name, old_name, old_rev, kind in changes.apply_reverse_changes(
1209
1203
                self._ancestors.keys(), paths):
1210
1204
                self._unusual.discard(new_name)
1211
1205
                if old_name is None:
1225
1219
 
1226
1220
            # Update the prefixes, if necessary
1227
1221
            if self._prefixes:
1228
 
                for new_name, old_name, old_rev in changes.apply_reverse_changes(
 
1222
                for new_name, old_name, old_rev, kind in changes.apply_reverse_changes(
1229
1223
                    self._prefixes, paths):
1230
1224
                    if old_name is None:
1231
1225
                        # Didn't exist previously, terminate prefix
1320
1314
        if self.in_cache(path, revnum):
1321
1315
            cached = self._revmeta_cache[path,revnum]
1322
1316
            if changes is not None:
1323
 
                cached.paths = changes
 
1317
                cached._paths = changes
1324
1318
            if cached._changed_fileprops is None:
1325
1319
                cached._changed_fileprops = changed_fileprops
1326
1320
            if cached._fileprops is None: