bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
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 command classes."""
|
|
18 |
||
19 |
||
20 |
# Lists of command names
|
|
21 |
COMMAND_NAMES = ['blob', 'checkpoint', 'commit', 'progress', 'reset', 'tag'] |
|
22 |
FILE_COMMAND_NAMES = ['modify', 'delete', 'copy', 'rename', 'deleteall'] |
|
23 |
||
|
0.64.2
by Ian Clatworthy
use Bazaar file kinds |
24 |
# Bazaar file kinds
|
25 |
FILE_KIND = 'file' |
|
26 |
SYMLINK_KIND = 'symlink' |
|
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
27 |
|
28 |
||
29 |
class ImportCommand(object): |
|
30 |
"""Base class for import commands.""" |
|
31 |
||
32 |
def __init__(self, name): |
|
33 |
self.name = name |
|
|
0.64.9
by Ian Clatworthy
dump parameter for info processor |
34 |
# List of field names not to display
|
35 |
self._binary = [] |
|
36 |
||
37 |
def __str__(self): |
|
38 |
interesting = {} |
|
39 |
for field,value in self.__dict__.iteritems(): |
|
40 |
if field.startswith('_'): |
|
41 |
continue
|
|
42 |
elif field in self._binary: |
|
43 |
if value is not None: |
|
44 |
value = '(...)' |
|
45 |
interesting[field] = value |
|
46 |
return "%s: %s" % (self.__class__.__name__, interesting) |
|
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
47 |
|
48 |
||
49 |
class BlobCommand(ImportCommand): |
|
50 |
||
51 |
def __init__(self, mark, data): |
|
52 |
ImportCommand.__init__(self, 'blob') |
|
53 |
self.mark = mark |
|
54 |
self.data = data |
|
|
0.64.9
by Ian Clatworthy
dump parameter for info processor |
55 |
self._binary = ['data'] |
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
56 |
|
57 |
||
58 |
class CheckpointCommand(ImportCommand): |
|
59 |
||
60 |
def __init__(self): |
|
61 |
ImportCommand.__init__(self, 'checkpoint') |
|
62 |
||
63 |
||
64 |
class CommitCommand(ImportCommand): |
|
65 |
||
66 |
def __init__(self, ref, mark, author, committer, message, parents, |
|
67 |
file_iter): |
|
68 |
ImportCommand.__init__(self, 'commit') |
|
69 |
self.ref = ref |
|
70 |
self.mark = mark |
|
71 |
self.author = author |
|
72 |
self.committer = committer |
|
73 |
self.message = message |
|
74 |
self.parents = parents |
|
75 |
self.file_iter = file_iter |
|
|
0.64.9
by Ian Clatworthy
dump parameter for info processor |
76 |
self._binary = ['file_iter'] |
77 |
||
78 |
def __str__(self): |
|
79 |
result = [ImportCommand.__str__(self)] |
|
80 |
for f in self.file_iter(): |
|
81 |
result.append("\t%s" % f) |
|
82 |
return '\n'.join(result) |
|
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
83 |
|
84 |
||
85 |
class ProgressCommand(ImportCommand): |
|
86 |
||
87 |
def __init__(self, message): |
|
88 |
ImportCommand.__init__(self, 'progress') |
|
89 |
self.message = message |
|
90 |
||
91 |
||
92 |
class ResetCommand(ImportCommand): |
|
93 |
||
94 |
def __init__(self, ref, from_): |
|
95 |
ImportCommand.__init__(self, 'reset') |
|
96 |
self.ref = ref |
|
97 |
self.from_ = from_ |
|
98 |
||
99 |
||
100 |
class TagCommand(ImportCommand): |
|
101 |
||
102 |
def __init__(self, id, from_, tagger, message): |
|
103 |
ImportCommand.__init__(self, 'tag') |
|
104 |
self.id = id |
|
105 |
self.from_ = from_ |
|
106 |
self.tagger = tagger |
|
107 |
self.message = message |
|
108 |
||
109 |
||
110 |
class FileCommand(ImportCommand): |
|
111 |
"""Base class for file commands.""" |
|
112 |
pass
|
|
113 |
||
114 |
||
115 |
class FileModifyCommand(FileCommand): |
|
116 |
||
117 |
def __init__(self, path, kind, is_executable, dataref, data): |
|
118 |
# Either dataref or data should be null
|
|
119 |
FileCommand.__init__(self, 'modify') |
|
120 |
self.path = path |
|
121 |
self.kind = kind |
|
122 |
self.is_executable = is_executable |
|
123 |
self.dataref = dataref |
|
124 |
self.data = data |
|
|
0.64.9
by Ian Clatworthy
dump parameter for info processor |
125 |
self._binary = ['data'] |
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
126 |
|
127 |
||
128 |
class FileDeleteCommand(FileCommand): |
|
129 |
||
130 |
def __init__(self, path): |
|
131 |
FileCommand.__init__(self, 'delete') |
|
132 |
self.path = path |
|
133 |
||
134 |
||
135 |
class FileCopyCommand(FileCommand): |
|
136 |
||
137 |
def __init__(self, src_path, dest_path): |
|
138 |
FileCommand.__init__(self, 'copy') |
|
139 |
self.src_path = src_path |
|
140 |
self.dest_path = dest_path |
|
141 |
||
142 |
||
143 |
class FileRenameCommand(FileCommand): |
|
144 |
||
|
0.64.2
by Ian Clatworthy
use Bazaar file kinds |
145 |
def __init__(self, old_path, new_path): |
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
146 |
FileCommand.__init__(self, 'rename') |
|
0.64.2
by Ian Clatworthy
use Bazaar file kinds |
147 |
self.old_path = old_path |
148 |
self.new_path = new_path |
|
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
149 |
|
150 |
||
151 |
class FileDeleteAllCommand(FileCommand): |
|
152 |
||
|
0.64.2
by Ian Clatworthy
use Bazaar file kinds |
153 |
def __init__(self): |
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
154 |
FileCommand.__init__(self, 'deleteall') |