bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.358.2
by Jelmer Vernooij
Refresh copyright headers, add my email. |
1 |
# Copyright (C) 2007-2018 Jelmer Vernoij <jelmer@jelmer.uk>
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
2 |
# Copyright (C) 2006, 2007 Canonical Ltd
|
3 |
#
|
|
|
0.201.1
by Jelmer Vernooij
Add very small initial testsuite. |
4 |
# This program is free software; you can redistribute it and/or modify
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
8 |
#
|
|
0.201.1
by Jelmer Vernooij
Add very small initial testsuite. |
9 |
# This program is distributed in the hope that it will be useful,
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
13 |
#
|
|
0.201.1
by Jelmer Vernooij
Add very small initial testsuite. |
14 |
# You should have received a copy of the GNU General Public License
|
15 |
# along with this program; if not, write to the Free Software
|
|
|
0.358.1
by Jelmer Vernooij
Fix FSF address. |
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
0.201.1
by Jelmer Vernooij
Add very small initial testsuite. |
17 |
|
|
0.200.19
by John Arbash Meinel
More refactoring. Add some direct tests for GitModel. |
18 |
"""The basic test suite for bzr-git."""
|
19 |
||
|
0.358.3
by Jelmer Vernooij
Enable absolute import. |
20 |
from __future__ import absolute_import |
21 |
||
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
22 |
from io import BytesIO |
|
0.200.993
by Jelmer Vernooij
Remove all remaining dependencies on C git. |
23 |
|
|
0.200.22
by John Arbash Meinel
Initial work on a GitCommitBuilder to make the test suite run in no-glacial time. |
24 |
import time |
|
0.200.19
by John Arbash Meinel
More refactoring. Add some direct tests for GitModel. |
25 |
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
26 |
from ... import ( |
|
0.200.987
by Jelmer Vernooij
Add DulwichFeature. |
27 |
errors as bzr_errors, |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
28 |
tests, |
29 |
)
|
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
30 |
from ...tests.features import ( |
|
6964.2.6
by Jelmer Vernooij
Avoid importing fastimport until used. |
31 |
Feature, |
32 |
ModuleAvailableFeature, |
|
33 |
)
|
|
|
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
34 |
from .. import ( |
|
0.200.987
by Jelmer Vernooij
Add DulwichFeature. |
35 |
import_dulwich, |
|
0.200.255
by Jelmer Vernooij
Fix formatting. |
36 |
)
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
37 |
|
38 |
TestCase = tests.TestCase |
|
39 |
TestCaseInTempDir = tests.TestCaseInTempDir |
|
40 |
TestCaseWithTransport = tests.TestCaseWithTransport |
|
|
0.202.2
by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data. |
41 |
TestCaseWithMemoryTransport = tests.TestCaseWithMemoryTransport |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
42 |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
43 |
|
|
0.200.1296
by Jelmer Vernooij
Cope with Feature only being available from bzrlib.tests.features. |
44 |
class _DulwichFeature(Feature): |
|
0.200.987
by Jelmer Vernooij
Add DulwichFeature. |
45 |
|
46 |
def _probe(self): |
|
47 |
try: |
|
48 |
import_dulwich() |
|
49 |
except bzr_errors.DependencyNotPresent: |
|
50 |
return False |
|
51 |
return True |
|
52 |
||
53 |
def feature_name(self): |
|
54 |
return 'dulwich' |
|
55 |
||
56 |
||
57 |
DulwichFeature = _DulwichFeature() |
|
|
6964.2.6
by Jelmer Vernooij
Avoid importing fastimport until used. |
58 |
FastimportFeature = ModuleAvailableFeature('fastimport') |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
59 |
|
60 |
||
|
0.200.22
by John Arbash Meinel
Initial work on a GitCommitBuilder to make the test suite run in no-glacial time. |
61 |
class GitBranchBuilder(object): |
62 |
||
|
0.200.23
by John Arbash Meinel
Clean up the builder, start using it for big speed gains. |
63 |
def __init__(self, stream=None): |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
64 |
if not FastimportFeature.available(): |
65 |
raise tests.UnavailableFeature(FastimportFeature) |
|
|
0.200.22
by John Arbash Meinel
Initial work on a GitCommitBuilder to make the test suite run in no-glacial time. |
66 |
self.commit_info = [] |
|
0.200.993
by Jelmer Vernooij
Remove all remaining dependencies on C git. |
67 |
self.orig_stream = stream |
68 |
if stream is None: |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
69 |
self.stream = BytesIO() |
|
0.200.993
by Jelmer Vernooij
Remove all remaining dependencies on C git. |
70 |
else: |
71 |
self.stream = stream |
|
|
0.200.22
by John Arbash Meinel
Initial work on a GitCommitBuilder to make the test suite run in no-glacial time. |
72 |
self._counter = 0 |
|
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
73 |
self._branch = b'refs/heads/master' |
|
0.200.22
by John Arbash Meinel
Initial work on a GitCommitBuilder to make the test suite run in no-glacial time. |
74 |
|
75 |
def set_branch(self, branch): |
|
76 |
"""Set the branch we are committing.""" |
|
77 |
self._branch = branch |
|
78 |
||
|
0.200.23
by John Arbash Meinel
Clean up the builder, start using it for big speed gains. |
79 |
def _write(self, text): |
|
0.200.993
by Jelmer Vernooij
Remove all remaining dependencies on C git. |
80 |
self.stream.write(text) |
|
0.200.23
by John Arbash Meinel
Clean up the builder, start using it for big speed gains. |
81 |
|
82 |
def _writelines(self, lines): |
|
|
0.200.993
by Jelmer Vernooij
Remove all remaining dependencies on C git. |
83 |
self.stream.writelines(lines) |
|
0.200.23
by John Arbash Meinel
Clean up the builder, start using it for big speed gains. |
84 |
|
|
0.200.22
by John Arbash Meinel
Initial work on a GitCommitBuilder to make the test suite run in no-glacial time. |
85 |
def _create_blob(self, content): |
86 |
self._counter += 1 |
|
|
6964.2.6
by Jelmer Vernooij
Avoid importing fastimport until used. |
87 |
from fastimport.commands import BlobCommand |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
88 |
blob = BlobCommand(b'%d' % self._counter, content) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
89 |
self._write(bytes(blob) + b"\n") |
|
0.200.22
by John Arbash Meinel
Initial work on a GitCommitBuilder to make the test suite run in no-glacial time. |
90 |
return self._counter |
91 |
||
|
0.200.551
by Jelmer Vernooij
Properly set InventoryEntry revision when changing symlink targets. |
92 |
def set_symlink(self, path, content): |
93 |
"""Create or update symlink at a given path.""" |
|
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
94 |
mark = self._create_blob(self._encode_path(content)) |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
95 |
mode = b'120000' |
96 |
self.commit_info.append(b'M %s :%d %s\n' |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
97 |
% (mode, mark, self._encode_path(path))) |
|
0.200.551
by Jelmer Vernooij
Properly set InventoryEntry revision when changing symlink targets. |
98 |
|
|
7458.1.1
by Jelmer Vernooij
Support importing Git submodules as tree references. |
99 |
def set_submodule(self, path, commit_sha): |
100 |
"""Create or update submodule at a given path.""" |
|
101 |
mode = b'160000' |
|
102 |
self.commit_info.append( |
|
103 |
b'M %s %s %s\n' % (mode, commit_sha, self._encode_path(path))) |
|
104 |
||
|
0.200.22
by John Arbash Meinel
Initial work on a GitCommitBuilder to make the test suite run in no-glacial time. |
105 |
def set_file(self, path, content, executable): |
106 |
"""Create or update content at a given path.""" |
|
107 |
mark = self._create_blob(content) |
|
108 |
if executable: |
|
|
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
109 |
mode = b'100755' |
|
0.200.22
by John Arbash Meinel
Initial work on a GitCommitBuilder to make the test suite run in no-glacial time. |
110 |
else: |
|
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
111 |
mode = b'100644' |
112 |
self.commit_info.append(b'M %s :%d %s\n' |
|
|
0.200.36
by David Allouche
GitBranchBuilder now handles file names with newlines correctly. |
113 |
% (mode, mark, self._encode_path(path))) |
|
0.200.22
by John Arbash Meinel
Initial work on a GitCommitBuilder to make the test suite run in no-glacial time. |
114 |
|
115 |
def delete_entry(self, path): |
|
116 |
"""This will delete files or symlinks at the given location.""" |
|
|
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
117 |
self.commit_info.append(b'D %s\n' % (self._encode_path(path),)) |
|
0.200.36
by David Allouche
GitBranchBuilder now handles file names with newlines correctly. |
118 |
|
119 |
@staticmethod
|
|
120 |
def _encode_path(path): |
|
|
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
121 |
if isinstance(path, bytes): |
122 |
return path |
|
|
0.200.36
by David Allouche
GitBranchBuilder now handles file names with newlines correctly. |
123 |
if '\n' in path or path[0] == '"': |
124 |
path = path.replace('\\', '\\\\') |
|
125 |
path = path.replace('\n', '\\n') |
|
126 |
path = path.replace('"', '\\"') |
|
127 |
path = '"' + path + '"' |
|
128 |
return path.encode('utf-8') |
|
|
0.200.22
by John Arbash Meinel
Initial work on a GitCommitBuilder to make the test suite run in no-glacial time. |
129 |
|
|
0.200.23
by John Arbash Meinel
Clean up the builder, start using it for big speed gains. |
130 |
# TODO: Author
|
131 |
# TODO: Author timestamp+timezone
|
|
|
0.200.22
by John Arbash Meinel
Initial work on a GitCommitBuilder to make the test suite run in no-glacial time. |
132 |
def commit(self, committer, message, timestamp=None, |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
133 |
timezone=b'+0000', author=None, |
|
0.200.23
by John Arbash Meinel
Clean up the builder, start using it for big speed gains. |
134 |
merge=None, base=None): |
135 |
"""Commit the new content. |
|
136 |
||
137 |
:param committer: The name and address for the committer
|
|
138 |
:param message: The commit message
|
|
139 |
:param timestamp: The timestamp for the commit
|
|
140 |
:param timezone: The timezone of the commit, such as '+0000' or '-1000'
|
|
141 |
:param author: The name and address of the author (if different from
|
|
142 |
committer)
|
|
143 |
:param merge: A list of marks if this should merge in another commit
|
|
144 |
:param base: An id for the base revision (primary parent) if that
|
|
145 |
is not the last commit.
|
|
146 |
:return: A mark which can be used in the future to reference this
|
|
147 |
commit.
|
|
148 |
"""
|
|
|
0.200.22
by John Arbash Meinel
Initial work on a GitCommitBuilder to make the test suite run in no-glacial time. |
149 |
self._counter += 1 |
|
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
150 |
mark = b'%d' % (self._counter,) |
|
0.200.23
by John Arbash Meinel
Clean up the builder, start using it for big speed gains. |
151 |
if timestamp is None: |
152 |
timestamp = int(time.time()) |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
153 |
self._write(b'commit %s\n' % (self._branch,)) |
154 |
self._write(b'mark :%s\n' % (mark,)) |
|
|
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
155 |
self._write(b'committer %s %ld %s\n' |
|
0.200.23
by John Arbash Meinel
Clean up the builder, start using it for big speed gains. |
156 |
% (committer, timestamp, timezone)) |
|
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
157 |
if not isinstance(message, bytes): |
158 |
message = message.encode('UTF-8') |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
159 |
self._write(b'data %d\n' % (len(message),)) |
|
0.200.23
by John Arbash Meinel
Clean up the builder, start using it for big speed gains. |
160 |
self._write(message) |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
161 |
self._write(b'\n') |
|
0.200.23
by John Arbash Meinel
Clean up the builder, start using it for big speed gains. |
162 |
if base is not None: |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
163 |
self._write(b'from :%s\n' % (base,)) |
|
0.200.23
by John Arbash Meinel
Clean up the builder, start using it for big speed gains. |
164 |
if merge is not None: |
165 |
for m in merge: |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
166 |
self._write(b'merge :%s\n' % (m,)) |
|
0.200.23
by John Arbash Meinel
Clean up the builder, start using it for big speed gains. |
167 |
self._writelines(self.commit_info) |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
168 |
self._write(b'\n') |
|
0.200.22
by John Arbash Meinel
Initial work on a GitCommitBuilder to make the test suite run in no-glacial time. |
169 |
self.commit_info = [] |
170 |
return mark |
|
171 |
||
|
0.200.34
by David Allouche
GitBranchBuilder.reset() |
172 |
def reset(self, ref=None, mark=None): |
173 |
"""Create or recreate the named branch. |
|
174 |
||
175 |
:param ref: branch name, defaults to the current branch.
|
|
176 |
:param mark: commit the branch will point to.
|
|
177 |
"""
|
|
178 |
if ref is None: |
|
179 |
ref = self._branch |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
180 |
self._write(b'reset %s\n' % (ref,)) |
|
0.200.34
by David Allouche
GitBranchBuilder.reset() |
181 |
if mark is not None: |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
182 |
self._write(b'from :%s\n' % mark) |
183 |
self._write(b'\n') |
|
|
0.200.34
by David Allouche
GitBranchBuilder.reset() |
184 |
|
|
0.200.23
by John Arbash Meinel
Clean up the builder, start using it for big speed gains. |
185 |
def finish(self): |
186 |
"""We are finished building, close the stream, get the id mapping""" |
|
|
0.200.993
by Jelmer Vernooij
Remove all remaining dependencies on C git. |
187 |
self.stream.seek(0) |
188 |
if self.orig_stream is None: |
|
189 |
from dulwich.repo import Repo |
|
190 |
r = Repo(".") |
|
|
0.200.1045
by Jelmer Vernooij
Use new fastexport import processor in Dulwich. |
191 |
from dulwich.fastexport import GitImportProcessor |
192 |
importer = GitImportProcessor(r) |
|
|
0.200.993
by Jelmer Vernooij
Remove all remaining dependencies on C git. |
193 |
return importer.import_stream(self.stream) |
|
0.200.22
by John Arbash Meinel
Initial work on a GitCommitBuilder to make the test suite run in no-glacial time. |
194 |
|
195 |
||
|
7002.2.1
by Martin
Avoid import error from bp.git without dulwich |
196 |
class MissingFeature(tests.TestCase): |
197 |
||
198 |
def test_dulwich(self): |
|
199 |
self.requireFeature(DulwichFeature) |
|
200 |
||
201 |
||
|
7490.51.1
by Jelmer Vernooij
Move vfs ratchet functions to a separate function. |
202 |
def load_tests(loader, basic_tests, pattern): |
203 |
suite = loader.suiteClass() |
|
204 |
# add the tests for this module
|
|
205 |
suite.addTests(basic_tests) |
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
206 |
|
|
7490.51.1
by Jelmer Vernooij
Move vfs ratchet functions to a separate function. |
207 |
prefix = __name__ + '.' |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
208 |
|
|
7002.2.1
by Martin
Avoid import error from bp.git without dulwich |
209 |
if not DulwichFeature.available(): |
210 |
suite.addTests(loader.loadTestsFromTestCase(MissingFeature)) |
|
211 |
return suite |
|
212 |
||
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
213 |
testmod_names = [ |
|
0.200.813
by Jelmer Vernooij
Add tests for revspec. |
214 |
'test_blackbox', |
|
0.200.22
by John Arbash Meinel
Initial work on a GitCommitBuilder to make the test suite run in no-glacial time. |
215 |
'test_builder', |
|
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
216 |
'test_branch', |
|
0.200.938
by Jelmer Vernooij
Rename shamap to cache, as it can also do content caching now. |
217 |
'test_cache', |
|
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
218 |
'test_dir', |
|
0.200.196
by Jelmer Vernooij
Add simple tests and docstrings for GraphWalker. |
219 |
'test_fetch', |
|
0.200.1515
by Jelmer Vernooij
Add tests for git_remote_helper. |
220 |
'test_git_remote_helper', |
|
0.200.258
by Jelmer Vernooij
add tests for file id escape/unescape. |
221 |
'test_mapping', |
|
0.360.7
by Jelmer Vernooij
Add tests for memorytree. |
222 |
'test_memorytree', |
|
0.200.799
by Jelmer Vernooij
Add trivial object store tests. |
223 |
'test_object_store', |
|
0.277.2
by Jelmer Vernooij
Add tests for basic pristine tar extraction function. |
224 |
'test_pristine_tar', |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
225 |
'test_push', |
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
226 |
'test_remote', |
|
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
227 |
'test_repository', |
|
0.200.872
by Jelmer Vernooij
Move refs code to separate module. |
228 |
'test_refs', |
|
0.200.813
by Jelmer Vernooij
Add tests for revspec. |
229 |
'test_revspec', |
|
0.252.1
by Jelmer Vernooij
Support storing revision id data. |
230 |
'test_roundtrip', |
|
0.200.1430
by Jelmer Vernooij
Add basic tests for server. |
231 |
'test_server', |
|
0.200.936
by Jelmer Vernooij
Test transportgit. |
232 |
'test_transportgit', |
|
7490.63.2
by Jelmer Vernooij
Fix rename tracking for git. |
233 |
'test_tree', |
|
0.200.1292
by Jelmer Vernooij
Fix repeeling objects when determining what to send. |
234 |
'test_unpeel_map', |
|
0.408.1
by Jelmer Vernooij
Convert Git URLs in stored config to Breezy URLs. |
235 |
'test_urls', |
|
0.262.1
by Jelmer Vernooij
Fix WorkingTree.conflicts(). |
236 |
'test_workingtree', |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
237 |
]
|
|
0.201.1
by Jelmer Vernooij
Add very small initial testsuite. |
238 |
|
|
7490.51.1
by Jelmer Vernooij
Move vfs ratchet functions to a separate function. |
239 |
# add the tests for the sub modules
|
240 |
suite.addTests(loader.loadTestsFromModuleNames( |
|
241 |
[prefix + module_name for module_name in testmod_names])) |
|
|
0.201.1
by Jelmer Vernooij
Add very small initial testsuite. |
242 |
return suite |