/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/branch.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-22 00:56:52 UTC
  • mfrom: (6621.2.26 py3_pokes)
  • Revision ID: jelmer@jelmer.uk-20170522005652-yjahcr9hwmjkno7n
Merge Python3 porting work ('py3 pokes')

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import breezy.bzrdir
20
20
 
21
 
from cStringIO import StringIO
22
 
 
23
 
from breezy.lazy_import import lazy_import
 
21
from .lazy_import import lazy_import
24
22
lazy_import(globals(), """
25
23
import itertools
26
24
from breezy import (
53
51
# is guaranteed to be registered.
54
52
import breezy.bzrdir
55
53
 
56
 
from breezy import (
 
54
from . import (
57
55
    bzrdir,
58
56
    controldir,
 
57
    registry,
59
58
    )
60
 
from breezy.decorators import (
 
59
from .decorators import (
61
60
    needs_read_lock,
62
61
    needs_write_lock,
63
62
    only_raises,
64
63
    )
65
 
from breezy.hooks import Hooks
66
 
from breezy.inter import InterObject
67
 
from breezy.lock import _RelockDebugMixin, LogicalLockResult
68
 
from breezy import registry
69
 
from breezy.symbol_versioning import (
 
64
from .hooks import Hooks
 
65
from .inter import InterObject
 
66
from .lock import _RelockDebugMixin, LogicalLockResult
 
67
from .sixish import (
 
68
    BytesIO,
 
69
    )
 
70
from .symbol_versioning import (
70
71
    deprecated_in,
71
72
    deprecated_method,
72
73
    )
73
 
from breezy.trace import mutter, mutter_callsite, note, is_quiet
 
74
from .trace import mutter, mutter_callsite, note, is_quiet
74
75
 
75
76
 
76
77
class Branch(controldir.ControlComponent):
303
304
                if master is not None:
304
305
                    # return the master branch value
305
306
                    return master.nick
306
 
            except errors.RecursiveBind, e:
 
307
            except errors.RecursiveBind as e:
307
308
                raise e
308
 
            except errors.BzrError, e:
 
309
            except errors.BzrError as e:
309
310
                # Silently fall back to local implicit nick if the master is
310
311
                # unavailable
311
312
                mutter("Could not connect to bound branch, "
1139
1140
            parent = urlutils.local_path_to_url(parent.decode('utf8'))
1140
1141
        try:
1141
1142
            return urlutils.join(self.base[:-1], parent)
1142
 
        except errors.InvalidURLJoin, e:
 
1143
        except errors.InvalidURLJoin as e:
1143
1144
            raise errors.InaccessibleParent(parent, self.user_url)
1144
1145
 
1145
1146
    def _get_parent_location(self):
1538
1539
        :returns: One of: 'a_descends_from_b', 'b_descends_from_a', 'diverged'
1539
1540
        """
1540
1541
        heads = graph.heads([revision_a, revision_b])
1541
 
        if heads == set([revision_b]):
 
1542
        if heads == {revision_b}:
1542
1543
            return 'b_descends_from_a'
1543
 
        elif heads == set([revision_a, revision_b]):
 
1544
        elif heads == {revision_a, revision_b}:
1544
1545
            # These branches have diverged
1545
1546
            return 'diverged'
1546
 
        elif heads == set([revision_a]):
 
1547
        elif heads == {revision_a}:
1547
1548
            return 'a_descends_from_b'
1548
1549
        else:
1549
1550
            raise AssertionError("invalid heads: %r" % (heads,))
1559
1560
        """
1560
1561
        # For bzr native formats must_fetch is just the tip, and
1561
1562
        # if_present_fetch are the tags.
1562
 
        must_fetch = set([self.last_revision()])
 
1563
        must_fetch = {self.last_revision()}
1563
1564
        if_present_fetch = set()
1564
1565
        if self.get_config_stack().get('branch.fetch_tags'):
1565
1566
            try:
2425
2426
            return
2426
2427
        if branch._transport.has('stored-transform'):
2427
2428
            raise errors.ChangesAlreadyStored
2428
 
        transform = StringIO()
 
2429
        transform = BytesIO()
2429
2430
        creator.write_shelf(transform)
2430
2431
        transform.seek(0)
2431
2432
        branch._transport.put_file('stored-transform', transform)
2612
2613
        try:
2613
2614
            return Branch.open(bound_loc,
2614
2615
                               possible_transports=possible_transports)
2615
 
        except (errors.NotBranchError, errors.ConnectionError), e:
 
2616
        except (errors.NotBranchError, errors.ConnectionError) as e:
2616
2617
            raise errors.BoundBranchConnectionFailure(
2617
2618
                    self, bound_loc, e)
2618
2619
 
2749
2750
 
2750
2751
        :param info_dict: A dict of {file_id: (tree_path, branch_location)}
2751
2752
        """
2752
 
        s = StringIO()
 
2753
        s = BytesIO()
2753
2754
        writer = rio.RioWriter(s)
2754
2755
        for key, (tree_path, branch_location) in info_dict.iteritems():
2755
2756
            stanza = rio.Stanza(file_id=key, tree_path=tree_path,
2900
2901
        except ValueError:
2901
2902
            try:
2902
2903
                self._extend_partial_history(stop_revision=revision_id)
2903
 
            except errors.RevisionNotPresent, e:
 
2904
            except errors.RevisionNotPresent as e:
2904
2905
                raise errors.GhostRevisionsHaveNoRevno(revision_id, e.revision_id)
2905
2906
            index = len(self._partial_revision_history_cache) - 1
2906
2907
            if index < 0:
3200
3201
        self.source._synchronize_history(self.target, revision_id)
3201
3202
        try:
3202
3203
            parent = self.source.get_parent()
3203
 
        except errors.InaccessibleParent, e:
 
3204
        except errors.InaccessibleParent as e:
3204
3205
            mutter('parent was not accessible to copy: %s', e)
3205
3206
        else:
3206
3207
            if parent: