diff mercurial/cmdutil.py @ 24837:edf907bd8144 stable

record: fix record with change on moved file crashes (issue4619) reverting 79fceed67676, add a test to prevent the issue from coming back.
author Laurent Charignon <lcharignon@fb.com>
date Wed, 22 Apr 2015 13:56:30 -0700
parents c560d8c68791
children 21b33f0460e0
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Wed Apr 22 23:38:55 2015 +0900
+++ b/mercurial/cmdutil.py	Wed Apr 22 13:56:30 2015 -0700
@@ -59,8 +59,6 @@
 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall,
             filterfn, *pats, **opts):
     import merge as mergemod
-    hunkclasses = (crecordmod.uihunk, patch.recordhunk)
-    ishunk = lambda x: isinstance(x, hunkclasses)
 
     if not ui.interactive():
         raise util.Abort(_('running non-interactively, use %s instead') %
@@ -117,12 +115,6 @@
             ui.status(_('no changes to record\n'))
             return 0
 
-        newandmodifiedfiles = set()
-        for h in chunks:
-            isnew = h.filename() in status.added
-            if ishunk(h) and isnew and not h in originalchunks:
-                newandmodifiedfiles.add(h.filename())
-
         modified = set(status.modified)
 
         # 2. backup changed files, so we can restore them in the end
@@ -130,8 +122,7 @@
         if backupall:
             tobackup = changed
         else:
-            tobackup = [f for f in newfiles
-                        if f in modified or f in newandmodifiedfiles]
+            tobackup = [f for f in newfiles if f in modified]
 
         backups = {}
         if tobackup:
@@ -155,13 +146,11 @@
             fp = cStringIO.StringIO()
             for c in chunks:
                 fname = c.filename()
-                if fname in backups or fname in newandmodifiedfiles:
+                if fname in backups:
                     c.write(fp)
             dopatch = fp.tell()
             fp.seek(0)
 
-            [os.unlink(c) for c in newandmodifiedfiles]
-
             # 3a. apply filtered patch to clean repo  (clean)
             if backups:
                 # Equivalent to hg.revert