comparison mercurial/localrepo.py @ 23929:a43fdf33a6be stable

commit: remove reverse search for copy source when not in parent (issue4476) Previously, we had weird, nonsensical behavior when committing a file move with a missing source. This removes that weird logic and tests that the bug this strange behavior caused is fixed. Also adds a longish comment to prevent some poor soul from accidentally re-implementing the bug in the future.
author Ryan McElroy <rmcelroy@fb.com>
date Tue, 20 Jan 2015 15:05:44 -0800
parents 3cbb5bf4035d
children ed5e8a9598ce
comparison
equal deleted inserted replaced
23928:ca6cfc2f8197 23929:a43fdf33a6be
1204 if fparent2 == nullid or crev is None: # copied on remote side 1204 if fparent2 == nullid or crev is None: # copied on remote side
1205 if cfname in manifest2: 1205 if cfname in manifest2:
1206 crev = manifest2[cfname] 1206 crev = manifest2[cfname]
1207 newfparent = fparent1 1207 newfparent = fparent1
1208 1208
1209 # find source in nearest ancestor if we've lost track 1209 # Here, we used to search backwards through history to try to find
1210 if not crev: 1210 # where the file copy came from if the source of a copy was not in
1211 self.ui.debug(" %s: searching for copy revision for %s\n" % 1211 # the parent diretory. However, this doesn't actually make sense to
1212 (fname, cfname)) 1212 # do (what does a copy from something not in your working copy even
1213 for ancestor in self[None].ancestors(): 1213 # mean?) and it causes bugs (eg, issue4476). Instead, we will warn
1214 if cfname in ancestor: 1214 # the user that copy information was dropped, so if they didn't
1215 crev = ancestor[cfname].filenode() 1215 # expect this outcome it can be fixed, but this is the correct
1216 break 1216 # behavior in this circumstance.
1217 1217
1218 if crev: 1218 if crev:
1219 self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev))) 1219 self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev)))
1220 meta["copy"] = cfname 1220 meta["copy"] = cfname
1221 meta["copyrev"] = hex(crev) 1221 meta["copyrev"] = hex(crev)