~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Martin Pool
  • Date: 2010-09-13 04:41:17 UTC
  • mfrom: (5417.1.2 scripts)
  • mto: This revision was merged to the branch mainline in revision 5426.
  • Revision ID: mbp@sourcefrog.net-20100913044117-2wmxp0ahf4ptz0uf
Merge ScriptRunner interaction support

Show diffs side-by-side

added added

removed removed

Lines of Context:
434
434
            else:
435
435
                # we don't need to commit this, because the caller already
436
436
                # determined that an existing revision of this file is
437
 
                # appropriate. If it's not being considered for committing then
 
437
                # appropriate. If its not being considered for committing then
438
438
                # it and all its parents to the root must be unaltered so
439
439
                # no-change against the basis.
440
440
                if ie.revision == self._new_revision_id:
756
756
                    # after iter_changes examines and decides it has changed,
757
757
                    # we will unconditionally record a new version even if some
758
758
                    # other process reverts it while commit is running (with
759
 
                    # the revert happening after iter_changes did its
 
759
                    # the revert happening after iter_changes did it's
760
760
                    # examination).
761
761
                    if change[7][1]:
762
762
                        entry.executable = True
945
945
        pointing to .bzr/repository.
946
946
    """
947
947
 
948
 
    # What class to use for a CommitBuilder. Often it's simpler to change this
 
948
    # What class to use for a CommitBuilder. Often its simpler to change this
949
949
    # in a Repository class subclass rather than to override
950
950
    # get_commit_builder.
951
951
    _commit_builder_class = CommitBuilder
2511
2511
            ancestors will be traversed.
2512
2512
        """
2513
2513
        graph = self.get_graph()
2514
 
        stop_revisions = (None, _mod_revision.NULL_REVISION)
2515
 
        return graph.iter_lefthand_ancestry(revision_id, stop_revisions)
 
2514
        next_id = revision_id
 
2515
        while True:
 
2516
            if next_id in (None, _mod_revision.NULL_REVISION):
 
2517
                return
 
2518
            try:
 
2519
                parents = graph.get_parent_map([next_id])[next_id]
 
2520
            except KeyError:
 
2521
                raise errors.RevisionNotPresent(next_id, self)
 
2522
            yield next_id
 
2523
            if len(parents) == 0:
 
2524
                return
 
2525
            else:
 
2526
                next_id = parents[0]
2516
2527
 
2517
2528
    def is_shared(self):
2518
2529
        """Return True if this repository is flagged as a shared repository."""
2619
2630
        types it should be a no-op that just returns.
2620
2631
 
2621
2632
        This stub method does not require a lock, but subclasses should use
2622
 
        @needs_write_lock as this is a long running call it's reasonable to
 
2633
        @needs_write_lock as this is a long running call its reasonable to
2623
2634
        implicitly lock for the user.
2624
2635
 
2625
2636
        :param hint: If not supplied, the whole repository is packed.
3842
3853
                basis_id, delta, current_revision_id, parents_parents)
3843
3854
            cache[current_revision_id] = parent_tree
3844
3855
 
3845
 
    def _fetch_batch(self, revision_ids, basis_id, cache):
 
3856
    def _fetch_batch(self, revision_ids, basis_id, cache, a_graph=None):
3846
3857
        """Fetch across a few revisions.
3847
3858
 
3848
3859
        :param revision_ids: The revisions to copy
3849
3860
        :param basis_id: The revision_id of a tree that must be in cache, used
3850
3861
            as a basis for delta when no other base is available
3851
3862
        :param cache: A cache of RevisionTrees that we can use.
 
3863
        :param a_graph: A Graph object to determine the heads() of the
 
3864
            rich-root data stream.
3852
3865
        :return: The revision_id of the last converted tree. The RevisionTree
3853
3866
            for it will be in cache
3854
3867
        """
3922
3935
        if root_keys_to_create:
3923
3936
            root_stream = _mod_fetch._new_root_data_stream(
3924
3937
                root_keys_to_create, self._revision_id_to_root_id, parent_map,
3925
 
                self.source)
 
3938
                self.source, graph=a_graph)
3926
3939
            to_texts.insert_record_stream(root_stream)
3927
3940
        to_texts.insert_record_stream(from_texts.get_record_stream(
3928
3941
            text_keys, self.target._format._fetch_order,
3985
3998
        cache[basis_id] = basis_tree
3986
3999
        del basis_tree # We don't want to hang on to it here
3987
4000
        hints = []
3988
 
        a_graph = None
 
4001
        if self._converting_to_rich_root and len(revision_ids) > 100:
 
4002
            a_graph = _mod_fetch._get_rich_root_heads_graph(self.source,
 
4003
                                                            revision_ids)
 
4004
        else:
 
4005
            a_graph = None
3989
4006
 
3990
4007
        for offset in range(0, len(revision_ids), batch_size):
3991
4008
            self.target.start_write_group()
3993
4010
                pb.update('Transferring revisions', offset,
3994
4011
                          len(revision_ids))
3995
4012
                batch = revision_ids[offset:offset+batch_size]
3996
 
                basis_id = self._fetch_batch(batch, basis_id, cache)
 
4013
                basis_id = self._fetch_batch(batch, basis_id, cache,
 
4014
                                             a_graph=a_graph)
3997
4015
            except:
3998
4016
                self.source._safe_to_return_from_cache = False
3999
4017
                self.target.abort_write_group()
4065
4083
            basis_id = first_rev.parent_ids[0]
4066
4084
            # only valid as a basis if the target has it
4067
4085
            self.target.get_revision(basis_id)
4068
 
            # Try to get a basis tree - if it's a ghost it will hit the
 
4086
            # Try to get a basis tree - if its a ghost it will hit the
4069
4087
            # NoSuchRevision case.
4070
4088
            basis_tree = self.source.revision_tree(basis_id)
4071
4089
        except (IndexError, errors.NoSuchRevision):