~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to testchangeset.py

  • Committer: John Arbash Meinel
  • Date: 2005-07-16 17:38:55 UTC
  • mto: (1185.82.1 bzr-w-changeset) (0.5.98)
  • mto: This revision was merged to the branch mainline in revision 1738.
  • Revision ID: john@arbash-meinel.com-20050716173855-a38d2990b32a4649
Fixed a bug in the rename code, added more tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
258
258
 
259
259
class CSetTester(InTempDir):
260
260
 
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)
310
310
 
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)
312
313
 
313
314
        return cset
314
315
 
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.
317
318
        """
318
319
        from bzrlib.branch import find_branch
319
320
        import tempfile
320
321
        from bzrlib.merge import merge
321
322
 
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)
336
338
        return to_branch
337
339
 
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.
341
344
        """
342
345
        from apply_changeset import _apply_cset
343
346
 
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)
346
349
 
347
350
        info = cset[0]
469
472
 
470
473
        # Modified files
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)
478
481