bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
| 0.200.208
by Jelmer Vernooij Add dummy Repository.texts. | 1 | # Copyright (C) 2009 Jelmer Vernooij <jelmer@samba.org>
 | 
| 2 | ||
| 3 | # This program is free software; you can redistribute it and/or modify
 | |
| 4 | # it under the terms of the GNU General Public License as published by
 | |
| 5 | # the Free Software Foundation; either version 2 of the License, or
 | |
| 6 | # (at your option) any later version.
 | |
| 7 | #
 | |
| 8 | # This program is distributed in the hope that it will be useful,
 | |
| 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
 | |
| 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | |
| 11 | # GNU General Public License for more details.
 | |
| 12 | #
 | |
| 13 | # You should have received a copy of the GNU General Public License
 | |
| 14 | # along with this program; if not, write to the Free Software
 | |
| 15 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | |
| 16 | ||
| 0.200.320
by Jelmer Vernooij Handle lightweight checkouts. | 17 | from dulwich.object_store import ( | 
| 18 | tree_lookup_path, | |
| 19 |     )
 | |
| 20 | from dulwich.objects import ( | |
| 21 | Blob, | |
| 0.200.506
by Jelmer Vernooij Remove bzr-foreign. | 22 | Commit, | 
| 0.200.320
by Jelmer Vernooij Handle lightweight checkouts. | 23 | Tree, | 
| 24 |     )
 | |
| 25 | ||
| 0.200.974
by Jelmer Vernooij Provide VersionedFiles.get_annotator. | 26 | from bzrlib import ( | 
| 27 | annotate, | |
| 28 |     )
 | |
| 29 | ||
| 0.200.292
by Jelmer Vernooij Fix formatting. | 30 | from bzrlib.versionedfile import ( | 
| 31 | AbsentContentFactory, | |
| 0.200.851
by Jelmer Vernooij Use blob.chunked. | 32 | ChunkedContentFactory, | 
| 0.200.292
by Jelmer Vernooij Fix formatting. | 33 | VersionedFiles, | 
| 34 |     )
 | |
