~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-15 13:49:38 UTC
  • mfrom: (6060.3.1 fix-last-revno-args)
  • Revision ID: pqm@pqm.ubuntu.com-20110815134938-4fuo63g4v2hj8jdt
(jelmer) Cope with the localhost having the name 'localhost' when running
 the test suite. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
from bzrlib.trace import mutter, mutter_callsite, note, is_quiet
67
67
 
68
68
 
69
 
BZR_BRANCH_FORMAT_4 = "Bazaar-NG branch, format 0.0.4\n"
70
 
BZR_BRANCH_FORMAT_5 = "Bazaar-NG branch, format 5\n"
71
 
BZR_BRANCH_FORMAT_6 = "Bazaar Branch Format 6 (bzr 0.15)\n"
72
 
 
73
 
 
74
69
class Branch(controldir.ControlComponent):
75
70
    """Branch holding a history of revisions.
76
71
 
513
508
        rev_iter = iter(merge_sorted_revisions)
514
509
        if start_revision_id is not None:
515
510
            for node in rev_iter:
516
 
                rev_id = node.key[-1]
 
511
                rev_id = node.key
517
512
                if rev_id != start_revision_id:
518
513
                    continue
519
514
                else:
525
520
        if stop_revision_id is None:
526
521
            # Yield everything
527
522
            for node in rev_iter:
528
 
                rev_id = node.key[-1]
 
523
                rev_id = node.key
529
524
                yield (rev_id, node.merge_depth, node.revno,
530
525
                       node.end_of_merge)
531
526
        elif stop_rule == 'exclude':
532
527
            for node in rev_iter:
533
 
                rev_id = node.key[-1]
 
528
                rev_id = node.key
534
529
                if rev_id == stop_revision_id:
535
530
                    return
536
531
                yield (rev_id, node.merge_depth, node.revno,
537
532
                       node.end_of_merge)
538
533
        elif stop_rule == 'include':
539
534
            for node in rev_iter:
540
 
                rev_id = node.key[-1]
 
535
                rev_id = node.key
541
536
                yield (rev_id, node.merge_depth, node.revno,
542
537
                       node.end_of_merge)
543
538
                if rev_id == stop_revision_id:
549
544
            ancestors = graph.find_unique_ancestors(start_revision_id,
550
545
                                                    [stop_revision_id])
551
546
            for node in rev_iter:
552
 
                rev_id = node.key[-1]
 
547
                rev_id = node.key
553
548
                if rev_id not in ancestors:
554
549
                    continue
555
550
                yield (rev_id, node.merge_depth, node.revno,
565
560
            reached_stop_revision_id = False
566
561
            revision_id_whitelist = []
567
562
            for node in rev_iter:
568
 
                rev_id = node.key[-1]
 
563
                rev_id = node.key
569
564
                if rev_id == left_parent:
570
565
                    # reached the left parent after the stop_revision
571
566
                    return
785
780
                                  other_branch=None):
786
781
        """See Branch.generate_revision_history"""
787
782
        graph = self.repository.get_graph()
 
783
        (last_revno, last_revid) = self.last_revision_info()
788
784
        known_revision_ids = [
789
 
            self.last_revision_info(),
 
785
            (last_revid, last_revno),
790
786
            (_mod_revision.NULL_REVISION, 0),
791
787
            ]
792
788
        if last_rev is not None:
1293
1289
            if repository_policy is not None:
1294
1290
                repository_policy.configure_branch(result)
1295
1291
            self.copy_content_into(result, revision_id=revision_id)
1296
 
            master_branch = self.get_master_branch()
1297
 
            if master_branch is None:
 
1292
            master_url = self.get_bound_location()
 
1293
            if master_url is None:
1298
1294
                result.set_parent(self.bzrdir.root_transport.base)
1299
1295
            else:
1300
 
                result.set_parent(master_branch.bzrdir.root_transport.base)
 
1296
                result.set_parent(master_url)
1301
1297
        finally:
1302
1298
            result.unlock()
1303
1299
        return result
1545
1541
        # For bzr native formats must_fetch is just the tip, and if_present_fetch
1546
1542
        # are the tags.
1547
1543
        must_fetch = set([self.last_revision()])
1548
 
        try:
1549
 
            if_present_fetch = set(self.tags.get_reverse_tag_dict())
1550
 
        except errors.TagsNotSupported:
1551
 
            if_present_fetch = set()
 
1544
        if_present_fetch = set()
 
1545
        c = self.get_config()
 
1546
        include_tags = c.get_user_option_as_bool('branch.fetch_tags',
 
1547
                                                 default=False)
 
1548
        if include_tags:
 
1549
            try:
 
1550
                if_present_fetch = set(self.tags.get_reverse_tag_dict())
 
1551
            except errors.TagsNotSupported:
 
1552
                pass
1552
1553
        must_fetch.discard(_mod_revision.NULL_REVISION)
1553
1554
        if_present_fetch.discard(_mod_revision.NULL_REVISION)
1554
1555
        return must_fetch, if_present_fetch
2942
2943
        # you can always ask for the URL; but you might not be able to use it
2943
2944
        # if the repo can't support stacking.
2944
2945
        ## self._check_stackable_repo()
2945
 
        stacked_url = self._get_config_location('stacked_on_location')
 
2946
        # stacked_on_location is only ever defined in branch.conf, so don't
 
2947
        # waste effort reading the whole stack of config files.
 
2948
        config = self.get_config()._get_branch_data_config()
 
2949
        stacked_url = self._get_config_location('stacked_on_location',
 
2950
            config=config)
2946
2951
        if stacked_url is None:
2947
2952
            raise errors.NotStacked(self)
2948
2953
        return stacked_url
3161
3166
 
3162
3167
 
3163
3168
class Converter7to8(object):
3164
 
    """Perform an in-place upgrade of format 6 to format 7"""
 
3169
    """Perform an in-place upgrade of format 7 to format 8"""
3165
3170
 
3166
3171
    def convert(self, branch):
3167
3172
        format = BzrBranchFormat8()
3340
3345
        if local and not bound_location:
3341
3346
            raise errors.LocalRequiresBoundBranch()
3342
3347
        master_branch = None
3343
 
        source_is_master = (self.source.user_url == bound_location)
 
3348
        source_is_master = False
 
3349
        if bound_location:
 
3350
            # bound_location comes from a config file, some care has to be
 
3351
            # taken to relate it to source.user_url
 
3352
            normalized = urlutils.normalize_url(bound_location)
 
3353
            try:
 
3354
                relpath = self.source.user_transport.relpath(normalized)
 
3355
                source_is_master = (relpath == '')
 
3356
            except (errors.PathNotChild, errors.InvalidURL):
 
3357
                source_is_master = False
3344
3358
        if not local and bound_location and not source_is_master:
3345
3359
            # not pulling from master, so we need to update master.
3346
3360
            master_branch = self.target.get_master_branch(possible_transports)