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.1594
by Jelmer Vernooij
Use absolute_import everywhere. |
20 |
from __future__ import absolute_import |
|
0.200.381
by Jelmer Vernooij
Support working trees properly, status and ls. |
21 |
|
|
0.200.1731
by Jelmer Vernooij
Add support for checking untracked changes. |
22 |
import itertools |
|
0.200.385
by Jelmer Vernooij
Cope with removed files. |
23 |
from cStringIO import ( |
24 |
StringIO, |
|
25 |
)
|
|
|
0.200.1210
by Jelmer Vernooij
Implement GitWorkingTree._walkdirs. |
26 |
from collections import defaultdict |
|
0.239.4
by Jelmer Vernooij
Cope with nonexistent files and directories in get_file_sha1. |
27 |
import errno |
|
0.200.1538
by Jelmer Vernooij
More work on tree-reference support. |
28 |
from dulwich.errors import NotGitRepository |
|
0.200.1655
by Jelmer Vernooij
Basic support for git ignores. |
29 |
from dulwich.ignore import ( |
|
0.200.1658
by Jelmer Vernooij
Fix handling of ignores - return patterns that matched. |
30 |
IgnoreFilterManager, |
|
0.200.1655
by Jelmer Vernooij
Basic support for git ignores. |
31 |
)
|
|
0.200.1096
by Jelmer Vernooij
Implement GitWorkingTreeFormat.initialize. |
32 |
from dulwich.index import ( |
33 |
Index, |
|
|
0.200.1531
by Jelmer Vernooij
Don't trust index contents - verify against file timestamps. |
34 |
changes_from_tree, |
35 |
cleanup_mode, |
|
36 |
index_entry_from_stat, |
|
|
0.200.1096
by Jelmer Vernooij
Implement GitWorkingTreeFormat.initialize. |
37 |
)
|
|
0.200.1202
by Jelmer Vernooij
Implement has_or_had_id. |
38 |
from dulwich.object_store import ( |
39 |
tree_lookup_path, |
|
40 |
)
|
|
|
0.200.383
by Jelmer Vernooij
Simplify, support rewriting index based on inventory. |
41 |
from dulwich.objects import ( |
42 |
Blob, |
|
|
0.200.1538
by Jelmer Vernooij
More work on tree-reference support. |
43 |
S_IFGITLINK, |
|
0.200.948
by Jelmer Vernooij
Cope with empty inventories. |
44 |
ZERO_SHA, |
45 |
)
|
|
|
0.200.1538
by Jelmer Vernooij
More work on tree-reference support. |
46 |
from dulwich.repo import Repo |
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
47 |
import os |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
48 |
import posixpath |
|
0.200.1655
by Jelmer Vernooij
Basic support for git ignores. |
49 |
import re |
|
0.200.384
by Jelmer Vernooij
Fix reading of inventory from index. |
50 |
import stat |
|
0.200.1215
by Jelmer Vernooij
Implement GitWorkingTree.remove. |
51 |
import sys |
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
52 |
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
53 |
from ... import ( |
|
0.200.382
by Jelmer Vernooij
Support flushing index. |
54 |
errors, |
|
0.262.1
by Jelmer Vernooij
Fix WorkingTree.conflicts(). |
55 |
conflicts as _mod_conflicts, |
|
0.200.1655
by Jelmer Vernooij
Basic support for git ignores. |
56 |
globbing, |
|
0.200.409
by Jelmer Vernooij
Support parsing .gitignore. |
57 |
ignores, |
|
0.200.1476
by Jelmer Vernooij
Cope with working tree refactoring. |
58 |
lock, |
|
0.200.381
by Jelmer Vernooij
Support working trees properly, status and ls. |
59 |
osutils, |
|
0.200.1720
by Jelmer Vernooij
Fix handling of pending merges. |
60 |
revision as _mod_revision, |
|
0.200.1215
by Jelmer Vernooij
Implement GitWorkingTree.remove. |
61 |
trace, |
|
0.200.519
by Jelmer Vernooij
Move imports down, might not be available in older bzr-git versions. |
62 |
tree, |
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
63 |
workingtree, |
64 |
)
|
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
65 |
from ...bzr import ( |
66 |
inventory, |
|
67 |
)
|
|
|
0.200.1680
by Jelmer Vernooij
Fix repo locks. |
68 |
from ...mutabletree import ( |
69 |
MutableTree, |
|
70 |
)
|
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
71 |
|
72 |
||
73 |
from .dir import ( |
|
|
0.200.1096
by Jelmer Vernooij
Implement GitWorkingTreeFormat.initialize. |
74 |
LocalGitDir, |
75 |
)
|
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
76 |
from .tree import ( |
|
0.200.622
by Jelmer Vernooij
Implement InterTree.iter_changes() as well. |
77 |
changes_from_git_changes, |
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
78 |
tree_delta_from_git_changes, |
79 |
)
|
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
80 |
from .mapping import ( |
|
0.200.971
by Chadrik
Fix 'bzr status' after 'bzr add' in native git working trees. |
81 |
GitFileIdMap, |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
82 |
mode_kind, |
|
0.200.971
by Chadrik
Fix 'bzr status' after 'bzr add' in native git working trees. |
83 |
)
|
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
84 |
|
|
0.200.409
by Jelmer Vernooij
Support parsing .gitignore. |
85 |
IGNORE_FILENAME = ".gitignore" |
86 |
||
87 |
||
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
88 |
class GitWorkingTree(workingtree.WorkingTree): |
89 |
"""A Git working tree.""" |
|
90 |
||
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
91 |
def __init__(self, controldir, repo, branch, index): |
|
0.200.1741
by Jelmer Vernooij
Fix opentree tests. |
92 |
basedir = controldir.root_transport.local_abspath('.') |
93 |
self.basedir = osutils.realpath(basedir) |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
94 |
self.controldir = controldir |
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
95 |
self.repository = repo |
|
0.200.1205
by Jelmer Vernooij
Implement GitWorkingTree.stored_kind. |
96 |
self.store = self.repository._git.object_store |
|
0.200.384
by Jelmer Vernooij
Fix reading of inventory from index. |
97 |
self.mapping = self.repository.get_mapping() |
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
98 |
self._branch = branch |
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
99 |
self._transport = controldir.transport |
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
100 |
self._format = GitWorkingTreeFormat() |
|
0.200.803
by Jelmer Vernooij
Default to non-bare repositories when initializing a control directory. |
101 |
self.index = index |
|
0.200.1242
by Jelmer Vernooij
Support directories better. |
102 |
self._versioned_dirs = None |
|
0.200.239
by Jelmer Vernooij
Provide views. |
103 |
self.views = self._make_views() |
|
0.200.1173
by Jelmer Vernooij
Provide GitWorkingTree._rules_searcher. |
104 |
self._rules_searcher = None |
|
0.200.381
by Jelmer Vernooij
Support working trees properly, status and ls. |
105 |
self._detect_case_handling() |
|
0.200.1202
by Jelmer Vernooij
Implement has_or_had_id. |
106 |
self._reset_data() |
107 |
self._fileid_map = self._basis_fileid_map.copy() |
|
|
0.200.1476
by Jelmer Vernooij
Cope with working tree refactoring. |
108 |
self._lock_mode = None |
109 |
self._lock_count = 0 |
|
110 |
||
|
0.200.1650
by Jelmer Vernooij
Implement GitWorkingTree.supports_tree_reference. |
111 |
def supports_tree_reference(self): |
112 |
return False |
|
113 |
||
|
0.200.1476
by Jelmer Vernooij
Cope with working tree refactoring. |
114 |
def lock_read(self): |
115 |
"""Lock the repository for read operations. |
|
116 |
||
|
0.200.1646
by Jelmer Vernooij
Rename bzrlib to breezy. |
117 |
:return: A breezy.lock.LogicalLockResult.
|
|
0.200.1476
by Jelmer Vernooij
Cope with working tree refactoring. |
118 |
"""
|
119 |
if not self._lock_mode: |
|
120 |
self._lock_mode = 'r' |
|
121 |
self._lock_count = 1 |
|
|
0.200.1525
by Jelmer Vernooij
Make sure to always use an up-to-date index. |
122 |
self.index.read() |
|
0.200.1476
by Jelmer Vernooij
Cope with working tree refactoring. |
123 |
else: |
124 |
self._lock_count += 1 |
|
125 |
self.branch.lock_read() |
|
126 |
return lock.LogicalLockResult(self.unlock) |
|
127 |
||
|
0.200.1477
by Jelmer Vernooij
Implement GitWorkingTree.lock_tree_write. |
128 |
def lock_tree_write(self): |
129 |
if not self._lock_mode: |
|
130 |
self._lock_mode = 'w' |
|
131 |
self._lock_count = 1 |
|
|
0.200.1525
by Jelmer Vernooij
Make sure to always use an up-to-date index. |
132 |
self.index.read() |
|
0.200.1477
by Jelmer Vernooij
Implement GitWorkingTree.lock_tree_write. |
133 |
elif self._lock_mode == 'r': |
134 |
raise errors.ReadOnlyError(self) |
|
135 |
else: |
|
136 |
self._lock_count +=1 |
|
137 |
self.branch.lock_read() |
|
138 |
return lock.LogicalLockResult(self.unlock) |
|
139 |
||
|
0.200.1476
by Jelmer Vernooij
Cope with working tree refactoring. |
140 |
def lock_write(self, token=None): |
141 |
if not self._lock_mode: |
|
142 |
self._lock_mode = 'w' |
|
143 |
self._lock_count = 1 |
|
|
0.200.1525
by Jelmer Vernooij
Make sure to always use an up-to-date index. |
144 |
self.index.read() |
|
0.200.1476
by Jelmer Vernooij
Cope with working tree refactoring. |
145 |
elif self._lock_mode == 'r': |
146 |
raise errors.ReadOnlyError(self) |
|
147 |
else: |
|
148 |
self._lock_count +=1 |
|
149 |
self.branch.lock_write() |
|
150 |
return lock.LogicalLockResult(self.unlock) |
|
151 |
||
152 |
def is_locked(self): |
|
153 |
return self._lock_count >= 1 |
|
154 |
||
155 |
def get_physical_lock_status(self): |
|
156 |
return False |
|
157 |
||
158 |
def unlock(self): |
|
159 |
if not self._lock_count: |
|
160 |
return lock.cant_unlock_not_held(self) |
|
|
0.200.1530
by Jelmer Vernooij
Fix lock order. |
161 |
self.branch.unlock() |
|
0.200.1476
by Jelmer Vernooij
Cope with working tree refactoring. |
162 |
self._cleanup() |
163 |
self._lock_count -= 1 |
|
164 |
if self._lock_count > 0: |
|
165 |
return
|
|
166 |
self._lock_mode = None |
|
|
0.200.173
by Jelmer Vernooij
Merge changes, open index. |
167 |
|
|
0.200.1658
by Jelmer Vernooij
Fix handling of ignores - return patterns that matched. |
168 |
def _cleanup(self): |
169 |
pass
|
|
170 |
||
|
0.200.1322
by Jelmer Vernooij
Add case detection. |
171 |
def _detect_case_handling(self): |
172 |
try: |
|
173 |
self._transport.stat(".git/cOnFiG") |
|
174 |
except errors.NoSuchFile: |
|
175 |
self.case_sensitive = True |
|
176 |
else: |
|
177 |
self.case_sensitive = False |
|
178 |
||
|
0.200.1315
by Jelmer Vernooij
Implement WorkingTree.merge_modified. |
179 |
def merge_modified(self): |
180 |
return {} |
|
181 |
||
|
0.200.1696
by Jelmer Vernooij
Fix set_merge_modified. |
182 |
def set_merge_modified(self, modified_hashes): |
|
0.200.1690
by Jelmer Vernooij
Implement WorkingTree.set_merge_modified. |
183 |
# TODO(jelmer)
|
184 |
pass
|
|
185 |
||
|
0.200.1220
by Jelmer Vernooij
Support set_parent_trees. |
186 |
def set_parent_trees(self, parents_list, allow_leftmost_as_ghost=False): |
187 |
self.set_parent_ids([p for p, t in parents_list]) |
|
188 |
||
|
0.200.1720
by Jelmer Vernooij
Fix handling of pending merges. |
189 |
def _set_merges_from_parent_ids(self, parent_ids): |
190 |
merges = parent_ids[1:] |
|
191 |
self.control_transport.put_bytes('MERGE_HEAD', '\n'.join(merges), |
|
192 |
mode=self.controldir._get_file_mode()) |
|
193 |
||
194 |
def set_parent_ids(self, revision_ids, allow_leftmost_as_ghost=False): |
|
195 |
"""Set the parent ids to revision_ids. |
|
196 |
||
197 |
See also set_parent_trees. This api will try to retrieve the tree data
|
|
198 |
for each element of revision_ids from the trees repository. If you have
|
|
199 |
tree data already available, it is more efficient to use
|
|
200 |
set_parent_trees rather than set_parent_ids. set_parent_ids is however
|
|
201 |
an easier API to use.
|
|
202 |
||
203 |
:param revision_ids: The revision_ids to set as the parent ids of this
|
|
204 |
working tree. Any of these may be ghosts.
|
|
205 |
"""
|
|
206 |
with self.lock_tree_write(): |
|
207 |
self._check_parents_for_ghosts(revision_ids, |
|
208 |
allow_leftmost_as_ghost=allow_leftmost_as_ghost) |
|
209 |
for revision_id in revision_ids: |
|
210 |
_mod_revision.check_not_reserved_id(revision_id) |
|
211 |
||
212 |
revision_ids = self._filter_parent_ids_by_ancestry(revision_ids) |
|
213 |
||
214 |
if len(revision_ids) > 0: |
|
215 |
self.set_last_revision(revision_ids[0]) |
|
216 |
else: |
|
217 |
self.set_last_revision(_mod_revision.NULL_REVISION) |
|
218 |
||
219 |
self._set_merges_from_parent_ids(revision_ids) |
|
220 |
||
221 |
def get_parent_ids(self): |
|
222 |
"""See Tree.get_parent_ids. |
|
223 |
||
224 |
This implementation reads the pending merges list and last_revision
|
|
225 |
value and uses that to decide what the parents list should be.
|
|
226 |
"""
|
|
227 |
last_rev = _mod_revision.ensure_null(self._last_revision()) |
|
228 |
if _mod_revision.NULL_REVISION == last_rev: |
|
229 |
parents = [] |
|
230 |
else: |
|
231 |
parents = [last_rev] |
|
232 |
try: |
|
233 |
merges_bytes = self.control_transport.get_bytes('MERGE_HEAD') |
|
234 |
except errors.NoSuchFile: |
|
235 |
pass
|
|
236 |
else: |
|
237 |
for l in osutils.split_lines(merges_bytes): |
|
238 |
revision_id = l.rstrip('\n') |
|
239 |
parents.append(revision_id) |
|
240 |
return parents |
|
241 |
||
|
0.200.1599
by Jelmer Vernooij
Implement GitWorkingTree.iter_children. |
242 |
def iter_children(self, file_id): |
243 |
dpath = self.id2path(file_id) + "/" |
|
244 |
if dpath in self.index: |
|
245 |
return
|
|
246 |
for path in self.index: |
|
247 |
if not path.startswith(dpath): |
|
248 |
continue
|
|
249 |
if "/" in path[len(dpath):]: |
|
250 |
# Not a direct child but something further down
|
|
251 |
continue
|
|
252 |
yield self.path2id(path) |
|
253 |
||
|
0.200.1663
by Jelmer Vernooij
Raise SettingFileIdUnsupported |
254 |
def _index_add_entry(self, path, kind): |
|
0.200.1525
by Jelmer Vernooij
Make sure to always use an up-to-date index. |
255 |
assert self._lock_mode is not None |
|
0.200.1206
by Jelmer Vernooij
Implement GitWorkingTree.all_file_ids. |
256 |
assert isinstance(path, basestring) |
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
257 |
if kind == "directory": |
258 |
# Git indexes don't contain directories
|
|
259 |
return
|
|
260 |
if kind == "file": |
|
261 |
blob = Blob() |
|
262 |
try: |
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
263 |
file, stat_val = self.get_file_with_stat(path) |
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
264 |
except (errors.NoSuchFile, IOError): |
265 |
# TODO: Rather than come up with something here, use the old index
|
|
266 |
file = StringIO() |
|
|
0.265.1
by Martin
Don't import posix module, the os wrapper exists for portability |
267 |
stat_val = os.stat_result( |
268 |
(stat.S_IFREG | 0644, 0, 0, 0, 0, 0, 0, 0, 0, 0)) |
|
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
269 |
blob.set_raw_string(file.read()) |
270 |
elif kind == "symlink": |
|
271 |
blob = Blob() |
|
272 |
try: |
|
273 |
stat_val = os.lstat(self.abspath(path)) |
|
274 |
except (errors.NoSuchFile, OSError): |
|
|
0.200.1636
by Jelmer Vernooij
Some formatting fixes. |
275 |
# TODO: Rather than come up with something here, use the
|
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
276 |
# old index
|
|
0.265.1
by Martin
Don't import posix module, the os wrapper exists for portability |
277 |
stat_val = os.stat_result( |
278 |
(stat.S_IFLNK, 0, 0, 0, 0, 0, 0, 0, 0, 0)) |
|
|
0.200.1321
by Jelmer Vernooij
More fixes for compatibility with bzr.dev testsuite. |
279 |
blob.set_raw_string( |
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
280 |
self.get_symlink_target(path).encode("utf-8")) |
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
281 |
else: |
282 |
raise AssertionError("unknown kind '%s'" % kind) |
|
283 |
# Add object to the repository if it didn't exist yet
|
|
|
0.200.1205
by Jelmer Vernooij
Implement GitWorkingTree.stored_kind. |
284 |
if not blob.id in self.store: |
285 |
self.store.add_object(blob) |
|
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
286 |
# Add an entry to the index or update the existing entry
|
287 |
flags = 0 # FIXME |
|
|
0.200.1242
by Jelmer Vernooij
Support directories better. |
288 |
encoded_path = path.encode("utf-8") |
|
0.200.1531
by Jelmer Vernooij
Don't trust index contents - verify against file timestamps. |
289 |
self.index[encoded_path] = index_entry_from_stat( |
290 |
stat_val, blob.id, flags) |
|
|
0.200.1242
by Jelmer Vernooij
Support directories better. |
291 |
if self._versioned_dirs is not None: |
292 |
self._ensure_versioned_dir(encoded_path) |
|
293 |
||
294 |
def _ensure_versioned_dir(self, dirname): |
|
|
0.200.1249
by Jelmer Vernooij
Fix file id for tree root |
295 |
if dirname in self._versioned_dirs: |
|
0.200.1242
by Jelmer Vernooij
Support directories better. |
296 |
return
|
|
0.200.1249
by Jelmer Vernooij
Fix file id for tree root |
297 |
if dirname != "": |
298 |
self._ensure_versioned_dir(posixpath.dirname(dirname)) |
|
|
0.200.1242
by Jelmer Vernooij
Support directories better. |
299 |
self._versioned_dirs.add(dirname) |
300 |
||
301 |
def _load_dirs(self): |
|
|
0.200.1525
by Jelmer Vernooij
Make sure to always use an up-to-date index. |
302 |
assert self._lock_mode is not None |
|
0.200.1242
by Jelmer Vernooij
Support directories better. |
303 |
self._versioned_dirs = set() |
304 |
for p in self.index: |
|
305 |
self._ensure_versioned_dir(posixpath.dirname(p)) |
|
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
306 |
|
|
0.200.1215
by Jelmer Vernooij
Implement GitWorkingTree.remove. |
307 |
def _unversion_path(self, path): |
|
0.200.1525
by Jelmer Vernooij
Make sure to always use an up-to-date index. |
308 |
assert self._lock_mode is not None |
|
0.200.1215
by Jelmer Vernooij
Implement GitWorkingTree.remove. |
309 |
encoded_path = path.encode("utf-8") |
310 |
try: |
|
311 |
del self.index[encoded_path] |
|
312 |
except KeyError: |
|
313 |
# A directory, perhaps?
|
|
314 |
for p in list(self.index): |
|
|
0.200.1692
by Jelmer Vernooij
Mark three more tests as xfail. |
315 |
if p.startswith(encoded_path+b"/"): |
|
0.200.1215
by Jelmer Vernooij
Implement GitWorkingTree.remove. |
316 |
del self.index[p] |
|
0.200.1242
by Jelmer Vernooij
Support directories better. |
317 |
# FIXME: remove empty directories
|
|
0.200.1215
by Jelmer Vernooij
Implement GitWorkingTree.remove. |
318 |
|
|
0.285.8
by Jelmer Vernooij
Fix more tests for swapped arguments. |
319 |
def unversion(self, paths, file_ids=None): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
320 |
with self.lock_tree_write(): |
|
0.200.1690
by Jelmer Vernooij
Implement WorkingTree.set_merge_modified. |
321 |
for path in paths: |
|
0.200.1742
by Jelmer Vernooij
Fix some unversion tests. |
322 |
encoded_path = path.encode("utf-8") |
323 |
try: |
|
324 |
del self.index[encoded_path] |
|
325 |
except KeyError: |
|
326 |
if not self._has_dir(path): |
|
327 |
raise errors.NoSuchFile(path) |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
328 |
self.flush() |
|
0.200.1215
by Jelmer Vernooij
Implement GitWorkingTree.remove. |
329 |
|
|
0.200.1678
by Jelmer Vernooij
Fix tests. |
330 |
def update_basis_by_delta(self, revid, delta): |
331 |
# TODO(jelmer): This shouldn't be called, it's inventory specific.
|
|
332 |
pass
|
|
333 |
||
|
0.200.1243
by Jelmer Vernooij
Implement WorkingTree.check_state. |
334 |
def check_state(self): |
335 |
"""Check that the working state is/isn't valid.""" |
|
336 |
pass
|
|
337 |
||
|
0.200.1215
by Jelmer Vernooij
Implement GitWorkingTree.remove. |
338 |
def remove(self, files, verbose=False, to_file=None, keep_files=True, |
339 |
force=False): |
|
340 |
"""Remove nominated files from the working tree metadata. |
|
341 |
||
342 |
:param files: File paths relative to the basedir.
|
|
343 |
:param keep_files: If true, the files will also be kept.
|
|
344 |
:param force: Delete files and directories, even if they are changed
|
|
345 |
and even if the directories are not empty.
|
|
346 |
"""
|
|
347 |
if isinstance(files, basestring): |
|
348 |
files = [files] |
|
349 |
||
350 |
if to_file is None: |
|
351 |
to_file = sys.stdout |
|
352 |
||
|
0.200.1735
by Jelmer Vernooij
Fix remove tests. |
353 |
files = list(files) |
|
0.200.1215
by Jelmer Vernooij
Implement GitWorkingTree.remove. |
354 |
|
355 |
if len(files) == 0: |
|
356 |
return # nothing to do |
|
357 |
||
358 |
# Sort needed to first handle directory content before the directory
|
|
359 |
files.sort(reverse=True) |
|
360 |
||
361 |
def backup(file_to_backup): |
|
362 |
abs_path = self.abspath(file_to_backup) |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
363 |
backup_name = self.controldir._available_backup_name(file_to_backup) |
|
0.200.1215
by Jelmer Vernooij
Implement GitWorkingTree.remove. |
364 |
osutils.rename(abs_path, self.abspath(backup_name)) |
365 |
return "removed %s (but kept a copy: %s)" % ( |
|
366 |
file_to_backup, backup_name) |
|
367 |
||
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
368 |
with self.lock_tree_write(): |
369 |
for f in files: |
|
|
0.200.1735
by Jelmer Vernooij
Fix remove tests. |
370 |
if f == '': |
371 |
continue
|
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
372 |
fid = self.path2id(f) |
373 |
if not fid: |
|
374 |
message = "%s is not versioned." % (f,) |
|
375 |
else: |
|
376 |
abs_path = self.abspath(f) |
|
377 |
if verbose: |
|
378 |
# having removed it, it must be either ignored or unknown
|
|
379 |
if self.is_ignored(f): |
|
380 |
new_status = 'I' |
|
381 |
else: |
|
382 |
new_status = '?' |
|
383 |
# XXX: Really should be a more abstract reporter interface
|
|
384 |
kind_ch = osutils.kind_marker(self.kind(fid)) |
|
385 |
to_file.write(new_status + ' ' + f + kind_ch + '\n') |
|
386 |
# Unversion file
|
|
387 |
# FIXME: _unversion_path() is O(size-of-index) for directories
|
|
388 |
self._unversion_path(f) |
|
389 |
message = "removed %s" % (f,) |
|
390 |
if osutils.lexists(abs_path): |
|
391 |
if (osutils.isdir(abs_path) and |
|
392 |
len(os.listdir(abs_path)) > 0): |
|
393 |
if force: |
|
394 |
osutils.rmtree(abs_path) |
|
395 |
message = "deleted %s" % (f,) |
|
396 |
else: |
|
397 |
message = backup(f) |
|
398 |
else: |
|
399 |
if not keep_files: |
|
400 |
osutils.delete_any(abs_path) |
|
401 |
message = "deleted %s" % (f,) |
|
|
0.200.1215
by Jelmer Vernooij
Implement GitWorkingTree.remove. |
402 |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
403 |
# print only one message (if any) per file.
|
404 |
if message is not None: |
|
405 |
trace.note(message) |
|
406 |
self.flush() |
|
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
407 |
|
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
408 |
def _add(self, files, ids, kinds): |
409 |
for (path, file_id, kind) in zip(files, ids, kinds): |
|
|
0.200.1201
by Jelmer Vernooij
Implement _set_root_id. |
410 |
if file_id is not None: |
|
0.200.1663
by Jelmer Vernooij
Raise SettingFileIdUnsupported |
411 |
raise workingtree.SettingFileIdUnsupported() |
412 |
self._index_add_entry(path, kind) |
|
|
0.200.1201
by Jelmer Vernooij
Implement _set_root_id. |
413 |
|
|
0.200.1240
by Jelmer Vernooij
Implement GitWorkingTree.smart_add. |
414 |
def smart_add(self, file_list, recurse=True, action=None, save=True): |
415 |
added = [] |
|
416 |
ignored = {} |
|
417 |
user_dirs = [] |
|
|
0.200.1733
by Jelmer Vernooij
Support handling of custom ids in smart_add. |
418 |
def call_action(filepath, kind): |
419 |
if action is not None: |
|
420 |
parent_path = posixpath.dirname(filepath) |
|
421 |
parent_id = self.path2id(parent_path) |
|
422 |
parent_ie = self._get_dir_ie(parent_path, parent_id) |
|
423 |
file_id = action(self, parent_ie, filepath, kind) |
|
424 |
if file_id is not None: |
|
425 |
raise workingtree.SettingFileIdUnsupported() |
|
426 |
||
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
427 |
with self.lock_tree_write(): |
428 |
for filepath in osutils.canonical_relpaths(self.basedir, file_list): |
|
429 |
abspath = self.abspath(filepath) |
|
|
0.200.1240
by Jelmer Vernooij
Implement GitWorkingTree.smart_add. |
430 |
kind = osutils.file_kind(abspath) |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
431 |
if kind in ("file", "symlink"): |
|
0.200.1733
by Jelmer Vernooij
Support handling of custom ids in smart_add. |
432 |
call_action(filepath, kind) |
|
0.200.1308
by Jelmer Vernooij
Write index to disk after adding files. |
433 |
if save: |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
434 |
self._index_add_entry(filepath, kind) |
435 |
added.append(filepath) |
|
436 |
elif kind == "directory": |
|
|
0.200.1733
by Jelmer Vernooij
Support handling of custom ids in smart_add. |
437 |
call_action(filepath, kind) |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
438 |
if recurse: |
439 |
user_dirs.append(filepath) |
|
440 |
else: |
|
441 |
raise errors.BadFileKindError(filename=abspath, kind=kind) |
|
442 |
for user_dir in user_dirs: |
|
443 |
abs_user_dir = self.abspath(user_dir) |
|
444 |
for name in os.listdir(abs_user_dir): |
|
445 |
subp = os.path.join(user_dir, name) |
|
446 |
if self.is_control_filename(subp) or self.mapping.is_special_file(subp): |
|
447 |
continue
|
|
448 |
ignore_glob = self.is_ignored(subp) |
|
449 |
if ignore_glob is not None: |
|
450 |
ignored.setdefault(ignore_glob, []).append(subp) |
|
451 |
continue
|
|
452 |
abspath = self.abspath(subp) |
|
453 |
kind = osutils.file_kind(abspath) |
|
454 |
if kind == "directory": |
|
455 |
user_dirs.append(subp) |
|
456 |
else: |
|
|
0.200.1733
by Jelmer Vernooij
Support handling of custom ids in smart_add. |
457 |
call_action(filepath, kind) |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
458 |
if save: |
459 |
self._index_add_entry(subp, kind) |
|
460 |
if added and save: |
|
461 |
self.flush() |
|
462 |
return added, ignored |
|
|
0.200.1240
by Jelmer Vernooij
Implement GitWorkingTree.smart_add. |
463 |
|
|
0.200.1201
by Jelmer Vernooij
Implement _set_root_id. |
464 |
def _set_root_id(self, file_id): |
465 |
self._fileid_map.set_file_id("", file_id) |
|
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
466 |
|
|
0.200.1193
by Jelmer Vernooij
Implement GitWorkingTree.{move,rename_one}. |
467 |
def move(self, from_paths, to_dir=None, after=False): |
468 |
rename_tuples = [] |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
469 |
with self.lock_tree_write(): |
470 |
to_abs = self.abspath(to_dir) |
|
471 |
if not os.path.isdir(to_abs): |
|
472 |
raise errors.BzrMoveFailedError('', to_dir, |
|
473 |
errors.NotADirectory(to_abs)) |
|
474 |
||
475 |
for from_rel in from_paths: |
|
476 |
from_tail = os.path.split(from_rel)[-1] |
|
477 |
to_rel = os.path.join(to_dir, from_tail) |
|
478 |
self.rename_one(from_rel, to_rel, after=after) |
|
479 |
rename_tuples.append((from_rel, to_rel)) |
|
480 |
self.flush() |
|
481 |
return rename_tuples |
|
482 |
||
|
0.200.1193
by Jelmer Vernooij
Implement GitWorkingTree.{move,rename_one}. |
483 |
def rename_one(self, from_rel, to_rel, after=False): |
|
0.200.1203
by Jelmer Vernooij
Fix per_workingtree.test_rename_one.TestRenameOne.test_rename_after_non_existant_non_ascii |
484 |
from_path = from_rel.encode("utf-8") |
485 |
to_path = to_rel.encode("utf-8") |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
486 |
with self.lock_tree_write(): |
|
0.200.1737
by Jelmer Vernooij
Fix rename tests. |
487 |
if not after: |
488 |
if not self.has_filename(from_rel): |
|
489 |
raise errors.BzrMoveFailedError(from_rel, to_rel, |
|
490 |
errors.NoSuchFile(from_rel)) |
|
491 |
else: |
|
492 |
if not self.has_filename(to_rel): |
|
493 |
raise errors.BzrMoveFailedError(from_rel, to_rel, |
|
494 |
errors.NoSuchFile(to_rel)) |
|
495 |
||
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
496 |
if not from_path in self.index: |
497 |
raise errors.BzrMoveFailedError(from_rel, to_rel, |
|
498 |
errors.NotVersionedError(path=from_rel)) |
|
|
0.200.1737
by Jelmer Vernooij
Fix rename tests. |
499 |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
500 |
if not after: |
|
0.200.1737
by Jelmer Vernooij
Fix rename tests. |
501 |
try: |
502 |
os.rename(self.abspath(from_rel), self.abspath(to_rel)) |
|
503 |
except OSError as e: |
|
504 |
if e.errno == errno.ENOENT: |
|
505 |
raise errors.BzrMoveFailedError(from_rel, to_rel, |
|
506 |
errors.NoSuchFile(to_rel)) |
|
507 |
raise
|
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
508 |
self.index[to_path] = self.index[from_path] |
509 |
del self.index[from_path] |
|
510 |
self.flush() |
|
|
0.200.1193
by Jelmer Vernooij
Implement GitWorkingTree.{move,rename_one}. |
511 |
|
|
0.264.1
by Jelmer Vernooij
Provide stubs using inventory for the moment.: |
512 |
def get_root_id(self): |
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
513 |
return self.path2id("") |
514 |
||
|
0.200.1712
by Jelmer Vernooij
Add file_id prefix. |
515 |
def has_filename(self, filename): |
516 |
return osutils.lexists(self.abspath(filename)) |
|
517 |
||
|
0.200.1242
by Jelmer Vernooij
Support directories better. |
518 |
def _has_dir(self, path): |
|
0.200.1368
by Jelmer Vernooij
There is always a tree root. |
519 |
if path == "": |
520 |
return True |
|
|
0.200.1242
by Jelmer Vernooij
Support directories better. |
521 |
if self._versioned_dirs is None: |
522 |
self._load_dirs() |
|
523 |
return path in self._versioned_dirs |
|
524 |
||
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
525 |
def path2id(self, path): |
|
0.200.1600
by Jelmer Vernooij
Cope with paths as lists of elements. |
526 |
if type(path) is list: |
527 |
path = u"/".join(path) |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
528 |
with self.lock_read(): |
529 |
encoded_path = path.encode("utf-8") |
|
530 |
if self._is_versioned(encoded_path): |
|
531 |
return self._fileid_map.lookup_file_id(encoded_path) |
|
532 |
return None |
|
|
0.264.1
by Jelmer Vernooij
Provide stubs using inventory for the moment.: |
533 |
|
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
534 |
def _iter_files_recursive(self, from_dir=None): |
535 |
if from_dir is None: |
|
536 |
from_dir = "" |
|
537 |
for (dirpath, dirnames, filenames) in os.walk(self.abspath(from_dir)): |
|
|
0.200.1302
by Jelmer Vernooij
Significantly improve performance of WorkingTree.extras(). |
538 |
dir_relpath = dirpath[len(self.basedir):].strip("/") |
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
539 |
if self.controldir.is_control_filename(dir_relpath): |
|
0.200.605
by Jelmer Vernooij
Ignore directories in WorkingTree.extras(). |
540 |
continue
|
|
0.200.615
by Jelmer Vernooij
Optimize WorkingTree.extras(). |
541 |
for filename in filenames: |
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
542 |
if not self.mapping.is_special_file(filename): |
543 |
yield os.path.join(dir_relpath, filename) |
|
|
0.200.1327
by Jelmer Vernooij
Factor out all file browsing in extras. |
544 |
|
545 |
def extras(self): |
|
546 |
"""Yield all unversioned files in this WorkingTree. |
|
547 |
"""
|
|
|
0.200.1676
by Jelmer Vernooij
Fix typo. |
548 |
with self.lock_read(): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
549 |
return set(self._iter_files_recursive()) - set(self.index) |
|
0.200.605
by Jelmer Vernooij
Ignore directories in WorkingTree.extras(). |
550 |
|
|
0.200.382
by Jelmer Vernooij
Support flushing index. |
551 |
def flush(self): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
552 |
with self.lock_tree_write(): |
553 |
# TODO: Maybe this should only write on dirty ?
|
|
554 |
if self._lock_mode != 'w': |
|
555 |
raise errors.NotWriteLocked(self) |
|
556 |
self.index.write() |
|
|
0.200.382
by Jelmer Vernooij
Support flushing index. |
557 |
|
|
0.264.1
by Jelmer Vernooij
Provide stubs using inventory for the moment.: |
558 |
def __iter__(self): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
559 |
with self.lock_read(): |
560 |
for path in self.index: |
|
561 |
yield self.path2id(path) |
|
562 |
self._load_dirs() |
|
563 |
for path in self._versioned_dirs: |
|
564 |
yield self.path2id(path) |
|
|
0.264.1
by Jelmer Vernooij
Provide stubs using inventory for the moment.: |
565 |
|
|
0.200.1202
by Jelmer Vernooij
Implement has_or_had_id. |
566 |
def has_or_had_id(self, file_id): |
567 |
if self.has_id(file_id): |
|
568 |
return True |
|
569 |
if self.had_id(file_id): |
|
570 |
return True |
|
571 |
return False |
|
572 |
||
573 |
def had_id(self, file_id): |
|
574 |
path = self._basis_fileid_map.lookup_file_id(file_id) |
|
575 |
try: |
|
576 |
head = self.repository._git.head() |
|
577 |
except KeyError: |
|
578 |
# Assume no if basis is not accessible
|
|
579 |
return False |
|
|
0.200.1205
by Jelmer Vernooij
Implement GitWorkingTree.stored_kind. |
580 |
if head == ZERO_SHA: |
581 |
return False |
|
|
0.200.1202
by Jelmer Vernooij
Implement has_or_had_id. |
582 |
root_tree = self.store[head].tree |
583 |
try: |
|
584 |
tree_lookup_path(self.store.__getitem__, root_tree, path) |
|
585 |
except KeyError: |
|
586 |
return False |
|
587 |
else: |
|
588 |
return True |
|
589 |
||
|
0.200.1198
by Jelmer Vernooij
Implement GitWorkingTree.has_id. |
590 |
def has_id(self, file_id): |
591 |
try: |
|
592 |
self.id2path(file_id) |
|
593 |
except errors.NoSuchId: |
|
594 |
return False |
|
595 |
else: |
|
596 |
return True |
|
597 |
||
|
0.264.1
by Jelmer Vernooij
Provide stubs using inventory for the moment.: |
598 |
def id2path(self, file_id): |
|
0.200.1532
by Jelmer Vernooij
Cope with float timestamps. |
599 |
assert type(file_id) is str, "file id not a string: %r" % file_id |
|
0.200.1411
by Jelmer Vernooij
Fix control files. |
600 |
file_id = osutils.safe_utf8(file_id) |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
601 |
with self.lock_read(): |
|
0.200.1712
by Jelmer Vernooij
Add file_id prefix. |
602 |
try: |
603 |
path = self._fileid_map.lookup_path(file_id) |
|
604 |
except ValueError: |
|
605 |
raise errors.NoSuchId(self, file_id) |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
606 |
# FIXME: What about directories?
|
607 |
if self._is_versioned(path): |
|
608 |
return path.decode("utf-8") |
|
609 |
raise errors.NoSuchId(self, file_id) |
|
|
0.264.1
by Jelmer Vernooij
Provide stubs using inventory for the moment.: |
610 |
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
611 |
def get_file_mtime(self, path, file_id=None): |
|
0.200.1200
by Jelmer Vernooij
Support GitWorkingTree.get_file_mtime. |
612 |
"""See Tree.get_file_mtime.""" |
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
613 |
try: |
614 |
return os.lstat(self.abspath(path)).st_mtime |
|
615 |
except OSError, (num, msg): |
|
616 |
if num == errno.ENOENT: |
|
617 |
raise errors.NoSuchFile(path) |
|
618 |
raise
|
|
|
0.200.1200
by Jelmer Vernooij
Support GitWorkingTree.get_file_mtime. |
619 |
|
|
0.200.1655
by Jelmer Vernooij
Basic support for git ignores. |
620 |
def is_ignored(self, filename): |
621 |
r"""Check whether the filename matches an ignore pattern. |
|
622 |
||
623 |
If the file is ignored, returns the pattern which caused it to
|
|
624 |
be ignored, otherwise None. So this can simply be used as a
|
|
625 |
boolean if desired."""
|
|
626 |
if getattr(self, '_global_ignoreglobster', None) is None: |
|
627 |
ignore_globs = set() |
|
628 |
ignore_globs.update(ignores.get_runtime_ignores()) |
|
629 |
ignore_globs.update(ignores.get_user_ignores()) |
|
630 |
self._global_ignoreglobster = globbing.ExceptionGlobster(ignore_globs) |
|
|
0.200.1656
by Jelmer Vernooij
Report proper patterns, ignore files. |
631 |
match = self._global_ignoreglobster.match(filename) |
632 |
if match is not None: |
|
633 |
return match |
|
|
0.200.1716
by Jelmer Vernooij
Fix some more tests. |
634 |
try: |
635 |
if self.kind(filename) == 'directory': |
|
636 |
filename += b'/' |
|
637 |
except errors.NoSuchFile: |
|
638 |
pass
|
|
639 |
filename = filename.lstrip(b'/') |
|
|
0.200.1658
by Jelmer Vernooij
Fix handling of ignores - return patterns that matched. |
640 |
ignore_manager = self._get_ignore_manager() |
641 |
ps = list(ignore_manager.find_matching(filename)) |
|
642 |
if not ps: |
|
643 |
return None |
|
644 |
if not ps[-1].is_exclude: |
|
645 |
return None |
|
646 |
return bytes(ps[-1]) |
|
647 |
||
648 |
def _get_ignore_manager(self): |
|
649 |
ignoremanager = getattr(self, '_ignoremanager', None) |
|
650 |
if ignoremanager is not None: |
|
651 |
return ignoremanager |
|
652 |
||
653 |
ignore_manager = IgnoreFilterManager.from_repo(self.repository._git) |
|
654 |
self._ignoremanager = ignore_manager |
|
655 |
return ignore_manager |
|
|
0.200.409
by Jelmer Vernooij
Support parsing .gitignore. |
656 |
|
|
0.200.1716
by Jelmer Vernooij
Fix some more tests. |
657 |
def _flush_ignore_list_cache(self): |
658 |
self._ignoremanager = None |
|
659 |
||
|
0.200.508
by Jelmer Vernooij
Skip inventory caching bits. |
660 |
def set_last_revision(self, revid): |
|
0.200.1720
by Jelmer Vernooij
Fix handling of pending merges. |
661 |
if _mod_revision.is_null(revid): |
662 |
self.branch.set_last_revision_info(0, revid) |
|
663 |
return False |
|
664 |
_mod_revision.check_not_reserved_id(revid) |
|
665 |
try: |
|
666 |
self.branch.generate_revision_history(revid) |
|
667 |
except errors.NoSuchRevision: |
|
668 |
raise errors.GhostRevisionUnusableHere(revid) |
|
|
0.200.508
by Jelmer Vernooij
Skip inventory caching bits. |
669 |
|
|
0.200.379
by Jelmer Vernooij
Re-enable working tree support. |
670 |
def _reset_data(self): |
|
0.248.3
by Jelmer Vernooij
Handle working trees without valid HEAD branch. |
671 |
try: |
672 |
head = self.repository._git.head() |
|
673 |
except KeyError, name: |
|
|
0.200.1308
by Jelmer Vernooij
Write index to disk after adding files. |
674 |
raise errors.NotBranchError("branch %s at %s" % (name, |
675 |
self.repository.base)) |
|
|
0.200.948
by Jelmer Vernooij
Cope with empty inventories. |
676 |
if head == ZERO_SHA: |
|
0.200.1202
by Jelmer Vernooij
Implement has_or_had_id. |
677 |
self._basis_fileid_map = GitFileIdMap({}, self.mapping) |
|
0.200.948
by Jelmer Vernooij
Cope with empty inventories. |
678 |
else: |
|
0.200.1308
by Jelmer Vernooij
Write index to disk after adding files. |
679 |
self._basis_fileid_map = self.mapping.get_fileid_map( |
680 |
self.store.__getitem__, self.store[head].tree) |
|
|
0.200.379
by Jelmer Vernooij
Re-enable working tree support. |
681 |
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
682 |
def get_file_verifier(self, path, file_id=None, stat_value=None): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
683 |
with self.lock_read(): |
684 |
try: |
|
685 |
return ("GIT", self.index[path][-2]) |
|
686 |
except KeyError: |
|
687 |
if self._has_dir(path): |
|
688 |
return ("GIT", None) |
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
689 |
raise errors.NoSuchFile(path) |
|
0.200.1302
by Jelmer Vernooij
Significantly improve performance of WorkingTree.extras(). |
690 |
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
691 |
def get_file_sha1(self, path, file_id=None, stat_value=None): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
692 |
with self.lock_read(): |
693 |
abspath = self.abspath(path).encode(osutils._fs_enc) |
|
694 |
try: |
|
695 |
return osutils.sha_file_by_name(abspath) |
|
696 |
except OSError, (num, msg): |
|
697 |
if num in (errno.EISDIR, errno.ENOENT): |
|
698 |
return None |
|
699 |
raise
|
|
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
700 |
|
|
0.200.610
by Jelmer Vernooij
Support retrieving basis tree properly. |
701 |
def revision_tree(self, revid): |
702 |
return self.repository.revision_tree(revid) |
|
703 |
||
|
0.200.1242
by Jelmer Vernooij
Support directories better. |
704 |
def _is_versioned(self, path): |
|
0.200.1525
by Jelmer Vernooij
Make sure to always use an up-to-date index. |
705 |
assert self._lock_mode is not None |
|
0.200.1242
by Jelmer Vernooij
Support directories better. |
706 |
return (path in self.index or self._has_dir(path)) |
707 |
||
|
0.200.1239
by Jelmer Vernooij
Implement GitWorkingTree.filter_unversioned_files. |
708 |
def filter_unversioned_files(self, files): |
|
0.200.1316
by Jelmer Vernooij
Fix filter_unversioned_files. |
709 |
return set([p for p in files if not self._is_versioned(p.encode("utf-8"))]) |
|
0.200.1239
by Jelmer Vernooij
Implement GitWorkingTree.filter_unversioned_files. |
710 |
|
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
711 |
def _get_dir_ie(self, path, parent_id): |
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
712 |
file_id = self.path2id(path) |
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
713 |
return inventory.InventoryDirectory(file_id, |
|
0.200.1190
by Jelmer Vernooij
Fix get_symlink_target call. |
714 |
posixpath.basename(path).strip("/"), parent_id) |
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
715 |
|
716 |
def _add_missing_parent_ids(self, path, dir_ids): |
|
717 |
if path in dir_ids: |
|
718 |
return [] |
|
719 |
parent = posixpath.dirname(path).strip("/") |
|
720 |
ret = self._add_missing_parent_ids(parent, dir_ids) |
|
721 |
parent_id = dir_ids[parent] |
|
722 |
ie = self._get_dir_ie(path, parent_id) |
|
723 |
dir_ids[path] = ie.file_id |
|
724 |
ret.append((path, ie)) |
|
725 |
return ret |
|
726 |
||
|
0.200.1321
by Jelmer Vernooij
More fixes for compatibility with bzr.dev testsuite. |
727 |
def _get_file_ie(self, name, path, value, parent_id): |
728 |
assert isinstance(name, unicode) |
|
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
729 |
assert isinstance(path, unicode) |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
730 |
assert isinstance(value, tuple) and len(value) == 10 |
731 |
(ctime, mtime, dev, ino, mode, uid, gid, size, sha, flags) = value |
|
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
732 |
file_id = self.path2id(path) |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
733 |
if type(file_id) != str: |
734 |
raise AssertionError |
|
735 |
kind = mode_kind(mode) |
|
|
0.200.1321
by Jelmer Vernooij
More fixes for compatibility with bzr.dev testsuite. |
736 |
ie = inventory.entry_factory[kind](file_id, name, parent_id) |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
737 |
if kind == 'symlink': |
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
738 |
ie.symlink_target = self.get_symlink_target(path, file_id) |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
739 |
else: |
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
740 |
data = self.get_file_text(path, file_id) |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
741 |
ie.text_sha1 = osutils.sha_string(data) |
742 |
ie.text_size = len(data) |
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
743 |
ie.executable = self.is_executable(path, file_id) |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
744 |
ie.revision = None |
745 |
return ie |
|
746 |
||
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
747 |
def _is_executable_from_path_and_stat_from_stat(self, path, stat_result): |
748 |
mode = stat_result.st_mode |
|
749 |
return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode) |
|
750 |
||
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
751 |
def stored_kind(self, path, file_id=None): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
752 |
with self.lock_read(): |
753 |
try: |
|
754 |
return mode_kind(self.index[path.encode("utf-8")][4]) |
|
755 |
except KeyError: |
|
756 |
# Maybe it's a directory?
|
|
757 |
if self._has_dir(path): |
|
758 |
return "directory" |
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
759 |
raise errors.NoSuchFile(path) |
|
0.200.1205
by Jelmer Vernooij
Implement GitWorkingTree.stored_kind. |
760 |
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
761 |
def is_executable(self, path, file_id=None): |
|
0.200.1539
by Jelmer Vernooij
Cope with new is_executable. |
762 |
if getattr(self, "_supports_executable", osutils.supports_executable)(): |
763 |
mode = os.lstat(self.abspath(path)).st_mode |
|
764 |
return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode) |
|
765 |
else: |
|
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
766 |
basis_tree = self.basis_tree() |
767 |
if file_id in basis_tree: |
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
768 |
return basis_tree.is_executable(path, file_id) |
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
769 |
# Default to not executable
|
770 |
return False |
|
771 |
||
|
0.200.1539
by Jelmer Vernooij
Cope with new is_executable. |
772 |
def _is_executable_from_path_and_stat(self, path, stat_result): |
773 |
if getattr(self, "_supports_executable", osutils.supports_executable)(): |
|
774 |
return self._is_executable_from_path_and_stat_from_stat(path, stat_result) |
|
775 |
else: |
|
776 |
return self._is_executable_from_path_and_stat_from_basis(path, stat_result) |
|
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
777 |
|
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
778 |
def list_files(self, include_root=False, from_dir=None, recursive=True): |
|
0.200.1321
by Jelmer Vernooij
More fixes for compatibility with bzr.dev testsuite. |
779 |
if from_dir is None: |
780 |
from_dir = "" |
|
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
781 |
dir_ids = {} |
|
0.200.1339
by Jelmer Vernooij
Some reformatting. |
782 |
fk_entries = {'directory': workingtree.TreeDirectory, |
783 |
'file': workingtree.TreeFile, |
|
784 |
'symlink': workingtree.TreeLink} |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
785 |
with self.lock_read(): |
786 |
root_ie = self._get_dir_ie(u"", None) |
|
787 |
if include_root and not from_dir: |
|
788 |
yield "", "V", root_ie.kind, root_ie.file_id, root_ie |
|
789 |
dir_ids[u""] = root_ie.file_id |
|
790 |
if recursive: |
|
791 |
path_iterator = self._iter_files_recursive(from_dir) |
|
792 |
else: |
|
793 |
if from_dir is None: |
|
794 |
start = self.basedir |
|
795 |
else: |
|
796 |
start = os.path.join(self.basedir, from_dir) |
|
797 |
path_iterator = sorted([os.path.join(from_dir, name) for name in |
|
798 |
os.listdir(start) if not self.controldir.is_control_filename(name) |
|
799 |
and not self.mapping.is_special_file(name)]) |
|
800 |
for path in path_iterator: |
|
801 |
try: |
|
802 |
value = self.index[path] |
|
803 |
except KeyError: |
|
804 |
value = None |
|
805 |
path = path.decode("utf-8") |
|
806 |
parent, name = posixpath.split(path) |
|
807 |
for dir_path, dir_ie in self._add_missing_parent_ids(parent, dir_ids): |
|
808 |
yield dir_path, "V", dir_ie.kind, dir_ie.file_id, dir_ie |
|
809 |
if value is not None: |
|
810 |
ie = self._get_file_ie(name, path, value, dir_ids[parent]) |
|
811 |
yield path, "V", ie.kind, ie.file_id, ie |
|
812 |
else: |
|
813 |
kind = osutils.file_kind(self.abspath(path)) |
|
814 |
ie = fk_entries[kind]() |
|
815 |
yield path, ("I" if self.is_ignored(path) else "?"), kind, None, ie |
|
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
816 |
|
|
0.200.1206
by Jelmer Vernooij
Implement GitWorkingTree.all_file_ids. |
817 |
def all_file_ids(self): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
818 |
with self.lock_read(): |
819 |
ids = {u"": self.path2id("")} |
|
820 |
for path in self.index: |
|
821 |
if self.mapping.is_special_file(path): |
|
822 |
continue
|
|
823 |
path = path.decode("utf-8") |
|
824 |
parent = posixpath.dirname(path).strip("/") |
|
825 |
for e in self._add_missing_parent_ids(parent, ids): |
|
826 |
pass
|
|
827 |
ids[path] = self.path2id(path) |
|
828 |
return set(ids.values()) |
|
|
0.200.1206
by Jelmer Vernooij
Implement GitWorkingTree.all_file_ids. |
829 |
|
|
0.200.1710
by Jelmer Vernooij
Regenerate xfail. |
830 |
def all_versioned_paths(self): |
831 |
with self.lock_read(): |
|
832 |
paths = {u""} |
|
833 |
for path in self.index: |
|
834 |
if self.mapping.is_special_file(path): |
|
835 |
continue
|
|
836 |
path = path.decode("utf-8") |
|
837 |
paths.add(path) |
|
838 |
while path != "": |
|
839 |
path = posixpath.dirname(path).strip("/") |
|
840 |
if path in paths: |
|
841 |
break
|
|
842 |
paths.add(path) |
|
843 |
return paths |
|
844 |
||
|
0.200.1374
by Jelmer Vernooij
Implement GitWorkingTree._directory_is_tree_reference. |
845 |
def _directory_is_tree_reference(self, path): |
846 |
# FIXME: Check .gitsubmodules for path
|
|
847 |
return False |
|
848 |
||
|
0.200.1716
by Jelmer Vernooij
Fix some more tests. |
849 |
def iter_child_entries(self, path, file_id=None): |
850 |
encoded_path = path.encode('utf-8') |
|
|
0.200.1739
by Jelmer Vernooij
Fix iteration order for iter_child_entries. |
851 |
parent_id = self.path2id(path) |
|
0.200.1738
by Jelmer Vernooij
Fix test_does_not_exist. |
852 |
found_any = False |
|
0.200.1739
by Jelmer Vernooij
Fix iteration order for iter_child_entries. |
853 |
seen_children = set() |
|
0.200.1716
by Jelmer Vernooij
Fix some more tests. |
854 |
for item_path, value in self.index.iteritems(): |
855 |
if self.mapping.is_special_file(item_path): |
|
856 |
continue
|
|
|
0.200.1739
by Jelmer Vernooij
Fix iteration order for iter_child_entries. |
857 |
if not osutils.is_inside(encoded_path, item_path): |
|
0.200.1716
by Jelmer Vernooij
Fix some more tests. |
858 |
continue
|
|
0.200.1738
by Jelmer Vernooij
Fix test_does_not_exist. |
859 |
found_any = True |
|
0.200.1739
by Jelmer Vernooij
Fix iteration order for iter_child_entries. |
860 |
subpath = posixpath.relpath(item_path, encoded_path) |
|
0.200.1716
by Jelmer Vernooij
Fix some more tests. |
861 |
if b'/' in subpath: |
|
0.200.1739
by Jelmer Vernooij
Fix iteration order for iter_child_entries. |
862 |
dirname = subpath.split(b'/', 1)[0] |
863 |
file_ie = self._get_dir_ie(posixpath.join(path, dirname), parent_id) |
|
864 |
else: |
|
865 |
(parent, name) = posixpath.split(item_path) |
|
866 |
try: |
|
867 |
file_ie = self._get_file_ie(name, item_path, value, parent_id) |
|
868 |
except IOError: |
|
869 |
continue
|
|
|
0.200.1716
by Jelmer Vernooij
Fix some more tests. |
870 |
yield file_ie |
|
0.200.1738
by Jelmer Vernooij
Fix test_does_not_exist. |
871 |
if not found_any: |
872 |
raise errors.NoSuchFile(path) |
|
|
0.200.1716
by Jelmer Vernooij
Fix some more tests. |
873 |
|
|
0.264.9
by Jelmer Vernooij
Implement basic GitWorkingTree.iter_entries_by_dir. |
874 |
def iter_entries_by_dir(self, specific_file_ids=None, yield_parents=False): |
|
0.200.1252
by Jelmer Vernooij
Support specific_file_ids in GitWorkingTree.iter_entries_by_dir. |
875 |
if yield_parents: |
876 |
raise NotImplementedError(self.iter_entries_by_dir) |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
877 |
with self.lock_read(): |
878 |
if specific_file_ids is not None: |
|
|
0.200.1712
by Jelmer Vernooij
Add file_id prefix. |
879 |
specific_paths = [] |
880 |
for file_id in specific_file_ids: |
|
881 |
assert file_id is not None, "file id %r" % file_id |
|
882 |
specific_paths.append(self.id2path(file_id)) |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
883 |
if specific_paths in ([u""], []): |
884 |
specific_paths = None |
|
885 |
else: |
|
886 |
specific_paths = set(specific_paths) |
|
887 |
else: |
|
|
0.200.1252
by Jelmer Vernooij
Support specific_file_ids in GitWorkingTree.iter_entries_by_dir. |
888 |
specific_paths = None |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
889 |
root_ie = self._get_dir_ie(u"", None) |
|
0.200.1740
by Jelmer Vernooij
Fix iter_entries_by_dir order. |
890 |
ret = {} |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
891 |
if specific_paths is None: |
|
0.200.1740
by Jelmer Vernooij
Fix iter_entries_by_dir order. |
892 |
ret[(None, u"")] = root_ie |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
893 |
dir_ids = {u"": root_ie.file_id} |
894 |
for path, value in self.index.iteritems(): |
|
895 |
if self.mapping.is_special_file(path): |
|
896 |
continue
|
|
897 |
path = path.decode("utf-8") |
|
898 |
if specific_paths is not None and not path in specific_paths: |
|
899 |
continue
|
|
900 |
(parent, name) = posixpath.split(path) |
|
901 |
try: |
|
902 |
file_ie = self._get_file_ie(name, path, value, None) |
|
903 |
except IOError: |
|
904 |
continue
|
|
|
0.200.1730
by Jelmer Vernooij
Fix test_is_executable_dir. |
905 |
if yield_parents or specific_file_ids is None: |
906 |
for (dir_path, dir_ie) in self._add_missing_parent_ids(parent, |
|
907 |
dir_ids): |
|
|
0.200.1740
by Jelmer Vernooij
Fix iter_entries_by_dir order. |
908 |
ret[(posixpath.dirname(dir_path), dir_path)] = dir_ie |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
909 |
file_ie.parent_id = self.path2id(parent) |
|
0.200.1740
by Jelmer Vernooij
Fix iter_entries_by_dir order. |
910 |
ret[(posixpath.dirname(path), path)] = file_ie |
911 |
return ((path, ie) for ((_, path), ie) in sorted(ret.items())) |
|
|
0.264.9
by Jelmer Vernooij
Implement basic GitWorkingTree.iter_entries_by_dir. |
912 |
|
|
0.200.619
by Jelmer Vernooij
Provide dummy WorkingTree.conflicts() implementation rather than spending a lot of time not finding any conflicts. |
913 |
def conflicts(self): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
914 |
with self.lock_read(): |
915 |
# FIXME:
|
|
916 |
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. |
917 |
|
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
918 |
def get_canonical_inventory_path(self, path): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
919 |
with self.lock_read(): |
920 |
for p in self.index: |
|
921 |
if p.lower() == path.lower(): |
|
922 |
return p |
|
923 |
else: |
|
924 |
return path |
|
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
925 |
|
|
0.200.1705
by Jelmer Vernooij
Fix walkdirs. |
926 |
def walkdirs(self, prefix=""): |
|
0.200.1210
by Jelmer Vernooij
Implement GitWorkingTree._walkdirs. |
927 |
if prefix != "": |
928 |
prefix += "/" |
|
929 |
per_dir = defaultdict(list) |
|
930 |
for path, value in self.index.iteritems(): |
|
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
931 |
if self.mapping.is_special_file(path): |
932 |
continue
|
|
|
0.200.1210
by Jelmer Vernooij
Implement GitWorkingTree._walkdirs. |
933 |
if not path.startswith(prefix): |
934 |
continue
|
|
935 |
(dirname, child_name) = posixpath.split(path) |
|
936 |
dirname = dirname.decode("utf-8") |
|
937 |
dir_file_id = self.path2id(dirname) |
|
938 |
assert isinstance(value, tuple) and len(value) == 10 |
|
939 |
(ctime, mtime, dev, ino, mode, uid, gid, size, sha, flags) = value |
|
|
0.265.1
by Martin
Don't import posix module, the os wrapper exists for portability |
940 |
stat_result = os.stat_result((mode, ino, |
|
0.200.1211
by Jelmer Vernooij
Fix statresult. |
941 |
dev, 1, uid, gid, size, |
|
0.200.1736
by Jelmer Vernooij
Fix a walkdirs test. |
942 |
int(mtime), int(mtime), int(ctime))) |
|
0.200.1210
by Jelmer Vernooij
Implement GitWorkingTree._walkdirs. |
943 |
per_dir[(dirname, dir_file_id)].append( |
944 |
(path.decode("utf-8"), child_name.decode("utf-8"), |
|
945 |
mode_kind(mode), stat_result, |
|
946 |
self.path2id(path.decode("utf-8")), |
|
947 |
mode_kind(mode))) |
|
948 |
return per_dir.iteritems() |
|
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
949 |
|
|
0.200.1542
by Jelmer Vernooij
Refactor iter_changes. |
950 |
def _lookup_entry(self, path, update_index=False): |
|
0.200.1543
by Jelmer Vernooij
Support symlinks. |
951 |
assert type(path) == str |
|
0.200.1542
by Jelmer Vernooij
Refactor iter_changes. |
952 |
entry = self.index[path] |
953 |
index_mode = entry[-6] |
|
954 |
index_sha = entry[-2] |
|
|
0.200.1741
by Jelmer Vernooij
Fix opentree tests. |
955 |
disk_path = self.abspath(path.decode('utf-8')).encode( |
956 |
osutils._fs_enc) |
|
|
0.284.1
by Jelmer Vernooij
Raise KeyError when file was removed. |
957 |
try: |
958 |
disk_stat = os.lstat(disk_path) |
|
959 |
except OSError, (num, msg): |
|
960 |
if num in (errno.EISDIR, errno.ENOENT): |
|
961 |
raise KeyError(path) |
|
962 |
raise
|
|
|
0.200.1542
by Jelmer Vernooij
Refactor iter_changes. |
963 |
disk_mtime = disk_stat.st_mtime |
964 |
if isinstance(entry[1], tuple): |
|
965 |
index_mtime = entry[1][0] |
|
966 |
else: |
|
967 |
index_mtime = int(entry[1]) |
|
968 |
mtime_delta = (disk_mtime - index_mtime) |
|
969 |
disk_mode = cleanup_mode(disk_stat.st_mode) |
|
970 |
if mtime_delta > 0 or disk_mode != index_mode: |
|
971 |
if stat.S_ISDIR(disk_mode): |
|
972 |
try: |
|
973 |
subrepo = Repo(disk_path) |
|
974 |
except NotGitRepository: |
|
975 |
return (None, None) |
|
976 |
else: |
|
977 |
disk_mode = S_IFGITLINK |
|
978 |
git_id = subrepo.head() |
|
|
0.200.1543
by Jelmer Vernooij
Support symlinks. |
979 |
elif stat.S_ISLNK(disk_mode): |
|
0.200.1715
by Jelmer Vernooij
Fix some more tests. |
980 |
blob = Blob.from_string(os.readlink(disk_path)) |
|
0.200.1543
by Jelmer Vernooij
Support symlinks. |
981 |
git_id = blob.id |
982 |
elif stat.S_ISREG(disk_mode): |
|
|
0.200.1542
by Jelmer Vernooij
Refactor iter_changes. |
983 |
with open(disk_path, 'r') as f: |
984 |
blob = Blob.from_string(f.read()) |
|
985 |
git_id = blob.id |
|
|
0.200.1543
by Jelmer Vernooij
Support symlinks. |
986 |
else: |
987 |
raise AssertionError |
|
|
0.200.1542
by Jelmer Vernooij
Refactor iter_changes. |
988 |
if update_index: |
989 |
flags = 0 # FIXME |
|
|
0.200.1545
by Jelmer Vernooij
Some more test fixes. |
990 |
self.index[path] = index_entry_from_stat(disk_stat, git_id, flags, disk_mode) |
|
0.200.1542
by Jelmer Vernooij
Refactor iter_changes. |
991 |
return (git_id, disk_mode) |
992 |
return (index_sha, index_mode) |
|
993 |
||
|
0.200.1677
by Jelmer Vernooij
Mark shelving as unsupported. |
994 |
def get_shelf_manager(self): |
|
0.200.1729
by Jelmer Vernooij
ShelvingUnsupported doesn't take an argument. |
995 |
raise workingtree.ShelvingUnsupported() |
|
0.200.1677
by Jelmer Vernooij
Mark shelving as unsupported. |
996 |
|
|
0.200.1678
by Jelmer Vernooij
Fix tests. |
997 |
def store_uncommitted(self): |
998 |
raise errors.StoringUncommittedNotSupported(self) |
|
999 |
||
|
0.200.1703
by Jelmer Vernooij
Implement apply_inventory_delta. |
1000 |
def apply_inventory_delta(self, changes): |
1001 |
for (old_path, new_path, file_id, ie) in changes: |
|
1002 |
if old_path is not None: |
|
1003 |
del self.index[old_path.encode('utf-8')] |
|
1004 |
if new_path is not None and ie.kind != 'directory': |
|
1005 |
self._index_add_entry(new_path, ie.kind) |
|
1006 |
||
|
0.200.1308
by Jelmer Vernooij
Write index to disk after adding files. |
1007 |
|
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
1008 |
class GitWorkingTreeFormat(workingtree.WorkingTreeFormat): |
1009 |
||
|
0.200.1206
by Jelmer Vernooij
Implement GitWorkingTree.all_file_ids. |
1010 |
_tree_class = GitWorkingTree |
1011 |
||
|
0.200.1295
by Jelmer Vernooij
Mark working trees as not supporting directories. |
1012 |
supports_versioned_directories = False |
1013 |
||
|
0.200.1661
by Jelmer Vernooij
Set supports_setting_file_ids to False. |
1014 |
supports_setting_file_ids = False |
1015 |
||
|
0.200.1677
by Jelmer Vernooij
Mark shelving as unsupported. |
1016 |
supports_store_uncommitted = False |
1017 |
||
|
0.200.1723
by Jelmer Vernooij
Set supports_leftmost_parent_id_as_ghost property. |
1018 |
supports_leftmost_parent_id_as_ghost = False |
1019 |
||
|
0.200.656
by Jelmer Vernooij
Implement GitWorkingTreeFormat._matchingbzrdir. |
1020 |
@property
|
|
0.200.1665
by Jelmer Vernooij
Rename _matchingbzrdir to _matchingcnotroldir. |
1021 |
def _matchingcontroldir(self): |
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
1022 |
from .dir import LocalGitControlDirFormat |
|
0.200.1013
by Jelmer Vernooij
More renames. |
1023 |
return LocalGitControlDirFormat() |
|
0.200.656
by Jelmer Vernooij
Implement GitWorkingTreeFormat._matchingbzrdir. |
1024 |
|
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
1025 |
def get_format_description(self): |
1026 |
return "Git Working Tree" |
|
|
0.200.616
by Jelmer Vernooij
Provide custom intertree implementation for GitRevisionTree->GitWorkingTree. |
1027 |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
1028 |
def initialize(self, a_controldir, revision_id=None, from_branch=None, |
|
0.200.1096
by Jelmer Vernooij
Implement GitWorkingTreeFormat.initialize. |
1029 |
accelerator_tree=None, hardlink=False): |
1030 |
"""See WorkingTreeFormat.initialize().""" |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
1031 |
if not isinstance(a_controldir, LocalGitDir): |
1032 |
raise errors.IncompatibleFormat(self, a_controldir) |
|
1033 |
index = Index(a_controldir.root_transport.local_abspath(".git/index")) |
|
|
0.200.1096
by Jelmer Vernooij
Implement GitWorkingTreeFormat.initialize. |
1034 |
index.write() |
|
0.200.1680
by Jelmer Vernooij
Fix repo locks. |
1035 |
wt = GitWorkingTree( |
1036 |
a_controldir, a_controldir.open_repository(), |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
1037 |
a_controldir.open_branch(), index) |
|
0.200.1680
by Jelmer Vernooij
Fix repo locks. |
1038 |
for hook in MutableTree.hooks['post_build_tree']: |
1039 |
hook(wt) |
|
1040 |
return wt |
|
|
0.200.1096
by Jelmer Vernooij
Implement GitWorkingTreeFormat.initialize. |
1041 |
|
|
0.200.616
by Jelmer Vernooij
Provide custom intertree implementation for GitRevisionTree->GitWorkingTree. |
1042 |
|
1043 |
class InterIndexGitTree(tree.InterTree): |
|
1044 |
"""InterTree that works between a Git revision tree and an index.""" |
|
1045 |
||
1046 |
def __init__(self, source, target): |
|
1047 |
super(InterIndexGitTree, self).__init__(source, target) |
|
1048 |
self._index = target.index |
|
1049 |
||
1050 |
@classmethod
|
|
1051 |
def is_compatible(cls, source, target): |
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
1052 |
from .repository import GitRevisionTree |
|
0.200.1636
by Jelmer Vernooij
Some formatting fixes. |
1053 |
return (isinstance(source, GitRevisionTree) and |
|
0.200.616
by Jelmer Vernooij
Provide custom intertree implementation for GitRevisionTree->GitWorkingTree. |
1054 |
isinstance(target, GitWorkingTree)) |
1055 |
||
1056 |
def compare(self, want_unchanged=False, specific_files=None, |
|
1057 |
extra_trees=None, require_versioned=False, include_root=False, |
|
1058 |
want_unversioned=False): |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
1059 |
with self.lock_read(): |
1060 |
# FIXME: Handle include_root
|
|
1061 |
changes = changes_between_git_tree_and_index( |
|
1062 |
self.source.store, self.source.tree, |
|
|
0.200.1731
by Jelmer Vernooij
Add support for checking untracked changes. |
1063 |
self.target, want_unchanged=want_unchanged) |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
1064 |
source_fileid_map = self.source._fileid_map |
1065 |
target_fileid_map = self.target._fileid_map |
|
1066 |
ret = tree_delta_from_git_changes(changes, self.target.mapping, |
|
1067 |
(source_fileid_map, target_fileid_map), |
|
|
0.200.1743
by Jelmer Vernooij
Fix some revision delta filtering. |
1068 |
specific_files=specific_files, require_versioned=require_versioned) |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
1069 |
if want_unversioned: |
1070 |
for e in self.target.extras(): |
|
|
0.200.1731
by Jelmer Vernooij
Add support for checking untracked changes. |
1071 |
ret.unversioned.append( |
|
0.200.1732
by Jelmer Vernooij
Fix ignore. |
1072 |
(osutils.normalized_filename(e)[0], None, |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
1073 |
osutils.file_kind(self.target.abspath(e)))) |
1074 |
return ret |
|
|
0.200.616
by Jelmer Vernooij
Provide custom intertree implementation for GitRevisionTree->GitWorkingTree. |
1075 |
|
|
0.200.622
by Jelmer Vernooij
Implement InterTree.iter_changes() as well. |
1076 |
def iter_changes(self, include_unchanged=False, specific_files=None, |
|
0.200.1207
by Jelmer Vernooij
Fix some formatting. |
1077 |
pb=None, extra_trees=[], require_versioned=True, |
1078 |
want_unversioned=False): |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
1079 |
with self.lock_read(): |
1080 |
changes = changes_between_git_tree_and_index( |
|
1081 |
self.source.store, self.source.tree, |
|
|
0.200.1731
by Jelmer Vernooij
Add support for checking untracked changes. |
1082 |
self.target, want_unchanged=include_unchanged) |
1083 |
if want_unversioned: |
|
1084 |
changes = itertools.chain( |
|
1085 |
changes, |
|
1086 |
untracked_changes(self.target)) |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
1087 |
return changes_from_git_changes( |
|
0.200.1743
by Jelmer Vernooij
Fix some revision delta filtering. |
1088 |
changes, self.target.mapping, specific_files=specific_files) |
|
0.200.616
by Jelmer Vernooij
Provide custom intertree implementation for GitRevisionTree->GitWorkingTree. |
1089 |
|
|
0.200.1179
by Jelmer Vernooij
Avoid using verifiers for natively imported revisions, save a lot of time. |
1090 |
|
|
0.200.616
by Jelmer Vernooij
Provide custom intertree implementation for GitRevisionTree->GitWorkingTree. |
1091 |
tree.InterTree.register_optimiser(InterIndexGitTree) |
|
0.200.1529
by Jelmer Vernooij
Add changes_between_tree_and_index. |
1092 |
|
1093 |
||
|
0.200.1731
by Jelmer Vernooij
Add support for checking untracked changes. |
1094 |
def untracked_changes(tree): |
1095 |
for e in tree.extras(): |
|
1096 |
ap = tree.abspath(e) |
|
1097 |
st = os.stat(ap) |
|
1098 |
try: |
|
1099 |
np, accessible = osutils.normalized_filename(e) |
|
1100 |
except UnicodeDecodeError: |
|
1101 |
raise errors.BadFilenameEncoding( |
|
1102 |
e, osutils._fs_enc) |
|
1103 |
yield (np, st.st_mode, |
|
1104 |
blob_from_path_and_stat(ap, st).id) |
|
1105 |
||
1106 |
||
|
0.200.1542
by Jelmer Vernooij
Refactor iter_changes. |
1107 |
def changes_between_git_tree_and_index(object_store, tree, target, |
|
0.200.1731
by Jelmer Vernooij
Add support for checking untracked changes. |
1108 |
want_unchanged=False, update_index=False): |
|
0.200.1529
by Jelmer Vernooij
Add changes_between_tree_and_index. |
1109 |
"""Determine the changes between a git tree and a working tree with index. |
1110 |
||
1111 |
"""
|
|
|
0.200.1538
by Jelmer Vernooij
More work on tree-reference support. |
1112 |
|
|
0.200.1542
by Jelmer Vernooij
Refactor iter_changes. |
1113 |
names = target.index._byname.keys() |
1114 |
for (name, mode, sha) in changes_from_tree(names, target._lookup_entry, |
|
|
0.200.1531
by Jelmer Vernooij
Don't trust index contents - verify against file timestamps. |
1115 |
object_store, tree, want_unchanged=want_unchanged): |
|
0.200.1538
by Jelmer Vernooij
More work on tree-reference support. |
1116 |
if name == (None, None): |
1117 |
continue
|
|
|
0.200.1531
by Jelmer Vernooij
Don't trust index contents - verify against file timestamps. |
1118 |
yield (name, mode, sha) |