Mercurial > hg
changeset 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 | 1f9127c9239b |
children | b2c1ff96c1e1 |
files | mercurial/cmdutil.py mercurial/patch.py tests/test-commit-interactive-curses.t tests/test-commit-interactive.t tests/test-keyword.t tests/test-mq-subrepo.t |
diffstat | 6 files changed, 30 insertions(+), 127 deletions(-) [+] |
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
--- a/mercurial/patch.py Wed Apr 22 23:38:55 2015 +0900 +++ b/mercurial/patch.py Wed Apr 22 13:56:30 2015 -0700 @@ -820,7 +820,7 @@ """ diffgit_re = re.compile('diff --git a/(.*) b/(.*)$') diff_re = re.compile('diff -r .* (.*)$') - allhunks_re = re.compile('(?:index|deleted file) ') + allhunks_re = re.compile('(?:index|new file|deleted file) ') pretty_re = re.compile('(?:new file|deleted file) ') special_re = re.compile('(?:index|new|deleted|copy|rename) ')
--- a/tests/test-commit-interactive-curses.t Wed Apr 22 23:38:55 2015 +0900 +++ b/tests/test-commit-interactive-curses.t Wed Apr 22 13:56:30 2015 -0700 @@ -143,48 +143,10 @@ 10 y -Editing patch of newly added file - - $ cat > editor.sh << '__EOF__' - > cat "$1" | sed "s/first/very/g" > tt - > mv tt "$1" - > __EOF__ - $ cat > newfile << '__EOF__' - > This is the first line - > This is the second line - > This is the third line - > __EOF__ - $ hg add newfile - $ cat <<EOF >testModeCommands - > f - > KEY_DOWN - > KEY_DOWN - > KEY_DOWN - > e - > X - > EOF - $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -d '23 0' -medit-patch-new - $ hg tip - changeset: 4:6a0a43e9eff5 - tag: tip - user: test - date: Thu Jan 01 00:00:23 1970 +0000 - summary: edit-patch-new - - $ hg cat -r tip newfile - This is the very line - This is the second line - This is the third line - - $ cat newfile - This is the first line - This is the second line - This is the third line - Newly added files can be selected with the curses interface $ hg update -C . - 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ echo "hello" > x $ hg add x $ cat <<EOF >testModeCommands @@ -194,10 +156,8 @@ > EOF $ hg st A x - ? editor.sh ? testModeCommands $ hg commit -i -m "newly added file" -d "0 0" $ hg st - ? editor.sh ? testModeCommands
--- a/tests/test-commit-interactive.t Wed Apr 22 23:38:55 2015 +0900 +++ b/tests/test-commit-interactive.t Wed Apr 22 13:56:30 2015 -0700 @@ -229,25 +229,11 @@ $ hg add plain $ hg commit -i -d '7 0' -m plain plain<<EOF > y - > y > EOF diff --git a/plain b/plain new file mode 100644 examine changes to 'plain'? [Ynesfdaq?] y - @@ -0,0 +1,10 @@ - +1 - +2 - +3 - +4 - +5 - +6 - +7 - +8 - +9 - +10 - record this change to 'plain'? [Ynesfdaq?] y - $ hg tip -p changeset: 7:11fb457c1be4 tag: tip @@ -348,10 +334,6 @@ new file mode 100644 examine changes to 'plain2'? [Ynesfdaq?] y - @@ -0,0 +1,1 @@ - +1 - record change 2/2 to 'plain2'? [Ynesfdaq?] y - Modify beginning, trim end, record both, add another file to test changes numbering @@ -1395,40 +1377,34 @@ $ export HGUSER -Editing patch of newly added file +Moving files - $ cat > editor.sh << '__EOF__' - > cat "$1" | sed "s/first/very/g" > tt - > mv tt "$1" - > __EOF__ - $ cat > newfile << '__EOF__' - > This is the first line - > This is the second line - > This is the third line - > __EOF__ - $ hg add newfile - $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -d '23 0' -medit-patch-new <<EOF + $ hg update -C . + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg mv plain plain3 + $ echo somechange >> plain3 + $ hg commit -i -d '23 0' -mmoving_files << EOF > y - > e + > y > EOF - diff --git a/newfile b/newfile - new file mode 100644 - examine changes to 'newfile'? [Ynesfdaq?] y - - @@ -0,0 +1,3 @@ - +This is the first line - +This is the second line - +This is the third line - record this change to 'newfile'? [Ynesfdaq?] e + diff --git a/plain b/plain3 + rename from plain + rename to plain3 + 1 hunks, 1 lines changed + examine changes to 'plain' and 'plain3'? [Ynesfdaq?] y - $ hg cat -r tip newfile - This is the very line - This is the second line - This is the third line - - $ cat newfile - This is the first line - This is the second line - This is the third line - + @@ -11,3 +11,4 @@ + 9 + 10 + 11 + +somechange + record this change to 'plain3'? [Ynesfdaq?] y + + $ hg tip + changeset: 30:542e1f362a22 + tag: tip + user: test + date: Thu Jan 01 00:00:23 1970 +0000 + summary: moving_files + $ cd ..
--- a/tests/test-keyword.t Wed Apr 22 23:38:55 2015 +0900 +++ b/tests/test-keyword.t Wed Apr 22 13:56:30 2015 -0700 @@ -479,12 +479,6 @@ new file mode 100644 examine changes to 'r'? [Ynesfdaq?] y - @@ -0,0 +1,1 @@ - +$Id$ - record this change to 'r'? [Ynesfdaq?] y - - resolving manifests - patching file r committing files: r committing manifest @@ -513,12 +507,6 @@ new file mode 100644 examine changes to 'i'? [Ynesfdaq?] y - @@ -0,0 +1,1 @@ - +$Id$ - record this change to 'i'? [Ynesfdaq?] y - - resolving manifests - patching file i committing files: i committing manifest
--- a/tests/test-mq-subrepo.t Wed Apr 22 23:38:55 2015 +0900 +++ b/tests/test-mq-subrepo.t Wed Apr 22 13:56:30 2015 -0700 @@ -295,11 +295,6 @@ new file mode 100644 examine changes to '.hgsub'? [Ynesfdaq?] y - @@ -0,0 +1,1 @@ - +sub = sub - record this change to '.hgsub'? [Ynesfdaq?] y - - warning: subrepo spec file '.hgsub' not found abort: uncommitted changes in subrepository 'sub' [255] % update substate when adding .hgsub w/clean updated subrepo @@ -309,11 +304,6 @@ new file mode 100644 examine changes to '.hgsub'? [Ynesfdaq?] y - @@ -0,0 +1,1 @@ - +sub = sub - record this change to '.hgsub'? [Ynesfdaq?] y - - warning: subrepo spec file '.hgsub' not found path sub source sub revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31