~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: John Arbash Meinel
  • Date: 2009-10-21 21:27:19 UTC
  • mto: This revision was merged to the branch mainline in revision 4771.
  • Revision ID: john@arbash-meinel.com-20091021212719-05zh4t7oo5kaird3
More cleanups and clarifications.

Show diffs side-by-side

added added

removed removed

Lines of Context:
503
503
                left_parent = stop_rev.parent_ids[0]
504
504
            else:
505
505
                left_parent = _mod_revision.NULL_REVISION
506
 
            # left_parent is the actual revision we want to stop logging at,
507
 
            # since we want to show the merged revisions after the stop_rev too
508
 
            reached_stop_revision_id = False
509
 
            revision_id_whitelist = []
510
506
            for node in rev_iter:
511
507
                rev_id = node.key[-1]
512
508
                if rev_id == left_parent:
513
 
                    # reached the left parent after the stop_revision
514
509
                    return
515
 
                if (not reached_stop_revision_id or
516
 
                        rev_id in revision_id_whitelist):
517
 
                    yield (rev_id, node.merge_depth, node.revno,
 
510
                yield (rev_id, node.merge_depth, node.revno,
518
511
                       node.end_of_merge)
519
 
                    if reached_stop_revision_id or rev_id == stop_revision_id:
520
 
                        # only do the merged revs of rev_id from now on
521
 
                        rev = self.repository.get_revision(rev_id)
522
 
                        if rev.parent_ids:
523
 
                            reached_stop_revision_id = True
524
 
                            revision_id_whitelist.extend(rev.parent_ids)
525
512
        else:
526
513
            raise ValueError('invalid stop_rule %r' % stop_rule)
527
514
 
1103
1090
        params = ChangeBranchTipParams(
1104
1091
            self, old_revno, new_revno, old_revid, new_revid)
1105
1092
        for hook in hooks:
1106
 
            hook(params)
 
1093
            try:
 
1094
                hook(params)
 
1095
            except errors.TipChangeRejected:
 
1096
                raise
 
1097
            except Exception:
 
1098
                exc_info = sys.exc_info()
 
1099
                hook_name = Branch.hooks.get_hook_name(hook)
 
1100
                raise errors.HookFailed(
 
1101
                    'pre_change_branch_tip', hook_name, exc_info)
1107
1102
 
1108
1103
    @needs_write_lock
1109
1104
    def update(self):
1290
1285
        # clone call. Or something. 20090224 RBC/spiv.
1291
1286
        if revision_id is None:
1292
1287
            revision_id = self.last_revision()
1293
 
        dir_to = self.bzrdir.clone_on_transport(to_transport,
1294
 
            revision_id=revision_id, stacked_on=stacked_on,
1295
 
            create_prefix=create_prefix, use_existing_dir=use_existing_dir)
 
1288
        try:
 
1289
            dir_to = self.bzrdir.clone_on_transport(to_transport,
 
1290
                revision_id=revision_id, stacked_on=stacked_on,
 
1291
                create_prefix=create_prefix, use_existing_dir=use_existing_dir)
 
1292
        except errors.FileExists:
 
1293
            if not use_existing_dir:
 
1294
                raise
 
1295
        except errors.NoSuchFile:
 
1296
            if not create_prefix:
 
1297
                raise
1296
1298
        return dir_to.open_branch()
1297
1299
 
1298
1300
    def create_checkout(self, to_location, revision_id=None,
1438
1440
        """Return the format for the branch object in a_bzrdir."""
1439
1441
        try:
1440
1442
            transport = a_bzrdir.get_branch_transport(None)
1441
 
            format_string = transport.get_bytes("format")
 
1443
            format_string = transport.get("format").read()
1442
1444
            return klass._formats[format_string]
1443
1445
        except errors.NoSuchFile:
1444
 
            raise errors.NotBranchError(path=transport.base, bzrdir=a_bzrdir)
 
1446
            raise errors.NotBranchError(path=transport.base)
1445
1447
        except KeyError:
1446
1448
            raise errors.UnknownFormatError(format=format_string, kind='branch')
1447
1449
 
1796
1798
                              _repository=a_bzrdir.find_repository(),
1797
1799
                              ignore_fallbacks=ignore_fallbacks)
1798
1800
        except errors.NoSuchFile:
1799
 
            raise errors.NotBranchError(path=transport.base, bzrdir=a_bzrdir)
 
1801
            raise errors.NotBranchError(path=transport.base)
1800
1802
 
1801
1803
    def __init__(self):
1802
1804
        super(BranchFormatMetadir, self).__init__()
1977
1979
    def get_reference(self, a_bzrdir):
1978
1980
        """See BranchFormat.get_reference()."""
1979
1981
        transport = a_bzrdir.get_branch_transport(None)
1980
 
        return transport.get_bytes('location')
 
1982
        return transport.get('location').read()
1981
1983
 
1982
1984
    def set_reference(self, a_bzrdir, to_branch):
1983
1985
        """See BranchFormat.set_reference()."""
2135
2137
        # All-in-one needs to always unlock/lock.
2136
2138
        repo_control = getattr(self.repository, 'control_files', None)
2137
2139
        if self.control_files == repo_control or not self.is_locked():
2138
 
            self.repository._warn_if_deprecated(self)
2139
2140
            self.repository.lock_write()
2140
2141
            took_lock = True
2141
2142
        else:
2153
2154
        # All-in-one needs to always unlock/lock.
2154
2155
        repo_control = getattr(self.repository, 'control_files', None)
2155
2156
        if self.control_files == repo_control or not self.is_locked():
2156
 
            self.repository._warn_if_deprecated(self)
2157
2157
            self.repository.lock_read()
2158
2158
            took_lock = True
2159
2159
        else: