|
| 1 | +# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | +# |
| 3 | +# This software may be used and distributed according to the terms of the |
| 4 | +# GNU General Public License found in the LICENSE file in the root |
| 5 | +# directory of this source tree. |
| 6 | + |
| 7 | + $ . "${TEST_FIXTURES}/library.sh" |
| 8 | + |
| 9 | +Set up local hgrc and Mononoke config. |
| 10 | + $ setup_common_config |
| 11 | + $ cd $TESTTMP |
| 12 | + |
| 13 | +Setup testing repo for mononoke with multiple bookmarks: |
| 14 | + $ testtool_drawdag -R repo --print-hg-hashes << EOF |
| 15 | + > C E G |
| 16 | + > | | | |
| 17 | + > B D F |
| 18 | + > \|/ |
| 19 | + > A |
| 20 | + > # bookmark: C test/one |
| 21 | + > # bookmark: E test/two |
| 22 | + > # bookmark: G test/three |
| 23 | + > # bookmark: B special/__test__ |
| 24 | + > # bookmark: D special/xxtestxx |
| 25 | + > EOF |
| 26 | + A=20ca2a4749a439b459125ef0f6a4f26e88ee7538 |
| 27 | + B=80521a640a0c8f51dcc128c2658b224d595840ac |
| 28 | + C=d3b399ca8757acdb81c3681b052eb978db6768d8 |
| 29 | + D=8aa9560e921df1a2d4503bbfa9875505ef5e65eb |
| 30 | + E=4a55f53cc855ecee0391508d73e905770b0361e6 |
| 31 | + F=75e28e690892ad8d7849e877ea16f8196d444c41 |
| 32 | + G=a5418225e3986ee2c8c49429c777f01469d4c8c7 |
| 33 | + |
| 34 | +Start up SaplingRemoteAPI server. |
| 35 | + $ start_and_wait_for_mononoke_server |
| 36 | + |
| 37 | +Clone repo |
| 38 | + $ hg clone -q mono:repo repo-client |
| 39 | + $ cd repo-client |
| 40 | + |
| 41 | +Test exact bookmark match |
| 42 | + $ hg debugapi -e listbookmarkpatterns -i '["test/one"]' |
| 43 | + {"test/one": "d3b399ca8757acdb81c3681b052eb978db6768d8"} |
| 44 | + |
| 45 | +Test multiple exact bookmarks |
| 46 | + $ hg debugapi -e listbookmarkpatterns -i '["test/one", "test/two"]' |
| 47 | + {"test/one": "d3b399ca8757acdb81c3681b052eb978db6768d8", |
| 48 | + "test/two": "4a55f53cc855ecee0391508d73e905770b0361e6"} |
| 49 | + |
| 50 | +Test glob pattern with wildcard |
| 51 | + $ hg debugapi -e listbookmarkpatterns -i '["test/*"]' --sort |
| 52 | + {"test/one": "d3b399ca8757acdb81c3681b052eb978db6768d8", |
| 53 | + "test/two": "4a55f53cc855ecee0391508d73e905770b0361e6", |
| 54 | + "test/three": "a5418225e3986ee2c8c49429c777f01469d4c8c7"} |
| 55 | + |
| 56 | +Test partial prefix match |
| 57 | + $ hg debugapi -e listbookmarkpatterns -i '["test/t*"]' --sort |
| 58 | + {"test/two": "4a55f53cc855ecee0391508d73e905770b0361e6", |
| 59 | + "test/three": "a5418225e3986ee2c8c49429c777f01469d4c8c7"} |
| 60 | + |
| 61 | +Test non-existent bookmark (should return empty) |
| 62 | + $ hg debugapi -e listbookmarkpatterns -i '["nonexistent"]' |
| 63 | + {} |
| 64 | + |
| 65 | +Test non-matching pattern (should return empty) |
| 66 | + $ hg debugapi -e listbookmarkpatterns -i '["nomatch/*"]' |
| 67 | + {} |
| 68 | + |
| 69 | +Test special characters in bookmark names |
| 70 | + $ hg debugapi -e listbookmarkpatterns -i '["special/*"]' --sort |
| 71 | + {"special/__test__": "80521a640a0c8f51dcc128c2658b224d595840ac", |
| 72 | + "special/xxtestxx": "8aa9560e921df1a2d4503bbfa9875505ef5e65eb"} |
| 73 | + |
| 74 | +Test SQL wildcards don't match arbitrary things (should match nothing) |
| 75 | + $ hg debugapi -e listbookmarkpatterns -i '["t__t/*"]' |
| 76 | + {} |
| 77 | + |
| 78 | +Test SQL wildcards match things with those characters |
| 79 | + $ hg debugapi -e listbookmarkpatterns -i '["special/__test*"]' |
| 80 | + {"special/__test__": "80521a640a0c8f51dcc128c2658b224d595840ac"} |
| 81 | + |
| 82 | +Test multiple patterns in single call |
| 83 | + $ hg debugapi -e listbookmarkpatterns -i '["test/one", "special/*"]' --sort |
| 84 | + {"test/one": "d3b399ca8757acdb81c3681b052eb978db6768d8", |
| 85 | + "special/__test__": "80521a640a0c8f51dcc128c2658b224d595840ac", |
| 86 | + "special/xxtestxx": "8aa9560e921df1a2d4503bbfa9875505ef5e65eb"} |
0 commit comments