# HG changeset patch # User Alexis S. L. Carvalho # Date 1202079826 7200 # Node ID a732eebf195840a6a17e8a5276d241301d221530 # Parent 850494d626741ccdb8361f77c05bb08e7a7f9d96 hg import: write the dirstate after every commit This allows the transaction system to backup the correct file, so that a future rollback can do the right thing. This should fix issue963. diff -r 850494d62674 -r a732eebf1958 mercurial/commands.py --- a/mercurial/commands.py Sun Feb 03 21:03:46 2008 -0200 +++ b/mercurial/commands.py Sun Feb 03 21:03:46 2008 -0200 @@ -1632,6 +1632,9 @@ repo.rollback() raise util.Abort(_('patch is damaged' + ' or loses information')) + # Force a dirstate write so that the next transaction backups + # an up-do-date file. + repo.dirstate.write() finally: os.unlink(tmpname) finally: diff -r 850494d62674 -r a732eebf1958 tests/test-import --- a/tests/test-import Sun Feb 03 21:03:46 2008 -0200 +++ b/tests/test-import Sun Feb 03 21:03:46 2008 -0200 @@ -111,6 +111,18 @@ hg --cwd b tip --template '{desc}\n' rm -r b +# We weren't backing up the correct dirstate file when importing many patches +# (issue963) +echo '% import patch1 patch2; rollback' +echo line 3 >> a/a +hg --cwd a ci -m'third change' +hg --cwd a export -o '../patch%R' 1 2 +hg clone -qr0 a b +hg --cwd b parents --template 'parent: #rev#\n' +hg --cwd b import ../patch1 ../patch2 +hg --cwd b rollback +hg --cwd b parents --template 'parent: #rev#\n' +rm -r b # bug non regression test # importing a patch in a subdirectory failed at the commit stage diff -r 850494d62674 -r a732eebf1958 tests/test-import.out --- a/tests/test-import.out Sun Feb 03 21:03:46 2008 -0200 +++ b/tests/test-import.out Sun Feb 03 21:03:46 2008 -0200 @@ -112,6 +112,12 @@ next line --- +% import patch1 patch2; rollback +parent: 0 +applying ../patch1 +applying ../patch2 +rolling back last transaction +parent: 1 % hg import in a subdirectory requesting all changes adding changesets