/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

Don't peel tags automatically when pushing back.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Conversion between refs and Bazaar revision pointers."""
18
18
 
19
19
from collections import defaultdict
 
20
from cStringIO import StringIO
20
21
 
21
22
from dulwich.repo import (
22
23
    RefsContainer,
24
25
 
25
26
from bzrlib import (
26
27
    errors,
 
28
    trace,
27
29
    )
28
30
 
29
31
is_tag = lambda x: x.startswith("refs/tags/")
206
208
            for v in vs:
207
209
                f.write("%s: %s\n" % (k, v))
208
210
 
 
211
    def save_in_repository(self, repository):
 
212
        f = StringIO()
 
213
        try:
 
214
            self.save(f)
 
215
            f.seek(0)
 
216
            repository.control_transport.put_file("git-unpeel-map", f)
 
217
        finally:
 
218
            f.close()
 
219
 
209
220
    def re_unpeel_tag(self, new_git_sha, old_git_sha):
210
221
        """Re-unpeel tags.
211
222
 
212
223
        Bazaar can't store unpeeled refs so in order to prevent peeling
213
224
        existing tags when pushing they are "re-peeled" here.
214
225
        """
215
 
        if old_git_sha in self._map[new_git_sha]:
 
226
        if old_git_sha is not None and old_git_sha in self._map[new_git_sha]:
 
227
            trace.mutter("re-unpeeling %r to %r", new_git_sha, old_git_sha)
216
228
            return old_git_sha
217
229
        return new_git_sha
218
230
 
219
 
 
220
 
def get_unpeel_map(repository):
221
 
    """Load the unpeel map for a repository.
222
 
    """
223
 
    m = UnpeelMap()
224
 
    try:
225
 
        m.load(repository.transport.get("git-unpeel-map"))
226
 
    except errors.NoSuchFile:
227
 
        pass
228
 
    return m
 
231
    @classmethod
 
232
    def from_repository(cls, repository):
 
233
        """Load the unpeel map for a repository.
 
234
        """
 
235
        m = UnpeelMap()
 
236
        try:
 
237
            m.load(repository.control_transport.get("git-unpeel-map"))
 
238
        except errors.NoSuchFile:
 
239
            pass
 
240
        return m