1
# Copyright (C) 2008 Canonical Ltd
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.
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.
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
17
"""Import command classes."""
20
# Lists of command names
21
COMMAND_NAMES = ['blob', 'checkpoint', 'commit', 'progress', 'reset', 'tag']
22
FILE_COMMAND_NAMES = ['modify', 'delete', 'copy', 'rename', 'deleteall']
29
class ImportCommand(object):
30
"""Base class for import commands."""
32
def __init__(self, name):
36
class BlobCommand(ImportCommand):
38
def __init__(self, mark, data):
39
ImportCommand.__init__(self, 'blob')
44
class CheckpointCommand(ImportCommand):
47
ImportCommand.__init__(self, 'checkpoint')
50
class CommitCommand(ImportCommand):
52
def __init__(self, ref, mark, author, committer, message, parents,
54
ImportCommand.__init__(self, 'commit')
58
self.committer = committer
59
self.message = message
60
self.parents = parents
61
self.file_iter = file_iter
64
class ProgressCommand(ImportCommand):
66
def __init__(self, message):
67
ImportCommand.__init__(self, 'progress')
68
self.message = message
71
class ResetCommand(ImportCommand):
73
def __init__(self, ref, from_):
74
ImportCommand.__init__(self, 'reset')
79
class TagCommand(ImportCommand):
81
def __init__(self, id, from_, tagger, message):
82
ImportCommand.__init__(self, 'tag')
86
self.message = message
89
class FileCommand(ImportCommand):
90
"""Base class for file commands."""
94
class FileModifyCommand(FileCommand):
96
def __init__(self, path, kind, is_executable, dataref, data):
97
# Either dataref or data should be null
98
FileCommand.__init__(self, 'modify')
101
self.is_executable = is_executable
102
self.dataref = dataref
106
class FileDeleteCommand(FileCommand):
108
def __init__(self, path):
109
FileCommand.__init__(self, 'delete')
113
class FileCopyCommand(FileCommand):
115
def __init__(self, src_path, dest_path):
116
FileCommand.__init__(self, 'copy')
117
self.src_path = src_path
118
self.dest_path = dest_path
121
class FileRenameCommand(FileCommand):
123
def __init__(self, src_path, dest_path):
124
FileCommand.__init__(self, 'rename')
125
self.src_path = src_path
126
self.dest_path = dest_path
129
class FileDeleteAllCommand(FileCommand):
131
def __init__(self, path):
132
FileCommand.__init__(self, 'deleteall')