~garyvdm/bzr/diff_ext_tree

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

(lifeless) Add --clean-obsolete-packs option to the pack command. (Parth Malwankar)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4426
4426
 
4427
4427
 
4428
4428
class cmd_pack(Command):
4429
 
    """Compress the data within a repository."""
 
4429
    """Compress the data within a repository.
 
4430
 
 
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.
 
4434
 
 
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
 
4439
    used.
 
4440
 
 
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.
 
4445
    """
4430
4446
 
4431
4447
    _see_also = ['repositories']
4432
4448
    takes_args = ['branch_or_repo?']
 
4449
    takes_options = [
 
4450
        Option('clean-obsolete-packs', 'Delete obsolete packs to save disk space.'),
 
4451
        ]
4433
4452
 
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]
4436
4455
        try:
4437
4456
            branch = dir.open_branch()
4438
4457
            repository = branch.repository
4439
4458
        except errors.NotBranchError:
4440
4459
            repository = dir.open_repository()
4441
 
        repository.pack()
 
4460
        repository.pack(clean_obsolete_packs=clean_obsolete_packs)
4442
4461
 
4443
4462
 
4444
4463
class cmd_plugins(Command):