Failure to fetch to old format via Smart Server

John Arbash Meinel john at arbash-meinel.com
Mon Jun 1 18:48:39 BST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm trying to write a fairly simple test case to expose some issues with
our code and ghost handling.

Specifically, my recent gc-stacking patch broke the ability to push
bzr.dev via the smart server.

So I tried to add this test:
=== modified file 'bzrlib/tests/per_repository/test_fetch.py'
- --- bzrlib/tests/per_repository/test_fetch.py   2009-05-23 04:55:52 +0000
+++ bzrlib/tests/per_repository/test_fetch.py   2009-06-01 17:38:34 +0000
@@ -300,6 +300,48 @@
         repo.fetch(tree.branch.repository)
         repo.fetch(tree.branch.repository)

+    def make_simple_branch_with_ghost(self):
+        builder = self.make_branch_builder('source')
+        builder.start_series()
+        builder.build_snapshot('A-id', None, [
+            ('add', ('', 'root-id', 'directory', None)),
+            ('add', ('file', 'file-id', 'file', 'content\n'))])
+        builder.build_snapshot('B-id', ['A-id', 'ghost-id'], [])
+        builder.finish_series()
+        source_b = builder.get_branch()
+        source_b.lock_read()
+        self.addCleanup(source_b.unlock)
+        return source_b
+
+    def test_fetch_with_ghost(self):
+        source_b = self.make_simple_branch_with_ghost()
+        target = self.make_repository('target')
+        target.lock_write()
+        self.addCleanup(target.unlock)
+        target.fetch(source_b.repository, revision_id='B-id')
+
+    def test_fetch_into_smart_with_ghost(self):
+        trans = self.make_smart_server('target')
+        source_b = self.make_simple_branch_with_ghost()
+        target = self.make_repository('target')
+        # Re-open the repository over the smart protocol
+        target = repository.Repository.open(trans.base)
+        target.lock_write()
+        self.addCleanup(target.unlock)
+        target.fetch(source_b.repository, revision_id='B-id')


However, when I go to run that I get:
ERROR: test_fetch_into_smart_with_ghost
(bzrlib.tests.per_repository.test_fetch.TestFetchSameReposit
ory)

vvvv[log from
bzrlib.tests.per_repository.test_fetch.TestFetchSameRepository.test_fetch_into_smart_w
ith_ghost(RepositoryFormat6)]
...
> 
> 
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "C:\Users\jameinel\dev\bzr\alt_work\bzrlib\tests\per_repository\test_fetch.py", line 331, in
> test_fetch_into_smart_with_ghost
>     target.fetch(source_b.repository, revision_id='B-id')
>   File "C:\Users\jameinel\dev\bzr\alt_work\bzrlib\remote.py", line 1211, in fetch
>     find_ghosts=find_ghosts, fetch_spec=fetch_spec)
>   File "C:\Users\jameinel\dev\bzr\alt_work\bzrlib\decorators.py", line 192, in write_locked
>     result = unbound(self, *args, **kwargs)
>   File "C:\Users\jameinel\dev\bzr\alt_work\bzrlib\repository.py", line 3116, in fetch
>     pb=pb, find_ghosts=find_ghosts)
>   File "C:\Users\jameinel\dev\bzr\alt_work\bzrlib\fetch.py", line 82, in __init__
>     self.__fetch()
>   File "C:\Users\jameinel\dev\bzr\alt_work\bzrlib\fetch.py", line 108, in __fetch
>     self._fetch_everything_for_search(search)
>   File "C:\Users\jameinel\dev\bzr\alt_work\bzrlib\fetch.py", line 155, in _fetch_everything_for_sear
> ch
>     self.sink.finished()
>   File "C:\Users\jameinel\dev\bzr\alt_work\bzrlib\repository.py", line 4135, in finished
>     self.target_repo.reconcile()
>   File "C:\Users\jameinel\dev\bzr\alt_work\bzrlib\remote.py", line 1387, in reconcile
>     self._ensure_real()
>   File "C:\Users\jameinel\dev\bzr\alt_work\bzrlib\remote.py", line 699, in _ensure_real
>     self.bzrdir._real_bzrdir.open_repository())
>   File "C:\Users\jameinel\dev\bzr\alt_work\bzrlib\remote.py", line 964, in _set_real_repository
>     self._real_repository.lock_write(self._lock_token)
>   File "C:\Users\jameinel\dev\bzr\alt_work\bzrlib\repository.py", line 1246, in lock_write
>     result = self.control_files.lock_write(token=token)
>   File "C:\Users\jameinel\dev\bzr\alt_work\bzrlib\lockable_files.py", line 279, in lock_write
>     token_from_lock = self._lock.lock_write(token=token)
>   File "C:\Users\jameinel\dev\bzr\alt_work\bzrlib\lockable_files.py", line 398, in lock_write
>     raise errors.TokenLockingNotSupported(self)
> TokenLockingNotSupported: The object <bzrlib.lockable_files.TransportLock object at 0x046C9810> does
>  not support token specifying a token when locking.

(sorry about the ugly formatting)

Anyway, it would seem that Smart Server + fetch + Knit formats is
broken, and we never knew it, because we never had a per-format test of
fetching and the smart server.

I don't feel like fixing this for my current patch, so I'll probably
just blacklist specific versions.

I'll note that it looks like an even simpler failing test would be:


def test_can_ensure_real_locked_repo(self):
  trans = self.make_smart_server('repo')
  self.make_repository('repo')
  # Open repo via smart server
  repo = repository.Repository.open(trans.base)
  repo.lock_write()
  self.addCleanup(repo.unlock)
  repo._ensure_real() # Boom

Any thoughts?

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkokFHcACgkQJdeBCYSNAAOs7QCguFJaZ5UJFhL7uKLgKkg7w+4f
SQYAoKLShiAd/U3kzAiPc5X3X+ao9rr0
=uetb
-----END PGP SIGNATURE-----



More information about the bazaar mailing list