Rev 2610: (robertc) Introduce a pack command. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Jul 12 14:35:58 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2610
revision-id: pqm at pqm.ubuntu.com-20070712133554-r8me4pz4j68p2ytf
parent: pqm at pqm.ubuntu.com-20070712124245-vaw0ajlwrexg8d0m
parent: robertc at robertcollins.net-20070712120713-c2vfm2n61l63wt6s
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2007-07-12 14:35:54 +0100
message:
(robertc) Introduce a pack command.
added:
bzrlib/tests/blackbox/test_pack.py test_pack.py-20070712120702-0c7585lh56p894mo-1
bzrlib/tests/repository_implementations/test_pack.py test_pack.py-20070712120702-0c7585lh56p894mo-2
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/help_topics.py help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/blackbox/__init__.py __init__.py-20051128053524-eba30d8255e08dc3
bzrlib/tests/repository_implementations/__init__.py __init__.py-20060131092037-9564957a7d4a841b
------------------------------------------------------------
revno: 2604.2.1
merged: robertc at robertcollins.net-20070712120713-c2vfm2n61l63wt6s
parent: pqm at pqm.ubuntu.com-20070712075207-pgz7ur4rxmklmrxr
committer: Robert Collins <robertc at robertcollins.net>
branch nick: pack
timestamp: Thu 2007-07-12 22:07:13 +1000
message:
(robertc) Introduce a pack command.
=== added file 'bzrlib/tests/blackbox/test_pack.py'
--- a/bzrlib/tests/blackbox/test_pack.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/blackbox/test_pack.py 2007-07-12 12:07:13 +0000
@@ -0,0 +1,44 @@
+# Copyright (C) 2007 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+"""Tests of the 'bzr pack' command."""
+
+from bzrlib.tests.blackbox import ExternalBase
+
+
+class TestPack(ExternalBase):
+
+ def test_pack_silent(self):
+ """pack command has no intrinsic output."""
+ self.make_branch('.')
+ out, err = self.run_bzr('pack')
+ self.assertEqual('', out)
+ self.assertEqual('', err)
+
+ def test_pack_accepts_branch_url(self):
+ """pack command accepts the url to a branch."""
+ self.make_branch('branch')
+ out, err = self.run_bzr('pack branch')
+ self.assertEqual('', out)
+ self.assertEqual('', err)
+
+ def test_pack_accepts_repo_url(self):
+ """pack command accepts the url to a branch."""
+ self.make_repository('repository')
+ out, err = self.run_bzr('pack repository')
+ self.assertEqual('', out)
+ self.assertEqual('', err)
=== added file 'bzrlib/tests/repository_implementations/test_pack.py'
--- a/bzrlib/tests/repository_implementations/test_pack.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/repository_implementations/test_pack.py 2007-07-12 12:07:13 +0000
@@ -0,0 +1,26 @@
+# Copyright (C) 2007 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+"""Tests for repository packing."""
+
+from bzrlib.tests.repository_implementations.test_repository import TestCaseWithRepository
+
+
+class TestPack(TestCaseWithRepository):
+
+ def test_pack_empty_does_not_error(self):
+ repo = self.make_repository('.')
+ repo.pack()
=== modified file 'NEWS'
--- a/NEWS 2007-07-12 12:42:45 +0000
+++ b/NEWS 2007-07-12 13:35:54 +0000
@@ -11,7 +11,8 @@
* ``info`` now formats locations more nicely and lists "submit" and
"public" branches (Aaron Bentley)
- * None yet ...
+ * New ``pack`` command that will trigger database compression within
+ the repository (Robert Collins)
LIBRARY API BREAKS:
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2007-07-12 10:48:58 +0000
+++ b/bzrlib/builtins.py 2007-07-12 13:35:54 +0000
@@ -3068,6 +3068,22 @@
return status_code
+class cmd_pack(Command):
+ """Compress the data within a repository."""
+
+ _see_also = ['repositories']
+ takes_args = ['branch_or_repo?']
+
+ def run(self, branch_or_repo='.'):
+ dir = bzrdir.BzrDir.open_containing(branch_or_repo)[0]
+ try:
+ branch = dir.open_branch()
+ repository = branch.repository
+ except errors.NotBranchError:
+ repository = dir.open_repository()
+ repository.pack()
+
+
class cmd_plugins(Command):
"""List plugins"""
hidden = True
=== modified file 'bzrlib/help_topics.py'
--- a/bzrlib/help_topics.py 2007-07-03 00:40:04 +0000
+++ b/bzrlib/help_topics.py 2007-07-12 12:07:13 +0000
@@ -284,11 +284,19 @@
_repositories = \
"""Repositories
-Repositories in Bazaar are where committed information is stored. It is
-possible to create a shared repository which allows multiple branches to
-share their information in the same location. When a new branch is
-created it will first look to see if there is a containing repository it
-can share.
+Repositories in Bazaar are where committed information is stored. There is
+a repository associated with every branch.
+
+Repositories are a form of database. Bzr will usually maintain this for
+good performance automatically, but in some situations (e.g. when doing
+very many commits in a short time period) you may want to ask bzr to
+optimise the database indices. This can be done by the 'bzr pack' command.
+
+By default just running 'bzr init' will create a repository within the new
+branch but it is possible to create a shared repository which allows multiple
+branches to share their information in the same location. When a new branch is
+created it will first look to see if there is a containing shared repository it
+can use.
When two branches of the same project share a repository, there is
generally a large space saving. For some operations (e.g. branching
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2007-06-27 04:33:04 +0000
+++ b/bzrlib/remote.py 2007-07-12 12:07:13 +0000
@@ -633,6 +633,15 @@
# TODO: Suggestion from john: using external tar is much faster than
# python's tarfile library, but it may not work on windows.
+ @needs_write_lock
+ def pack(self):
+ """Compress the data within the repository.
+
+ This is not currently implemented within the smart server.
+ """
+ self._ensure_real()
+ return self._real_repository.pack()
+
def set_make_working_trees(self, new_value):
raise NotImplementedError(self.set_make_working_trees)
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2007-07-12 07:22:52 +0000
+++ b/bzrlib/repository.py 2007-07-12 13:35:54 +0000
@@ -836,6 +836,17 @@
candidates = w.get_ancestry(revision_id, topo_sorted)
return [None] + candidates # self._eliminate_revisions_not_present(candidates)
+ def pack(self):
+ """Compress the data within the repository.
+
+ This operation only makes sense for some repository types. For other
+ types it should be a no-op that just returns.
+
+ This stub method does not require a lock, but subclasses should use
+ @needs_write_lock as this is a long running call its reasonable to
+ implicitly lock for the user.
+ """
+
@needs_read_lock
def print_file(self, file, revision_id):
"""Print `file` to stdout.
=== modified file 'bzrlib/tests/blackbox/__init__.py'
--- a/bzrlib/tests/blackbox/__init__.py 2007-06-27 19:13:50 +0000
+++ b/bzrlib/tests/blackbox/__init__.py 2007-07-12 12:07:13 +0000
@@ -80,6 +80,7 @@
'bzrlib.tests.blackbox.test_mv',
'bzrlib.tests.blackbox.test_nick',
'bzrlib.tests.blackbox.test_outside_wt',
+ 'bzrlib.tests.blackbox.test_pack',
'bzrlib.tests.blackbox.test_pull',
'bzrlib.tests.blackbox.test_push',
'bzrlib.tests.blackbox.test_reconcile',
=== modified file 'bzrlib/tests/repository_implementations/__init__.py'
--- a/bzrlib/tests/repository_implementations/__init__.py 2007-06-28 04:25:15 +0000
+++ b/bzrlib/tests/repository_implementations/__init__.py 2007-07-12 12:07:13 +0000
@@ -102,6 +102,7 @@
'bzrlib.tests.repository_implementations.test_commit_builder',
'bzrlib.tests.repository_implementations.test_fileid_involved',
'bzrlib.tests.repository_implementations.test_iter_reverse_revision_history',
+ 'bzrlib.tests.repository_implementations.test_pack',
'bzrlib.tests.repository_implementations.test_reconcile',
'bzrlib.tests.repository_implementations.test_repository',
'bzrlib.tests.repository_implementations.test_revision',
More information about the bazaar-commits
mailing list