bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
1 |
# Copyright (C) 2008-2011 Jelmer Vernooij <jelmer@samba.org>
|
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
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.381
by Jelmer Vernooij
Support working trees properly, status and ls. |
17 |
|
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
18 |
"""An adapter between a Git index and a Bazaar Working Tree"""
|
19 |
||
|
0.200.381
by Jelmer Vernooij
Support working trees properly, status and ls. |
20 |
|
|
0.200.385
by Jelmer Vernooij
Cope with removed files. |
21 |
from cStringIO import ( |
22 |
StringIO, |
|
23 |
)
|
|
|
0.239.4
by Jelmer Vernooij
Cope with nonexistent files and directories in get_file_sha1. |
24 |
import errno |
|
0.200.1096
by Jelmer Vernooij
Implement GitWorkingTreeFormat.initialize. |
25 |
from dulwich.index import ( |
26 |
Index, |
|
27 |
)
|
|
|
0.200.383
by Jelmer Vernooij
Simplify, support rewriting index based on inventory. |
28 |
from dulwich.objects import ( |
29 |
Blob, |
|
|
0.200.948
by Jelmer Vernooij
Cope with empty inventories. |
30 |
ZERO_SHA, |
31 |
)
|
|
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
32 |
import os |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
33 |
import posixpath |
|
0.200.384
by Jelmer Vernooij
Fix reading of inventory from index. |
34 |
import stat |
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
35 |
|
36 |
from bzrlib import ( |
|
|
0.200.382
by Jelmer Vernooij
Support flushing index. |
37 |
errors, |
|
0.262.1
by Jelmer Vernooij
Fix WorkingTree.conflicts(). |
38 |
conflicts as _mod_conflicts, |
|
0.200.409
by Jelmer Vernooij
Support parsing .gitignore. |
39 |
ignores, |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
40 |
inventory, |
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
41 |
lockable_files, |
42 |
lockdir, |
|
|
0.200.381
by Jelmer Vernooij
Support working trees properly, status and ls. |
43 |
osutils, |
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
44 |
transport, |
|
0.200.519
by Jelmer Vernooij
Move imports down, might not be available in older bzr-git versions. |
45 |
tree, |
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
46 |
workingtree, |
47 |
)
|
|
|
0.200.381
by Jelmer Vernooij
Support working trees properly, status and ls. |
48 |
from bzrlib.decorators import ( |
49 |
needs_read_lock, |
|
50 |
)
|
|
51 |
||
52 |
||
|
0.200.1096
by Jelmer Vernooij
Implement GitWorkingTreeFormat.initialize. |
53 |
from bzrlib.plugins.git.dir import ( |
54 |
LocalGitDir, |
|
55 |
)
|
|
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
56 |
from bzrlib.plugins.git.tree import ( |
|
0.200.622
by Jelmer Vernooij
Implement InterTree.iter_changes() as well. |
57 |
changes_from_git_changes, |
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
58 |
tree_delta_from_git_changes, |
59 |
)
|
|
|
0.200.971
by Chadrik
Fix 'bzr status' after 'bzr add' in native git working trees. |
60 |
from bzrlib.plugins.git.mapping import ( |
61 |
GitFileIdMap, |
|
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
62 |
mode_kind, |
|
0.200.971
by Chadrik
Fix 'bzr status' after 'bzr add' in native git working trees. |
63 |
)
|
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
64 |
|
|
0.200.409
by Jelmer Vernooij
Support parsing .gitignore. |
65 |
IGNORE_FILENAME = ".gitignore" |
66 |
||
67 |
||
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
68 |
class GitWorkingTree(workingtree.WorkingTree): |
69 |
"""A Git working tree.""" |
|
70 |
||
|
0.200.803
by Jelmer Vernooij
Default to non-bare repositories when initializing a control directory. |
71 |
def __init__(self, bzrdir, repo, branch, index): |
|
0.200.379
by Jelmer Vernooij
Re-enable working tree support. |
72 |
self.basedir = bzrdir.root_transport.local_abspath('.') |
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
73 |
self.bzrdir = bzrdir |
74 |
self.repository = repo |
|
|
0.200.384
by Jelmer Vernooij
Fix reading of inventory from index. |
75 |
self.mapping = self.repository.get_mapping() |
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
76 |
self._branch = branch |
77 |
self._transport = bzrdir.transport |
|
78 |
||
|
0.246.3
by Jelmer Vernooij
Simplify call to abspath, without involving private variables. |
79 |
self.controldir = self.bzrdir.transport.local_abspath('bzr') |
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
80 |
|
81 |
try: |
|
82 |
os.makedirs(self.controldir) |
|
83 |
os.makedirs(os.path.join(self.controldir, 'lock')) |
|
84 |
except OSError: |
|
85 |
pass
|
|
86 |
||
87 |
self._control_files = lockable_files.LockableFiles( |
|
88 |
transport.get_transport(self.controldir), 'lock', lockdir.LockDir) |
|
89 |
self._format = GitWorkingTreeFormat() |
|
|
0.200.803
by Jelmer Vernooij
Default to non-bare repositories when initializing a control directory. |
90 |
self.index = index |
|
0.200.239
by Jelmer Vernooij
Provide views. |
91 |
self.views = self._make_views() |
|
0.200.1173
by Jelmer Vernooij
Provide GitWorkingTree._rules_searcher. |
92 |
self._rules_searcher = None |
|
0.200.381
by Jelmer Vernooij
Support working trees properly, status and ls. |
93 |
self._detect_case_handling() |
|
0.200.173
by Jelmer Vernooij
Merge changes, open index. |
94 |
|
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
95 |
def _index_add_entry(self, path, file_id, kind): |
96 |
if kind == "directory": |
|
97 |
# Git indexes don't contain directories
|
|
98 |
return
|
|
99 |
if kind == "file": |
|
100 |
blob = Blob() |
|
101 |
try: |
|
102 |
file, stat_val = self.get_file_with_stat(file_id, path) |
|
103 |
except (errors.NoSuchFile, IOError): |
|
104 |
# TODO: Rather than come up with something here, use the old index
|
|
105 |
file = StringIO() |
|
106 |
from posix import stat_result |
|
107 |
stat_val = stat_result((stat.S_IFREG | 0644, 0, 0, 0, 0, 0, 0, 0, 0, 0)) |
|
108 |
blob.set_raw_string(file.read()) |
|
109 |
elif kind == "symlink": |
|
110 |
blob = Blob() |
|
111 |
try: |
|
112 |
stat_val = os.lstat(self.abspath(path)) |
|
113 |
except (errors.NoSuchFile, OSError): |
|
114 |
# TODO: Rather than come up with something here, use the
|
|
115 |
# old index
|
|
116 |
from posix import stat_result |
|
117 |
stat_val = stat_result((stat.S_IFLNK, 0, 0, 0, 0, 0, 0, 0, 0, 0)) |
|
118 |
blob.set_raw_string(self.get_symlink_target(file_id).encode("utf-8")) |
|
119 |
else: |
|
120 |
raise AssertionError("unknown kind '%s'" % kind) |
|
121 |
# Add object to the repository if it didn't exist yet
|
|
122 |
if not blob.id in self.repository._git.object_store: |
|
123 |
self.repository._git.object_store.add_object(blob) |
|
124 |
# Add an entry to the index or update the existing entry
|
|
125 |
flags = 0 # FIXME |
|
126 |
self.index[path.encode("utf-8")] = (stat_val.st_ctime, |
|
127 |
stat_val.st_mtime, stat_val.st_dev, stat_val.st_ino, |
|
128 |
stat_val.st_mode, stat_val.st_uid, stat_val.st_gid, |
|
129 |
stat_val.st_size, blob.id, flags) |
|
130 |
||
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
131 |
def unversion(self, file_ids): |
132 |
for file_id in file_ids: |
|
133 |
path = self.id2path(file_id) |
|
134 |
del self.index[path.encode("utf-8")] |
|
135 |
||
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
136 |
def _add(self, files, ids, kinds): |
137 |
for (path, file_id, kind) in zip(files, ids, kinds): |
|
138 |
self._index_add_entry(path, file_id, kind) |
|
|
0.200.1201
by Jelmer Vernooij
Implement _set_root_id. |
139 |
if file_id is not None: |
140 |
self._fileid_map.set_file_id(path, file_id) |
|
141 |
||
142 |
def _set_root_id(self, file_id): |
|
143 |
self._fileid_map.set_file_id("", file_id) |
|
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
144 |
|
|
0.200.1193
by Jelmer Vernooij
Implement GitWorkingTree.{move,rename_one}. |
145 |
def move(self, from_paths, to_dir=None, after=False): |
146 |
rename_tuples = [] |
|
147 |
to_abs = self.abspath(to_dir) |
|
148 |
if not os.path.isdir(to_abs): |
|
149 |
raise errors.BzrMoveFailedError('', to_dir, |
|
150 |
errors.NotADirectory(to_abs)) |
|
151 |
||
152 |
for from_rel in from_paths: |
|
153 |
from_tail = os.path.split(from_rel)[-1] |
|
154 |
to_rel = os.path.join(to_dir, from_tail) |
|
155 |
self.rename_one(from_rel, to_rel, after=after) |
|
156 |
rename_tuples.append((from_rel, to_rel)) |
|
157 |
return rename_tuples |
|
158 |
||
159 |
def rename_one(self, from_rel, to_rel, after=False): |
|
160 |
if not after: |
|
161 |
os.rename(self.abspath(from_rel), self.abspath(to_rel)) |
|
162 |
self.index[to_rel] = self.index[from_rel] |
|
163 |
del self.index[from_rel] |
|
164 |
||
|
0.264.1
by Jelmer Vernooij
Provide stubs using inventory for the moment.: |
165 |
def get_root_id(self): |
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
166 |
return self.path2id("") |
167 |
||
168 |
@needs_read_lock
|
|
169 |
def path2id(self, path): |
|
170 |
return self._fileid_map.lookup_file_id(path.encode("utf-8")) |
|
|
0.264.1
by Jelmer Vernooij
Provide stubs using inventory for the moment.: |
171 |
|
|
0.200.605
by Jelmer Vernooij
Ignore directories in WorkingTree.extras(). |
172 |
def extras(self): |
173 |
"""Yield all unversioned files in this WorkingTree. |
|
174 |
"""
|
|
|
0.200.615
by Jelmer Vernooij
Optimize WorkingTree.extras(). |
175 |
for (dirpath, dirnames, filenames) in os.walk(self.basedir): |
176 |
if self.bzrdir.is_control_filename(dirpath[len(self.basedir):].strip("/")): |
|
|
0.200.605
by Jelmer Vernooij
Ignore directories in WorkingTree.extras(). |
177 |
continue
|
|
0.200.615
by Jelmer Vernooij
Optimize WorkingTree.extras(). |
178 |
for filename in filenames: |
179 |
relpath = os.path.join(dirpath[len(self.basedir):].strip("/"), filename) |
|
180 |
if not relpath in self.index: |
|
|
0.200.605
by Jelmer Vernooij
Ignore directories in WorkingTree.extras(). |
181 |
yield relpath |
182 |
||
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
183 |
def unlock(self): |
|
0.200.224
by Jelmer Vernooij
Fix working tree locking. |
184 |
# non-implementation specific cleanup
|
185 |
self._cleanup() |
|
186 |
||
187 |
# reverse order of locking.
|
|
188 |
try: |
|
189 |
return self._control_files.unlock() |
|
190 |
finally: |
|
191 |
self.branch.unlock() |
|
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
192 |
|
|
0.200.382
by Jelmer Vernooij
Support flushing index. |
193 |
def flush(self): |
194 |
# TODO: Maybe this should only write on dirty ?
|
|
195 |
if self._control_files._lock_mode != 'w': |
|
196 |
raise errors.NotWriteLocked(self) |
|
|
0.200.385
by Jelmer Vernooij
Cope with removed files. |
197 |
self.index.write() |
|
0.200.382
by Jelmer Vernooij
Support flushing index. |
198 |
|
|
0.264.1
by Jelmer Vernooij
Provide stubs using inventory for the moment.: |
199 |
def __iter__(self): |
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
200 |
for path in self.index: |
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
201 |
yield self.path2id(path) |
|
0.264.1
by Jelmer Vernooij
Provide stubs using inventory for the moment.: |
202 |
|
|
0.200.1198
by Jelmer Vernooij
Implement GitWorkingTree.has_id. |
203 |
def has_id(self, file_id): |
204 |
try: |
|
205 |
self.id2path(file_id) |
|
206 |
except errors.NoSuchId: |
|
207 |
return False |
|
208 |
else: |
|
209 |
return True |
|
210 |
||
|
0.264.1
by Jelmer Vernooij
Provide stubs using inventory for the moment.: |
211 |
def id2path(self, file_id): |
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
212 |
if type(file_id) != str: |
213 |
raise AssertionError |
|
214 |
path = self._fileid_map.lookup_path(file_id) |
|
215 |
if path in self.index: |
|
216 |
return path |
|
217 |
raise errors.NoSuchId(None, file_id) |
|
|
0.264.1
by Jelmer Vernooij
Provide stubs using inventory for the moment.: |
218 |
|
|
0.200.1200
by Jelmer Vernooij
Support GitWorkingTree.get_file_mtime. |
219 |
def get_file_mtime(self, file_id, path=None): |
220 |
"""See Tree.get_file_mtime.""" |
|
221 |
if not path: |
|
222 |
path = self.id2path(file_id) |
|
223 |
return os.lstat(self.abspath(path)).st_mtime |
|
224 |
||
|
0.200.409
by Jelmer Vernooij
Support parsing .gitignore. |
225 |
def get_ignore_list(self): |
226 |
ignoreset = getattr(self, '_ignoreset', None) |
|
227 |
if ignoreset is not None: |
|
228 |
return ignoreset |
|
229 |
||
230 |
ignore_globs = set() |
|
231 |
ignore_globs.update(ignores.get_runtime_ignores()) |
|
232 |
ignore_globs.update(ignores.get_user_ignores()) |
|
233 |
if self.has_filename(IGNORE_FILENAME): |
|
234 |
f = self.get_file_byname(IGNORE_FILENAME) |
|
235 |
try: |
|
|
0.200.1198
by Jelmer Vernooij
Implement GitWorkingTree.has_id. |
236 |
# FIXME: Parse git file format, rather than assuming it's
|
237 |
# the same as for bzr's native formats.
|
|
|
0.200.409
by Jelmer Vernooij
Support parsing .gitignore. |
238 |
ignore_globs.update(ignores.parse_ignore_file(f)) |
239 |
finally: |
|
240 |
f.close() |
|
241 |
self._ignoreset = ignore_globs |
|
242 |
return ignore_globs |
|
243 |
||
|
0.200.508
by Jelmer Vernooij
Skip inventory caching bits. |
244 |
def set_last_revision(self, revid): |
245 |
self._change_last_revision(revid) |
|
246 |
||
|
0.200.379
by Jelmer Vernooij
Re-enable working tree support. |
247 |
def _reset_data(self): |
|
0.248.3
by Jelmer Vernooij
Handle working trees without valid HEAD branch. |
248 |
try: |
249 |
head = self.repository._git.head() |
|
250 |
except KeyError, name: |
|
251 |
raise errors.NotBranchError("branch %s at %s" % (name, self.repository.base)) |
|
|
0.252.33
by Jelmer Vernooij
Fix file id map lookups. |
252 |
store = self.repository._git.object_store |
|
0.200.948
by Jelmer Vernooij
Cope with empty inventories. |
253 |
if head == ZERO_SHA: |
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
254 |
self._fileid_map = GitFileIdMap({}, self.mapping) |
|
0.200.948
by Jelmer Vernooij
Cope with empty inventories. |
255 |
else: |
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
256 |
self._fileid_map = self.mapping.get_fileid_map(store.__getitem__, |
|
0.200.948
by Jelmer Vernooij
Cope with empty inventories. |
257 |
store[head].tree) |
|
0.200.379
by Jelmer Vernooij
Re-enable working tree support. |
258 |
|
|
0.200.381
by Jelmer Vernooij
Support working trees properly, status and ls. |
259 |
@needs_read_lock
|
260 |
def get_file_sha1(self, file_id, path=None, stat_value=None): |
|
261 |
if not path: |
|
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
262 |
path = self.id2path(file_id) |
|
0.239.4
by Jelmer Vernooij
Cope with nonexistent files and directories in get_file_sha1. |
263 |
try: |
264 |
return osutils.sha_file_by_name(self.abspath(path).encode(osutils._fs_enc)) |
|
265 |
except OSError, (num, msg): |
|
266 |
if num in (errno.EISDIR, errno.ENOENT): |
|
267 |
return None |
|
268 |
raise
|
|
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
269 |
|
|
0.200.610
by Jelmer Vernooij
Support retrieving basis tree properly. |
270 |
def revision_tree(self, revid): |
271 |
return self.repository.revision_tree(revid) |
|
272 |
||
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
273 |
def _get_dir_ie(self, path, parent_id): |
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
274 |
file_id = self.path2id(path) |
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
275 |
return inventory.InventoryDirectory(file_id, |
|
0.200.1190
by Jelmer Vernooij
Fix get_symlink_target call. |
276 |
posixpath.basename(path).strip("/"), parent_id) |
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
277 |
|
278 |
def _add_missing_parent_ids(self, path, dir_ids): |
|
279 |
if path in dir_ids: |
|
280 |
return [] |
|
281 |
parent = posixpath.dirname(path).strip("/") |
|
282 |
ret = self._add_missing_parent_ids(parent, dir_ids) |
|
283 |
parent_id = dir_ids[parent] |
|
284 |
ie = self._get_dir_ie(path, parent_id) |
|
285 |
dir_ids[path] = ie.file_id |
|
286 |
ret.append((path, ie)) |
|
287 |
return ret |
|
288 |
||
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
289 |
def _get_file_ie(self, path, value, parent_id): |
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
290 |
assert isinstance(path, unicode) |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
291 |
assert isinstance(value, tuple) and len(value) == 10 |
292 |
(ctime, mtime, dev, ino, mode, uid, gid, size, sha, flags) = value |
|
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
293 |
file_id = self.path2id(path) |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
294 |
if type(file_id) != str: |
295 |
raise AssertionError |
|
296 |
kind = mode_kind(mode) |
|
297 |
ie = inventory.entry_factory[kind](file_id, |
|
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
298 |
posixpath.basename(path), parent_id) |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
299 |
if kind == 'symlink': |
|
0.200.1190
by Jelmer Vernooij
Fix get_symlink_target call. |
300 |
ie.symlink_target = self.get_symlink_target(file_id) |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
301 |
else: |
302 |
data = self.get_file_text(file_id, path) |
|
303 |
ie.text_sha1 = osutils.sha_string(data) |
|
304 |
ie.text_size = len(data) |
|
305 |
ie.executable = self.is_executable(file_id, path) |
|
306 |
ie.revision = None |
|
307 |
return ie |
|
308 |
||
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
309 |
def _is_executable_from_path_and_stat_from_stat(self, path, stat_result): |
310 |
mode = stat_result.st_mode |
|
311 |
return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode) |
|
312 |
||
313 |
if not osutils.supports_executable(): |
|
314 |
def is_executable(self, file_id, path=None): |
|
315 |
basis_tree = self.basis_tree() |
|
316 |
if file_id in basis_tree: |
|
317 |
return basis_tree.is_executable(file_id) |
|
318 |
# Default to not executable
|
|
319 |
return False |
|
320 |
else: |
|
321 |
def is_executable(self, file_id, path=None): |
|
322 |
if not path: |
|
323 |
path = self.id2path(file_id) |
|
324 |
mode = os.lstat(self.abspath(path)).st_mode |
|
325 |
return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode) |
|
326 |
||
327 |
_is_executable_from_path_and_stat = \ |
|
328 |
_is_executable_from_path_and_stat_from_stat
|
|
329 |
||
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
330 |
def list_files(self, include_root=False, from_dir=None, recursive=True): |
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
331 |
# FIXME: Yield non-versioned files
|
332 |
# FIXME: support from_dir
|
|
333 |
# FIXME: Support recursive
|
|
334 |
dir_ids = {} |
|
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
335 |
root_ie = self._get_dir_ie(u"", None) |
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
336 |
if include_root and not from_dir: |
337 |
yield "", "V", root_ie.kind, root_ie.file_id, root_ie |
|
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
338 |
dir_ids[u""] = root_ie.file_id |
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
339 |
for path, value in self.index.iteritems(): |
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
340 |
path = path.decode("utf-8") |
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
341 |
parent = posixpath.dirname(path).strip("/") |
342 |
for dir_path, dir_ie in self._add_missing_parent_ids(parent, dir_ids): |
|
343 |
yield dir_path, "V", dir_ie.kind, dir_ie.file_id, dir_ie |
|
344 |
ie = self._get_file_ie(path, value, dir_ids[parent]) |
|
345 |
yield path, "V", ie.kind, ie.file_id, ie |
|
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
346 |
|
|
0.264.9
by Jelmer Vernooij
Implement basic GitWorkingTree.iter_entries_by_dir. |
347 |
def iter_entries_by_dir(self, specific_file_ids=None, yield_parents=False): |
348 |
# FIXME: Support specific_file_ids
|
|
349 |
# FIXME: Is return order correct?
|
|
350 |
if specific_file_ids is not None: |
|
351 |
raise NotImplementedError(self.iter_entries_by_dir) |
|
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
352 |
root_ie = self._get_dir_ie(u"", None) |
353 |
yield u"", root_ie |
|
354 |
dir_ids = {u"": root_ie.file_id} |
|
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
355 |
for path, value in self.index.iteritems(): |
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
356 |
path = path.decode("utf-8") |
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
357 |
parent = posixpath.dirname(path).strip("/") |
358 |
for (dir_path, dir_ie) in self._add_missing_parent_ids(parent, dir_ids): |
|
359 |
yield dir_path, dir_ie |
|
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
360 |
parent_id = self.path2id(parent) |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
361 |
yield path, self._get_file_ie(path, value, parent_id) |
|
0.264.9
by Jelmer Vernooij
Implement basic GitWorkingTree.iter_entries_by_dir. |
362 |
|
|
0.200.619
by Jelmer Vernooij
Provide dummy WorkingTree.conflicts() implementation rather than spending a lot of time not finding any conflicts. |
363 |
@needs_read_lock
|
364 |
def conflicts(self): |
|
365 |
# FIXME:
|
|
|
0.262.1
by Jelmer Vernooij
Fix WorkingTree.conflicts(). |
366 |
return _mod_conflicts.ConflictList() |
|
0.200.619
by Jelmer Vernooij
Provide dummy WorkingTree.conflicts() implementation rather than spending a lot of time not finding any conflicts. |
367 |
|
|
0.200.1193
by Jelmer Vernooij
Implement GitWorkingTree.{move,rename_one}. |
368 |
def update_basis_by_delta(self, new_revid, delta): |
|
0.200.1196
by Jelmer Vernooij
Implement GitWorkingTree.update_basis_by_delta. |
369 |
# The index just contains content, which won't have changed.
|
370 |
return
|
|
|
0.200.1193
by Jelmer Vernooij
Implement GitWorkingTree.{move,rename_one}. |
371 |
|
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
372 |
|
373 |
class GitWorkingTreeFormat(workingtree.WorkingTreeFormat): |
|
374 |
||
|
0.200.656
by Jelmer Vernooij
Implement GitWorkingTreeFormat._matchingbzrdir. |
375 |
@property
|
376 |
def _matchingbzrdir(self): |
|
|
0.200.1140
by Jelmer Vernooij
Update now that the control dir formats are no longer in __init__. |
377 |
from bzrlib.plugins.git.dir import LocalGitControlDirFormat |
|
0.200.1013
by Jelmer Vernooij
More renames. |
378 |
return LocalGitControlDirFormat() |
|
0.200.656
by Jelmer Vernooij
Implement GitWorkingTreeFormat._matchingbzrdir. |
379 |
|
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
380 |
def get_format_description(self): |
381 |
return "Git Working Tree" |
|
|
0.200.616
by Jelmer Vernooij
Provide custom intertree implementation for GitRevisionTree->GitWorkingTree. |
382 |
|
|
0.200.1096
by Jelmer Vernooij
Implement GitWorkingTreeFormat.initialize. |
383 |
def initialize(self, a_bzrdir, revision_id=None, from_branch=None, |
384 |
accelerator_tree=None, hardlink=False): |
|
385 |
"""See WorkingTreeFormat.initialize().""" |
|
386 |
if not isinstance(a_bzrdir, LocalGitDir): |
|
387 |
raise errors.IncompatibleFormat(self, a_bzrdir) |
|
388 |
index = Index(a_bzrdir.root_transport.local_abspath(".git/index")) |
|
389 |
index.write() |
|
390 |
return GitWorkingTree(a_bzrdir, a_bzrdir.open_repository(), |
|
391 |
a_bzrdir.open_branch(), index) |
|
392 |
||
|
0.200.616
by Jelmer Vernooij
Provide custom intertree implementation for GitRevisionTree->GitWorkingTree. |
393 |
|
394 |
class InterIndexGitTree(tree.InterTree): |
|
395 |
"""InterTree that works between a Git revision tree and an index.""" |
|
396 |
||
397 |
def __init__(self, source, target): |
|
398 |
super(InterIndexGitTree, self).__init__(source, target) |
|
399 |
self._index = target.index |
|
400 |
||
401 |
@classmethod
|
|
402 |
def is_compatible(cls, source, target): |
|
403 |
from bzrlib.plugins.git.repository import GitRevisionTree |
|
404 |
return (isinstance(source, GitRevisionTree) and |
|
405 |
isinstance(target, GitWorkingTree)) |
|
406 |
||
407 |
def compare(self, want_unchanged=False, specific_files=None, |
|
408 |
extra_trees=None, require_versioned=False, include_root=False, |
|
409 |
want_unversioned=False): |
|
410 |
changes = self._index.changes_from_tree( |
|
411 |
self.source._repository._git.object_store, self.source.tree, |
|
412 |
want_unchanged=want_unchanged) |
|
|
0.200.920
by Jelmer Vernooij
Fix some more tests. |
413 |
source_fileid_map = self.source.mapping.get_fileid_map( |
|
0.252.43
by Jelmer Vernooij
Some refactoring, support proper file ids in revision deltas. |
414 |
self.source._repository._git.object_store.__getitem__, |
415 |
self.source.tree) |
|
|
0.200.922
by Jelmer Vernooij
Fix remaining test. |
416 |
if self.target.mapping.BZR_FILE_IDS_FILE is not None: |
|
0.200.1030
by Jelmer Vernooij
More work on supporting roundtripping push. |
417 |
file_id = self.target.path2id( |
418 |
self.target.mapping.BZR_FILE_IDS_FILE) |
|
419 |
if file_id is None: |
|
|
0.200.922
by Jelmer Vernooij
Fix remaining test. |
420 |
target_fileid_map = {} |
421 |
else: |
|
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
422 |
target_fileid_map = self.target.mapping.import_fileid_map(Blob.from_string(self.target.get_file_text(file_id))) |
|
0.200.922
by Jelmer Vernooij
Fix remaining test. |
423 |
else: |
424 |
target_fileid_map = {} |
|
|
0.200.971
by Chadrik
Fix 'bzr status' after 'bzr add' in native git working trees. |
425 |
target_fileid_map = GitFileIdMap(target_fileid_map, self.target.mapping) |
|
0.200.1030
by Jelmer Vernooij
More work on supporting roundtripping push. |
426 |
ret = tree_delta_from_git_changes(changes, self.target.mapping, |
|
0.252.43
by Jelmer Vernooij
Some refactoring, support proper file ids in revision deltas. |
427 |
(source_fileid_map, target_fileid_map), |
|
0.200.616
by Jelmer Vernooij
Provide custom intertree implementation for GitRevisionTree->GitWorkingTree. |
428 |
specific_file=specific_files, require_versioned=require_versioned) |
429 |
if want_unversioned: |
|
430 |
for e in self.target.extras(): |
|
431 |
ret.unversioned.append((e, None, osutils.file_kind(self.target.abspath(e)))) |
|
432 |
return ret |
|
433 |
||
|
0.200.622
by Jelmer Vernooij
Implement InterTree.iter_changes() as well. |
434 |
def iter_changes(self, include_unchanged=False, specific_files=None, |
435 |
pb=None, extra_trees=[], require_versioned=True, want_unversioned=False): |
|
436 |
changes = self._index.changes_from_tree( |
|
|
0.200.1179
by Jelmer Vernooij
Avoid using verifiers for natively imported revisions, save a lot of time. |
437 |
self.source._repository._git.object_store, self.source.tree, |
|
0.200.622
by Jelmer Vernooij
Implement InterTree.iter_changes() as well. |
438 |
want_unchanged=include_unchanged) |
439 |
# FIXME: Handle want_unversioned
|
|
|
0.200.1179
by Jelmer Vernooij
Avoid using verifiers for natively imported revisions, save a lot of time. |
440 |
return changes_from_git_changes(changes, self.target.mapping, |
|
0.200.622
by Jelmer Vernooij
Implement InterTree.iter_changes() as well. |
441 |
specific_file=specific_files) |
|
0.200.616
by Jelmer Vernooij
Provide custom intertree implementation for GitRevisionTree->GitWorkingTree. |
442 |
|
|
0.200.1179
by Jelmer Vernooij
Avoid using verifiers for natively imported revisions, save a lot of time. |
443 |
|
|
0.200.616
by Jelmer Vernooij
Provide custom intertree implementation for GitRevisionTree->GitWorkingTree. |
444 |
tree.InterTree.register_optimiser(InterIndexGitTree) |