Rev 2605: (robertc) Introduce a pack command. in http://people.ubuntu.com/~robertc/baz2.0/pack
Robert Collins
robertc at robertcollins.net
Thu Jul 12 09:54:48 BST 2007
At http://people.ubuntu.com/~robertc/baz2.0/pack
------------------------------------------------------------
revno: 2605
revision-id: robertc at robertcollins.net-20070712085443-uq55hrguyme493db
parent: pqm at pqm.ubuntu.com-20070712075207-pgz7ur4rxmklmrxr
committer: Robert Collins <robertc at robertcollins.net>
branch nick: pack
timestamp: Thu 2007-07-12 18:54:43 +1000
message:
(robertc) Introduce a pack command.
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
=== modified file 'NEWS'
--- a/NEWS 2007-07-12 03:55:39 +0000
+++ b/NEWS 2007-07-12 08:54:43 +0000
@@ -9,7 +9,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 03:55:39 +0000
+++ b/bzrlib/builtins.py 2007-07-12 08:54:43 +0000
@@ -3023,6 +3023,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 08:54:43 +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 08:54:43 +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-06-28 04:25:15 +0000
+++ b/bzrlib/repository.py 2007-07-12 08:54:43 +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 08:54:43 +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 08:54:43 +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