diff mercurial/copies.py @ 30188:8a864844d5a0

checkcopies: add a sanity check against false-positive copies When grafting a copy backwards through a rename, a copy is wrongly detected, which causes the graft to be applied inappropriately, in a destructive way. Make sure that the old file name really exists in the common ancestor, and bail out if it doesn't. This fixes the aggravated case of bug 5343, although the basic issue (failure to duplicate the copy information) still occurs.
author Gábor Stefanik <gabor.stefanik@nng.com>
date Wed, 12 Oct 2016 21:33:45 +0200
parents f7ed5af31242
children 368e27eb1ffa
line wrap: on
line diff
--- a/mercurial/copies.py	Sun Oct 16 10:38:52 2016 -0700
+++ b/mercurial/copies.py	Wed Oct 12 21:33:45 2016 +0200
@@ -543,7 +543,8 @@
         # unrelated to the droids we are looking for.
         cr = _related(oc, c2, base.rev())
         if cr and (of == f or of == c2.path()): # non-divergent
-            data['copy'][f] = of
+            if of in mb:
+                data['copy'][f] = of
             return
 
     if of in mb: