/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/git/refs.py

  • Committer: Jelmer Vernooij
  • Date: 2018-06-14 17:59:16 UTC
  • mto: This revision was merged to the branch mainline in revision 7065.
  • Revision ID: jelmer@jelmer.uk-20180614175916-a2e2xh5k533guq1x
Move breezy.plugins.git to breezy.git.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Conversion between refs and Bazaar revision pointers."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
from dulwich.refs import (
20
22
    ANNOTATED_TAG_SUFFIX,
21
23
    LOCAL_BRANCH_PREFIX,
31
33
    revision as _mod_revision,
32
34
    )
33
35
 
34
 
 
35
 
def is_tag(x):
36
 
    return x.startswith(LOCAL_TAG_PREFIX)
37
 
 
38
 
 
39
 
def is_head(x):
40
 
    return x.startswith(LOCAL_BRANCH_PREFIX)
41
 
 
42
 
 
43
 
def is_peeled(x):
44
 
    return x.endswith(ANNOTATED_TAG_SUFFIX)
 
36
is_tag = lambda x: x.startswith(LOCAL_TAG_PREFIX)
 
37
is_head = lambda x: x.startswith(LOCAL_BRANCH_PREFIX)
 
38
is_peeled = lambda x: x.endswith(ANNOTATED_TAG_SUFFIX)
45
39
 
46
40
 
47
41
def gather_peeled(refs):
50
44
        if is_peeled(k):
51
45
            continue
52
46
        try:
53
 
            peeled = refs[k + ANNOTATED_TAG_SUFFIX]
 
47
            peeled = refs[k+ANNOTATED_TAG_SUFFIX]
54
48
            unpeeled = v
55
49
        except KeyError:
56
50
            peeled = v
93
87
    if ref is None:
94
88
        return ref
95
89
    if ref.startswith(LOCAL_BRANCH_PREFIX):
96
 
        return ref[len(LOCAL_BRANCH_PREFIX):].decode('utf-8')
 
90
        return osutils.safe_unicode(ref[len(LOCAL_BRANCH_PREFIX):])
97
91
    raise ValueError("unable to map ref %s back to branch name" % ref)
98
92
 
99
93
 
113
107
        return {}
114
108
 
115
109
    def set_symbolic_ref(self, name, other):
116
 
        if name == b"HEAD":
117
 
            pass  # FIXME: Switch default branch
 
110
        if name == "HEAD":
 
111
            pass # FIXME: Switch default branch
118
112
        else:
119
113
            raise NotImplementedError(
120
114
                "Symbolic references not supported for anything other than "
175
169
        try:
176
170
            branch_name = ref_to_branch_name(ref)
177
171
        except ValueError:
178
 
            return  # FIXME: Cope with tags!
 
172
            return # FIXME: Cope with tags!
179
173
        self.dir.destroy_branch(branch_name)
180
174
 
181
175
    def __setitem__(self, ref, sha):
210
204
        else:
211
205
            base[k] = v
212
206
            peeled[k] = v
213
 
    all_keys = set().union(base.keys(), peeled.keys())
214
 
    for n in all_keys:
 
207
    for n in set(base.keys() + peeled.keys()):
215
208
        try:
216
209
            tag_name = ref_to_tag_name(n)
217
210
        except ValueError: