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