Rev 2678: Stop allocating new names unless new data has been inserted. in http://people.ubuntu.com/~robertc/baz2.0/repository
Robert Collins
robertc at robertcollins.net
Thu Jul 26 05:35:59 BST 2007
At http://people.ubuntu.com/~robertc/baz2.0/repository
------------------------------------------------------------
revno: 2678
revision-id: robertc at robertcollins.net-20070726043556-f27nyuewg69iopql
parent: robertc at robertcollins.net-20070726041805-k4ysxvqab6mrxyt9
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Thu 2007-07-26 14:35:56 +1000
message:
Stop allocating new names unless new data has been inserted.
modified:
bzrlib/repofmt/knitrepo.py knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
=== modified file 'bzrlib/repofmt/knitrepo.py'
--- a/bzrlib/repofmt/knitrepo.py 2007-07-26 04:18:05 +0000
+++ b/bzrlib/repofmt/knitrepo.py 2007-07-26 04:35:56 +0000
@@ -382,14 +382,18 @@
def flush(self):
"""Write out pending indices."""
- # if any work has been done, allocate a new name
- if (getattr(self.repo, '_revision_knit', None) is not None or
- getattr(self.repo, '_signature_knit', None) is not None):
- new_name = self.repo._revision_indices.allocate()
- self.repo._revision_indices.save()
- else:
- # no knits actually accessed
+ data_inserted = False
+ # XXX: Should we define __len__ for indices?
+ if (getattr(self.repo, '_revision_write_index', None) and
+ len(list(self.repo._revision_write_index.iter_all_entries()))):
+ data_inserted = True
+ if (getattr(self.repo, '_signature_write_index', None) and
+ len(list(self.repo._signature_write_index.iter_all_entries()))):
+ data_inserted = True
+ if not data_inserted:
return
+ new_name = self.repo._revision_indices.allocate()
+ self.repo._revision_indices.save()
index_transport = self.get_indices_transport()
# write a revision index (might be empty)
new_index_name = self.name_to_revision_index_name(new_name)
=== modified file 'bzrlib/tests/test_repository.py'
--- a/bzrlib/tests/test_repository.py 2007-07-19 07:19:21 +0000
+++ b/bzrlib/tests/test_repository.py 2007-07-26 04:35:56 +0000
@@ -609,6 +609,17 @@
tree.commit('foobarbaz')
self.assertTrue(trans.has('indices/0.six'))
+ def test_pulling_nothing_leads_to_no_new_names(self):
+ format = self.get_format()
+ tree1 = self.make_branch_and_tree('1', format=format)
+ tree2 = self.make_branch_and_tree('2', format=format)
+ tree1.branch.repository.fetch(tree2.branch.repository)
+ trans = tree1.branch.repository.bzrdir.get_repository_transport(None)
+ self.assertFalse(trans.has('indices/0.rix'))
+ self.assertFalse(trans.has('indices/0.six'))
+ names = FileNames(trans.clone('indices'), 'index')
+ names.load()
+ self.assertEqual(set(), names.names())
class TestExperimentalSubtrees(TestExperimentalNoSubtrees):
More information about the bazaar-commits
mailing list