comparison tests/test-hooklib-reject_merge_commits.t @ 44413:4cabeea6d214

hgext: start building a library for simple hooks Many workflows depend on hooks to enforce certain policies, e.g. to prevent forced pushes. The Mercurial Guide includes some cases and Google can help finding others, but it can save users a lot of time if hg itself has a couple of examples for further customization. Differential Revision: https://phab.mercurial-scm.org/D6825
author Joerg Sonnenberger <joerg@bec.de>
date Sat, 07 Sep 2019 14:50:39 +0200
parents
children
comparison
equal deleted inserted replaced
44412:edc8504bc26b 44413:4cabeea6d214
1 $ cat <<EOF >> $HGRCPATH
2 > [extensions]
3 > hooklib =
4 >
5 > [phases]
6 > publish = False
7 > EOF
8 $ hg init a
9 $ hg --cwd a debugbuilddag '.:parent.:childa*parent/childa<parent@otherbranch./childa'
10 $ hg --cwd a log -G
11 o changeset: 4:a9fb040caedd
12 |\ branch: otherbranch
13 | | tag: tip
14 | | parent: 3:af739dfc49b4
15 | | parent: 1:66f7d451a68b
16 | | user: debugbuilddag
17 | | date: Thu Jan 01 00:00:04 1970 +0000
18 | | summary: r4
19 | |
20 | o changeset: 3:af739dfc49b4
21 | | branch: otherbranch
22 | | parent: 0:1ea73414a91b
23 | | user: debugbuilddag
24 | | date: Thu Jan 01 00:00:03 1970 +0000
25 | | summary: r3
26 | |
27 +---o changeset: 2:a6b287721c3b
28 | |/ parent: 0:1ea73414a91b
29 | | parent: 1:66f7d451a68b
30 | | user: debugbuilddag
31 | | date: Thu Jan 01 00:00:02 1970 +0000
32 | | summary: r2
33 | |
34 o | changeset: 1:66f7d451a68b
35 |/ tag: childa
36 | user: debugbuilddag
37 | date: Thu Jan 01 00:00:01 1970 +0000
38 | summary: r1
39 |
40 o changeset: 0:1ea73414a91b
41 tag: parent
42 user: debugbuilddag
43 date: Thu Jan 01 00:00:00 1970 +0000
44 summary: r0
45
46 $ hg init b
47 $ cat <<EOF >> b/.hg/hgrc
48 > [hooks]
49 > pretxnchangegroup.reject_merge_commits = \
50 > python:hgext.hooklib.reject_merge_commits.hook
51 > EOF
52 $ hg --cwd b pull ../a -r a6b287721c3b
53 pulling from ../a
54 adding changesets
55 adding manifests
56 adding file changes
57 error: pretxnchangegroup.reject_merge_commits hook failed: a6b287721c3b rejected as merge on the same branch. Please consider rebase.
58 transaction abort!
59 rollback completed
60 abort: a6b287721c3b rejected as merge on the same branch. Please consider rebase.
61 [255]
62 $ hg --cwd b pull ../a -r 1ea73414a91b
63 pulling from ../a
64 adding changesets
65 adding manifests
66 adding file changes
67 added 1 changesets with 0 changes to 0 files
68 new changesets 1ea73414a91b (1 drafts)
69 (run 'hg update' to get a working copy)
70 $ hg --cwd b pull ../a -r a9fb040caedd
71 pulling from ../a
72 searching for changes
73 adding changesets
74 adding manifests
75 adding file changes
76 added 3 changesets with 0 changes to 0 files
77 new changesets 66f7d451a68b:a9fb040caedd (3 drafts)
78 (run 'hg update' to get a working copy)