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.1675
by Jelmer Vernooij
Remove uses of decorators. |
322 |
self._unversion_path(path) |
323 |
self.flush() |
|
|
0.200.1215
by Jelmer Vernooij
Implement GitWorkingTree.remove. |
324 |
|
|
0.200.1678
by Jelmer Vernooij
Fix tests. |
325 |
def update_basis_by_delta(self, revid, delta): |
326 |
# TODO(jelmer): This shouldn't be called, it's inventory specific.
|
|
327 |
pass
|
|
328 |
||
|
0.200.1243
by Jelmer Vernooij
Implement WorkingTree.check_state. |
329 |
def check_state(self): |
330 |
"""Check that the working state is/isn't valid.""" |
|
331 |
pass
|
|
332 |
||
|
0.200.1215
by Jelmer Vernooij
Implement GitWorkingTree.remove. |
333 |
def remove(self, files, verbose=False, to_file=None, keep_files=True, |
334 |
force=False): |
|
335 |
"""Remove nominated files from the working tree metadata. |
|
336 |
||
337 |
:param files: File paths relative to the basedir.
|
|
338 |
:param keep_files: If true, the files will also be kept.
|
|
339 |
:param force: Delete files and directories, even if they are changed
|
|
340 |
and even if the directories are not empty.
|
|
341 |
"""
|
|
342 |
if isinstance(files, basestring): |
|
343 |
files = [files] |
|
344 |
||
345 |
if to_file is None: |
|
346 |
to_file = sys.stdout |
|
347 |
||
|
0.200.1735
by Jelmer Vernooij
Fix remove tests. |
348 |
files = list(files) |
|
0.200.1215
by Jelmer Vernooij
Implement GitWorkingTree.remove. |
349 |
|
350 |
if len(files) == 0: |
|
351 |
return # nothing to do |
|
352 |
||
353 |
# Sort needed to first handle directory content before the directory
|
|
354 |
files.sort(reverse=True) |
|
355 |
||
356 |
def backup(file_to_backup): |
|
357 |
abs_path = self.abspath(file_to_backup) |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
358 |
backup_name = self.controldir._available_backup_name(file_to_backup) |
|
0.200.1215
by Jelmer Vernooij
Implement GitWorkingTree.remove. |
359 |
osutils.rename(abs_path, self.abspath(backup_name)) |
360 |
return "removed %s (but kept a copy: %s)" % ( |
|
361 |
file_to_backup, backup_name) |
|
362 |
||
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
363 |
with self.lock_tree_write(): |
364 |
for f in files: |
|
|
0.200.1735
by Jelmer Vernooij
Fix remove tests. |
365 |
if f == '': |
366 |
continue
|
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
367 |
fid = self.path2id(f) |
368 |
if not fid: |
|
369 |
message = "%s is not versioned." % (f,) |
|
370 |
else: |
|
371 |
abs_path = self.abspath(f) |
|
372 |
if verbose: |
|
373 |
# having removed it, it must be either ignored or unknown
|
|
374 |
if self.is_ignored(f): |
|
375 |
new_status = 'I' |
|
376 |
else: |
|
377 |
new_status = '?' |
|
378 |
# XXX: Really should be a more abstract reporter interface
|
|
379 |
kind_ch = osutils.kind_marker(self.kind(fid)) |
|
380 |
to_file.write(new_status + ' ' + f + kind_ch + '\n') |
|
381 |
# Unversion file
|
|
382 |
# FIXME: _unversion_path() is O(size-of-index) for directories
|
|
383 |
self._unversion_path(f) |
|
384 |
message = "removed %s" % (f,) |
|
385 |
if osutils.lexists(abs_path): |
|
386 |
if (osutils.isdir(abs_path) and |
|
387 |
len(os.listdir(abs_path)) > 0): |
|
388 |
if force: |
|
389 |
osutils.rmtree(abs_path) |
|
390 |
message = "deleted %s" % (f,) |
|
391 |
else: |
|
392 |
message = backup(f) |
|
393 |
else: |
|
394 |
if not keep_files: |
|
395 |
osutils.delete_any(abs_path) |
|
396 |
message = "deleted %s" % (f,) |
|
|
0.200.1215
by Jelmer Vernooij
Implement GitWorkingTree.remove. |
397 |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
398 |
# print only one message (if any) per file.
|
399 |
if message is not None: |
|
400 |
trace.note(message) |
|
401 |
self.flush() |
|
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
402 |
|
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
403 |
def _add(self, files, ids, kinds): |
404 |
for (path, file_id, kind) in zip(files, ids, kinds): |
|
|
0.200.1201
by Jelmer Vernooij
Implement _set_root_id. |
405 |
if file_id is not None: |
|
0.200.1663
by Jelmer Vernooij
Raise SettingFileIdUnsupported |
406 |
raise workingtree.SettingFileIdUnsupported() |
407 |
self._index_add_entry(path, kind) |
|
|
0.200.1201
by Jelmer Vernooij
Implement _set_root_id. |
408 |
|
|
0.200.1240
by Jelmer Vernooij
Implement GitWorkingTree.smart_add. |
409 |
def smart_add(self, file_list, recurse=True, action=None, save=True): |
410 |
added = [] |
|
411 |
ignored = {} |
|
412 |
user_dirs = [] |
|
|
0.200.1733
by Jelmer Vernooij
Support handling of custom ids in smart_add. |
413 |
def call_action(filepath, kind): |
414 |
if action is not None: |
|
415 |
parent_path = posixpath.dirname(filepath) |
|
416 |
parent_id = self.path2id(parent_path) |
|
417 |
parent_ie = self._get_dir_ie(parent_path, parent_id) |
|
418 |
file_id = action(self, parent_ie, filepath, kind) |
|
419 |
if file_id is not None: |
|
420 |
raise workingtree.SettingFileIdUnsupported() |
|
421 |
||
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
422 |
with self.lock_tree_write(): |
423 |
for filepath in osutils.canonical_relpaths(self.basedir, file_list): |
|
424 |
abspath = self.abspath(filepath) |
|
|
0.200.1240
by Jelmer Vernooij
Implement GitWorkingTree.smart_add. |
425 |
kind = osutils.file_kind(abspath) |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
426 |
if kind in ("file", "symlink"): |
|
0.200.1733
by Jelmer Vernooij
Support handling of custom ids in smart_add. |
427 |
call_action(filepath, kind) |
|
0.200.1308
by Jelmer Vernooij
Write index to disk after adding files. |
428 |
if save: |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
429 |
self._index_add_entry(filepath, kind) |
430 |
added.append(filepath) |
|
431 |
elif kind == "directory": |
|
|
0.200.1733
by Jelmer Vernooij
Support handling of custom ids in smart_add. |
432 |
call_action(filepath, kind) |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
433 |
if recurse: |
434 |
user_dirs.append(filepath) |
|
435 |
else: |
|
436 |
raise errors.BadFileKindError(filename=abspath, kind=kind) |
|
437 |
for user_dir in user_dirs: |
|
438 |
abs_user_dir = self.abspath(user_dir) |
|
439 |
for name in os.listdir(abs_user_dir): |
|
440 |
subp = os.path.join(user_dir, name) |
|
441 |
if self.is_control_filename(subp) or self.mapping.is_special_file(subp): |
|
442 |
continue
|
|
443 |
ignore_glob = self.is_ignored(subp) |
|
444 |
if ignore_glob is not None: |
|
445 |
ignored.setdefault(ignore_glob, []).append(subp) |
|
446 |
continue
|
|
447 |
abspath = self.abspath(subp) |
|
448 |
kind = osutils.file_kind(abspath) |
|
449 |
if kind == "directory": |
|
450 |
user_dirs.append(subp) |
|
451 |
else: |
|
|
0.200.1733
by Jelmer Vernooij
Support handling of custom ids in smart_add. |
452 |
call_action(filepath, kind) |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
453 |
if save: |
454 |
self._index_add_entry(subp, kind) |
|
455 |
if added and save: |
|
456 |
self.flush() |
|
457 |
return added, ignored |
|
|
0.200.1240
by Jelmer Vernooij
Implement GitWorkingTree.smart_add. |
458 |
|
|
0.200.1201
by Jelmer Vernooij
Implement _set_root_id. |
459 |
def _set_root_id(self, file_id): |
460 |
self._fileid_map.set_file_id("", file_id) |
|
|
0.264.2
by Jelmer Vernooij
Implement GitWorkingTree.{_add,__iter__,id2path}. |
461 |
|
|
0.200.1193
by Jelmer Vernooij
Implement GitWorkingTree.{move,rename_one}. |
462 |
def move(self, from_paths, to_dir=None, after=False): |
463 |
rename_tuples = [] |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
464 |
with self.lock_tree_write(): |
465 |
to_abs = self.abspath(to_dir) |
|
466 |
if not os.path.isdir(to_abs): |
|
467 |
raise errors.BzrMoveFailedError('', to_dir, |
|
468 |
errors.NotADirectory(to_abs)) |
|
469 |
||
470 |
for from_rel in from_paths: |
|
471 |
from_tail = os.path.split(from_rel)[-1] |
|
472 |
to_rel = os.path.join(to_dir, from_tail) |
|
473 |
self.rename_one(from_rel, to_rel, after=after) |
|
474 |
rename_tuples.append((from_rel, to_rel)) |
|
475 |
self.flush() |
|
476 |
return rename_tuples |
|
477 |
||
|
0.200.1193
by Jelmer Vernooij
Implement GitWorkingTree.{move,rename_one}. |
478 |
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 |
479 |
from_path = from_rel.encode("utf-8") |
480 |
to_path = to_rel.encode("utf-8") |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
481 |
with self.lock_tree_write(): |
|
0.200.1737
by Jelmer Vernooij
Fix rename tests. |
482 |
if not after: |
483 |
if not self.has_filename(from_rel): |
|
484 |
raise errors.BzrMoveFailedError(from_rel, to_rel, |
|
485 |
errors.NoSuchFile(from_rel)) |
|
486 |
else: |
|
487 |
if not self.has_filename(to_rel): |
|
488 |
raise errors.BzrMoveFailedError(from_rel, to_rel, |
|
489 |
errors.NoSuchFile(to_rel)) |
|
490 |
||
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
491 |
if not from_path in self.index: |
492 |
raise errors.BzrMoveFailedError(from_rel, to_rel, |
|
493 |
errors.NotVersionedError(path=from_rel)) |
|
|
0.200.1737
by Jelmer Vernooij
Fix rename tests. |
494 |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
495 |
if not after: |
|
0.200.1737
by Jelmer Vernooij
Fix rename tests. |
496 |
try: |
497 |
os.rename(self.abspath(from_rel), self.abspath(to_rel)) |
|
498 |
except OSError as e: |
|
499 |
if e.errno == errno.ENOENT: |
|
500 |
raise errors.BzrMoveFailedError(from_rel, to_rel, |
|
501 |
errors.NoSuchFile(to_rel)) |
|
502 |
raise
|
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
503 |
self.index[to_path] = self.index[from_path] |
504 |
del self.index[from_path] |
|
505 |
self.flush() |
|
|
0.200.1193
by Jelmer Vernooij
Implement GitWorkingTree.{move,rename_one}. |
506 |
|
|
0.264.1
by Jelmer Vernooij
Provide stubs using inventory for the moment.: |
507 |
def get_root_id(self): |
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
508 |
return self.path2id("") |
509 |
||
|
0.200.1712
by Jelmer Vernooij
Add file_id prefix. |
510 |
def has_filename(self, filename): |
511 |
return osutils.lexists(self.abspath(filename)) |
|
512 |
||
|
0.200.1242
by Jelmer Vernooij
Support directories better. |
513 |
def _has_dir(self, path): |
|
0.200.1368
by Jelmer Vernooij
There is always a tree root. |
514 |
if path == "": |
515 |
return True |
|
|
0.200.1242
by Jelmer Vernooij
Support directories better. |
516 |
if self._versioned_dirs is None: |
517 |
self._load_dirs() |
|
518 |
return path in self._versioned_dirs |
|
519 |
||
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
520 |
def path2id(self, path): |
|
0.200.1600
by Jelmer Vernooij
Cope with paths as lists of elements. |
521 |
if type(path) is list: |
522 |
path = u"/".join(path) |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
523 |
with self.lock_read(): |
524 |
encoded_path = path.encode("utf-8") |
|
525 |
if self._is_versioned(encoded_path): |
|
526 |
return self._fileid_map.lookup_file_id(encoded_path) |
|
527 |
return None |
|
|
0.264.1
by Jelmer Vernooij
Provide stubs using inventory for the moment.: |
528 |
|
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
529 |
def _iter_files_recursive(self, from_dir=None): |
530 |
if from_dir is None: |
|
531 |
from_dir = "" |
|
532 |
for (dirpath, dirnames, filenames) in os.walk(self.abspath(from_dir)): |
|
|
0.200.1302
by Jelmer Vernooij
Significantly improve performance of WorkingTree.extras(). |
533 |
dir_relpath = dirpath[len(self.basedir):].strip("/") |
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
534 |
if self.controldir.is_control_filename(dir_relpath): |
|
0.200.605
by Jelmer Vernooij
Ignore directories in WorkingTree.extras(). |
535 |
continue
|
|
0.200.615
by Jelmer Vernooij
Optimize WorkingTree.extras(). |
536 |
for filename in filenames: |
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
537 |
if not self.mapping.is_special_file(filename): |
538 |
yield os.path.join(dir_relpath, filename) |
|
|
0.200.1327
by Jelmer Vernooij
Factor out all file browsing in extras. |
539 |
|
540 |
def extras(self): |
|
541 |
"""Yield all unversioned files in this WorkingTree. |
|
542 |
"""
|
|
|
0.200.1676
by Jelmer Vernooij
Fix typo. |
543 |
with self.lock_read(): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
544 |
return set(self._iter_files_recursive()) - set(self.index) |
|
0.200.605
by Jelmer Vernooij
Ignore directories in WorkingTree.extras(). |
545 |
|
|
0.200.382
by Jelmer Vernooij
Support flushing index. |
546 |
def flush(self): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
547 |
with self.lock_tree_write(): |
548 |
# TODO: Maybe this should only write on dirty ?
|
|
549 |
if self._lock_mode != 'w': |
|
550 |
raise errors.NotWriteLocked(self) |
|
551 |
self.index.write() |
|
|
0.200.382
by Jelmer Vernooij
Support flushing index. |
552 |
|
|
0.264.1
by Jelmer Vernooij
Provide stubs using inventory for the moment.: |
553 |
def __iter__(self): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
554 |
with self.lock_read(): |
555 |
for path in self.index: |
|
556 |
yield self.path2id(path) |
|
557 |
self._load_dirs() |
|
558 |
for path in self._versioned_dirs: |
|
559 |
yield self.path2id(path) |
|
|
0.264.1
by Jelmer Vernooij
Provide stubs using inventory for the moment.: |
560 |
|
|
0.200.1202
by Jelmer Vernooij
Implement has_or_had_id. |
561 |
def has_or_had_id(self, file_id): |
562 |
if self.has_id(file_id): |
|
563 |
return True |
|
564 |
if self.had_id(file_id): |
|
565 |
return True |
|
566 |
return False |
|
567 |
||
568 |
def had_id(self, file_id): |
|
569 |
path = self._basis_fileid_map.lookup_file_id(file_id) |
|
570 |
try: |
|
571 |
head = self.repository._git.head() |
|
572 |
except KeyError: |
|
573 |
# Assume no if basis is not accessible
|
|
574 |
return False |
|
|
0.200.1205
by Jelmer Vernooij
Implement GitWorkingTree.stored_kind. |
575 |
if head == ZERO_SHA: |
576 |
return False |
|
|
0.200.1202
by Jelmer Vernooij
Implement has_or_had_id. |
577 |
root_tree = self.store[head].tree |
578 |
try: |
|
579 |
tree_lookup_path(self.store.__getitem__, root_tree, path) |
|
580 |
except KeyError: |
|
581 |
return False |
|
582 |
else: |
|
583 |
return True |
|
584 |
||
|
0.200.1198
by Jelmer Vernooij
Implement GitWorkingTree.has_id. |
585 |
def has_id(self, file_id): |
586 |
try: |
|
587 |
self.id2path(file_id) |
|
588 |
except errors.NoSuchId: |
|
589 |
return False |
|
590 |
else: |
|
591 |
return True |
|
592 |
||
|
0.264.1
by Jelmer Vernooij
Provide stubs using inventory for the moment.: |
593 |
def id2path(self, file_id): |
|
0.200.1532
by Jelmer Vernooij
Cope with float timestamps. |
594 |
assert type(file_id) is str, "file id not a string: %r" % file_id |
|
0.200.1411
by Jelmer Vernooij
Fix control files. |
595 |
file_id = osutils.safe_utf8(file_id) |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
596 |
with self.lock_read(): |
|
0.200.1712
by Jelmer Vernooij
Add file_id prefix. |
597 |
try: |
598 |
path = self._fileid_map.lookup_path(file_id) |
|
599 |
except ValueError: |
|
600 |
raise errors.NoSuchId(self, file_id) |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
601 |
# FIXME: What about directories?
|
602 |
if self._is_versioned(path): |
|
603 |
return path.decode("utf-8") |
|
604 |
raise errors.NoSuchId(self, file_id) |
|
|
0.264.1
by Jelmer Vernooij
Provide stubs using inventory for the moment.: |
605 |
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
606 |
def get_file_mtime(self, path, file_id=None): |
|
0.200.1200
by Jelmer Vernooij
Support GitWorkingTree.get_file_mtime. |
607 |
"""See Tree.get_file_mtime.""" |
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
608 |
try: |
609 |
return os.lstat(self.abspath(path)).st_mtime |
|
610 |
except OSError, (num, msg): |
|
611 |
if num == errno.ENOENT: |
|
612 |
raise errors.NoSuchFile(path) |
|
613 |
raise
|
|
|
0.200.1200
by Jelmer Vernooij
Support GitWorkingTree.get_file_mtime. |
614 |
|
|
0.200.1655
by Jelmer Vernooij
Basic support for git ignores. |
615 |
def is_ignored(self, filename): |
616 |
r"""Check whether the filename matches an ignore pattern. |
|
617 |
||
618 |
If the file is ignored, returns the pattern which caused it to
|
|
619 |
be ignored, otherwise None. So this can simply be used as a
|
|
620 |
boolean if desired."""
|
|
621 |
if getattr(self, '_global_ignoreglobster', None) is None: |
|
622 |
ignore_globs = set() |
|
623 |
ignore_globs.update(ignores.get_runtime_ignores()) |
|
624 |
ignore_globs.update(ignores.get_user_ignores()) |
|
625 |
self._global_ignoreglobster = globbing.ExceptionGlobster(ignore_globs) |
|
|
0.200.1656
by Jelmer Vernooij
Report proper patterns, ignore files. |
626 |
match = self._global_ignoreglobster.match(filename) |
627 |
if match is not None: |
|
628 |
return match |
|
|
0.200.1716
by Jelmer Vernooij
Fix some more tests. |
629 |
try: |
630 |
if self.kind(filename) == 'directory': |
|
631 |
filename += b'/' |
|
632 |
except errors.NoSuchFile: |
|
633 |
pass
|
|
634 |
filename = filename.lstrip(b'/') |
|
|
0.200.1658
by Jelmer Vernooij
Fix handling of ignores - return patterns that matched. |
635 |
ignore_manager = self._get_ignore_manager() |
636 |
ps = list(ignore_manager.find_matching(filename)) |
|
637 |
if not ps: |
|
638 |
return None |
|
639 |
if not ps[-1].is_exclude: |
|
640 |
return None |
|
641 |
return bytes(ps[-1]) |
|
642 |
||
643 |
def _get_ignore_manager(self): |
|
644 |
ignoremanager = getattr(self, '_ignoremanager', None) |
|
645 |
if ignoremanager is not None: |
|
646 |
return ignoremanager |
|
647 |
||
648 |
ignore_manager = IgnoreFilterManager.from_repo(self.repository._git) |
|
649 |
self._ignoremanager = ignore_manager |
|
650 |
return ignore_manager |
|
|
0.200.409
by Jelmer Vernooij
Support parsing .gitignore. |
651 |
|
|
0.200.1716
by Jelmer Vernooij
Fix some more tests. |
652 |
def _flush_ignore_list_cache(self): |
653 |
self._ignoremanager = None |
|
654 |
||
|
0.200.508
by Jelmer Vernooij
Skip inventory caching bits. |
655 |
def set_last_revision(self, revid): |
|
0.200.1720
by Jelmer Vernooij
Fix handling of pending merges. |
656 |
if _mod_revision.is_null(revid): |
657 |
self.branch.set_last_revision_info(0, revid) |
|
658 |
return False |
|
659 |
_mod_revision.check_not_reserved_id(revid) |
|
660 |
try: |
|
661 |
self.branch.generate_revision_history(revid) |
|
662 |
except errors.NoSuchRevision: |
|
663 |
raise errors.GhostRevisionUnusableHere(revid) |
|
|
0.200.508
by Jelmer Vernooij
Skip inventory caching bits. |
664 |
|
|
0.200.379
by Jelmer Vernooij
Re-enable working tree support. |
665 |
def _reset_data(self): |
|
0.248.3
by Jelmer Vernooij
Handle working trees without valid HEAD branch. |
666 |
try: |
667 |
head = self.repository._git.head() |
|
668 |
except KeyError, name: |
|
|
0.200.1308
by Jelmer Vernooij
Write index to disk after adding files. |
669 |
raise errors.NotBranchError("branch %s at %s" % (name, |
670 |
self.repository.base)) |
|
|
0.200.948
by Jelmer Vernooij
Cope with empty inventories. |
671 |
if head == ZERO_SHA: |
|
0.200.1202
by Jelmer Vernooij
Implement has_or_had_id. |
672 |
self._basis_fileid_map = GitFileIdMap({}, self.mapping) |
|
0.200.948
by Jelmer Vernooij
Cope with empty inventories. |
673 |
else: |
|
0.200.1308
by Jelmer Vernooij
Write index to disk after adding files. |
674 |
self._basis_fileid_map = self.mapping.get_fileid_map( |
675 |
self.store.__getitem__, self.store[head].tree) |
|
|
0.200.379
by Jelmer Vernooij
Re-enable working tree support. |
676 |
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
677 |
def get_file_verifier(self, path, file_id=None, stat_value=None): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
678 |
with self.lock_read(): |
679 |
try: |
|
680 |
return ("GIT", self.index[path][-2]) |
|
681 |
except KeyError: |
|
682 |
if self._has_dir(path): |
|
683 |
return ("GIT", None) |
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
684 |
raise errors.NoSuchFile(path) |
|
0.200.1302
by Jelmer Vernooij
Significantly improve performance of WorkingTree.extras(). |
685 |
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
686 |
def get_file_sha1(self, path, file_id=None, stat_value=None): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
687 |
with self.lock_read(): |
688 |
abspath = self.abspath(path).encode(osutils._fs_enc) |
|
689 |
try: |
|
690 |
return osutils.sha_file_by_name(abspath) |
|
691 |
except OSError, (num, msg): |
|
692 |
if num in (errno.EISDIR, errno.ENOENT): |
|
693 |
return None |
|
694 |
raise
|
|
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
695 |
|
|
0.200.610
by Jelmer Vernooij
Support retrieving basis tree properly. |
696 |
def revision_tree(self, revid): |
697 |
return self.repository.revision_tree(revid) |
|
698 |
||
|
0.200.1242
by Jelmer Vernooij
Support directories better. |
699 |
def _is_versioned(self, path): |
|
0.200.1525
by Jelmer Vernooij
Make sure to always use an up-to-date index. |
700 |
assert self._lock_mode is not None |
|
0.200.1242
by Jelmer Vernooij
Support directories better. |
701 |
return (path in self.index or self._has_dir(path)) |
702 |
||
|
0.200.1239
by Jelmer Vernooij
Implement GitWorkingTree.filter_unversioned_files. |
703 |
def filter_unversioned_files(self, files): |
|
0.200.1316
by Jelmer Vernooij
Fix filter_unversioned_files. |
704 |
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. |
705 |
|
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
706 |
def _get_dir_ie(self, path, parent_id): |
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
707 |
file_id = self.path2id(path) |
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
708 |
return inventory.InventoryDirectory(file_id, |
|
0.200.1190
by Jelmer Vernooij
Fix get_symlink_target call. |
709 |
posixpath.basename(path).strip("/"), parent_id) |
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
710 |
|
711 |
def _add_missing_parent_ids(self, path, dir_ids): |
|
712 |
if path in dir_ids: |
|
713 |
return [] |
|
714 |
parent = posixpath.dirname(path).strip("/") |
|
715 |
ret = self._add_missing_parent_ids(parent, dir_ids) |
|
716 |
parent_id = dir_ids[parent] |
|
717 |
ie = self._get_dir_ie(path, parent_id) |
|
718 |
dir_ids[path] = ie.file_id |
|
719 |
ret.append((path, ie)) |
|
720 |
return ret |
|
721 |
||
|
0.200.1321
by Jelmer Vernooij
More fixes for compatibility with bzr.dev testsuite. |
722 |
def _get_file_ie(self, name, path, value, parent_id): |
723 |
assert isinstance(name, unicode) |
|
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
724 |
assert isinstance(path, unicode) |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
725 |
assert isinstance(value, tuple) and len(value) == 10 |
726 |
(ctime, mtime, dev, ino, mode, uid, gid, size, sha, flags) = value |
|
|
0.200.1192
by Jelmer Vernooij
Implement path2id. |
727 |
file_id = self.path2id(path) |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
728 |
if type(file_id) != str: |
729 |
raise AssertionError |
|
730 |
kind = mode_kind(mode) |
|
|
0.200.1321
by Jelmer Vernooij
More fixes for compatibility with bzr.dev testsuite. |
731 |
ie = inventory.entry_factory[kind](file_id, name, parent_id) |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
732 |
if kind == 'symlink': |
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
733 |
ie.symlink_target = self.get_symlink_target(path, file_id) |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
734 |
else: |
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
735 |
data = self.get_file_text(path, file_id) |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
736 |
ie.text_sha1 = osutils.sha_string(data) |
737 |
ie.text_size = len(data) |
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
738 |
ie.executable = self.is_executable(path, file_id) |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
739 |
ie.revision = None |
740 |
return ie |
|
741 |
||
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
742 |
def _is_executable_from_path_and_stat_from_stat(self, path, stat_result): |
743 |
mode = stat_result.st_mode |
|
744 |
return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode) |
|
745 |
||
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
746 |
def stored_kind(self, path, file_id=None): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
747 |
with self.lock_read(): |
748 |
try: |
|
749 |
return mode_kind(self.index[path.encode("utf-8")][4]) |
|
750 |
except KeyError: |
|
751 |
# Maybe it's a directory?
|
|
752 |
if self._has_dir(path): |
|
753 |
return "directory" |
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
754 |
raise errors.NoSuchFile(path) |
|
0.200.1205
by Jelmer Vernooij
Implement GitWorkingTree.stored_kind. |
755 |
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
756 |
def is_executable(self, path, file_id=None): |
|
0.200.1539
by Jelmer Vernooij
Cope with new is_executable. |
757 |
if getattr(self, "_supports_executable", osutils.supports_executable)(): |
758 |
mode = os.lstat(self.abspath(path)).st_mode |
|
759 |
return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode) |
|
760 |
else: |
|
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
761 |
basis_tree = self.basis_tree() |
762 |
if file_id in basis_tree: |
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
763 |
return basis_tree.is_executable(path, file_id) |
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
764 |
# Default to not executable
|
765 |
return False |
|
766 |
||
|
0.200.1539
by Jelmer Vernooij
Cope with new is_executable. |
767 |
def _is_executable_from_path_and_stat(self, path, stat_result): |
768 |
if getattr(self, "_supports_executable", osutils.supports_executable)(): |
|
769 |
return self._is_executable_from_path_and_stat_from_stat(path, stat_result) |
|
770 |
else: |
|
771 |
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. |
772 |
|
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
773 |
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. |
774 |
if from_dir is None: |
775 |
from_dir = "" |
|
|
0.264.11
by Jelmer Vernooij
Completer implementation of iter_entries_by_dir and list_files. |
776 |
dir_ids = {} |
|
0.200.1339
by Jelmer Vernooij
Some reformatting. |
777 |
fk_entries = {'directory': workingtree.TreeDirectory, |
778 |
'file': workingtree.TreeFile, |
|
779 |
'symlink': workingtree.TreeLink} |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
780 |
with self.lock_read(): |
781 |
root_ie = self._get_dir_ie(u"", None) |
|
782 |
if include_root and not from_dir: |
|
783 |
yield "", "V", root_ie.kind, root_ie.file_id, root_ie |
|
784 |
dir_ids[u""] = root_ie.file_id |
|
785 |
if recursive: |
|
786 |
path_iterator = self._iter_files_recursive(from_dir) |
|
787 |
else: |
|
788 |
if from_dir is None: |
|
789 |
start = self.basedir |
|
790 |
else: |
|
791 |
start = os.path.join(self.basedir, from_dir) |
|
792 |
path_iterator = sorted([os.path.join(from_dir, name) for name in |
|
793 |
os.listdir(start) if not self.controldir.is_control_filename(name) |
|
794 |
and not self.mapping.is_special_file(name)]) |
|
795 |
for path in path_iterator: |
|
796 |
try: |
|
797 |
value = self.index[path] |
|
798 |
except KeyError: |
|
799 |
value = None |
|
800 |
path = path.decode("utf-8") |
|
801 |
parent, name = posixpath.split(path) |
|
802 |
for dir_path, dir_ie in self._add_missing_parent_ids(parent, dir_ids): |
|
803 |
yield dir_path, "V", dir_ie.kind, dir_ie.file_id, dir_ie |
|
804 |
if value is not None: |
|
805 |
ie = self._get_file_ie(name, path, value, dir_ids[parent]) |
|
806 |
yield path, "V", ie.kind, ie.file_id, ie |
|
807 |
else: |
|
808 |
kind = osutils.file_kind(self.abspath(path)) |
|
809 |
ie = fk_entries[kind]() |
|
810 |
yield path, ("I" if self.is_ignored(path) else "?"), kind, None, ie |
|
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
811 |
|
|
0.200.1206
by Jelmer Vernooij
Implement GitWorkingTree.all_file_ids. |
812 |
def all_file_ids(self): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
813 |
with self.lock_read(): |
814 |
ids = {u"": self.path2id("")} |
|
815 |
for path in self.index: |
|
816 |
if self.mapping.is_special_file(path): |
|
817 |
continue
|
|
818 |
path = path.decode("utf-8") |
|
819 |
parent = posixpath.dirname(path).strip("/") |
|
820 |
for e in self._add_missing_parent_ids(parent, ids): |
|
821 |
pass
|
|
822 |
ids[path] = self.path2id(path) |
|
823 |
return set(ids.values()) |
|
|
0.200.1206
by Jelmer Vernooij
Implement GitWorkingTree.all_file_ids. |
824 |
|
|
0.200.1710
by Jelmer Vernooij
Regenerate xfail. |
825 |
def all_versioned_paths(self): |
826 |
with self.lock_read(): |
|
827 |
paths = {u""} |
|
828 |
for path in self.index: |
|
829 |
if self.mapping.is_special_file(path): |
|
830 |
continue
|
|
831 |
path = path.decode("utf-8") |
|
832 |
paths.add(path) |
|
833 |
while path != "": |
|
834 |
path = posixpath.dirname(path).strip("/") |
|
835 |
if path in paths: |
|
836 |
break
|
|
837 |
paths.add(path) |
|
838 |
return paths |
|
839 |
||
|
0.200.1374
by Jelmer Vernooij
Implement GitWorkingTree._directory_is_tree_reference. |
840 |
def _directory_is_tree_reference(self, path): |
841 |
# FIXME: Check .gitsubmodules for path
|
|
842 |
return False |
|
843 |
||
|
0.200.1716
by Jelmer Vernooij
Fix some more tests. |
844 |
def iter_child_entries(self, path, file_id=None): |
845 |
encoded_path = path.encode('utf-8') |
|
|
0.200.1739
by Jelmer Vernooij
Fix iteration order for iter_child_entries. |
846 |
parent_id = self.path2id(path) |
|
0.200.1738
by Jelmer Vernooij
Fix test_does_not_exist. |
847 |
found_any = False |
|
0.200.1739
by Jelmer Vernooij
Fix iteration order for iter_child_entries. |
848 |
seen_children = set() |
|
0.200.1716
by Jelmer Vernooij
Fix some more tests. |
849 |
for item_path, value in self.index.iteritems(): |
850 |
if self.mapping.is_special_file(item_path): |
|
851 |
continue
|
|
|
0.200.1739
by Jelmer Vernooij
Fix iteration order for iter_child_entries. |
852 |
if not osutils.is_inside(encoded_path, item_path): |
|
0.200.1716
by Jelmer Vernooij
Fix some more tests. |
853 |
continue
|
|
0.200.1738
by Jelmer Vernooij
Fix test_does_not_exist. |
854 |
found_any = True |
|
0.200.1739
by Jelmer Vernooij
Fix iteration order for iter_child_entries. |
855 |
subpath = posixpath.relpath(item_path, encoded_path) |
|
0.200.1716
by Jelmer Vernooij
Fix some more tests. |
856 |
if b'/' in subpath: |
|
0.200.1739
by Jelmer Vernooij
Fix iteration order for iter_child_entries. |
857 |
dirname = subpath.split(b'/', 1)[0] |
858 |
file_ie = self._get_dir_ie(posixpath.join(path, dirname), parent_id) |
|
859 |
else: |
|
860 |
(parent, name) = posixpath.split(item_path) |
|
861 |
try: |
|
862 |
file_ie = self._get_file_ie(name, item_path, value, parent_id) |
|
863 |
except IOError: |
|
864 |
continue
|
|
|
0.200.1716
by Jelmer Vernooij
Fix some more tests. |
865 |
yield file_ie |
|
0.200.1738
by Jelmer Vernooij
Fix test_does_not_exist. |
866 |
if not found_any: |
867 |
raise errors.NoSuchFile(path) |
|
|
0.200.1716
by Jelmer Vernooij
Fix some more tests. |
868 |
|
|
0.264.9
by Jelmer Vernooij
Implement basic GitWorkingTree.iter_entries_by_dir. |
869 |
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. |
870 |
if yield_parents: |
871 |
raise NotImplementedError(self.iter_entries_by_dir) |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
872 |
with self.lock_read(): |
873 |
if specific_file_ids is not None: |
|
|
0.200.1712
by Jelmer Vernooij
Add file_id prefix. |
874 |
specific_paths = [] |
875 |
for file_id in specific_file_ids: |
|
876 |
assert file_id is not None, "file id %r" % file_id |
|
877 |
specific_paths.append(self.id2path(file_id)) |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
878 |
if specific_paths in ([u""], []): |
879 |
specific_paths = None |
|
880 |
else: |
|
881 |
specific_paths = set(specific_paths) |
|
882 |
else: |
|
|
0.200.1252
by Jelmer Vernooij
Support specific_file_ids in GitWorkingTree.iter_entries_by_dir. |
883 |
specific_paths = None |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
884 |
root_ie = self._get_dir_ie(u"", None) |
|
0.200.1740
by Jelmer Vernooij
Fix iter_entries_by_dir order. |
885 |
ret = {} |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
886 |
if specific_paths is None: |
|
0.200.1740
by Jelmer Vernooij
Fix iter_entries_by_dir order. |
887 |
ret[(None, u"")] = root_ie |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
888 |
dir_ids = {u"": root_ie.file_id} |
889 |
for path, value in self.index.iteritems(): |
|
890 |
if self.mapping.is_special_file(path): |
|
891 |
continue
|
|
892 |
path = path.decode("utf-8") |
|
893 |
if specific_paths is not None and not path in specific_paths: |
|
894 |
continue
|
|
895 |
(parent, name) = posixpath.split(path) |
|
896 |
try: |
|
897 |
file_ie = self._get_file_ie(name, path, value, None) |
|
898 |
except IOError: |
|
899 |
continue
|
|
|
0.200.1730
by Jelmer Vernooij
Fix test_is_executable_dir. |
900 |
if yield_parents or specific_file_ids is None: |
901 |
for (dir_path, dir_ie) in self._add_missing_parent_ids(parent, |
|
902 |
dir_ids): |
|
|
0.200.1740
by Jelmer Vernooij
Fix iter_entries_by_dir order. |
903 |
ret[(posixpath.dirname(dir_path), dir_path)] = dir_ie |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
904 |
file_ie.parent_id = self.path2id(parent) |
|
0.200.1740
by Jelmer Vernooij
Fix iter_entries_by_dir order. |
905 |
ret[(posixpath.dirname(path), path)] = file_ie |
906 |
return ((path, ie) for ((_, path), ie) in sorted(ret.items())) |
|
|
0.264.9
by Jelmer Vernooij
Implement basic GitWorkingTree.iter_entries_by_dir. |
907 |
|
|
0.200.619
by Jelmer Vernooij
Provide dummy WorkingTree.conflicts() implementation rather than spending a lot of time not finding any conflicts. |
908 |
def conflicts(self): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
909 |
with self.lock_read(): |
910 |
# FIXME:
|
|
911 |
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. |
912 |
|
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
913 |
def get_canonical_inventory_path(self, path): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
914 |
with self.lock_read(): |
915 |
for p in self.index: |
|
916 |
if p.lower() == path.lower(): |
|
917 |
return p |
|
918 |
else: |
|
919 |
return path |
|
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
920 |
|
|
0.200.1705
by Jelmer Vernooij
Fix walkdirs. |
921 |
def walkdirs(self, prefix=""): |
|
0.200.1210
by Jelmer Vernooij
Implement GitWorkingTree._walkdirs. |
922 |
if prefix != "": |
923 |
prefix += "/" |
|
924 |
per_dir = defaultdict(list) |
|
925 |
for path, value in self.index.iteritems(): |
|
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
926 |
if self.mapping.is_special_file(path): |
927 |
continue
|
|
|
0.200.1210
by Jelmer Vernooij
Implement GitWorkingTree._walkdirs. |
928 |
if not path.startswith(prefix): |
929 |
continue
|
|
930 |
(dirname, child_name) = posixpath.split(path) |
|
931 |
dirname = dirname.decode("utf-8") |
|
932 |
dir_file_id = self.path2id(dirname) |
|
933 |
assert isinstance(value, tuple) and len(value) == 10 |
|
934 |
(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 |
935 |
stat_result = os.stat_result((mode, ino, |
|
0.200.1211
by Jelmer Vernooij
Fix statresult. |
936 |
dev, 1, uid, gid, size, |
|
0.200.1736
by Jelmer Vernooij
Fix a walkdirs test. |
937 |
int(mtime), int(mtime), int(ctime))) |
|
0.200.1210
by Jelmer Vernooij
Implement GitWorkingTree._walkdirs. |
938 |
per_dir[(dirname, dir_file_id)].append( |
939 |
(path.decode("utf-8"), child_name.decode("utf-8"), |
|
940 |
mode_kind(mode), stat_result, |
|
941 |
self.path2id(path.decode("utf-8")), |
|
942 |
mode_kind(mode))) |
|
943 |
return per_dir.iteritems() |
|
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
944 |
|
|
0.200.1542
by Jelmer Vernooij
Refactor iter_changes. |
945 |
def _lookup_entry(self, path, update_index=False): |
|
0.200.1543
by Jelmer Vernooij
Support symlinks. |
946 |
assert type(path) == str |
|
0.200.1542
by Jelmer Vernooij
Refactor iter_changes. |
947 |
entry = self.index[path] |
948 |
index_mode = entry[-6] |
|
949 |
index_sha = entry[-2] |
|
|
0.200.1741
by Jelmer Vernooij
Fix opentree tests. |
950 |
disk_path = self.abspath(path.decode('utf-8')).encode( |
951 |
osutils._fs_enc) |
|
|
0.284.1
by Jelmer Vernooij
Raise KeyError when file was removed. |
952 |
try: |
953 |
disk_stat = os.lstat(disk_path) |
|
954 |
except OSError, (num, msg): |
|
955 |
if num in (errno.EISDIR, errno.ENOENT): |
|
956 |
raise KeyError(path) |
|
957 |
raise
|
|
|
0.200.1542
by Jelmer Vernooij
Refactor iter_changes. |
958 |
disk_mtime = disk_stat.st_mtime |
959 |
if isinstance(entry[1], tuple): |
|
960 |
index_mtime = entry[1][0] |
|
961 |
else: |
|
962 |
index_mtime = int(entry[1]) |
|
963 |
mtime_delta = (disk_mtime - index_mtime) |
|
964 |
disk_mode = cleanup_mode(disk_stat.st_mode) |
|
965 |
if mtime_delta > 0 or disk_mode != index_mode: |
|
966 |
if stat.S_ISDIR(disk_mode): |
|
967 |
try: |
|
968 |
subrepo = Repo(disk_path) |
|
969 |
except NotGitRepository: |
|
970 |
return (None, None) |
|
971 |
else: |
|
972 |
disk_mode = S_IFGITLINK |
|
973 |
git_id = subrepo.head() |
|
|
0.200.1543
by Jelmer Vernooij
Support symlinks. |
974 |
elif stat.S_ISLNK(disk_mode): |
|
0.200.1715
by Jelmer Vernooij
Fix some more tests. |
975 |
blob = Blob.from_string(os.readlink(disk_path)) |
|
0.200.1543
by Jelmer Vernooij
Support symlinks. |
976 |
git_id = blob.id |
977 |
elif stat.S_ISREG(disk_mode): |
|
|
0.200.1542
by Jelmer Vernooij
Refactor iter_changes. |
978 |
with open(disk_path, 'r') as f: |
979 |
blob = Blob.from_string(f.read()) |
|
980 |
git_id = blob.id |
|
|
0.200.1543
by Jelmer Vernooij
Support symlinks. |
981 |
else: |
982 |
raise AssertionError |
|
|
0.200.1542
by Jelmer Vernooij
Refactor iter_changes. |
983 |
if update_index: |
984 |
flags = 0 # FIXME |
|
|
0.200.1545
by Jelmer Vernooij
Some more test fixes. |
985 |
self.index[path] = index_entry_from_stat(disk_stat, git_id, flags, disk_mode) |
|
0.200.1542
by Jelmer Vernooij
Refactor iter_changes. |
986 |
return (git_id, disk_mode) |
987 |
return (index_sha, index_mode) |
|
988 |
||
|
0.200.1677
by Jelmer Vernooij
Mark shelving as unsupported. |
989 |
def get_shelf_manager(self): |
|
0.200.1729
by Jelmer Vernooij
ShelvingUnsupported doesn't take an argument. |
990 |
raise workingtree.ShelvingUnsupported() |
|
0.200.1677
by Jelmer Vernooij
Mark shelving as unsupported. |
991 |
|
|
0.200.1678
by Jelmer Vernooij
Fix tests. |
992 |
def store_uncommitted(self): |
993 |
raise errors.StoringUncommittedNotSupported(self) |
|
994 |
||
|
0.200.1703
by Jelmer Vernooij
Implement apply_inventory_delta. |
995 |
def apply_inventory_delta(self, changes): |
996 |
for (old_path, new_path, file_id, ie) in changes: |
|
997 |
if old_path is not None: |
|
998 |
del self.index[old_path.encode('utf-8')] |
|
999 |
if new_path is not None and ie.kind != 'directory': |
|
1000 |
self._index_add_entry(new_path, ie.kind) |
|
1001 |
||
|
0.200.1308
by Jelmer Vernooij
Write index to disk after adding files. |
1002 |
|
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
1003 |
class GitWorkingTreeFormat(workingtree.WorkingTreeFormat): |
1004 |
||
|
0.200.1206
by Jelmer Vernooij
Implement GitWorkingTree.all_file_ids. |
1005 |
_tree_class = GitWorkingTree |
1006 |
||
|
0.200.1295
by Jelmer Vernooij
Mark working trees as not supporting directories. |
1007 |
supports_versioned_directories = False |
1008 |
||
|
0.200.1661
by Jelmer Vernooij
Set supports_setting_file_ids to False. |
1009 |
supports_setting_file_ids = False |
1010 |
||
|
0.200.1677
by Jelmer Vernooij
Mark shelving as unsupported. |
1011 |
supports_store_uncommitted = False |
1012 |
||
|
0.200.1723
by Jelmer Vernooij
Set supports_leftmost_parent_id_as_ghost property. |
1013 |
supports_leftmost_parent_id_as_ghost = False |
1014 |
||
|
0.200.656
by Jelmer Vernooij
Implement GitWorkingTreeFormat._matchingbzrdir. |
1015 |
@property
|
|
0.200.1665
by Jelmer Vernooij
Rename _matchingbzrdir to _matchingcnotroldir. |
1016 |
def _matchingcontroldir(self): |
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
1017 |
from .dir import LocalGitControlDirFormat |
|
0.200.1013
by Jelmer Vernooij
More renames. |
1018 |
return LocalGitControlDirFormat() |
|
0.200.656
by Jelmer Vernooij
Implement GitWorkingTreeFormat._matchingbzrdir. |
1019 |
|
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
1020 |
def get_format_description(self): |
1021 |
return "Git Working Tree" |
|
|
0.200.616
by Jelmer Vernooij
Provide custom intertree implementation for GitRevisionTree->GitWorkingTree. |
1022 |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
1023 |
def initialize(self, a_controldir, revision_id=None, from_branch=None, |
|
0.200.1096
by Jelmer Vernooij
Implement GitWorkingTreeFormat.initialize. |
1024 |
accelerator_tree=None, hardlink=False): |
1025 |
"""See WorkingTreeFormat.initialize().""" |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
1026 |
if not isinstance(a_controldir, LocalGitDir): |
1027 |
raise errors.IncompatibleFormat(self, a_controldir) |
|
1028 |
index = Index(a_controldir.root_transport.local_abspath(".git/index")) |
|
|
0.200.1096
by Jelmer Vernooij
Implement GitWorkingTreeFormat.initialize. |
1029 |
index.write() |
|
0.200.1680
by Jelmer Vernooij
Fix repo locks. |
1030 |
wt = GitWorkingTree( |
1031 |
a_controldir, a_controldir.open_repository(), |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
1032 |
a_controldir.open_branch(), index) |
|
0.200.1680
by Jelmer Vernooij
Fix repo locks. |
1033 |
for hook in MutableTree.hooks['post_build_tree']: |
1034 |
hook(wt) |
|
1035 |
return wt |
|
|
0.200.1096
by Jelmer Vernooij
Implement GitWorkingTreeFormat.initialize. |
1036 |
|
|
0.200.616
by Jelmer Vernooij
Provide custom intertree implementation for GitRevisionTree->GitWorkingTree. |
1037 |
|
1038 |
class InterIndexGitTree(tree.InterTree): |
|
1039 |
"""InterTree that works between a Git revision tree and an index.""" |
|
1040 |
||
1041 |
def __init__(self, source, target): |
|
1042 |
super(InterIndexGitTree, self).__init__(source, target) |
|
1043 |
self._index = target.index |
|
1044 |
||
1045 |
@classmethod
|
|
1046 |
def is_compatible(cls, source, target): |
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
1047 |
from .repository import GitRevisionTree |
|
0.200.1636
by Jelmer Vernooij
Some formatting fixes. |
1048 |
return (isinstance(source, GitRevisionTree) and |
|
0.200.616
by Jelmer Vernooij
Provide custom intertree implementation for GitRevisionTree->GitWorkingTree. |
1049 |
isinstance(target, GitWorkingTree)) |
1050 |
||
1051 |
def compare(self, want_unchanged=False, specific_files=None, |
|
1052 |
extra_trees=None, require_versioned=False, include_root=False, |
|
1053 |
want_unversioned=False): |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
1054 |
with self.lock_read(): |
1055 |
# FIXME: Handle include_root
|
|
1056 |
changes = changes_between_git_tree_and_index( |
|
1057 |
self.source.store, self.source.tree, |
|
|
0.200.1731
by Jelmer Vernooij
Add support for checking untracked changes. |
1058 |
self.target, want_unchanged=want_unchanged) |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
1059 |
source_fileid_map = self.source._fileid_map |
1060 |
target_fileid_map = self.target._fileid_map |
|
1061 |
ret = tree_delta_from_git_changes(changes, self.target.mapping, |
|
1062 |
(source_fileid_map, target_fileid_map), |
|
1063 |
specific_file=specific_files, require_versioned=require_versioned) |
|
1064 |
if want_unversioned: |
|
1065 |
for e in self.target.extras(): |
|
|
0.200.1731
by Jelmer Vernooij
Add support for checking untracked changes. |
1066 |
ret.unversioned.append( |
|
0.200.1732
by Jelmer Vernooij
Fix ignore. |
1067 |
(osutils.normalized_filename(e)[0], None, |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
1068 |
osutils.file_kind(self.target.abspath(e)))) |
1069 |
return ret |
|
|
0.200.616
by Jelmer Vernooij
Provide custom intertree implementation for GitRevisionTree->GitWorkingTree. |
1070 |
|
|
0.200.622
by Jelmer Vernooij
Implement InterTree.iter_changes() as well. |
1071 |
def iter_changes(self, include_unchanged=False, specific_files=None, |
|
0.200.1207
by Jelmer Vernooij
Fix some formatting. |
1072 |
pb=None, extra_trees=[], require_versioned=True, |
1073 |
want_unversioned=False): |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
1074 |
with self.lock_read(): |
1075 |
changes = changes_between_git_tree_and_index( |
|
1076 |
self.source.store, self.source.tree, |
|
|
0.200.1731
by Jelmer Vernooij
Add support for checking untracked changes. |
1077 |
self.target, want_unchanged=include_unchanged) |
1078 |
if want_unversioned: |
|
1079 |
changes = itertools.chain( |
|
1080 |
changes, |
|
1081 |
untracked_changes(self.target)) |
|
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
1082 |
return changes_from_git_changes( |
1083 |
changes, self.target.mapping, specific_file=specific_files) |
|
|
0.200.616
by Jelmer Vernooij
Provide custom intertree implementation for GitRevisionTree->GitWorkingTree. |
1084 |
|
|
0.200.1179
by Jelmer Vernooij
Avoid using verifiers for natively imported revisions, save a lot of time. |
1085 |
|
|
0.200.616
by Jelmer Vernooij
Provide custom intertree implementation for GitRevisionTree->GitWorkingTree. |
1086 |
tree.InterTree.register_optimiser(InterIndexGitTree) |
|
0.200.1529
by Jelmer Vernooij
Add changes_between_tree_and_index. |
1087 |
|
1088 |
||
|
0.200.1731
by Jelmer Vernooij
Add support for checking untracked changes. |
1089 |
def untracked_changes(tree): |
1090 |
for e in tree.extras(): |
|
1091 |
ap = tree.abspath(e) |
|
1092 |
st = os.stat(ap) |
|
1093 |
try: |
|
1094 |
np, accessible = osutils.normalized_filename(e) |
|
1095 |
except UnicodeDecodeError: |
|
1096 |
raise errors.BadFilenameEncoding( |
|
1097 |
e, osutils._fs_enc) |
|
1098 |
yield (np, st.st_mode, |
|
1099 |
blob_from_path_and_stat(ap, st).id) |
|
1100 |
||
1101 |
||
|
0.200.1542
by Jelmer Vernooij
Refactor iter_changes. |
1102 |
def changes_between_git_tree_and_index(object_store, tree, target, |
|
0.200.1731
by Jelmer Vernooij
Add support for checking untracked changes. |
1103 |
want_unchanged=False, update_index=False): |
|
0.200.1529
by Jelmer Vernooij
Add changes_between_tree_and_index. |
1104 |
"""Determine the changes between a git tree and a working tree with index. |
1105 |
||
1106 |
"""
|
|
|
0.200.1538
by Jelmer Vernooij
More work on tree-reference support. |
1107 |
|
|
0.200.1542
by Jelmer Vernooij
Refactor iter_changes. |
1108 |
names = target.index._byname.keys() |
1109 |
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. |
1110 |
object_store, tree, want_unchanged=want_unchanged): |
|
0.200.1538
by Jelmer Vernooij
More work on tree-reference support. |
1111 |
if name == (None, None): |
1112 |
continue
|
|
|
0.200.1531
by Jelmer Vernooij
Don't trust index contents - verify against file timestamps. |
1113 |
yield (name, mode, sha) |