mirror of
https://github.com/facebook/sapling.git
synced 2024-12-29 08:02:24 +03:00
tests: replace print in debugshell with ui.write
Summary: Similar to D18926784. Mercurial makes sure content written by `ui.write` is flushed, while there is no such guarantee for `print`. When running using chg, it's more likely that `print` content gets disappeared. Therefore let's use `ui.write` instead. Reviewed By: ikostia Differential Revision: D18926983 fbshipit-source-id: 960c189cc48bc3c89bb4f7993d2033dd45c52a67
This commit is contained in:
parent
0f127e251d
commit
780faa2c10
@ -3,76 +3,76 @@
|
||||
$ cd master
|
||||
|
||||
Check that a repo without an entry is treated as RW
|
||||
$ hg debugshell -c "print(repo.sqlreporeadonlystate())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlreporeadonlystate()))"
|
||||
(False, 'no reason was provided')
|
||||
$ hg debugshell -c "print(repo.sqlisreporeadonly())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlisreporeadonly()))"
|
||||
False
|
||||
|
||||
Set the repo to RO for hg and mononoke
|
||||
$ mysql -h $DBHOST -P $DBPORT -D $DBNAME -u $DBUSER $DBPASSOPT -e 'REPLACE INTO repo_lock(repo, state) VALUES ("masterrepo", 0)'
|
||||
$ hg debugshell -c "print(repo.sqlreporeadonlystate())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlreporeadonlystate()))"
|
||||
(True, 'no reason was provided')
|
||||
$ hg debugshell -c "print(repo.sqlisreporeadonly())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlisreporeadonly()))"
|
||||
True
|
||||
|
||||
Set another repo to RW for hg and check that masterrepo is still RO
|
||||
$ mysql -h $DBHOST -P $DBPORT -D $DBNAME -u $DBUSER $DBPASSOPT -e 'REPLACE INTO repo_lock(repo, state) VALUES ("masterrepo2", 1)'
|
||||
$ hg debugshell -c "print(repo.sqlreporeadonlystate())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlreporeadonlystate()))"
|
||||
(True, 'no reason was provided')
|
||||
$ hg debugshell -c "print(repo.sqlisreporeadonly())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlisreporeadonly()))"
|
||||
True
|
||||
|
||||
Set the repo to RW for Mononoke only
|
||||
$ mysql -h $DBHOST -P $DBPORT -D $DBNAME -u $DBUSER $DBPASSOPT -e 'REPLACE INTO repo_lock(repo, state) VALUES ("masterrepo", 2)'
|
||||
$ hg debugshell -c "print(repo.sqlreporeadonlystate())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlreporeadonlystate()))"
|
||||
(True, 'writes are being served by Mononoke (fburl.com/mononoke)')
|
||||
$ hg debugshell -c "print(repo.sqlisreporeadonly())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlisreporeadonly()))"
|
||||
True
|
||||
|
||||
Set the repo to RW for hg only
|
||||
$ mysql -h $DBHOST -P $DBPORT -D $DBNAME -u $DBUSER $DBPASSOPT -e 'REPLACE INTO repo_lock(repo, state) VALUES ("masterrepo", 1)'
|
||||
$ hg debugshell -c "print(repo.sqlreporeadonlystate())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlreporeadonlystate()))"
|
||||
(False, 'no reason was provided')
|
||||
$ hg debugshell -c "print(repo.sqlisreporeadonly())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlisreporeadonly()))"
|
||||
False
|
||||
|
||||
Set the repo to RO again
|
||||
$ mysql -h $DBHOST -P $DBPORT -D $DBNAME -u $DBUSER $DBPASSOPT -e 'REPLACE INTO repo_lock(repo, state) VALUES ("masterrepo", 0)'
|
||||
$ hg debugshell -c "print(repo.sqlreporeadonlystate())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlreporeadonlystate()))"
|
||||
(True, 'no reason was provided')
|
||||
$ hg debugshell -c "print(repo.sqlisreporeadonly())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlisreporeadonly()))"
|
||||
True
|
||||
Set the repo to RO for hg and mononoke (with reason)
|
||||
$ mysql -h $DBHOST -P $DBPORT -D $DBNAME -u $DBUSER $DBPASSOPT -e 'REPLACE INTO repo_lock(repo, state, reason) VALUES ("masterrepo", 0, "reason123")'
|
||||
$ hg debugshell -c "print(repo.sqlreporeadonlystate())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlreporeadonlystate()))"
|
||||
(True, 'reason123')
|
||||
$ hg debugshell -c "print(repo.sqlisreporeadonly())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlisreporeadonly()))"
|
||||
True
|
||||
|
||||
Set another repo to RW (with reason) for hg and check that masterrepo is still RO
|
||||
$ mysql -h $DBHOST -P $DBPORT -D $DBNAME -u $DBUSER $DBPASSOPT -e 'REPLACE INTO repo_lock(repo, state, reason) VALUES ("masterrepo2", 1, "reason456")'
|
||||
$ hg debugshell -c "print(repo.sqlreporeadonlystate())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlreporeadonlystate()))"
|
||||
(True, 'reason123')
|
||||
$ hg debugshell -c "print(repo.sqlisreporeadonly())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlisreporeadonly()))"
|
||||
True
|
||||
|
||||
Set the repo to RW for Mononoke only (with reason)
|
||||
$ mysql -h $DBHOST -P $DBPORT -D $DBNAME -u $DBUSER $DBPASSOPT -e 'REPLACE INTO repo_lock(repo, state, reason) VALUES ("masterrepo", 2, "reason123")'
|
||||
$ hg debugshell -c "print(repo.sqlreporeadonlystate())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlreporeadonlystate()))"
|
||||
(True, 'reason123')
|
||||
$ hg debugshell -c "print(repo.sqlisreporeadonly())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlisreporeadonly()))"
|
||||
True
|
||||
|
||||
Set the repo to RW for hg only (with reason)
|
||||
$ mysql -h $DBHOST -P $DBPORT -D $DBNAME -u $DBUSER $DBPASSOPT -e 'REPLACE INTO repo_lock(repo, state, reason) VALUES ("masterrepo", 1, "reason123")'
|
||||
$ hg debugshell -c "print(repo.sqlreporeadonlystate())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlreporeadonlystate()))"
|
||||
(False, 'reason123')
|
||||
$ hg debugshell -c "print(repo.sqlisreporeadonly())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlisreporeadonly()))"
|
||||
False
|
||||
|
||||
Set the repo to RO again (with reason)
|
||||
$ mysql -h $DBHOST -P $DBPORT -D $DBNAME -u $DBUSER $DBPASSOPT -e 'REPLACE INTO repo_lock(repo, state, reason) VALUES ("masterrepo", 0, "reason123")'
|
||||
$ hg debugshell -c "print(repo.sqlreporeadonlystate())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlreporeadonlystate()))"
|
||||
(True, 'reason123')
|
||||
$ hg debugshell -c "print(repo.sqlisreporeadonly())"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlisreporeadonly()))"
|
||||
True
|
||||
|
@ -67,5 +67,5 @@ continuously cycles round the commit2 to commit4 loop.
|
||||
|
||||
Similarly, check that predecessorsset is also safe.
|
||||
|
||||
$ hg debugsh -c "print([m.node.hex(n) for n in m.mutation.predecessorsset(repo, m.node.bin(\"21c93100b04c543843a7dab4fa0d5bada061b7a0\"))])"
|
||||
$ hg debugsh -c "ui.write(str([m.node.hex(n) for n in m.mutation.predecessorsset(repo, m.node.bin(\"21c93100b04c543843a7dab4fa0d5bada061b7a0\"))]) + '\n')"
|
||||
['e6c779c67aa947c951f334f4f312bd2b21d27e55']
|
||||
|
@ -17,7 +17,7 @@ Test namespace registration using registrar
|
||||
> return namespaces.namespace()
|
||||
> EOF
|
||||
|
||||
$ hg debugshell -c "print(list(repo.names))"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(list(repo.names)))"
|
||||
['bookmarks', 'tags', 'branches', 'c', 'a']
|
||||
|
||||
$ newext << EOF
|
||||
@ -30,7 +30,7 @@ Test namespace registration using registrar
|
||||
> def d(_repo):
|
||||
> return namespaces.namespace()
|
||||
> EOF
|
||||
$ hg debugshell -c "print(list(repo.names))"
|
||||
$ hg debugshell -c "ui.write('%s\n' % str(list(repo.names)))"
|
||||
['bookmarks', 'd', 'tags', 'branches', 'c', 'a', 'z']
|
||||
|
||||
|
||||
|
@ -11,44 +11,44 @@ Explore the semi-mysterious matchmod.match API
|
||||
|
||||
"patterns="
|
||||
|
||||
$ hg dbsh -c 'print(list(repo["."].walk(m.match.match(repo.root, "", patterns=["a*"]))))'
|
||||
$ hg dbsh -c 'ui.write("%s\n" % str(list(repo["."].walk(m.match.match(repo.root, "", patterns=["a*"])))))'
|
||||
[]
|
||||
|
||||
$ hg dbsh -c 'print(list(repo["."].walk(m.match.match(repo.root, "", patterns=["a*1"]))))'
|
||||
$ hg dbsh -c 'ui.write("%s\n" % str(list(repo["."].walk(m.match.match(repo.root, "", patterns=["a*1"])))))'
|
||||
[]
|
||||
|
||||
$ hg dbsh -c 'print(list(repo["."].walk(m.match.match(repo.root, "", patterns=["a*/*"]))))'
|
||||
$ hg dbsh -c 'ui.write("%s\n" % str(list(repo["."].walk(m.match.match(repo.root, "", patterns=["a*/*"])))))'
|
||||
['a*1/a', 'a*2/b']
|
||||
|
||||
"include="
|
||||
|
||||
$ hg dbsh -c 'print(list(repo["."].walk(m.match.match(repo.root, "", include=["a*"]))))'
|
||||
$ hg dbsh -c 'ui.write("%s\n" % str(list(repo["."].walk(m.match.match(repo.root, "", include=["a*"])))))'
|
||||
['a*1/a', 'a*2/b']
|
||||
|
||||
$ hg dbsh -c 'print(list(repo["."].walk(m.match.match(repo.root, "", include=["a*1"]))))'
|
||||
$ hg dbsh -c 'ui.write("%s\n" % str(list(repo["."].walk(m.match.match(repo.root, "", include=["a*1"])))))'
|
||||
['a*1/a']
|
||||
|
||||
$ hg dbsh -c 'print(list(repo["."].walk(m.match.match(repo.root, "", include=["a*/*"]))))'
|
||||
$ hg dbsh -c 'ui.write("%s\n" % str(list(repo["."].walk(m.match.match(repo.root, "", include=["a*/*"])))))'
|
||||
['a*1/a', 'a*2/b']
|
||||
|
||||
"patterns=" with "default='path'"
|
||||
|
||||
$ hg dbsh -c 'print(list(repo["."].walk(m.match.match(repo.root, "", patterns=["a*"], default="path"))))'
|
||||
$ hg dbsh -c 'ui.write("%s\n" % str(list(repo["."].walk(m.match.match(repo.root, "", patterns=["a*"], default="path")))))'
|
||||
[]
|
||||
|
||||
$ hg dbsh -c 'print(list(repo["."].walk(m.match.match(repo.root, "", patterns=["a*1"], default="path"))))'
|
||||
$ hg dbsh -c 'ui.write("%s\n" % str(list(repo["."].walk(m.match.match(repo.root, "", patterns=["a*1"], default="path")))))'
|
||||
['a*1/a']
|
||||
|
||||
$ hg dbsh -c 'print(list(repo["."].walk(m.match.match(repo.root, "", patterns=["a*/*"], default="path"))))'
|
||||
$ hg dbsh -c 'ui.write("%s\n" % str(list(repo["."].walk(m.match.match(repo.root, "", patterns=["a*/*"], default="path")))))'
|
||||
[]
|
||||
|
||||
"include=" with "default='path'" (ex. "default=" has no effect on "include=")
|
||||
|
||||
$ hg dbsh -c 'print(list(repo["."].walk(m.match.match(repo.root, "", include=["a*"], default="path"))))'
|
||||
$ hg dbsh -c 'ui.write("%s\n" % str(list(repo["."].walk(m.match.match(repo.root, "", include=["a*"], default="path")))))'
|
||||
['a*1/a', 'a*2/b']
|
||||
|
||||
$ hg dbsh -c 'print(list(repo["."].walk(m.match.match(repo.root, "", include=["a*1"], default="path"))))'
|
||||
$ hg dbsh -c 'ui.write("%s\n" % str(list(repo["."].walk(m.match.match(repo.root, "", include=["a*1"], default="path")))))'
|
||||
['a*1/a']
|
||||
|
||||
$ hg dbsh -c 'print(list(repo["."].walk(m.match.match(repo.root, "", include=["a*/*"], default="path"))))'
|
||||
$ hg dbsh -c 'ui.write("%s\n" % str(list(repo["."].walk(m.match.match(repo.root, "", include=["a*/*"], default="path")))))'
|
||||
['a*1/a', 'a*2/b']
|
||||
|
@ -166,7 +166,7 @@ profiler extension could be loaded before other extensions
|
||||
|
||||
Test minelapsed config option
|
||||
|
||||
$ hg --profile --config profiling.minelapsed=1000 debugshell -c 'print(1)'
|
||||
$ hg --profile --config profiling.minelapsed=1000 debugshell -c 'ui.write("1\n")'
|
||||
1
|
||||
$ hg --profile --config profiling.minelapsed=1 debugshell -c 'import time; time.sleep(1.1)' 2>&1 | grep Sample
|
||||
Sample count: * (glob)
|
||||
|
@ -8,12 +8,12 @@ Watchman clock is set after "status"
|
||||
|
||||
$ hg status
|
||||
? x
|
||||
$ hg debugshell -c 'print(repo.dirstate.getclock())'
|
||||
$ hg debugshell -c 'ui.write("%s\n" % str(repo.dirstate.getclock()))'
|
||||
c:* (glob)
|
||||
|
||||
Watchman clock is not reset after a "purge --all"
|
||||
|
||||
$ hg purge --all
|
||||
$ hg debugshell -c 'print(repo.dirstate.getclock())'
|
||||
$ hg debugshell -c 'ui.write("%s\n" % str(repo.dirstate.getclock()))'
|
||||
c:* (glob)
|
||||
$ hg status
|
||||
|
@ -7,5 +7,5 @@
|
||||
|
||||
The root directory ("") should not be ignored
|
||||
|
||||
$ hg debugshell -c 'print(repo.dirstate._ignore.visitdir(""))'
|
||||
$ hg debugshell -c 'ui.write("%s\n" % str(repo.dirstate._ignore.visitdir("")))'
|
||||
True
|
||||
|
Loading…
Reference in New Issue
Block a user