comparison tests/test-import.t @ 45827:8d72e29ad1e0

errors: introduce InputError and use it from commands and cmdutil This patch introduces a `InputError` class and replaces many uses of `error.Abort` by it in `commands` and `cmdutil`. This is a part of https://www.mercurial-scm.org/wiki/ErrorCategoriesPlan. There will later be a different class for state errors (to raise e.g. when there's an unfinished operation). It's not always clear when one should report an input error and when it should be a state error. We can always adjust later if I got something wrong in this patch (but feel free to point out any you notice now). Differential Revision: https://phab.mercurial-scm.org/D9167
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 06 Oct 2020 22:36:15 -0700
parents d1cabce5ef05
children 2eb8ad899fa6
comparison
equal deleted inserted replaced
45826:21733e8c924f 45827:8d72e29ad1e0
12 12
13 import with no args: 13 import with no args:
14 14
15 $ hg --cwd a import 15 $ hg --cwd a import
16 abort: need at least one patch to import 16 abort: need at least one patch to import
17 [255] 17 [10]
18 18
19 generate patches for the test 19 generate patches for the test
20 20
21 $ hg --cwd a export tip > exported-tip.patch 21 $ hg --cwd a export tip > exported-tip.patch
22 $ hg --cwd a diff -r0:1 > diffed-tip.patch 22 $ hg --cwd a diff -r0:1 > diffed-tip.patch
125 HG: -- 125 HG: --
126 HG: user: test 126 HG: user: test
127 HG: branch 'default' 127 HG: branch 'default'
128 HG: changed a 128 HG: changed a
129 abort: empty commit message 129 abort: empty commit message
130 [255] 130 [10]
131 131
132 Test avoiding editor invocation at applying the patch with --exact, 132 Test avoiding editor invocation at applying the patch with --exact,
133 even if commit message is empty 133 even if commit message is empty
134 134
135 $ echo a >> b/a 135 $ echo a >> b/a
372 updating to branch default 372 updating to branch default
373 2 files updated, 0 files merged, 0 files removed, 0 files unresolved 373 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
374 $ egrep -v '^(Subject|email)' msg.patch | hg --cwd b import - 374 $ egrep -v '^(Subject|email)' msg.patch | hg --cwd b import -
375 applying patch from stdin 375 applying patch from stdin
376 abort: empty commit message 376 abort: empty commit message
377 [255] 377 [10]
378 $ rm -r b 378 $ rm -r b
379 379
380 380
381 hg export in email, should use patch header 381 hg export in email, should use patch header
382 382
443 hg import --secret 443 hg import --secret
444 444
445 $ hg clone -r0 a b -q 445 $ hg clone -r0 a b -q
446 $ hg --cwd b import --no-commit --secret ../exported-tip.patch 446 $ hg --cwd b import --no-commit --secret ../exported-tip.patch
447 abort: cannot specify both --no-commit and --secret 447 abort: cannot specify both --no-commit and --secret
448 [255] 448 [10]
449 $ hg --cwd b import --secret ../exported-tip.patch 449 $ hg --cwd b import --secret ../exported-tip.patch
450 applying ../exported-tip.patch 450 applying ../exported-tip.patch
451 $ hg --cwd b diff -c . --nodates 451 $ hg --cwd b diff -c . --nodates
452 diff -r 80971e65b431 -r 1d4bd90af0e4 a 452 diff -r 80971e65b431 -r 1d4bd90af0e4 a
453 --- a/a 453 --- a/a
1170 applying a.patch 1170 applying a.patch
1171 applying empty.patch 1171 applying empty.patch
1172 transaction abort! 1172 transaction abort!
1173 rollback completed 1173 rollback completed
1174 abort: empty.patch: no diffs found 1174 abort: empty.patch: no diffs found
1175 [255] 1175 [10]
1176 $ hg tip --template '{rev} {desc|firstline}\n' 1176 $ hg tip --template '{rev} {desc|firstline}\n'
1177 0 commit 1177 0 commit
1178 $ hg -q status 1178 $ hg -q status
1179 M a 1179 M a
1180 $ cd .. 1180 $ cd ..