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.292
by Jelmer Vernooij
 Fix formatting.  | 
26  | 
from bzrlib.versionedfile import (  | 
27  | 
AbsentContentFactory,  | 
|
| 
0.230.2
by Jelmer Vernooij
 Fix versionedfiles.  | 
28  | 
FulltextContentFactory,  | 
| 
0.200.292
by Jelmer Vernooij
 Fix formatting.  | 
29  | 
VersionedFiles,  | 
30  | 
    )
 | 
|
| 
0.200.208
by Jelmer Vernooij
 Add dummy Repository.texts.  | 
31  | 
|
| 
0.230.2
by Jelmer Vernooij
 Fix versionedfiles.  | 
32  | 
|
| 
0.200.506
by Jelmer Vernooij
 Remove bzr-foreign.  | 
33  | 
class GitRevisions(VersionedFiles):  | 
34  | 
||
| 
0.200.649
by Jelmer Vernooij
 Make GitRevisions VF implementation behave as the interface expects.  | 
35  | 
def __init__(self, repository, object_store):  | 
36  | 
self.repository = repository  | 
|
| 
0.200.506
by Jelmer Vernooij
 Remove bzr-foreign.  | 
37  | 
self.object_store = object_store  | 
38  | 
||
39  | 
def check(self, progressbar=None):  | 
|
40  | 
return True  | 
|
41  | 
||
42  | 
def iterkeys(self):  | 
|
43  | 
for sha in self.object_store:  | 
|
44  | 
if type(sha) == Commit:  | 
|
45  | 
yield (sha,)  | 
|
46  | 
||
47  | 
def keys(self):  | 
|
48  | 
return list(self.iterkeys())  | 
|
49  | 
||
50  | 
def add_mpdiffs(self, records):  | 
|
51  | 
raise NotImplementedError(self.add_mpdiffs)  | 
|
52  | 
||
53  | 
def get_record_stream(self, keys, ordering, include_delta_closure):  | 
|
54  | 
for key in keys:  | 
|
| 
0.200.649
by Jelmer Vernooij
 Make GitRevisions VF implementation behave as the interface expects.  | 
55  | 
(revid,) = key  | 
| 
0.200.650
by Jelmer Vernooij
 Use standard names for lookup functions.  | 
56  | 
(commit_id, mapping) = self.repository.lookup_bzr_revision_id(revid)  | 
| 
0.200.506
by Jelmer Vernooij
 Remove bzr-foreign.  | 
57  | 
try:  | 
| 
0.200.649
by Jelmer Vernooij
 Make GitRevisions VF implementation behave as the interface expects.  | 
58  | 
commit = self.object_store[commit_id]  | 
| 
0.200.506
by Jelmer Vernooij
 Remove bzr-foreign.  | 
59  | 
except KeyError:  | 
60  | 
yield AbsentContentFactory(key)  | 
|
61  | 
else:  | 
|
| 
0.200.634
by Jelmer Vernooij
 Cope with slight changes in dulwich API.  | 
62  | 
yield FulltextContentFactory(key,  | 
| 
0.200.650
by Jelmer Vernooij
 Use standard names for lookup functions.  | 
63  | 
tuple([(self.repository.lookup_foreign_revision_id(p, mapping),) for p in commit.parents]), None,  | 
| 
0.200.634
by Jelmer Vernooij
 Cope with slight changes in dulwich API.  | 
64  | 
commit.as_raw_string())  | 
| 
0.200.506
by Jelmer Vernooij
 Remove bzr-foreign.  | 
65  | 
|
66  | 
def get_parent_map(self, keys):  | 
|
67  | 
ret = {}  | 
|
| 
0.200.649
by Jelmer Vernooij
 Make GitRevisions VF implementation behave as the interface expects.  | 
68  | 
for (revid,) in keys:  | 
| 
0.200.650
by Jelmer Vernooij
 Use standard names for lookup functions.  | 
69  | 
(commit_id, mapping) = self.repository.lookup_bzr_revision_id(revid)  | 
| 
0.200.506
by Jelmer Vernooij
 Remove bzr-foreign.  | 
