sapling/eden/mononoke/tests/integration/test-allowed-users.t
Thomas Orozco 72b949340f mononoke: pretty-print root-cause
Summary:
Right now, we debug-print the root cause and pretty-print everything else. This
is pretty bad because the root cause is usually the one thing we would want to
pretty print so we can add instructions there (such as "your hooks failed, fix
it").

This fixes this so we stop pretty-printing the root cause, but also debug print
the whole error, which gives us more developer-friendly context and is easier
for automation to match on.

This is actually in common/rust ... but we're the only people using it AFAICT.

Reviewed By: StanislavGlebik

Differential Revision: D21522518

fbshipit-source-id: 10158811574b56024e14852229e4541da19d5609
2020-05-12 07:59:42 -07:00

148 lines
4.5 KiB
Perl

# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License found in the LICENSE file in the root
# directory of this source tree.
$ . "${TEST_FIXTURES}/library.sh"
setup configuration
$ setup_common_config
$ cd "$TESTTMP/mononoke-config"
$ cat >> repos/repo/server.toml << EOF
> [[bookmarks]]
> regex="A|B|X/Y"
> allowed_users="^(a|b)$"
> [[bookmarks]]
> name="C"
> allowed_users="^c$"
> EOF
$ cd "$TESTTMP"
setup repo
$ hginit_treemanifest repo-hg
$ cd repo-hg
$ hg debugdrawdag << EOF
> A B C
> | | |
> D E F
> \|/
> G
> EOF
$ hg bookmark A -r A
$ hg bookmark B -r B
$ hg bookmark C -r C
$ hg bookmark G -r G
$ cd $TESTTMP
setup client repo
$ hgclone_treemanifest ssh://user@dummy/repo-hg repo-client
$ cd repo-client
$ setup_hg_client
$ cat >> .hg/hgrc << EOF
> [extensions]
> remotenames =
> EOF
blobimport them into Mononoke storage and start Mononoke
$ cd ..
$ blobimport repo-hg/.hg repo
start mononoke
$ mononoke
$ wait_for_mononoke
$ cd repo-client
push new bookmark
$ hg up G
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
(activating bookmark G)
$ touch 1 && hg add 1 && hg ci -m 1
$ MOCK_USERNAME="aslpavel" hgmn push -r . --create --to X/Y
pushing rev 3dd539927db6 to destination ssh://user@dummy/repo bookmark X/Y
searching for changes
remote: Command failed
remote: Error:
remote: While doing a push
remote:
remote: Root cause:
remote: [push] This user `Some("aslpavel")` is not allowed to move `BookmarkName { bookmark: "X/Y" }`
remote:
remote: Caused by:
remote: [push] This user `Some("aslpavel")` is not allowed to move `BookmarkName { bookmark: "X/Y" }`
remote:
remote: Debug context:
remote: Error {
remote: context: "While doing a push",
remote: source: "[push] This user `Some(\"aslpavel\")` is not allowed to move `BookmarkName { bookmark: \"X/Y\" }`",
remote: }
abort: stream ended unexpectedly (got 0 bytes, expected 4)
[255]
$ MOCK_USERNAME="b" hgmn push -r . --create --to X/Y
pushing rev 3dd539927db6 to destination ssh://user@dummy/repo bookmark X/Y
searching for changes
exporting bookmark X/Y
push updates existing bookmark
$ hg up A
2 files updated, 0 files merged, 1 files removed, 0 files unresolved
(activating bookmark A)
$ touch 2 && hg add 2 && hg ci -m 2
$ MOCK_USERNAME="aslapvel" hgmn push -r . --to A
pushing rev fa8d8af14ee8 to destination ssh://user@dummy/repo bookmark A
searching for changes
remote: Command failed
remote: Error:
remote: While doing a push
remote:
remote: Root cause:
remote: [push] This user `Some("aslapvel")` is not allowed to move `BookmarkName { bookmark: "A" }`
remote:
remote: Caused by:
remote: [push] This user `Some("aslapvel")` is not allowed to move `BookmarkName { bookmark: "A" }`
remote:
remote: Debug context:
remote: Error {
remote: context: "While doing a push",
remote: source: "[push] This user `Some(\"aslapvel\")` is not allowed to move `BookmarkName { bookmark: \"A\" }`",
remote: }
abort: stream ended unexpectedly (got 0 bytes, expected 4)
[255]
$ MOCK_USERNAME="a" hgmn push -r . --to A
pushing rev fa8d8af14ee8 to destination ssh://user@dummy/repo bookmark A
searching for changes
updating bookmark A
enable pushrebase
$ cat >> .hg/hgrc << EOF
> pushrebase =
> EOF
pushrebase
$ hg up C
2 files updated, 0 files merged, 3 files removed, 0 files unresolved
(activating bookmark C)
$ touch 3 && hg add 3 && hg ci -m 3
$ MOCK_USERNAME="a" hgmn push -r . --to C
pushing rev 8f950fe5040c to destination ssh://user@dummy/repo bookmark C
searching for changes
remote: Command failed
remote: Error:
remote: [pushrebase] This user `Some("a")` is not allowed to move `BookmarkName { bookmark: "C" }`
remote:
remote: Root cause:
remote: [pushrebase] This user `Some("a")` is not allowed to move `BookmarkName { bookmark: "C" }`
remote:
remote: Debug context:
remote: "[pushrebase] This user `Some(\"a\")` is not allowed to move `BookmarkName { bookmark: \"C\" }`"
abort: stream ended unexpectedly (got 0 bytes, expected 4)
[255]
$ MOCK_USERNAME="c" hgmn push -r . --to C
pushing rev 8f950fe5040c to destination ssh://user@dummy/repo bookmark C
searching for changes
adding changesets
adding manifests
adding file changes
added 0 changesets with 0 changes to 0 files
updating bookmark C