259
259
class CSetTester(InTempDir):
261
def get_valid_cset(self, base_rev_id, rev_id, auto_commit=False):
261
def get_valid_cset(self, base_rev_id, rev_id, auto_commit=False, checkout_dir=None):
262
262
"""Create a changeset from base_rev_id -> rev_id in built-in branch.
263
263
Make sure that the text generated is valid, and that it
264
264
can be applied against the base, and generate the same information.
308
308
if sha1 is not None:
309
309
self.assertEqual(sha1, c_par.revision_sha1)
311
self.valid_apply_changeset(base_rev_id, cset, auto_commit=auto_commit)
311
self.valid_apply_changeset(base_rev_id, cset,
312
auto_commit=auto_commit, checkout_dir=checkout_dir)
315
def get_checkout(self, rev_id):
316
def get_checkout(self, rev_id, checkout_dir=None):
316
317
"""Get a new tree, with the specified revision in it.
318
319
from bzrlib.branch import find_branch
320
321
from bzrlib.merge import merge
322
dirname = tempfile.mkdtemp(prefix='test-branch-', dir='.')
323
to_branch = find_branch(dirname, init=True)
323
if checkout_dir is None:
324
checkout_dir = tempfile.mkdtemp(prefix='test-branch-', dir='.')
325
to_branch = find_branch(checkout_dir, init=True)
324
326
# TODO: Once root ids are established, remove this if
325
327
if hasattr(self.b1, 'get_root_id'):
326
328
to_branch.set_root_id(self.b1.get_root_id())
331
333
self.assert_(rev_id in rh, 'Missing revision %s in base tree' % rev_id)
332
334
revno = self.b1.revision_history().index(rev_id) + 1
333
335
to_branch.update_revisions(self.b1, stop_revision=revno)
334
merge((dirname, -1), (dirname, 0), this_dir=dirname,
336
merge((checkout_dir, -1), (checkout_dir, 0), this_dir=checkout_dir,
335
337
check_clean=False, ignore_zero=True)
338
def valid_apply_changeset(self, base_rev_id, cset, auto_commit=False):
340
def valid_apply_changeset(self, base_rev_id, cset,
341
auto_commit=False, checkout_dir=None):
339
342
"""Get the base revision, apply the changes, and make
340
343
sure everything matches the builtin branch.
342
345
from apply_changeset import _apply_cset
344
to_branch = self.get_checkout(base_rev_id)
347
to_branch = self.get_checkout(base_rev_id, checkout_dir=checkout_dir)
345
348
auto_committed = _apply_cset(to_branch, cset, auto_commit=auto_commit)
471
474
open('b1/sub/dir/WithCaps.txt', 'ab').write('\nAdding some text\n')
472
#open('b1/sub/dir/trailing space ', 'ab').write('\nAdding some\nDOS format lines\n')
473
#self.b1.rename_one('sub/dir/trailing space ', 'sub/start and end space')
475
open('b1/sub/dir/trailing space ', 'ab').write('\nAdding some\nDOS format lines\n')
476
self.b1.rename_one('sub/dir/trailing space ', 'sub/ start and end space ')
474
477
self.b1.commit('Modified files', rev_id='a@cset-0-5')
475
cset = self.get_valid_cset('a@cset-0-4', 'a@cset-0-5')
478
cset = self.get_valid_cset('a@cset-0-4', 'a@cset-0-5', checkout_dir='Broken')
476
479
cset = self.get_valid_cset('a@cset-0-4', 'a@cset-0-5', auto_commit=True)
477
480
cset = self.get_valid_cset(None, 'a@cset-0-5', auto_commit=True)