| 0.200.208
by Jelmer Vernooij Add dummy Repository.texts. | 35 | |
| 0.230.2
by Jelmer Vernooij Fix versionedfiles. | 36 | |
| 0.200.506
by Jelmer Vernooij Remove bzr-foreign. | 37 | class GitRevisions(VersionedFiles): | 
| 38 | ||
| 0.200.649
by Jelmer Vernooij Make GitRevisions VF implementation behave as the interface expects. | 39 | def __init__(self, repository, object_store): | 
| 40 | self.repository = repository | |
| 0.200.506
by Jelmer Vernooij Remove bzr-foreign. | 41 | self.object_store = object_store | 
| 42 | ||
| 43 | def check(self, progressbar=None): | |
| 44 | return True | |
| 45 | ||
| 0.200.974
by Jelmer Vernooij Provide VersionedFiles.get_annotator. | 46 | def get_annotator(self): | 
| 47 | return annotate.Annotator(self) | |
| 48 | ||
| 0.200.506
by Jelmer Vernooij Remove bzr-foreign. | 49 | def iterkeys(self): | 
| 50 | for sha in self.object_store: | |
| 51 | if type(sha) == Commit: | |
| 52 | yield (sha,) | |
| 53 | ||
| 54 | def keys(self): | |
| 55 | return list(self.iterkeys()) | |
| 56 | ||
| 57 | def add_mpdiffs(self, records): | |
| 58 | raise NotImplementedError(self.add_mpdiffs) | |
| 59 | ||
| 60 | def get_record_stream(self, keys, ordering, include_delta_closure): | |
| 61 | for key in keys: | |
| 0.200.649
by Jelmer Vernooij Make GitRevisions VF implementation behave as the interface expects. | 62 | (revid,) = key | 
| 0.200.650
by Jelmer Vernooij Use standard names for lookup functions. | 63 | (commit_id, mapping) = self.repository.lookup_bzr_revision_id(revid) | 
| 0.200.506
by Jelmer Vernooij Remove bzr-foreign. | 64 | try: | 
| 0.200.649
by Jelmer Vernooij Make GitRevisions VF implementation behave as the interface expects. | 65 | commit = self.object_store[commit_id] | 
| 0.200.506
by Jelmer Vernooij Remove bzr-foreign. | 66 | except KeyError: | 
| 67 | yield AbsentContentFactory(key) | |
| 68 | else: | |
| 0.200.851
by Jelmer Vernooij Use blob.chunked. | 69 | yield ChunkedContentFactory(key, | 
| 0.200.650
by Jelmer Vernooij Use standard names for lookup functions. | 70 | tuple([(self.repository.lookup_foreign_revision_id(p, mapping),) for p in commit.parents]), None, | 
| 0.200.851
by Jelmer Vernooij Use blob.chunked. | 71 | commit.as_raw_chunks()) | 
| 0.200.506
by Jelmer Vernooij Remove bzr-foreign. | 72 | |
| 73 | def get_parent_map(self, keys): | |
| 74 | ret = {} | |
| 0.200.649
by Jelmer Vernooij Make GitRevisions VF implementation behave as the interface expects. | 75 | for (revid,) in keys: | 
| 0.200.650
by Jelmer Vernooij Use standard names for lookup functions. | 76 | (commit_id, mapping) = self.repository.lookup_bzr_revision_id(revid) | 
| 0.200.506
by Jelmer Vernooij Remove bzr-foreign. | 77 | try: | 
| 0.200.650
by Jelmer Vernooij Use standard names for lookup functions. | 78 | ret[(revid,)] = [(self.repository.lookup_foreign_revision_id(p, mapping),) for p in self.object_store[commit_id].parents] | 
| 0.200.506
by Jelmer Vernooij Remove bzr-foreign. | 79 | except KeyError: | 
| 0.200.649
by Jelmer Vernooij Make GitRevisions VF implementation behave as the interface expects. | 80 | ret[(revid,)] = None | 
| 0.200.506
by Jelmer Vernooij Remove bzr-foreign. | 81 | return ret | 
| 82 | ||
| 83 | ||
| 0.200.208
by Jelmer Vernooij Add dummy Repository.texts. | 84 | class GitTexts(VersionedFiles): | 
| 0.200.320
by Jelmer Vernooij Handle lightweight checkouts. | 85 | """A texts VersionedFiles instance that is backed onto a Git object store.""" | 
| 0.200.208
by Jelmer Vernooij Add dummy Repository.texts. | 86 | |
| 0.200.209
by Jelmer Vernooij Pass repository object to versionedfiles. | 87 | def __init__(self, repository): | 
| 88 | self.repository = repository | |
| 0.200.320
by Jelmer Vernooij Handle lightweight checkouts. | 89 | self.object_store = self.repository._git.object_store | 
| 0.200.208
by Jelmer Vernooij Add dummy Repository.texts. | 90 | |
| 91 | def check(self, progressbar=None): | |
| 92 | return True | |
| 93 | ||
| 0.200.974
by Jelmer Vernooij Provide VersionedFiles.get_annotator. | 94 | def get_annotator(self): | 
| 95 | return annotate.Annotator(self) | |
| 96 | ||
| 0.200.208
by Jelmer Vernooij Add dummy Repository.texts. | 97 | def add_mpdiffs(self, records): | 
| 98 | raise NotImplementedError(self.add_mpdiffs) | |
| 99 | ||
| 100 | def get_record_stream(self, keys, ordering, include_delta_closure): | |
| 101 | for key in keys: | |
| 0.230.2
by Jelmer Vernooij Fix versionedfiles. | 102 | (fileid, revid) = key | 
| 0.200.650
by Jelmer Vernooij Use standard names for lookup functions. | 103 | (commit_id, mapping) = self.repository.lookup_bzr_revision_id(revid) | 
| 0.200.634
by Jelmer Vernooij Cope with slight changes in dulwich API. | 104 | root_tree = self.object_store[commit_id].tree | 
| 0.230.2
by Jelmer Vernooij Fix versionedfiles. | 105 | path = mapping.parse_file_id(fileid) | 
| 106 | try: | |
| 0.200.672
by Jelmer Vernooij Fix support for older versions of Dulwich. | 107 | obj = tree_lookup_path( | 
| 0.200.634
by Jelmer Vernooij Cope with slight changes in dulwich API. | 108 | self.object_store.__getitem__, root_tree, path) | 
| 0.200.672
by Jelmer Vernooij Fix support for older versions of Dulwich. | 109 | if isinstance(obj, tuple): | 
| 110 | (mode, item_id) = obj | |
| 111 | obj = self.object_store[item_id] | |
| 0.230.2
by Jelmer Vernooij Fix versionedfiles. | 112 | except KeyError: | 
| 0.200.320
by Jelmer Vernooij Handle lightweight checkouts. | 113 | yield AbsentContentFactory(key) | 
| 114 | else: | |
| 115 | if isinstance(obj, Tree): | |
| 0.200.851
by Jelmer Vernooij Use blob.chunked. | 116 | yield ChunkedContentFactory(key, None, None, []) | 
| 0.200.320
by Jelmer Vernooij Handle lightweight checkouts. | 117 | elif isinstance(obj, Blob): | 
| 0.200.851
by Jelmer Vernooij Use blob.chunked. | 118 | yield ChunkedContentFactory(key, None, None, obj.chunked) | 
| 0.200.320
by Jelmer Vernooij Handle lightweight checkouts. | 119 | else: | 
| 0.200.634
by Jelmer Vernooij Cope with slight changes in dulwich API. | 120 | raise AssertionError("file text resolved to %r" % obj) | 
| 0.200.208
by Jelmer Vernooij Add dummy Repository.texts. | 121 | |
| 122 | def get_parent_map(self, keys): | |
| 123 | raise NotImplementedError(self.get_parent_map) | |
| 124 |