Rev 4651: (robertc) Enable commit via record_iter_changes for specific file in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Aug 26 02:26:58 BST 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4651 [merge]
revision-id: pqm at pqm.ubuntu.com-20090826012647-b3egio20x35g31yd
parent: pqm at pqm.ubuntu.com-20090825233734-ozgeetbq9aagneer
parent: robertc at robertcollins.net-20090825234708-utgl9u6v12sosp5c
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2009-08-26 02:26:47 +0100
message:
(robertc) Enable commit via record_iter_changes for specific file
comments. (Robert Collins)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/commit.py commit.py-20050511101309-79ec1a0168e0e825
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/blackbox/test_commit.py test_commit.py-20060212094538-ae88fc861d969db0
bzrlib/tests/blackbox/test_versioning.py versioning.py-20050622071821-3ddf5e2e5e93c602
=== modified file 'NEWS'
--- a/NEWS 2009-08-25 23:37:34 +0000
+++ b/NEWS 2009-08-25 23:47:08 +0000
@@ -66,6 +66,17 @@
* ``bzr shelve`` and ``bzr unshelve`` now work on windows.
(Robert Collins, #305006)
+* Commit of specific files no longer prevents using the the iter_changes
+ codepath. On 2a repositories, commit of specific files should now be as
+ fast, or slightly faster, than a full commit. (Robert Collins)
+
+* The internal core code that handles specific file operations like
+ ``bzr st FILENAME`` or ``bzr commit FILENAME`` has been changed to
+ include the parent directories if they have altered, and when a
+ directory stops being a directory its children are always included. This
+ fixes a number of causes for ``InconsistentDelta`` errors, and permits
+ faster commit of specific paths. (Robert Collins, #347649)
+
Documentation
*************
@@ -160,13 +171,6 @@
example, ``bzr log -r -10..-1 -n0 bzr.dev`` is 2.5s down to 1.0s.
(John Arbash Meinel)
-* The internal core code that handles specific file operations like
- ``bzr st FILENAME`` or ``bzr commit FILENAME`` has been changed to
- include the parent directories if they have altered, and when a
- directory stops being a directory its children are always included. This
- fixes a number of causes for ``InconsistentDelta`` errors, and permits
- faster commit of specific paths. (Robert Collins, #347649)
-
Documentation
*************
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2009-08-25 21:09:17 +0000
+++ b/bzrlib/builtins.py 2009-08-25 23:47:08 +0000
@@ -3038,6 +3038,10 @@
raise errors.BzrCommandError("empty commit message specified")
return my_message
+ # The API permits a commit with a filter of [] to mean 'select nothing'
+ # but the command line should not do that.
+ if not selected_list:
+ selected_list = None
try:
tree.commit(message_callback=get_message,
specific_files=selected_list,
=== modified file 'bzrlib/commit.py'
--- a/bzrlib/commit.py 2009-07-15 05:54:37 +0000
+++ b/bzrlib/commit.py 2009-08-25 22:28:19 +0000
@@ -209,7 +209,8 @@
:param timestamp: if not None, seconds-since-epoch for a
postdated/predated commit.
- :param specific_files: If true, commit only those files.
+ :param specific_files: If not None, commit only those files. An empty
+ list means 'commit no files'.
:param rev_id: If set, use this as the new revision id.
Useful for test or import commands that need to tightly
@@ -264,6 +265,8 @@
self.master_locked = False
self.recursive = recursive
self.rev_id = None
+ # self.specific_files is None to indicate no filter, or any iterable to
+ # indicate a filter - [] means no files at all, as per iter_changes.
if specific_files is not None:
self.specific_files = sorted(
minimum_path_selection(specific_files))
@@ -285,7 +288,6 @@
# the command line parameters, and the repository has fast delta
# generation. See bug 347649.
self.use_record_iter_changes = (
- not self.specific_files and
not self.exclude and
not self.branch.repository._format.supports_tree_reference and
(self.branch.repository._format.fast_deltas or
@@ -333,7 +335,7 @@
self._gather_parents()
# After a merge, a selected file commit is not supported.
# See 'bzr help merge' for an explanation as to why.
- if len(self.parents) > 1 and self.specific_files:
+ if len(self.parents) > 1 and self.specific_files is not None:
raise errors.CannotCommitSelectedFileMerge(self.specific_files)
# Excludes are a form of selected file commit.
if len(self.parents) > 1 and self.exclude:
@@ -619,12 +621,13 @@
"""Update the commit builder with the data about what has changed.
"""
exclude = self.exclude
- specific_files = self.specific_files or []
+ specific_files = self.specific_files
mutter("Selecting files for commit with filter %s", specific_files)
self._check_strict()
if self.use_record_iter_changes:
- iter_changes = self.work_tree.iter_changes(self.basis_tree)
+ iter_changes = self.work_tree.iter_changes(self.basis_tree,
+ specific_files=specific_files)
iter_changes = self._filter_iter_changes(iter_changes)
for file_id, path, fs_hash in self.builder.record_iter_changes(
self.work_tree, self.basis_revid, iter_changes):
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2009-08-21 00:04:55 +0000
+++ b/bzrlib/repository.py 2009-08-25 22:28:19 +0000
@@ -807,6 +807,9 @@
seen_root = True
self.new_inventory = None
if len(inv_delta):
+ # This should perhaps be guarded by a check that the basis we
+ # commit against is the basis for the commit and if not do a delta
+ # against the basis.
self._any_changes = True
if not seen_root:
# housekeeping root entry changes do not affect no-change commits.
=== modified file 'bzrlib/tests/blackbox/test_commit.py'
--- a/bzrlib/tests/blackbox/test_commit.py 2009-07-23 15:58:22 +0000
+++ b/bzrlib/tests/blackbox/test_commit.py 2009-08-25 22:28:19 +0000
@@ -273,13 +273,15 @@
self.build_tree_contents([
('branch/foo.c', 'int main() {}'),
('branch/bar.c', 'int main() {}')])
- inner_tree.add('foo.c')
- inner_tree.add('bar.c')
+ inner_tree.add(['foo.c', 'bar.c'])
# can't commit files in different trees; sane error
self.run_bzr('commit -m newstuff branch/foo.c .', retcode=3)
+ # can commit to branch - records foo.c only
self.run_bzr('commit -m newstuff branch/foo.c')
+ # can commit to branch - records bar.c
self.run_bzr('commit -m newstuff branch')
- self.run_bzr('commit -m newstuff branch', retcode=3)
+ # No changes left
+ self.run_bzr_error(["No changes to commit"], 'commit -m newstuff branch')
def test_out_of_date_tree_commit(self):
# check we get an error code and a clear message committing with an out
=== modified file 'bzrlib/tests/blackbox/test_versioning.py'
--- a/bzrlib/tests/blackbox/test_versioning.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/blackbox/test_versioning.py 2009-08-25 22:28:19 +0000
@@ -22,10 +22,10 @@
import os
-from bzrlib.tests import TestCaseInTempDir
from bzrlib.branch import Branch
+from bzrlib.osutils import pathjoin
+from bzrlib.tests import TestCaseInTempDir, TestCaseWithTransport
from bzrlib.trace import mutter
-from bzrlib.osutils import pathjoin
from bzrlib.workingtree import WorkingTree
@@ -122,60 +122,51 @@
check(b, False)
-class SubdirCommit(TestCaseInTempDir):
+class SubdirCommit(TestCaseWithTransport):
def test_subdir_commit(self):
- """Test committing a subdirectory, and committing within a directory."""
- run_bzr = self.run_bzr
- eq = self.assertEqual
-
+ """Test committing a subdirectory, and committing a directory."""
+ tree = self.make_branch_and_tree('.')
+ b = tree.branch
self.build_tree(['a/', 'b/'])
-
- run_bzr('init')
- b = Branch.open(u'.')
-
- for fn in ('a/one', 'b/two', 'top'):
- file(fn, 'w').write('old contents')
-
- run_bzr('add')
- run_bzr(['commit', '-m', 'first revision'])
-
- for fn in ('a/one', 'b/two', 'top'):
- file(fn, 'w').write('new contents')
+ def set_contents(contents):
+ self.build_tree_contents([
+ ('a/one', contents),
+ ('b/two', contents),
+ ('top', contents),
+ ])
+ set_contents('old contents')
+ tree.smart_add(['.'])
+ tree.commit('first revision')
+ set_contents('new contents')
mutter('start selective subdir commit')
- run_bzr(['commit', 'a', '-m', 'commit a only'])
+ self.run_bzr(['commit', 'a', '-m', 'commit a only'])
- old = b.repository.revision_tree(b.get_rev_id(1))
new = b.repository.revision_tree(b.get_rev_id(2))
new.lock_read()
- eq(new.get_file_by_path('b/two').read(), 'old contents')
- eq(new.get_file_by_path('top').read(), 'old contents')
- eq(new.get_file_by_path('a/one').read(), 'new contents')
+ self.assertEqual(new.get_file_by_path('b/two').read(), 'old contents')
+ self.assertEqual(new.get_file_by_path('top').read(), 'old contents')
+ self.assertEqual(new.get_file_by_path('a/one').read(), 'new contents')
new.unlock()
os.chdir('a')
# commit from here should do nothing
- run_bzr(['commit', '.', '-m', 'commit subdir only', '--unchanged'])
+ self.run_bzr(['commit', '.', '-m', 'commit subdir only', '--unchanged'])
v3 = b.repository.revision_tree(b.get_rev_id(3))
v3.lock_read()
- eq(v3.get_file_by_path('b/two').read(), 'old contents')
- eq(v3.get_file_by_path('top').read(), 'old contents')
- eq(v3.get_file_by_path('a/one').read(), 'new contents')
+ self.assertEqual(v3.get_file_by_path('b/two').read(), 'old contents')
+ self.assertEqual(v3.get_file_by_path('top').read(), 'old contents')
+ self.assertEqual(v3.get_file_by_path('a/one').read(), 'new contents')
v3.unlock()
# commit in subdirectory commits whole tree
- run_bzr(['commit', '-m', 'commit whole tree from subdir'])
+ self.run_bzr(['commit', '-m', 'commit whole tree from subdir'])
v4 = b.repository.revision_tree(b.get_rev_id(4))
v4.lock_read()
- eq(v4.get_file_by_path('b/two').read(), 'new contents')
- eq(v4.get_file_by_path('top').read(), 'new contents')
+ self.assertEqual(v4.get_file_by_path('b/two').read(), 'new contents')
+ self.assertEqual(v4.get_file_by_path('top').read(), 'new contents')
v4.unlock()
# TODO: factor out some kind of assert_tree_state() method
-
-
-if __name__ == '__main__':
- import unittest
- unittest.main()
More information about the bazaar-commits
mailing list