/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_parents.py

  • Committer: Martin von Gagern
  • Date: 2010-04-20 08:47:38 UTC
  • mfrom: (5167 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5195.
  • Revision ID: martin.vgagern@gmx.net-20100420084738-ygymnqmdllzrhpfn
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
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
16
16
 
17
17
"""Tests of the parent related functions of WorkingTrees."""
18
18
 
24
24
    osutils,
25
25
    revision as _mod_revision,
26
26
    symbol_versioning,
 
27
    tests,
27
28
    )
28
29
from bzrlib.inventory import (
29
30
    Inventory,
32
33
    InventoryLink,
33
34
    )
34
35
from bzrlib.revision import Revision
35
 
from bzrlib.tests import SymlinkFeature, TestNotApplicable
36
 
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
 
36
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
37
37
from bzrlib.uncommit import uncommit
38
38
 
39
39
 
227
227
                            (rev3, rev_tree3)])
228
228
        self.assertConsistentParents([rev2, rev3], t)
229
229
 
 
230
    def test_unicode_symlink(self):
 
231
        # this tests bug #272444
 
232
        self.requireFeature(tests.SymlinkFeature)
 
233
        self.requireFeature(tests.UnicodeFilenameFeature)
 
234
 
 
235
        tree = self.make_branch_and_tree('tree1')
 
236
 
 
237
        # The link points to a file whose name is an omega
 
238
        # U+03A9 GREEK CAPITAL LETTER OMEGA
 
239
        # UTF-8: ce a9  UTF-16BE: 03a9  Decimal: Ω
 
240
        target = u'\u03a9'
 
241
        link_name = u'\N{Euro Sign}link'
 
242
        os.symlink(target, 'tree1/' + link_name)
 
243
        tree.add([link_name],['link-id'])
 
244
 
 
245
        revision1 = tree.commit('added a link to a Unicode target')
 
246
        revision2 = tree.commit('this revision will be discarded')
 
247
        tree.set_parent_ids([revision1])
 
248
        tree.lock_read()
 
249
        self.addCleanup(tree.unlock)
 
250
        # Check that the symlink target is safely round-tripped in the trees.
 
251
        self.assertEqual(target, tree.get_symlink_target('link-id'))
 
252
        basis = tree.basis_tree()
 
253
        self.assertEqual(target, basis.get_symlink_target('link-id'))
 
254
 
230
255
 
231
256
class TestAddParent(TestParents):
232
257
 
237
262
        uncommit(tree.branch, tree=tree)
238
263
        tree.add_parent_tree_id(first_revision)
239
264
        self.assertConsistentParents([first_revision], tree)
240
 
        
 
265
 
241
266
    def test_add_first_parent_id_ghost_rejects(self):
242
267
        """Test adding the first parent id - as a ghost"""
243
268
        tree = self.make_branch_and_tree('.')
244
269
        self.assertRaises(errors.GhostRevisionUnusableHere,
245
270
            tree.add_parent_tree_id, 'first-revision')
246
 
        
 
271
 
247
272
    def test_add_first_parent_id_ghost_force(self):
248
273
        """Test adding the first parent id - as a ghost"""
249
274
        tree = self.make_branch_and_tree('.')
256
281
        tree.add_parent_tree_id('first-revision', allow_leftmost_as_ghost=True)
257
282
        tree.add_parent_tree_id('second')
258
283
        self.assertConsistentParents(['first-revision', 'second'], tree)
259
 
        
 
284
 
260
285
    def test_add_second_parent_id(self):
261
286
        """Test adding the second parent id"""
262
287
        tree = self.make_branch_and_tree('.')
265
290
        second_revision = tree.commit('second post')
266
291
        tree.add_parent_tree_id(first_revision)
267
292
        self.assertConsistentParents([second_revision, first_revision], tree)
268
 
        
 
293
 
269
294
    def test_add_second_parent_id_ghost(self):
270
295
        """Test adding the second parent id - as a ghost"""
271
296
        tree = self.make_branch_and_tree('.')
272
297
        first_revision = tree.commit('first post')
273
298
        tree.add_parent_tree_id('second')
274
299
        self.assertConsistentParents([first_revision, 'second'], tree)
275
 
        
 
300
 
276
301
    def test_add_first_parent_tree(self):
277
302
        """Test adding the first parent id"""
278
303
        tree = self.make_branch_and_tree('.')
281
306
        tree.add_parent_tree((first_revision,
282
307
            tree.branch.repository.revision_tree(first_revision)))
283
308
        self.assertConsistentParents([first_revision], tree)
284
 
        
 
309
 
285
310
    def test_add_first_parent_tree_ghost_rejects(self):
286
311
        """Test adding the first parent id - as a ghost"""
287
312
        tree = self.make_branch_and_tree('.')
288
313
        self.assertRaises(errors.GhostRevisionUnusableHere,
289
314
            tree.add_parent_tree, ('first-revision', None))
290
 
        
 
315
 
291
316
    def test_add_first_parent_tree_ghost_force(self):
292
317
        """Test adding the first parent id - as a ghost"""
293
318
        tree = self.make_branch_and_tree('.')
294
319
        tree.add_parent_tree(('first-revision', None),
295
320
            allow_leftmost_as_ghost=True)
296
321
        self.assertConsistentParents(['first-revision'], tree)
297
 
        
 
322
 
298
323
    def test_add_second_parent_tree(self):
299
324
        """Test adding the second parent id"""
300
325
        tree = self.make_branch_and_tree('.')
304
329
        tree.add_parent_tree((first_revision,
305
330
            tree.branch.repository.revision_tree(first_revision)))
306
331
        self.assertConsistentParents([second_revision, first_revision], tree)
307
 
        
 
332
 
308
333
    def test_add_second_parent_tree_ghost(self):
309
334
        """Test adding the second parent id - as a ghost"""
310
335
        tree = self.make_branch_and_tree('.')
315
340
 
316
341
class UpdateToOneParentViaDeltaTests(TestCaseWithWorkingTree):
317
342
    """Tests for the update_basis_by_delta call.
318
 
    
 
343
 
319
344
    This is intuitively defined as 'apply an inventory delta to the basis and
320
345
    discard other parents', but for trees that have an inventory that is not
321
346
    managed as a tree-by-id, the implementation requires roughly duplicated
367
392
            try:
368
393
                if shape.root.revision is None:
369
394
                    shape.root.revision = revid
 
395
                # Create the text records for this inventory.
 
396
                for path, ie in shape.iter_entries():
 
397
                    if ie.text_size:
 
398
                        lines = ['a' * ie.text_size]
 
399
                    else:
 
400
                        lines = []
 
401
                    tree.branch.repository.texts.add_lines(
 
402
                        (ie.file_id, ie.revision), [], lines)
370
403
                sha1 = tree.branch.repository.add_inventory(revid, shape, [])
371
404
                rev = Revision(timestamp=0,
372
405
                               timezone=None,
375
408
                               inventory_sha1=sha1,
376
409
                               revision_id=revid)
377
410
                tree.branch.repository.add_revision(revid, rev)
 
411
                tree.branch.repository.commit_write_group()
378
412
            except:
379
413
                tree.branch.repository.abort_write_group()
380
414
                raise
381
 
            else:
382
 
                tree.branch.repository.commit_write_group()
383
415
        finally:
384
416
            tree.unlock()
385
417