##// END OF EJS Templates
convert: return calculated values from parse() instead of manpulating state
David Soria Parra -
r30631:c2be48e5 default
parent child Browse files
Show More
@@ -56,7 +56,6 b' class p4_source(common.converter_source)'
56 56 common.checktool('p4', abort=False)
57 57
58 58 self.revmap = {}
59 self.p4changes = {}
60 59 self.heads = []
61 60 self.changeset = {}
62 61 self.files = {}
@@ -75,7 +74,7 b' class p4_source(common.converter_source)'
75 74 if revs and len(revs) > 1:
76 75 raise error.Abort(_("p4 source does not support specifying "
77 76 "multiple revisions"))
78 self._parse(ui, path)
77 self._parse_once(ui, path)
79 78
80 79 def setrevmap(self, revmap):
81 80 """Sets the parsed revmap dictionary.
@@ -103,11 +102,19 b' class p4_source(common.converter_source)'
103 102
104 103 def _parse(self, ui, path):
105 104 "Prepare list of P4 filenames and revisions to import"
105 p4changes = {}
106 changeset = {}
107 files_map = {}
108 copies_map = {}
109 localname = {}
110 depotname = {}
111 heads = []
112
106 113 ui.status(_('reading p4 views\n'))
107 114
108 115 # read client spec or view
109 116 if "/" in path:
110 self.p4changes.update(self._parse_view(path))
117 p4changes.update(self._parse_view(path))
111 118 if path.startswith("//") and path.endswith("/..."):
112 119 views = {path[:-3]:""}
113 120 else:
@@ -120,7 +127,7 b' class p4_source(common.converter_source)'
120 127 for client in clientspec:
121 128 if client.startswith("View"):
122 129 sview, cview = clientspec[client].split()
123 self.p4changes.update(self._parse_view(sview))
130 p4changes.update(self._parse_view(sview))
124 131 if sview.endswith("...") and cview.endswith("..."):
125 132 sview = sview[:-3]
126 133 cview = cview[:-3]
@@ -129,8 +136,8 b' class p4_source(common.converter_source)'
129 136 views[sview] = cview
130 137
131 138 # list of changes that affect our source files
132 self.p4changes = self.p4changes.keys()
133 self.p4changes.sort(key=int)
139 p4changes = p4changes.keys()
140 p4changes.sort(key=int)
134 141
135 142 # list with depot pathnames, longest first
136 143 vieworder = views.keys()
@@ -142,7 +149,7 b' class p4_source(common.converter_source)'
142 149 # now read the full changelists to get the list of file revisions
143 150 ui.status(_('collecting p4 changelists\n'))
144 151 lastid = None
145 for change in self.p4changes:
152 for change in p4changes:
146 153 if startrev and int(change) < int(startrev):
147 154 continue
148 155 if self.revs and int(change) > int(self.revs[0]):
@@ -167,7 +174,6 b' class p4_source(common.converter_source)'
167 174 files = []
168 175 copies = {}
169 176 copiedfiles = []
170 localname = {}
171 177 i = 0
172 178 while ("depotFile%d" % i) in d and ("rev%d" % i) in d:
173 179 oldname = d["depotFile%d" % i]
@@ -178,7 +184,7 b' class p4_source(common.converter_source)'
178 184 break
179 185 if filename:
180 186 files.append((filename, d["rev%d" % i]))
181 self.depotname[filename] = oldname
187 depotname[filename] = oldname
182 188 if (d.get("action%d" % i) == "move/add"):
183 189 copiedfiles.append(filename)
184 190 localname[oldname] = filename
@@ -186,7 +192,7 b' class p4_source(common.converter_source)'
186 192
187 193 # Collect information about copied files
188 194 for filename in copiedfiles:
189 oldname = self.depotname[filename]
195 oldname = depotname[filename]
190 196
191 197 flcmd = 'p4 -G filelog %s' \
192 198 % util.shellquote(oldname)
@@ -218,13 +224,29 b' class p4_source(common.converter_source)'
218 224 ui.warn(_("cannot find source for copied file: %s@%s\n")
219 225 % (filename, change))
220 226
221 self.changeset[change] = c
222 self.files[change] = files
223 self.copies[change] = copies
227 changeset[change] = c
228 files_map[change] = files
229 copies_map[change] = copies
224 230 lastid = change
225 231
226 if lastid and len(self.changeset) > 0:
227 self.heads = [lastid]
232 if lastid and len(changeset) > 0:
233 heads = [lastid]
234
235 return {
236 'changeset': changeset,
237 'files': files_map,
238 'copies': copies_map,
239 'heads': heads,
240 'depotname': depotname,
241 }
242
243 def _parse_once(self, ui, path):
244 d = self._parse(ui, path)
245 self.changeset = d['changeset']
246 self.heads = d['heads']
247 self.files = d['files']
248 self.copies = d['copies']
249 self.depotname = d['depotname']
228 250
229 251 def getheads(self):
230 252 return self.heads
General Comments 0
You need to be logged in to leave comments. Login now