Debian Codegraph @

tests/test-clone-hgrc.t

raw
1 ===============
2 test clone hgrc
3 ===============
4
5 Verify that extension can alter the content of a hgrc during clone using clone
6 bundles. Motivated by issue #10019
7
8
9 Set up a server
10
11 $ hg init server
12 $ cd server
13 $ cat >> .hg/hgrc << EOF
14 > [extensions]
15 > clonebundles =
16 >
17 > [clone-bundles]
18 > auto-generate.formats = gzip-v2
19 > auto-generate.serve-inline=yes
20 > EOF
21
22 $ touch foo
23 $ hg -q commit -A -m 'add foo'
24 $ touch bar
25 $ hg -q commit -A -m 'add bar'
26 $ cd ..
27 $ hg -R server admin::clone-bundles-refresh
28 2 changesets found
29
30 clone remote without extension
31
32 $ hg clone ssh://user@dummy/server test
33 applying clone bundle from peer-bundle-cache://full-gzip-v2-2_revs-000000000000_tip-*_acbr.hg (glob)
34 adding changesets
35 adding manifests
36 adding file changes
37 added 2 changesets with 2 changes to 2 files
38 finished applying clone bundle
39 searching for changes
40 no changes found
41 2 local changesets published
42 updating to branch default
43 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
44 $ cat test/.hg/hgrc
45 # example repository config (see 'hg help config' for more info)
46 [paths]
47 default = ssh://user@dummy/server
48
49 # path aliases to other clones of this repo in URLs or filesystem paths
50 # (see 'hg help config.paths' for more info)
51 #
52 # default:pushurl = ssh://[email protected]/hg/jdoes-fork
53 # my-fork = ssh://[email protected]/hg/jdoes-fork
54 # my-clone = /home/jdoe/jdoes-clone
55
56 [ui]
57 # name and email (local to this repository, optional), e.g.
58 # username = Jane Doe <[email protected]>
59
60 add extension
61
62 $ cat > write_hgrc.py << EOF
63 > from mercurial import bundle2, extensions, util
64 > from mercurial import registrar
65 > configtable = {}
66 > configitem = registrar.configitem(configtable)
67 > def _write_hgrc(orig, repo, *args, **kwargs):
68 > with repo.wlock():
69 > op = orig(repo, *args, **kwargs)
70 > with op.repo.vfs(b'hgrc', b'w') as hgrc:
71 > hgrc.write(util.tonativeeol(b'# written by extension!\n'))
72 > def uisetup(ui):
73 > extensions.wrapfunction(bundle2, 'processbundle', _write_hgrc)
74 > EOF
75 $ hg --config extensions.write_hgrc=./write_hgrc.py clone ssh://user@dummy/server test-extended
76 applying clone bundle from peer-bundle-cache://full-gzip-v2-2_revs-000000000000_tip-*_acbr.hg (glob)
77 adding changesets
78 adding manifests
79 adding file changes
80 added 2 changesets with 2 changes to 2 files
81 finished applying clone bundle
82 searching for changes
83 no changes found
84 2 local changesets published
85 updating to branch default
86 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
87 $ cat ./test-extended/.hg/hgrc
88 # example repository config (see 'hg help config' for more info)
89 [paths]
90 default = ssh://user@dummy/server
91
92 # path aliases to other clones of this repo in URLs or filesystem paths
93 # (see 'hg help config.paths' for more info)
94 #
95 # default:pushurl = ssh://[email protected]/hg/jdoes-fork
96 # my-fork = ssh://[email protected]/hg/jdoes-fork
97 # my-clone = /home/jdoe/jdoes-clone
98
99 [ui]
100 # name and email (local to this repository, optional), e.g.
101 # username = Jane Doe <[email protected]>
102 # written by extension!