~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to fai/command/fill_library.py

  • Committer: Robert Collins
  • Date: 2005-09-14 11:27:20 UTC
  • mto: (147.2.6) (364.1.3 bzrtools)
  • mto: This revision was merged to the branch mainline in revision 324.
  • Revision ID: robertc@robertcollins.net-20050914112720-c66a21de86eafa6e
trim fai cribbage

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2004 Aaron Bentley
2
 
# <aaron.bentley@utoronto.ca>
3
 
#
4
 
#    This program is free software; you can redistribute it and/or modify
5
 
#    it under the terms of the GNU General Public License as published by
6
 
#    the Free Software Foundation; either version 2 of the License, or
7
 
#    (at your option) any later version.
8
 
#
9
 
#    This program is distributed in the hope that it will be useful,
10
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
#    GNU General Public License for more details.
13
 
#
14
 
#    You should have received a copy of the GNU General Public License
15
 
#    along with this program; if not, write to the Free Software
16
 
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 
 
18
 
import sys
19
 
import os
20
 
 
21
 
sys.path=[os.path.realpath(os.path.dirname(__file__)+"/..")]+sys.path
22
 
import pylon
23
 
from pylon import errors
24
 
 
25
 
import cmdutil
26
 
import commands
27
 
 
28
 
__docformat__ = "restructuredtext"
29
 
__doc__ = "fill-library command"
30
 
 
31
 
class FillLibrary(commands.BaseCommand):
32
 
    """Copy all library revisions to a single library"""
33
 
    def __init__(self):
34
 
        self.description = self.__doc__
35
 
 
36
 
    def get_completer(self, arg, index):
37
 
        return cmdutil.iter_dir_completions(arg)
38
 
 
39
 
    def do_command(self, cmdargs):
40
 
        parser=self.get_parser()
41
 
        (options, args) = parser.parse_args(cmdargs)
42
 
        if len(args) != 1:
43
 
            raise errors.GetHelp
44
 
        if not pylon.is_library_dir(args[0]):
45
 
            raise errors.CommandFailedWrapper(errors.NotLibrary(args[0]))
46
 
        for revision in arch_compound.iter_all_library_revisions():
47
 
            if revision.archive.is_registered():
48
 
                cmdutil.chatter("Adding %s" % revision)
49
 
                for line in pylon.iter_library_add(revision, args[0]):
50
 
                    cmdutil.colorize(line)
51
 
            else:
52
 
                cmdutil.chatter("Skipping %s" % revision)
53
 
        return 0
54
 
 
55
 
    def get_parser(self):
56
 
        parser = cmdutil.CmdOptionParser("fill-library DIR")
57
 
        return parser
58
 
 
59
 
    def help(self, parser=None):
60
 
        """
61
 
        Prints a help message.
62
 
 
63
 
        :param parser: If supplied, the parser to use for generating help.  If \
64
 
        not supplied, it is retrieved.
65
 
        :type parser: cmdutil.CmdOptionParser
66
 
        """
67
 
        if parser==None:
68
 
            parser=self.get_parser()
69
 
        parser.print_help()
70
 
        print """
71
 
This command can be used to copy all library revisions to a particular library,
72
 
presumably on a different filesystem.  
73
 
 
74
 
This process ensures correct inode signatures.  Unfortunately, most of the
75
 
copied revisions will not be hard-linked efficiently.
76
 
 
77
 
Limitations in some versions of tla library-add mean that revisions for
78
 
unregistered libraries will be skipped.
79
 
        """
80
 
 
81
 
 
82
 
def add_command(commands):
83
 
    commands["fill-library"] = FillLibrary
84
 
 
85
 
 
86
 
 
87
 
# arch-tag: 6591f6cc-3d18-4505-8061-ad42d3b28132