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

  • Committer: Jelmer Vernooij
  • Date: 2010-05-13 12:34:24 UTC
  • mto: (0.200.912 trunk)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@samba.org-20100513123424-c1sk9vcg2ekrcsol
Some refactoring, support proper file ids in revision deltas.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    for k,v in refs.iteritems():
36
36
        if k.startswith("refs/tags/") and not k.endswith("^{}"):
37
37
            v = refs.get(k+"^{}", v)
38
 
            try:
39
 
                tagname = ref_to_tag_name(k)
40
 
            except UnicodeDecodeError:
41
 
                pass
42
 
            else:
43
 
                ret[tagname] = v
 
38
            ret[k[len("refs/tags/"):]] = v
44
39
    return ret
45
40
 
46
41
 
53
48
    if name is None:
54
49
        return default
55
50
    if name == "HEAD":
56
 
        return name
 
51
        return "HEAD"
57
52
    if not name.startswith("refs/"):
58
53
        return "refs/heads/%s" % name
59
54
    else:
75
70
    :param ref: Ref
76
71
    :return: A branch name
77
72
    """
78
 
    if ref in (None, "HEAD"):
79
 
        return ref
 
73
    if ref == "HEAD":
 
74
        return "HEAD"
80
75
    if ref.startswith("refs/heads/"):
81
76
        return ref[len("refs/heads/"):]
82
77
    raise ValueError("unable to map ref %s back to branch name" % ref)
84
79
 
85
80
def ref_to_tag_name(ref):
86
81
    if ref.startswith("refs/tags/"):
87
 
        return ref[len('refs/tags/'):].decode("utf-8")
 
82
        return ref[len('refs/tags/'):]
88
83
    raise ValueError("unable to map ref %s back to branch name" % ref)
89
84
 
90
85
 
115
110
        try:
116
111
            branch = self.dir.open_branch(branch_name)
117
112
        except errors.NoColocatedBranchSupport:
118
 
            if branch_name in ("HEAD", "master"):
119
 
                branch = self.dir.open_branch()
120
 
            else:
121
 
                raise
 
113
            raise
122
114
        return branch.last_revision()
123
115
 
124
116
    def read_loose_ref(self, ref):
136
128
        for branch in self.dir.list_branches():
137
129
            repo = branch.repository
138
130
            if repo.has_revision(branch.last_revision()):
139
 
                ref = branch_name_to_ref(branch.name, "refs/heads/master")
140
 
                keys.add(ref)
141
 
                if branch.name is None:
142
 
                    keys.add("HEAD")
 
131
                keys.add(branch_name_to_ref(branch.name, "HEAD"))
143
132
            for tag_name, revid in branch.tags.get_tag_dict().iteritems():
144
133
                if repo.has_revision(revid):
145
134
                    keys.add(tag_name_to_ref(tag_name))