problems with committing merges in a dirstate tree with a symlink

Marien Zwart marienz at gentoo.org
Fri Mar 9 05:24:05 GMT 2007


Hi,

As far as I can tell committing a merge in a dirstate working tree
with a symlink in it (with bzr 0.15rc1) fails with a traceback like
this:

  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 650,
      in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 612,
      in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 304,
      in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 2109,
      in run
    reporter=reporter)
  File "/usr/lib/python2.5/site-packages/bzrlib/decorators.py", line 165,
      in write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 238,
      in commit
    result = WorkingTree3.commit(self, message, revprops, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/decorators.py", line 165,
      in write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/mutabletree.py", line 158,
      in commit
    revprops=revprops, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/commit.py", line 319, in commit
    self._populate_new_inv()
  File "/usr/lib/python2.5/site-packages/bzrlib/commit.py", line 656,
      in _populate_new_inv
    path, self.work_tree)
  File "/usr/lib/python2.5/site-packages/bzrlib/repository.py", line 1977,
      in record_entry_contents
    self.repository.get_transaction())
  File "/usr/lib/python2.5/site-packages/bzrlib/inventory.py", line 208,
      in find_previous_heads
    assert candidates[ie.revision] == ie
AssertionError

This traceback is mentioned in launchpad bug 90111 but that seems to
be a different problem. In this case the "ie" inventory entry and the
one in candidates are both InventoryLink entries but one has its
text_size set to None and the other has it set to 0. The attached
patch made my commit work but I have absolutely no idea if the fix or
the new test make any sense at all, so please review thoroughly :)

-- 
Marien.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_commit_merge.py'
--- bzrlib/tests/test_commit_merge.py	2006-10-16 01:50:48 +0000
+++ bzrlib/tests/test_commit_merge.py	2007-03-09 04:54:47 +0000
@@ -22,6 +22,7 @@
 from bzrlib.branch import Branch
 from bzrlib.errors import PointlessCommit, BzrError
 from bzrlib.tests.test_revision import make_branches
+from bzrlib import osutils
 
 
 class TestCommitMerge(TestCaseWithTransport):
@@ -96,3 +97,20 @@
         by.check()
         bx.repository.check([bx.last_revision()])
         by.repository.check([by.last_revision()])
+
+    def test_merge_with_symlink(self):
+        if not osutils.has_symlinks():
+            raise TestSkipped('Symlinks are not supported on this platform')
+        tree_a = self.make_branch_and_tree('tree_a')
+        os.symlink('target', osutils.pathjoin('tree_a', 'link'))
+        tree_a.add('link')
+        tree_a.commit('added link')
+        tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
+        self.build_tree(['tree_a/file'])
+        tree_a.add('file')
+        tree_a.commit('added file')
+        self.build_tree(['tree_b/another_file'])
+        tree_b.add('another_file')
+        tree_b.commit('add another file')
+        tree_b.merge_from_branch(tree_a.branch)
+        tree_b.commit('merge')

=== modified file 'bzrlib/workingtree_4.py'
--- bzrlib/workingtree_4.py	2007-03-07 03:09:14 +0000
+++ bzrlib/workingtree_4.py	2007-03-09 05:03:42 +0000
@@ -1393,7 +1393,8 @@
                     parent_ies[(dirname + '/' + name).strip('/')] = inv_entry
                 elif kind == 'symlink':
                     inv_entry.executable = False
-                    inv_entry.text_size = size
+                    assert not size
+                    inv_entry.text_size = None
                     inv_entry.symlink_target = utf8_decode(fingerprint)[0]
                 elif kind == 'tree-reference':
                     inv_entry.reference_revision = fingerprint or None

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070309/4c4fe692/attachment-0001.pgp 


More information about the bazaar mailing list