bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
4763.2.4
by John Arbash Meinel
merge bzr.2.1 in preparation for NEWS entry. |
1 |
# Copyright (C) 2006-2010 Canonical Ltd
|
1852.7.1
by Robert Collins
Move RevisionTree out of tree.py. |
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
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1852.7.1
by Robert Collins
Move RevisionTree out of tree.py. |
16 |
|
6379.6.7
by Jelmer Vernooij
Move importing from future until after doc string, otherwise the doc string will disappear. |
17 |
"""RevisionTree - a Tree implementation backed by repository data for a revision."""
|
18 |
||
6379.6.3
by Jelmer Vernooij
Use absolute_import. |
19 |
from __future__ import absolute_import |
20 |
||
6977.2.1
by Jelmer Vernooij
Require that get_file implementations are contect managers, simplify file handling in transform. |
21 |
from io import BytesIO |
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
22 |
from . import ( |
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
23 |
errors, |
6754.8.3
by Jelmer Vernooij
Use context manager in decorators. |
24 |
lock, |
2255.2.83
by John Arbash Meinel
[merge] bzr.dev 2294 |
25 |
revision, |
4241.6.7
by Vincent Ladeuil
Add InterCHKRevisionTree |
26 |
tree, |
2249.5.13
by John Arbash Meinel
Finish auditing Repository, and fix generate_ids to always generate utf8 ids. |
27 |
)
|
4241.6.7
by Vincent Ladeuil
Add InterCHKRevisionTree |
28 |
|
29 |
||
5793.2.2
by Jelmer Vernooij
Split inventory-specific code out of RevisionTree into InventoryRevisionTree. |
30 |
class RevisionTree(tree.Tree): |
1852.7.1
by Robert Collins
Move RevisionTree out of tree.py. |
31 |
"""Tree viewing a previous revision. |
32 |
||
33 |
File text can be retrieved from the text store.
|
|
34 |
"""
|
|
3008.1.13
by Michael Hudson
merge bzr.dev |
35 |
|
5793.2.2
by Jelmer Vernooij
Split inventory-specific code out of RevisionTree into InventoryRevisionTree. |
36 |
def __init__(self, repository, revision_id): |
37 |
self._repository = repository |
|
2858.2.1
by Martin Pool
Remove most calls to safe_file_id and safe_revision_id. |
38 |
self._revision_id = revision_id |
3398.1.24
by Ian Clatworthy
make iter_search_rules a tree method |
39 |
self._rules_searcher = None |
1852.7.1
by Robert Collins
Move RevisionTree out of tree.py. |
40 |
|
6110.6.1
by Jelmer Vernooij
Add Tree.has_versioned_directories. |
41 |
def has_versioned_directories(self): |
42 |
"""See `Tree.has_versioned_directories`.""" |
|
43 |
return self._repository._format.supports_versioned_directories |
|
44 |
||
2100.3.20
by Aaron Bentley
Implement tree comparison for tree references |
45 |
def supports_tree_reference(self): |
4370.3.2
by Ian Clatworthy
apply jam's review feedback |
46 |
return getattr(self._repository._format, "supports_tree_reference", |
47 |
False) |
|
2100.3.20
by Aaron Bentley
Implement tree comparison for tree references |
48 |
|
1852.7.1
by Robert Collins
Move RevisionTree out of tree.py. |
49 |
def get_parent_ids(self): |
50 |
"""See Tree.get_parent_ids. |
|
51 |
||
52 |
A RevisionTree's parents match the revision graph.
|
|
53 |
"""
|
|
1908.11.3
by Robert Collins
Merge bzr.dev |
54 |
if self._revision_id in (None, revision.NULL_REVISION): |
55 |
parent_ids = [] |
|
1908.11.2
by Robert Collins
Implement WorkingTree interface conformance tests for |
56 |
else: |
1986.1.2
by Robert Collins
Various changes to allow non-workingtree specific tests to run entirely |
57 |
parent_ids = self._repository.get_revision( |
58 |
self._revision_id).parent_ids |
|
1852.7.1
by Robert Collins
Move RevisionTree out of tree.py. |
59 |
return parent_ids |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
60 |
|
1852.7.1
by Robert Collins
Move RevisionTree out of tree.py. |
61 |
def get_revision_id(self): |
62 |
"""Return the revision id associated with this tree.""" |
|
63 |
return self._revision_id |
|
64 |
||
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
65 |
def get_file_revision(self, path, file_id=None): |
5793.2.3
by Jelmer Vernooij
Add a RevisionTree.get_file_revision() method. |
66 |
"""Return the revision id in which a file was last changed.""" |
67 |
raise NotImplementedError(self.get_file_revision) |
|
68 |
||
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
69 |
def get_file_text(self, path, file_id=None): |
6874.2.1
by Jelmer Vernooij
Make Tree.iter_files_bytes() take paths rather than file_ids. |
70 |
for (identifier, content) in self.iter_files_bytes([(path, None)]): |
6973.5.10
by Jelmer Vernooij
Random bunch of python3 bee-improvements. |
71 |
ret = b"".join(content) |
6280.10.14
by Jelmer Vernooij
cope with slightly different behaviour. |
72 |
return ret |
1852.7.1
by Robert Collins
Move RevisionTree out of tree.py. |
73 |
|
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
74 |
def get_file(self, path, file_id=None): |
75 |
return BytesIO(self.get_file_text(path, file_id)) |
|
1852.7.1
by Robert Collins
Move RevisionTree out of tree.py. |
76 |
|
5793.2.2
by Jelmer Vernooij
Split inventory-specific code out of RevisionTree into InventoryRevisionTree. |
77 |
def is_locked(self): |
78 |
return self._repository.is_locked() |
|
79 |
||
80 |
def lock_read(self): |
|
81 |
self._repository.lock_read() |
|
6754.8.3
by Jelmer Vernooij
Use context manager in decorators. |
82 |
return lock.LogicalLockResult(self.unlock) |
5793.2.2
by Jelmer Vernooij
Split inventory-specific code out of RevisionTree into InventoryRevisionTree. |
83 |
|
84 |
def __repr__(self): |
|
85 |
return '<%s instance at %x, rev_id=%r>' % ( |
|
86 |
self.__class__.__name__, id(self), self._revision_id) |
|
87 |
||
88 |
def unlock(self): |
|
89 |
self._repository.unlock() |
|
90 |
||
91 |
def _get_rules_searcher(self, default_searcher): |
|
92 |
"""See Tree._get_rules_searcher.""" |
|
93 |
if self._rules_searcher is None: |
|
94 |
self._rules_searcher = super(RevisionTree, |
|
95 |
self)._get_rules_searcher(default_searcher) |
|
96 |
return self._rules_searcher |