~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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 = []
506
510
            for node in rev_iter:
507
511
                rev_id = node.key[-1]
508
512
                if rev_id == left_parent:
 
513
                    # reached the left parent after the stop_revision
509
514
                    return
510
 
                yield (rev_id, node.merge_depth, node.revno,
 
515
                if (not reached_stop_revision_id or
 
516
                        rev_id in revision_id_whitelist):
 
517
                    yield (rev_id, node.merge_depth, node.revno,
511
518
                       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)
512
525
        else:
513
526
            raise ValueError('invalid stop_rule %r' % stop_rule)
514
527
 
1090
1103
        params = ChangeBranchTipParams(
1091
1104
            self, old_revno, new_revno, old_revid, new_revid)
1092
1105
        for hook in hooks:
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)
 
1106
            hook(params)
1102
1107
 
1103
1108
    @needs_write_lock
1104
1109
    def update(self):
1285
1290
        # clone call. Or something. 20090224 RBC/spiv.
1286
1291
        if revision_id is None:
1287
1292
            revision_id = self.last_revision()
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
 
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)
1298
1296
        return dir_to.open_branch()
1299
1297
 
1300
1298
    def create_checkout(self, to_location, revision_id=None,
1440
1438
        """Return the format for the branch object in a_bzrdir."""
1441
1439
        try:
1442
1440
            transport = a_bzrdir.get_branch_transport(None)
1443
 
            format_string = transport.get("format").read()
 
1441
            format_string = transport.get_bytes("format")
1444
1442
            return klass._formats[format_string]
1445
1443
        except errors.NoSuchFile:
1446
 
            raise errors.NotBranchError(path=transport.base)
 
1444
            raise errors.NotBranchError(path=transport.base, bzrdir=a_bzrdir)
1447
1445
        except KeyError:
1448
1446
            raise errors.UnknownFormatError(format=format_string, kind='branch')
1449
1447
 
1798
1796
                              _repository=a_bzrdir.find_repository(),
1799
1797
                              ignore_fallbacks=ignore_fallbacks)
1800
1798
        except errors.NoSuchFile:
1801
 
            raise errors.NotBranchError(path=transport.base)
 
1799
            raise errors.NotBranchError(path=transport.base, bzrdir=a_bzrdir)
1802
1800
 
1803
1801
    def __init__(self):
1804
1802
        super(BranchFormatMetadir, self).__init__()
1979
1977
    def get_reference(self, a_bzrdir):
1980
1978
        """See BranchFormat.get_reference()."""
1981
1979
        transport = a_bzrdir.get_branch_transport(None)
1982
 
        return transport.get('location').read()
 
1980
        return transport.get_bytes('location')
1983
1981
 
1984
1982
    def set_reference(self, a_bzrdir, to_branch):
1985
1983
        """See BranchFormat.set_reference()."""
2137
2135
        # All-in-one needs to always unlock/lock.
2138
2136
        repo_control = getattr(self.repository, 'control_files', None)
2139
2137
        if self.control_files == repo_control or not self.is_locked():
 
2138
            self.repository._warn_if_deprecated(self)
2140
2139
            self.repository.lock_write()
2141
2140
            took_lock = True
2142
2141
        else:
2154
2153
        # All-in-one needs to always unlock/lock.
2155
2154
        repo_control = getattr(self.repository, 'control_files', None)
2156
2155
        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: