Show More
@@ -36,11 +36,13 b' class p4_source(converter_source):' | |||
|
36 | 36 | self.heads = {} |
|
37 | 37 | self.changeset = {} |
|
38 | 38 | self.files = {} |
|
39 | self.copies = {} | |
|
39 | 40 | self.tags = {} |
|
40 | 41 | self.lastbranch = {} |
|
41 | 42 | self.parent = {} |
|
42 | 43 | self.encoding = "latin_1" |
|
43 | 44 | self.depotname = {} # mapping from local name to depot name |
|
45 | self.localname = {} # mapping from depot name to local name | |
|
44 | 46 | self.re_type = re.compile( |
|
45 | 47 | "([a-z]+)?(text|binary|symlink|apple|resource|unicode|utf\d+)" |
|
46 | 48 | "(\+\w+)?$") |
@@ -128,6 +130,8 b' class p4_source(converter_source):' | |||
|
128 | 130 | extra={"p4": change}) |
|
129 | 131 | |
|
130 | 132 | files = [] |
|
133 | copies = {} | |
|
134 | copiedfiles = [] | |
|
131 | 135 | i = 0 |
|
132 | 136 | while ("depotFile%d" % i) in d and ("rev%d" % i) in d: |
|
133 | 137 | oldname = d["depotFile%d" % i] |
@@ -139,9 +143,48 b' class p4_source(converter_source):' | |||
|
139 | 143 | if filename: |
|
140 | 144 | files.append((filename, d["rev%d" % i])) |
|
141 | 145 | self.depotname[filename] = oldname |
|
146 | if (d.get("action%d" % i) == "move/add"): | |
|
147 | copiedfiles.append(filename) | |
|
148 | self.localname[oldname] = filename | |
|
142 | 149 | i += 1 |
|
150 | ||
|
151 | # Collect information about copied files | |
|
152 | for filename in copiedfiles: | |
|
153 | oldname = self.depotname[filename] | |
|
154 | ||
|
155 | flcmd = 'p4 -G filelog %s' \ | |
|
156 | % util.shellquote(oldname) | |
|
157 | flstdout = util.popen(flcmd, mode='rb') | |
|
158 | ||
|
159 | copiedfilename = None | |
|
160 | for d in loaditer(flstdout): | |
|
161 | copiedoldname = None | |
|
162 | ||
|
163 | i = 0 | |
|
164 | while ("change%d" % i) in d: | |
|
165 | if (d["change%d" % i] == change and | |
|
166 | d["action%d" % i] == "move/add"): | |
|
167 | j = 0 | |
|
168 | while ("file%d,%d" % (i, j)) in d: | |
|
169 | if d["how%d,%d" % (i, j)] == "moved from": | |
|
170 | copiedoldname = d["file%d,%d" % (i, j)] | |
|
171 | break | |
|
172 | j += 1 | |
|
173 | i += 1 | |
|
174 | ||
|
175 | if copiedoldname and copiedoldname in self.localname: | |
|
176 | copiedfilename = self.localname[copiedoldname] | |
|
177 | break | |
|
178 | ||
|
179 | if copiedfilename: | |
|
180 | copies[filename] = copiedfilename | |
|
181 | else: | |
|
182 | ui.warn(_("cannot find source for copied file: %s@%s\n") | |
|
183 | % (filename, change)) | |
|
184 | ||
|
143 | 185 | self.changeset[change] = c |
|
144 | 186 | self.files[change] = files |
|
187 | self.copies[change] = copies | |
|
145 | 188 | lastid = change |
|
146 | 189 | |
|
147 | 190 | if lastid: |
@@ -198,7 +241,7 b' class p4_source(converter_source):' | |||
|
198 | 241 | def getchanges(self, rev, full): |
|
199 | 242 | if full: |
|
200 | 243 | raise util.Abort(_("convert from p4 do not support --full")) |
|
201 |
return self.files[rev], |
|
|
244 | return self.files[rev], self.copies[rev], set() | |
|
202 | 245 | |
|
203 | 246 | def getcommit(self, rev): |
|
204 | 247 | return self.changeset[rev] |
General Comments 0
You need to be logged in to leave comments.
Login now