~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/test_baz_import.py

  • Committer: Robert Collins
  • Date: 2005-09-13 16:52:44 UTC
  • mto: (147.2.6) (364.1.3 bzrtools)
  • mto: This revision was merged to the branch mainline in revision 324.
  • Revision ID: robertc@robertcollins.net-20050913165244-2c4a9223d286580c
handle missing ancestry

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import os
25
25
from baz_import import import_version, revision_id, cmd_baz_import
26
26
from bzrlib.branch import find_branch
 
27
from bzrlib.errors import NoSuchRevision
27
28
import shutil
28
29
from StringIO import StringIO
29
30
import tempfile
49
50
        self._oldhome = os.environ['HOME']
50
51
        os.mkdir(self._homedir)
51
52
        os.environ['HOME'] = self._homedir
 
53
 
52
54
        self._archiveroot = os.path.join(self._tmpdir, 'archive')
53
 
 
54
55
        self._archive = pybaz.make_archive('demo@DONOTUSE', str(self._archiveroot))
55
56
        pybaz.set_my_id("Test User<test@example.org>")
56
57
 
93
94
        shutil.rmtree(os.path.join(self._tmpdir, 'tree'))
94
95
 
95
96
        self.make_import_symlink()
 
97
        self.make_missing_ancestor()
96
98
 
97
99
    def make_import_symlink(self):
98
100
        self._import_symlink = 'demo@DONOTUSE/c--import-symlink--0'
120
122
        tree.import_(msg)
121
123
        shutil.rmtree(os.path.join(self._tmpdir, 'tree'))
122
124
 
 
125
    def make_missing_ancestor(self):
 
126
        self._archivegoneroot = os.path.join(self._tmpdir, 'archivegone')
 
127
        self._archive = pybaz.make_archive('demo-gone@DONOTUSE',
 
128
                                           str(self._archivegoneroot))
 
129
        self._missing_import = 'demo-gone@DONOTUSE/c--import--0'
 
130
        self._missing_import_bzr = revision_id(self._missing_import 
 
131
                                                 + '--base-0')
 
132
        self._missing_ancestor = 'demo@DONOTUSE/c--gone--0'
 
133
        self._missing_ancestor_bzr = revision_id(self._missing_ancestor 
 
134
                                                 + '--base-0')
 
135
        os.mkdir(os.path.join(self._tmpdir, 'tree'))
 
136
        tree = pybaz.init_tree(os.path.join(self._tmpdir, 'tree'), 
 
137
                               self._missing_import)
 
138
        msg = tree.log_message()
 
139
        msg["summary"] = "I am importing now"
 
140
        tree.import_(msg)
 
141
        shutil.rmtree(os.path.join(self._tmpdir, 'tree'))
 
142
        # tag into the kept archive
 
143
        pybaz.Revision(self._missing_import + '--base-0').make_continuation(
 
144
            pybaz.Version(self._missing_ancestor))
 
145
        # and make it inaccessible
 
146
        pybaz.Archive('demo-gone@DONOTUSE').unregister()
 
147
 
123
148
    @classmethod
124
149
    def _makeResource(self):
125
150
        return BazTreeResource()
333
358
        self.assertEqual(entry.kind, 'symlink')
334
359
        self.assertEqual(entry.symlink_target, 'missing-file-name')
335
360
 
 
361
    def test_missing_ancestor(self):
 
362
        import_version('output', pybaz.Version(self._baz._missing_ancestor),
 
363
                       self.collect)
 
364
        # expected results:
 
365
        # one commits, no files, revision identifiers of 
 
366
        # 'demo@DONOTUSE_c--gone--0--base-0' and
 
367
        # a merge of demo-gone@DONOTUSE%c--import--0
 
368
        branch = find_branch('output', find_root=False)
 
369
        self.assertEqual(branch.revision_history(),
 
370
                         [self._baz._missing_ancestor_bzr])
 
371
        rev = branch.get_revision(self._baz._missing_ancestor_bzr)
 
372
        # and again.
 
373
        import_version('output2', pybaz.Version(self._baz._missing_ancestor),
 
374
                       self.collect)
 
375
        branch2 = find_branch('output2', find_root=False)
 
376
        self.assertEqual(branch.revision_history(), branch2.revision_history())
 
377
        rev2 = branch2.get_revision(self._baz._missing_ancestor_bzr)
 
378
        # they must be the same
 
379
        self.assertEqual(rev, rev2)
 
380
 
 
381
        # and we should get some expected values:
 
382
        self.assertEqual(rev.committer, "Test User<test@example.org>")
 
383
        self.assertEqual(rev.message, "tag of demo-gone@DONOTUSE/c--import--0--base-0")
 
384
        self.assertEqual(rev.revision_id, self._baz._missing_ancestor_bzr)
 
385
        self.assertEqual(rev.parents[0].revision_id,
 
386
                         self._baz._missing_import_bzr)
 
387
        self.assertEqual(1, len(rev.parents))
 
388
 
 
389
        # must NOT be able to get the merged evision
 
390
        self.assertRaises(NoSuchRevision, branch.get_revision, 
 
391
                          self._baz._missing_import_bzr)
 
392
 
336
393
 
337
394
class TestNamespacePrevious(TestCase):
338
395