13
13
# You should have received a copy of the GNU General Public License
14
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
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
95
95
br_a3.fetch(br_a2, br_a.revision_history()[2])
96
96
# pull the 3 revisions introduced by a@u-0-3
97
97
br_a3.fetch(br_a2, br_a.revision_history()[3])
98
# InstallFailed should be raised if the branch is missing the revision
98
# NoSuchRevision should be raised if the branch is missing the revision
99
99
# that was requested.
100
self.assertRaises(errors.InstallFailed, br_a3.fetch, br_a2, 'pizza')
100
self.assertRaises(errors.NoSuchRevision, br_a3.fetch, br_a2, 'pizza')
102
102
# TODO: Test trying to fetch from a branch that points to a revision not
103
103
# actually present in its repository. Not every branch format allows you
321
321
self.assertEqual(1, self._count_log_matches('branch/format', http_logs))
322
322
self.assertEqual(1, self._count_log_matches('repository/format',
324
self.assertEqual(1, self._count_log_matches('revisions.kndx',
324
326
self.assertTrue(1 >= self._count_log_matches('revision-history',
326
328
self.assertTrue(1 >= self._count_log_matches('last-revision',
328
self.assertEqual(4, len(http_logs))
330
self.assertLength(5, http_logs)
331
333
class TestKnitToPackFetch(TestCaseWithTransport):
333
def find_get_record_stream(self, calls):
334
"""In a list of calls, find 'get_record_stream' calls.
335
def find_get_record_stream(self, calls, expected_count=1):
336
"""In a list of calls, find the last 'get_record_stream'.
336
This also ensures that there is only one get_record_stream call.
338
:param expected_count: The number of calls we should exepect to find.
339
If a different number is found, an assertion is raised.
338
341
get_record_call = None
339
343
for call in calls:
340
344
if call[0] == 'get_record_stream':
341
self.assertIs(None, get_record_call,
342
"there should only be one call to"
343
" get_record_stream")
344
346
get_record_call = call
345
self.assertIsNot(None, get_record_call,
346
"there should be exactly one call to "
347
" get_record_stream")
347
self.assertEqual(expected_count, call_count)
348
348
return get_record_call
350
350
def test_fetch_with_deltas_no_delta_closure(self):
370
370
target._format._fetch_order, False),
371
371
self.find_get_record_stream(source.texts.calls))
372
372
self.assertEqual(('get_record_stream', [('rev-one',)],
373
target._format._fetch_order, False),
374
self.find_get_record_stream(source.inventories.calls))
373
target._format._fetch_order, False),
374
self.find_get_record_stream(source.inventories.calls, 2))
375
375
self.assertEqual(('get_record_stream', [('rev-one',)],
376
376
target._format._fetch_order, False),
377
377
self.find_get_record_stream(source.revisions.calls))
414
414
target._format._fetch_order, True),
415
415
self.find_get_record_stream(source.texts.calls))
416
416
self.assertEqual(('get_record_stream', [('rev-one',)],
417
target._format._fetch_order, True),
418
self.find_get_record_stream(source.inventories.calls))
417
target._format._fetch_order, True),
418
self.find_get_record_stream(source.inventories.calls, 2))
419
419
self.assertEqual(('get_record_stream', [('rev-one',)],
420
420
target._format._fetch_order, True),
421
421
self.find_get_record_stream(source.revisions.calls))
578
578
self.repo.fetch(self.tree.branch.repository, 'second-id')
579
579
root_id = self.tree.get_root_id()
580
580
self.assertEqual(
581
((root_id, 'left-parent'), (root_id, 'ghost-parent'),
582
(root_id, 'not-ghost-parent')),
581
((root_id, 'left-parent'), (root_id, 'not-ghost-parent')),
583
582
self.get_parents(root_id, 'second-id'))
585
584
def make_two_commits(self, change_root, fetch_twice):