sapling/eden/scm/tests/test-patterns.t
Jun Wu 780faa2c10 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
2019-12-13 10:30:39 -08:00

55 lines
2.0 KiB
Perl

#require no-windows
Explore the semi-mysterious matchmod.match API
$ newrepo
$ mkdir 'a*1' 'a*2'
$ touch 'a*1/a' 'a*2/b'
$ hg ci -m 1 -A 'a*1/a' 'a*2/b' -q 2>&1 | sort
warning: filename contains '*', which is reserved on Windows: 'a*1/a'
warning: filename contains '*', which is reserved on Windows: 'a*2/b'
"patterns="
$ hg dbsh -c 'ui.write("%s\n" % str(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*1"])))))'
[]
$ 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 'ui.write("%s\n" % str(list(repo["."].walk(m.match.match(repo.root, "", include=["a*"])))))'
['a*1/a', 'a*2/b']
$ 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 '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 'ui.write("%s\n" % str(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*1"], default="path")))))'
['a*1/a']
$ 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 '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 'ui.write("%s\n" % str(list(repo["."].walk(m.match.match(repo.root, "", include=["a*1"], default="path")))))'
['a*1/a']
$ 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']