Merge lp:~jameinel/bzr/2.0.4-495000-win32-autopack into lp:bzr/2.0

Proposed by John A Meinel
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jameinel/bzr/2.0.4-495000-win32-autopack
Merge into: lp:bzr/2.0
Diff against target: 75 lines (+42/-1)
3 files modified
NEWS (+4/-0)
bzrlib/repofmt/groupcompress_repo.py (+2/-1)
bzrlib/tests/per_pack_repository.py (+36/-0)
To merge this branch: bzr merge lp:~jameinel/bzr/2.0.4-495000-win32-autopack
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+16264@code.launchpad.net
To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

This fixes bug #495000. The 2a format Packer code wasn't passing the 'reload_func' to the rest of the code, so if an autopack wanted to restart, reload_func() wasn't getting called properly.

The test is a bit brittle, but probably good enough, especially given the one-line fix.

Revision history for this message
John A Meinel (jameinel) wrote :

It seems I forgot to 'bzr push' after writing the test before I submitted. There is one now. (well, once lp refreshes the diff.)

Revision history for this message
Martin Pool (mbp) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2009-12-18 22:03:09 +0000
+++ NEWS 2009-12-21 16:48:15 +0000
@@ -31,6 +31,10 @@
31 This will likely have an impact on any other process that is serving for31 This will likely have an impact on any other process that is serving for
32 an extended period of time. (John Arbash Meinel, #494406)32 an extended period of time. (John Arbash Meinel, #494406)
3333
34* The 2a format wasn't properly restarting autopacks when something
35 changed underneath it (like another autopack). Now concurrent
36 autopackers will properly succeed. (John Arbash Meinel, #495000)
37
34Improvements38Improvements
35************39************
3640
3741
=== modified file 'bzrlib/repofmt/groupcompress_repo.py'
--- bzrlib/repofmt/groupcompress_repo.py 2009-09-24 20:03:43 +0000
+++ bzrlib/repofmt/groupcompress_repo.py 2009-12-21 16:48:15 +0000
@@ -352,7 +352,8 @@
352 """Build a VersionedFiles instance on top of this group of packs."""352 """Build a VersionedFiles instance on top of this group of packs."""
353 index_name = index_name + '_index'353 index_name = index_name + '_index'
354 index_to_pack = {}354 index_to_pack = {}
355 access = knit._DirectPackAccess(index_to_pack)355 access = knit._DirectPackAccess(index_to_pack,
356 reload_func=self._reload_func)
356 if for_write:357 if for_write:
357 # Use new_pack358 # Use new_pack
358 if self.new_pack is None:359 if self.new_pack is None:
359360
=== modified file 'bzrlib/tests/per_pack_repository.py'
--- bzrlib/tests/per_pack_repository.py 2009-09-07 03:00:23 +0000
+++ bzrlib/tests/per_pack_repository.py 2009-12-21 16:48:15 +0000
@@ -546,6 +546,42 @@
546 finally:546 finally:
547 tree.unlock()547 tree.unlock()
548548
549 def test_concurrent_pack_during_autopack(self):
550 tree = self.make_branch_and_tree('tree')
551 tree.lock_write()
552 try:
553 for i in xrange(9):
554 tree.commit('rev %d' % (i,))
555 r2 = repository.Repository.open('tree')
556 r2.lock_write()
557 try:
558 # Monkey patch so that pack occurs while the other repo is
559 # autopacking. This is slightly bad, but all current pack
560 # repository implementations have a _pack_collection, and we
561 # test that it gets triggered. So if a future format changes
562 # things, the test will fail rather than succeed accidentally.
563 autopack_count = [0]
564 r1 = tree.branch.repository
565 orig = r1._pack_collection.pack_distribution
566 def trigger_during_auto(*args, **kwargs):
567 ret = orig(*args, **kwargs)
568 if not autopack_count[0]:
569 r2.pack()
570 autopack_count[0] += 1
571 return ret
572 r1._pack_collection.pack_distribution = trigger_during_auto
573 tree.commit('autopack-rev')
574 # This triggers 2 autopacks. The first one causes r2.pack() to
575 # fire, but r2 doesn't see the new pack file yet. The
576 # autopack restarts and sees there are 2 files and there
577 # should be only 1 for 10 commits. So it goes ahead and
578 # finishes autopacking.
579 self.assertEqual([2], autopack_count)
580 finally:
581 r2.unlock()
582 finally:
583 tree.unlock()
584
549 def test_lock_write_does_not_physically_lock(self):585 def test_lock_write_does_not_physically_lock(self):
550 repo = self.make_repository('.', format=self.get_format())586 repo = self.make_repository('.', format=self.get_format())
551 repo.lock_write()587 repo.lock_write()

Subscribers

People subscribed via source and target branches