70  | 
try:  | 
| 
0.200.650
by Jelmer Vernooij
 Use standard names for lookup functions.  | 
71  | 
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.  | 
72  | 
except KeyError:  | 
| 
0.200.649
by Jelmer Vernooij
 Make GitRevisions VF implementation behave as the interface expects.  | 
73  | 
ret[(revid,)] = None  | 
| 
0.200.506
by Jelmer Vernooij
 Remove bzr-foreign.  | 
74  | 
return ret  | 
75  | 
||
76  | 
||
| 
0.200.208
by Jelmer Vernooij
 Add dummy Repository.texts.  | 
77  | 
class GitTexts(VersionedFiles):  | 
| 
0.200.320
by Jelmer Vernooij
 Handle lightweight checkouts.  | 
78  | 
"""A texts VersionedFiles instance that is backed onto a Git object store."""  | 
| 
0.200.208
by Jelmer Vernooij
 Add dummy Repository.texts.  | 
79  | 
|
| 
0.200.209
by Jelmer Vernooij
 Pass repository object to versionedfiles.  | 
80  | 
def __init__(self, repository):  | 
81  | 
self.repository = repository  | 
|
| 
0.200.320
by Jelmer Vernooij
 Handle lightweight checkouts.  | 
82  | 
self.object_store = self.repository._git.object_store  | 
| 
0.200.208
by Jelmer Vernooij
 Add dummy Repository.texts.  | 
83  | 
|
84  | 
def check(self, progressbar=None):  | 
|
85  | 
return True  | 
|
86  | 
||
87  | 
def add_mpdiffs(self, records):  | 
|
88  | 
raise NotImplementedError(self.add_mpdiffs)  | 
|
89  | 
||
90  | 
def get_record_stream(self, keys, ordering, include_delta_closure):  | 
|
91  | 
for key in keys:  | 
|
| 
0.230.2
by Jelmer Vernooij
 Fix versionedfiles.  | 
92  | 
(fileid, revid) = key  | 
| 
0.200.650
by Jelmer Vernooij
 Use standard names for lookup functions.  | 
93  | 
(commit_id, mapping) = self.repository.lookup_bzr_revision_id(revid)  | 
| 
0.200.634
by Jelmer Vernooij
 Cope with slight changes in dulwich API.  | 
94  | 
root_tree = self.object_store[commit_id].tree  | 
| 
0.230.2
by Jelmer Vernooij
 Fix versionedfiles.  | 
95  | 
path = mapping.parse_file_id(fileid)  | 
96  | 
try:  | 
|
| 
0.200.634
by Jelmer Vernooij
 Cope with slight changes in dulwich API.  | 
97  | 
(mode, item_id) = tree_lookup_path(  | 
98  | 
self.object_store.__getitem__, root_tree, path)  | 
|
99  | 
obj = self.object_store[item_id]  | 
|
| 
0.230.2
by Jelmer Vernooij
 Fix versionedfiles.  | 
100  | 
except KeyError:  | 
| 
0.200.320
by Jelmer Vernooij
 Handle lightweight checkouts.  | 
101  | 
yield AbsentContentFactory(key)  | 
102  | 
else:  | 
|
103  | 
if isinstance(obj, Tree):  | 
|
104  | 
yield FulltextContentFactory(key, None, None, "")  | 
|
105  | 
elif isinstance(obj, Blob):  | 
|
| 
0.200.634
by Jelmer Vernooij
 Cope with slight changes in dulwich API.  | 
106  | 
yield FulltextContentFactory(key, None, None, obj.data)  | 
| 
0.200.320
by Jelmer Vernooij
 Handle lightweight checkouts.  | 
107  | 
else:  | 
| 
0.200.634
by Jelmer Vernooij
 Cope with slight changes in dulwich API.  | 
108  | 
raise AssertionError("file text resolved to %r" % obj)  | 
| 
0.200.208
by Jelmer Vernooij
 Add dummy Repository.texts.  | 
109  | 
|
110  | 
def get_parent_map(self, keys):  | 
|
111  | 
raise NotImplementedError(self.get_parent_map)  | 
|
112  |