mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 17:27:53 +03:00
bdc7cca4fe
Summary: `sqlrecover`, `sqlrefill` and `sqlstrip` use `ui.environ["PWD"]` to get the current working directory which leads to not respecting the global `--cwd` option to the Mercurial commands. This commit just introduces a test case which exposes this issue in `sqlstrip` tests. Reviewed By: quark-zju Differential Revision: D8925896 fbshipit-source-id: 0c0e523adc79db8c1357978185d7f157230b9783
183 lines
5.0 KiB
Perl
183 lines
5.0 KiB
Perl
#testcases case-innodb case-rocksdb
|
|
|
|
#if case-rocksdb
|
|
$ DBENGINE=rocksdb
|
|
#else
|
|
$ DBENGINE=innodb
|
|
#endif
|
|
|
|
$ . "$TESTDIR/hgsql/library.sh"
|
|
|
|
Populate the db with an initial commit
|
|
|
|
$ initclient client
|
|
$ cd client
|
|
$ echo x > x
|
|
$ hg commit -qAm x
|
|
$ echo y > y
|
|
$ hg commit -qAm y
|
|
$ hg up 0
|
|
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
|
|
$ echo z > z
|
|
$ hg commit -qAm z
|
|
$ hg bookmark foo
|
|
$ cd ..
|
|
|
|
Create two masters
|
|
|
|
$ initserver master masterrepo
|
|
$ initserver master2 masterrepo
|
|
$ cd master
|
|
$ hg log
|
|
$ hg pull -q ../client
|
|
|
|
$ cd ../master2
|
|
$ hg log -G -T '{rev} {desc} {bookmarks}\n'
|
|
o 2 z foo
|
|
|
|
|
| o 1 y
|
|
|/
|
|
o 0 x
|
|
|
|
|
|
Stripping normally should fail
|
|
|
|
$ hg strip -r 1
|
|
saved backup bundle to $TESTTMP/master2/.hg/strip-backup/d34c38483be9-3839604f-backup.hg (glob)
|
|
transaction abort!
|
|
rollback completed
|
|
strip failed, backup bundle stored in '$TESTTMP/master2/.hg/strip-backup/d34c38483be9-3839604f-backup.hg'
|
|
strip failed, unrecovered changes stored in '$TESTTMP/master2/.hg/strip-backup/d34c38483be9-48128f20-temp.hg'
|
|
(fix the problem, then recover the changesets with "hg unbundle '$TESTTMP/master2/.hg/strip-backup/d34c38483be9-48128f20-temp.hg'")
|
|
abort: invalid repo change - only hg push and pull are allowed
|
|
[255]
|
|
|
|
$ hg verify
|
|
checking changesets
|
|
checking manifests
|
|
crosschecking files in changesets and manifests
|
|
checking files
|
|
3 files, 3 changesets, 3 total revisions
|
|
|
|
Strip using sqlstrip
|
|
|
|
- Test that specifying `--i-know-what-i-am-doing` is required.
|
|
$ hg sqlstrip 1
|
|
abort: You must pass --i-know-what-i-am-doing to run this command. If you have multiple servers using the database, this command will break your servers until you run it on each one. Only the Mercurial server admins should ever run this.
|
|
[255]
|
|
|
|
- Test that specifying the `--cwd` option fails. This will be fixed in D8925908.
|
|
$ cd ..
|
|
$ hg --cwd master2 sqlstrip --i-know-what-i-am-doing 1
|
|
*** YOU ARE ABOUT TO DELETE HISTORY (MANDATORY 5 SECOND WAIT) ***
|
|
abort: repository $TESTTMP not found!
|
|
[255]
|
|
|
|
$ cd master2
|
|
|
|
- Finally, strip successfully using sqlstrip.
|
|
$ hg sqlstrip --i-know-what-i-am-doing 1
|
|
*** YOU ARE ABOUT TO DELETE HISTORY (MANDATORY 5 SECOND WAIT) ***
|
|
stripping locally
|
|
saved backup bundle to $TESTTMP/master2/.hg/strip-backup/bc3a71defa4a-f38e411b-sqlstrip.hg (glob)
|
|
stripping from the database
|
|
deleting old references
|
|
adding new head references
|
|
adding new tip reference
|
|
adding new bookmark references
|
|
deleting revision data
|
|
|
|
Repull, and then strip without a backup
|
|
$ hg pull -q ../client
|
|
$ hg verify
|
|
checking changesets
|
|
checking manifests
|
|
crosschecking files in changesets and manifests
|
|
checking files
|
|
3 files, 3 changesets, 3 total revisions
|
|
|
|
$ hg log -G -T '{rev} {desc} {bookmarks}\n'
|
|
o 2 z foo
|
|
|
|
|
| o 1 y
|
|
|/
|
|
o 0 x
|
|
|
|
$ hg sqlstrip --i-know-what-i-am-doing 1 --no-backup-permanent-data-loss
|
|
*** YOU ARE ABOUT TO DELETE HISTORY (MANDATORY 5 SECOND WAIT) ***
|
|
*** *** *** *** *** *** *** *** * *** *** *** *** *** *** *** ***
|
|
*** THERE ARE NO BACKUPS! * (MANDATORY 10 SECOND WAIT) ***
|
|
*** *** *** *** *** *** *** *** * *** *** *** *** *** *** *** ***
|
|
stripping locally
|
|
stripping from the database
|
|
deleting old references
|
|
adding new head references
|
|
adding new tip reference
|
|
adding new bookmark references
|
|
deleting revision data
|
|
|
|
Verify master2 is stripped
|
|
|
|
$ hg verify
|
|
checking changesets
|
|
checking manifests
|
|
crosschecking files in changesets and manifests
|
|
checking files
|
|
1 files, 1 changesets, 1 total revisions
|
|
$ hg log -G -T '{rev} {desc} {bookmarks}\n'
|
|
o 0 x foo
|
|
|
|
Verify master is broken
|
|
|
|
$ cd ../master
|
|
$ hg log 2>&1 | egrep 'hgext.hgsql.CorruptionException'
|
|
hgext.hgsql.CorruptionException: heads don't match after sync
|
|
|
|
Run sqlstrip on master as well
|
|
|
|
$ hg sqlstrip --i-know-what-i-am-doing 1
|
|
*** YOU ARE ABOUT TO DELETE HISTORY (MANDATORY 5 SECOND WAIT) ***
|
|
stripping locally
|
|
saved backup bundle to $TESTTMP/master/.hg/strip-backup/bc3a71defa4a-f38e411b-sqlstrip.hg (glob)
|
|
stripping from the database
|
|
deleting old references
|
|
adding new head references
|
|
adding new tip reference
|
|
adding new bookmark references
|
|
deleting revision data
|
|
|
|
$ hg verify
|
|
checking changesets
|
|
checking manifests
|
|
crosschecking files in changesets and manifests
|
|
checking files
|
|
1 files, 1 changesets, 1 total revisions
|
|
$ hg log -G -T '{rev} {desc} {bookmarks}\n'
|
|
o 0 x foo
|
|
|
|
Commit after the strip
|
|
|
|
$ hg up -q 0
|
|
$ echo z > z
|
|
$ hg commit -qAm z
|
|
|
|
$ cd ../master2
|
|
$ hg log -G -T '{rev} {desc} {bookmarks}\n'
|
|
o 1 z
|
|
|
|
|
o 0 x foo
|
|
|
|
Attempt to strip a non-existant rev
|
|
|
|
$ hg sqlstrip --i-know-what-i-am-doing 5
|
|
*** YOU ARE ABOUT TO DELETE HISTORY (MANDATORY 5 SECOND WAIT) ***
|
|
abort: revision 5 is not in the repo
|
|
[255]
|
|
|
|
Attempt to strip a non-integer
|
|
|
|
$ hg sqlstrip --i-know-what-i-am-doing master
|
|
*** YOU ARE ABOUT TO DELETE HISTORY (MANDATORY 5 SECOND WAIT) ***
|
|
abort: specified rev must be an integer: 'master'
|
|
[255]
|