4428
4428
class cmd_pack(Command):
4429
"""Compress the data within a repository."""
4429
"""Compress the data within a repository.
4431
This operation compresses the data within a bazaar repository. As
4432
bazaar supports automatic packing of repository, this operation is
4433
normally not required to be done manually.
4435
During the pack operation, bazaar takes a backup of existing repository
4436
data, i.e. pack files. This backup is eventually removed by bazaar
4437
automatically when it is safe to do so. To save disk space by removing
4438
the backed up pack files, the --clean-obsolete-packs option may be
4441
Warning: If you use --clean-obsolete-packs and your machine crashes
4442
during or immediately after repacking, you may be left with a state
4443
where the deletion has been written to disk but the new packs have not
4444
been. In this case the repository may be unusable.
4431
4447
_see_also = ['repositories']
4432
4448
takes_args = ['branch_or_repo?']
4450
Option('clean-obsolete-packs', 'Delete obsolete packs to save disk space.'),
4434
def run(self, branch_or_repo='.'):
4453
def run(self, branch_or_repo='.', clean_obsolete_packs=False):
4435
4454
dir = bzrdir.BzrDir.open_containing(branch_or_repo)[0]
4437
4456
branch = dir.open_branch()
4438
4457
repository = branch.repository
4439
4458
except errors.NotBranchError:
4440
4459
repository = dir.open_repository()
4460
repository.pack(clean_obsolete_packs=clean_obsolete_packs)
4444
4463
class cmd_plugins(Command):