177 * p2: revision number of first parent |
179 * p2: revision number of first parent |
178 * changes: a ChangingFiles object |
180 * changes: a ChangingFiles object |
179 """ |
181 """ |
180 cl = repo.changelog |
182 cl = repo.changelog |
181 parents = cl.parentrevs |
183 parents = cl.parentrevs |
|
184 flags = cl.flags |
|
185 |
|
186 HASCOPIESINFO = flagutil.REVIDX_HASCOPIESINFO |
182 |
187 |
183 changelogrevision = cl.changelogrevision |
188 changelogrevision = cl.changelogrevision |
184 |
189 |
185 # A small cache to avoid doing the work twice for merges |
190 # A small cache to avoid doing the work twice for merges |
186 # |
191 # |
211 p1, p2 = parents(rev) |
216 p1, p2 = parents(rev) |
212 value = None |
217 value = None |
213 e = merge_caches.pop(rev, None) |
218 e = merge_caches.pop(rev, None) |
214 if e is not None: |
219 if e is not None: |
215 return e |
220 return e |
216 value = (p1, p2, changelogrevision(rev).changes) |
221 changes = None |
|
222 if flags(rev) & HASCOPIESINFO: |
|
223 changes = changelogrevision(rev).changes |
|
224 value = (p1, p2, changes) |
217 if p1 != node.nullrev and p2 != node.nullrev: |
225 if p1 != node.nullrev and p2 != node.nullrev: |
218 # XXX some case we over cache, IGNORE |
226 # XXX some case we over cache, IGNORE |
219 merge_caches[rev] = value |
227 merge_caches[rev] = value |
220 return value |
228 return value |
221 |
229 |
291 if copies is None: |
299 if copies is None: |
292 # this is a root |
300 # this is a root |
293 copies = {} |
301 copies = {} |
294 for i, c in enumerate(children[r]): |
302 for i, c in enumerate(children[r]): |
295 p1, p2, changes = revinfo(c) |
303 p1, p2, changes = revinfo(c) |
|
304 childcopies = {} |
296 if r == p1: |
305 if r == p1: |
297 parent = 1 |
306 parent = 1 |
298 childcopies = changes.copied_from_p1 |
307 if changes is not None: |
|
308 childcopies = changes.copied_from_p1 |
299 else: |
309 else: |
300 assert r == p2 |
310 assert r == p2 |
301 parent = 2 |
311 parent = 2 |
302 childcopies = changes.copied_from_p2 |
312 if changes is not None: |
|
313 childcopies = changes.copied_from_p2 |
303 if not alwaysmatch: |
314 if not alwaysmatch: |
304 childcopies = { |
315 childcopies = { |
305 dst: src for dst, src in childcopies.items() if match(dst) |
316 dst: src for dst, src in childcopies.items() if match(dst) |
306 } |
317 } |
307 newcopies = copies |
318 newcopies = copies |
311 prev = copies.get(source) |
322 prev = copies.get(source) |
312 if prev is not None and prev[1] is not None: |
323 if prev is not None and prev[1] is not None: |
313 source = prev[1] |
324 source = prev[1] |
314 newcopies[dest] = (c, source) |
325 newcopies[dest] = (c, source) |
315 assert newcopies is not copies |
326 assert newcopies is not copies |
316 for f in changes.removed: |
327 if changes is not None: |
317 if f in newcopies: |
328 for f in changes.removed: |
318 if newcopies is copies: |
329 if f in newcopies: |
319 # copy on write to avoid affecting potential other |
330 if newcopies is copies: |
320 # branches. when there are no other branches, this |
331 # copy on write to avoid affecting potential other |
321 # could be avoided. |
332 # branches. when there are no other branches, this |
322 newcopies = copies.copy() |
333 # could be avoided. |
323 newcopies[f] = (c, None) |
334 newcopies = copies.copy() |
|
335 newcopies[f] = (c, None) |
324 othercopies = all_copies.get(c) |
336 othercopies = all_copies.get(c) |
325 if othercopies is None: |
337 if othercopies is None: |
326 all_copies[c] = newcopies |
338 all_copies[c] = newcopies |
327 else: |
339 else: |
328 # we are the second parent to work on c, we need to merge our |
340 # we are the second parent to work on c, we need to merge our |
371 continue |
383 continue |
372 # content from "major" wins, unless it is older |
384 # content from "major" wins, unless it is older |
373 # than the branch point or there is a merge |
385 # than the branch point or there is a merge |
374 if new_tt == other_tt: |
386 if new_tt == other_tt: |
375 minor[dest] = value |
387 minor[dest] = value |
376 elif value[1] is None and dest in changes.salvaged: |
388 elif ( |
|
389 changes is not None |
|
390 and value[1] is None |
|
391 and dest in changes.salvaged |
|
392 ): |
377 pass |
393 pass |
378 elif other[1] is None and dest in changes.salvaged: |
394 elif ( |
|
395 changes is not None |
|
396 and other[1] is None |
|
397 and dest in changes.salvaged |
|
398 ): |
379 minor[dest] = value |
399 minor[dest] = value |
380 elif not isancestor(new_tt, other_tt): |
400 elif not isancestor(new_tt, other_tt): |
381 minor[dest] = value |
401 minor[dest] = value |
382 elif dest in changes.merged: |
402 elif changes is not None and dest in changes.merged: |
383 minor[dest] = value |
403 minor[dest] = value |
384 |
404 |
385 |
405 |
386 def _revinfo_getter_extra(repo): |
406 def _revinfo_getter_extra(repo): |
387 """return a function that return multiple data given a <rev>"i |
407 """return a function that return multiple data given a <rev>"i |