/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to processors/query_processor.py

  • Committer: Ian Clatworthy
  • Date: 2009-02-17 23:37:24 UTC
  • mto: (0.64.114 trunk)
  • mto: This revision was merged to the branch mainline in revision 6631.
  • Revision ID: ian.clatworthy@canonical.com-20090217233724-y6q12cyoyln6vkh6
code & tests for file copying

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2008 Canonical Ltd
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
"""Import processor that queries the input (and doesn't import)."""
 
18
 
 
19
 
 
20
from bzrlib.plugins.fastimport import (
 
21
    commands,
 
22
    processor,
 
23
    )
 
24
 
 
25
 
 
26
class QueryProcessor(processor.ImportProcessor):
 
27
    """An import processor that queries the input.
 
28
 
 
29
    No changes to the current repository are made.
 
30
    """
 
31
 
 
32
    known_params = commands.COMMAND_NAMES + commands.FILE_COMMAND_NAMES
 
33
 
 
34
    def __init__(self, target=None, params=None, verbose=False):
 
35
        # Allow creation without a target
 
36
        processor.ImportProcessor.__init__(self, target, params, verbose)
 
37
        self.parsed_params = {}
 
38
        if params:
 
39
            for name, value in params.iteritems():
 
40
                if value == 1:
 
41
                    # All fields
 
42
                    fields = None
 
43
                else:
 
44
                    fields = value.split(',')
 
45
                self.parsed_params[name] = fields
 
46
 
 
47
    def pre_handler(self, cmd):
 
48
        """Hook for logic before each handler starts."""
 
49
        if self.parsed_params.has_key(cmd.name):
 
50
            fields = self.parsed_params[cmd.name]
 
51
            str = cmd.dump_str(fields, self.parsed_params, self.verbose)
 
52
            print "%s" % (str,)
 
53
 
 
54
    def progress_handler(self, cmd):
 
55
        """Process a ProgressCommand."""
 
56
        pass
 
57
 
 
58
    def blob_handler(self, cmd):
 
59
        """Process a BlobCommand."""
 
60
        pass
 
61
 
 
62
    def checkpoint_handler(self, cmd):
 
63
        """Process a CheckpointCommand."""
 
64
        pass
 
65
 
 
66
    def commit_handler(self, cmd):
 
67
        """Process a CommitCommand."""
 
68
        for fc in cmd.file_iter():
 
69
            pass
 
70
 
 
71
    def reset_handler(self, cmd):
 
72
        """Process a ResetCommand."""
 
73
        pass
 
74
 
 
75
    def tag_handler(self, cmd):
 
76
        """Process a TagCommand."""
 
77
        pass