##// END OF EJS Templates
errors: use detailed error for invalid commit-extras argument...
Martin von Zweigbergk -
r49193:45a073af default
parent child Browse files
Show More
@@ -1,89 +1,89 b''
1 # commitextras.py
1 # commitextras.py
2 #
2 #
3 # Copyright 2013 Facebook, Inc.
3 # Copyright 2013 Facebook, Inc.
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 '''adds a new flag extras to commit (ADVANCED)'''
8 '''adds a new flag extras to commit (ADVANCED)'''
9
9
10 from __future__ import absolute_import
10 from __future__ import absolute_import
11
11
12 import re
12 import re
13
13
14 from mercurial.i18n import _
14 from mercurial.i18n import _
15 from mercurial import (
15 from mercurial import (
16 commands,
16 commands,
17 error,
17 error,
18 extensions,
18 extensions,
19 registrar,
19 registrar,
20 util,
20 util,
21 )
21 )
22
22
23 cmdtable = {}
23 cmdtable = {}
24 command = registrar.command(cmdtable)
24 command = registrar.command(cmdtable)
25 testedwith = b'ships-with-hg-core'
25 testedwith = b'ships-with-hg-core'
26
26
27 usedinternally = {
27 usedinternally = {
28 b'amend_source',
28 b'amend_source',
29 b'branch',
29 b'branch',
30 b'close',
30 b'close',
31 b'histedit_source',
31 b'histedit_source',
32 b'topic',
32 b'topic',
33 b'rebase_source',
33 b'rebase_source',
34 b'intermediate-source',
34 b'intermediate-source',
35 b'__touch-noise__',
35 b'__touch-noise__',
36 b'source',
36 b'source',
37 b'transplant_source',
37 b'transplant_source',
38 }
38 }
39
39
40
40
41 def extsetup(ui):
41 def extsetup(ui):
42 entry = extensions.wrapcommand(commands.table, b'commit', _commit)
42 entry = extensions.wrapcommand(commands.table, b'commit', _commit)
43 options = entry[1]
43 options = entry[1]
44 options.append(
44 options.append(
45 (
45 (
46 b'',
46 b'',
47 b'extra',
47 b'extra',
48 [],
48 [],
49 _(b'set a changeset\'s extra values'),
49 _(b'set a changeset\'s extra values'),
50 _(b"KEY=VALUE"),
50 _(b"KEY=VALUE"),
51 )
51 )
52 )
52 )
53
53
54
54
55 def _commit(orig, ui, repo, *pats, **opts):
55 def _commit(orig, ui, repo, *pats, **opts):
56 if util.safehasattr(repo, 'unfiltered'):
56 if util.safehasattr(repo, 'unfiltered'):
57 repo = repo.unfiltered()
57 repo = repo.unfiltered()
58
58
59 class repoextra(repo.__class__):
59 class repoextra(repo.__class__):
60 def commit(self, *innerpats, **inneropts):
60 def commit(self, *innerpats, **inneropts):
61 extras = opts.get('extra')
61 extras = opts.get('extra')
62 for raw in extras:
62 for raw in extras:
63 if b'=' not in raw:
63 if b'=' not in raw:
64 msg = _(
64 msg = _(
65 b"unable to parse '%s', should follow "
65 b"unable to parse '%s', should follow "
66 b"KEY=VALUE format"
66 b"KEY=VALUE format"
67 )
67 )
68 raise error.Abort(msg % raw)
68 raise error.InputError(msg % raw)
69 k, v = raw.split(b'=', 1)
69 k, v = raw.split(b'=', 1)
70 if not k:
70 if not k:
71 msg = _(b"unable to parse '%s', keys can't be empty")
71 msg = _(b"unable to parse '%s', keys can't be empty")
72 raise error.Abort(msg % raw)
72 raise error.InputError(msg % raw)
73 if re.search(br'[^\w-]', k):
73 if re.search(br'[^\w-]', k):
74 msg = _(
74 msg = _(
75 b"keys can only contain ascii letters, digits,"
75 b"keys can only contain ascii letters, digits,"
76 b" '_' and '-'"
76 b" '_' and '-'"
77 )
77 )
78 raise error.Abort(msg)
78 raise error.InputError(msg)
79 if k in usedinternally:
79 if k in usedinternally:
80 msg = _(
80 msg = _(
81 b"key '%s' is used internally, can't be set "
81 b"key '%s' is used internally, can't be set "
82 b"manually"
82 b"manually"
83 )
83 )
84 raise error.Abort(msg % k)
84 raise error.InputError(msg % k)
85 inneropts['extra'][k] = v
85 inneropts['extra'][k] = v
86 return super(repoextra, self).commit(*innerpats, **inneropts)
86 return super(repoextra, self).commit(*innerpats, **inneropts)
87
87
88 repo.__class__ = repoextra
88 repo.__class__ = repoextra
89 return orig(ui, repo, *pats, **opts)
89 return orig(ui, repo, *pats, **opts)
@@ -1,879 +1,879 b''
1 commit date test
1 commit date test
2
2
3 $ hg init test
3 $ hg init test
4 $ cd test
4 $ cd test
5 $ echo foo > foo
5 $ echo foo > foo
6 $ hg add foo
6 $ hg add foo
7 $ cat > $TESTTMP/checkeditform.sh <<EOF
7 $ cat > $TESTTMP/checkeditform.sh <<EOF
8 > env | grep HGEDITFORM
8 > env | grep HGEDITFORM
9 > true
9 > true
10 > EOF
10 > EOF
11 $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg commit -m ""
11 $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg commit -m ""
12 HGEDITFORM=commit.normal.normal
12 HGEDITFORM=commit.normal.normal
13 abort: empty commit message
13 abort: empty commit message
14 [10]
14 [10]
15 $ hg commit -d '0 0' -m commit-1
15 $ hg commit -d '0 0' -m commit-1
16 $ echo foo >> foo
16 $ echo foo >> foo
17 $ hg commit -d '1 4444444' -m commit-3
17 $ hg commit -d '1 4444444' -m commit-3
18 hg: parse error: impossible time zone offset: 4444444
18 hg: parse error: impossible time zone offset: 4444444
19 [10]
19 [10]
20 $ hg commit -d '1 15.1' -m commit-4
20 $ hg commit -d '1 15.1' -m commit-4
21 hg: parse error: invalid date: '1\t15.1'
21 hg: parse error: invalid date: '1\t15.1'
22 [10]
22 [10]
23 $ hg commit -d 'foo bar' -m commit-5
23 $ hg commit -d 'foo bar' -m commit-5
24 hg: parse error: invalid date: 'foo bar'
24 hg: parse error: invalid date: 'foo bar'
25 [10]
25 [10]
26 $ hg commit -d ' 1 4444' -m commit-6
26 $ hg commit -d ' 1 4444' -m commit-6
27 $ hg commit -d '111111111111 0' -m commit-7
27 $ hg commit -d '111111111111 0' -m commit-7
28 hg: parse error: date exceeds 32 bits: 111111111111
28 hg: parse error: date exceeds 32 bits: 111111111111
29 [10]
29 [10]
30 $ hg commit -d '-111111111111 0' -m commit-7
30 $ hg commit -d '-111111111111 0' -m commit-7
31 hg: parse error: date exceeds 32 bits: -111111111111
31 hg: parse error: date exceeds 32 bits: -111111111111
32 [10]
32 [10]
33 $ echo foo >> foo
33 $ echo foo >> foo
34 $ hg commit -d '1901-12-13 20:45:52 +0000' -m commit-7-2
34 $ hg commit -d '1901-12-13 20:45:52 +0000' -m commit-7-2
35 $ echo foo >> foo
35 $ echo foo >> foo
36 $ hg commit -d '-2147483648 0' -m commit-7-3
36 $ hg commit -d '-2147483648 0' -m commit-7-3
37 $ hg log -T '{rev} {date|isodatesec}\n' -l2
37 $ hg log -T '{rev} {date|isodatesec}\n' -l2
38 3 1901-12-13 20:45:52 +0000
38 3 1901-12-13 20:45:52 +0000
39 2 1901-12-13 20:45:52 +0000
39 2 1901-12-13 20:45:52 +0000
40 $ hg commit -d '1901-12-13 20:45:51 +0000' -m commit-7
40 $ hg commit -d '1901-12-13 20:45:51 +0000' -m commit-7
41 hg: parse error: date exceeds 32 bits: -2147483649
41 hg: parse error: date exceeds 32 bits: -2147483649
42 [10]
42 [10]
43 $ hg commit -d '-2147483649 0' -m commit-7
43 $ hg commit -d '-2147483649 0' -m commit-7
44 hg: parse error: date exceeds 32 bits: -2147483649
44 hg: parse error: date exceeds 32 bits: -2147483649
45 [10]
45 [10]
46
46
47 commit added file that has been deleted
47 commit added file that has been deleted
48
48
49 $ echo bar > bar
49 $ echo bar > bar
50 $ hg add bar
50 $ hg add bar
51 $ rm bar
51 $ rm bar
52 $ hg commit -m commit-8
52 $ hg commit -m commit-8
53 nothing changed (1 missing files, see 'hg status')
53 nothing changed (1 missing files, see 'hg status')
54 [1]
54 [1]
55 $ hg commit -m commit-8-2 bar
55 $ hg commit -m commit-8-2 bar
56 abort: bar: file not found!
56 abort: bar: file not found!
57 [10]
57 [10]
58
58
59 $ hg -q revert -a --no-backup
59 $ hg -q revert -a --no-backup
60
60
61 $ mkdir dir
61 $ mkdir dir
62 $ echo boo > dir/file
62 $ echo boo > dir/file
63 $ hg add
63 $ hg add
64 adding dir/file
64 adding dir/file
65 $ hg -v commit -m commit-9 dir
65 $ hg -v commit -m commit-9 dir
66 committing files:
66 committing files:
67 dir/file
67 dir/file
68 committing manifest
68 committing manifest
69 committing changelog
69 committing changelog
70 committed changeset 4:1957363f1ced
70 committed changeset 4:1957363f1ced
71
71
72 $ echo > dir.file
72 $ echo > dir.file
73 $ hg add
73 $ hg add
74 adding dir.file
74 adding dir.file
75 $ hg commit -m commit-10 dir dir.file
75 $ hg commit -m commit-10 dir dir.file
76 abort: dir: no match under directory!
76 abort: dir: no match under directory!
77 [10]
77 [10]
78
78
79 $ echo >> dir/file
79 $ echo >> dir/file
80 $ mkdir bleh
80 $ mkdir bleh
81 $ mkdir dir2
81 $ mkdir dir2
82 $ cd bleh
82 $ cd bleh
83 $ hg commit -m commit-11 .
83 $ hg commit -m commit-11 .
84 abort: bleh: no match under directory!
84 abort: bleh: no match under directory!
85 [10]
85 [10]
86 $ hg commit -m commit-12 ../dir ../dir2
86 $ hg commit -m commit-12 ../dir ../dir2
87 abort: dir2: no match under directory!
87 abort: dir2: no match under directory!
88 [10]
88 [10]
89 $ hg -v commit -m commit-13 ../dir
89 $ hg -v commit -m commit-13 ../dir
90 committing files:
90 committing files:
91 dir/file
91 dir/file
92 committing manifest
92 committing manifest
93 committing changelog
93 committing changelog
94 committed changeset 5:a31d8f87544a
94 committed changeset 5:a31d8f87544a
95 $ cd ..
95 $ cd ..
96
96
97 $ hg commit -m commit-14 does-not-exist
97 $ hg commit -m commit-14 does-not-exist
98 abort: does-not-exist: * (glob)
98 abort: does-not-exist: * (glob)
99 [10]
99 [10]
100
100
101 #if symlink
101 #if symlink
102 $ ln -s foo baz
102 $ ln -s foo baz
103 $ hg commit -m commit-15 baz
103 $ hg commit -m commit-15 baz
104 abort: baz: file not tracked!
104 abort: baz: file not tracked!
105 [10]
105 [10]
106 $ rm baz
106 $ rm baz
107 #endif
107 #endif
108
108
109 $ touch quux
109 $ touch quux
110 $ hg commit -m commit-16 quux
110 $ hg commit -m commit-16 quux
111 abort: quux: file not tracked!
111 abort: quux: file not tracked!
112 [10]
112 [10]
113 $ echo >> dir/file
113 $ echo >> dir/file
114 $ hg -v commit -m commit-17 dir/file
114 $ hg -v commit -m commit-17 dir/file
115 committing files:
115 committing files:
116 dir/file
116 dir/file
117 committing manifest
117 committing manifest
118 committing changelog
118 committing changelog
119 committed changeset 6:32d054c9d085
119 committed changeset 6:32d054c9d085
120
120
121 An empty date was interpreted as epoch origin
121 An empty date was interpreted as epoch origin
122
122
123 $ echo foo >> foo
123 $ echo foo >> foo
124 $ hg commit -d '' -m commit-no-date --config devel.default-date=
124 $ hg commit -d '' -m commit-no-date --config devel.default-date=
125 $ hg tip --template '{date|isodate}\n' | grep '1970'
125 $ hg tip --template '{date|isodate}\n' | grep '1970'
126 [1]
126 [1]
127
127
128 Using the advanced --extra flag
128 Using the advanced --extra flag
129
129
130 $ echo "[extensions]" >> $HGRCPATH
130 $ echo "[extensions]" >> $HGRCPATH
131 $ echo "commitextras=" >> $HGRCPATH
131 $ echo "commitextras=" >> $HGRCPATH
132 $ hg status
132 $ hg status
133 ? quux
133 ? quux
134 $ hg add quux
134 $ hg add quux
135 $ hg commit -m "adding internal used extras" --extra amend_source=hash
135 $ hg commit -m "adding internal used extras" --extra amend_source=hash
136 abort: key 'amend_source' is used internally, can't be set manually
136 abort: key 'amend_source' is used internally, can't be set manually
137 [255]
137 [10]
138 $ hg commit -m "special chars in extra" --extra id@phab=214
138 $ hg commit -m "special chars in extra" --extra id@phab=214
139 abort: keys can only contain ascii letters, digits, '_' and '-'
139 abort: keys can only contain ascii letters, digits, '_' and '-'
140 [255]
140 [10]
141 $ hg commit -m "empty key" --extra =value
141 $ hg commit -m "empty key" --extra =value
142 abort: unable to parse '=value', keys can't be empty
142 abort: unable to parse '=value', keys can't be empty
143 [255]
143 [10]
144 $ hg commit -m "adding extras" --extra sourcehash=foo --extra oldhash=bar
144 $ hg commit -m "adding extras" --extra sourcehash=foo --extra oldhash=bar
145 $ hg log -r . -T '{extras % "{extra}\n"}'
145 $ hg log -r . -T '{extras % "{extra}\n"}'
146 branch=default
146 branch=default
147 oldhash=bar
147 oldhash=bar
148 sourcehash=foo
148 sourcehash=foo
149
149
150 Failed commit with --addremove should not update dirstate
150 Failed commit with --addremove should not update dirstate
151
151
152 $ echo foo > newfile
152 $ echo foo > newfile
153 $ hg status
153 $ hg status
154 ? newfile
154 ? newfile
155 $ HGEDITOR=false hg ci --addremove
155 $ HGEDITOR=false hg ci --addremove
156 adding newfile
156 adding newfile
157 abort: edit failed: false exited with status 1
157 abort: edit failed: false exited with status 1
158 [250]
158 [250]
159 $ hg status
159 $ hg status
160 ? newfile
160 ? newfile
161
161
162 Make sure we do not obscure unknown requires file entries (issue2649)
162 Make sure we do not obscure unknown requires file entries (issue2649)
163
163
164 $ echo foo >> foo
164 $ echo foo >> foo
165 $ echo fake >> .hg/requires
165 $ echo fake >> .hg/requires
166 $ hg commit -m bla
166 $ hg commit -m bla
167 abort: repository requires features unknown to this Mercurial: fake
167 abort: repository requires features unknown to this Mercurial: fake
168 (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
168 (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
169 [255]
169 [255]
170
170
171 $ cd ..
171 $ cd ..
172
172
173
173
174 partial subdir commit test
174 partial subdir commit test
175
175
176 $ hg init test2
176 $ hg init test2
177 $ cd test2
177 $ cd test2
178 $ mkdir foo
178 $ mkdir foo
179 $ echo foo > foo/foo
179 $ echo foo > foo/foo
180 $ mkdir bar
180 $ mkdir bar
181 $ echo bar > bar/bar
181 $ echo bar > bar/bar
182 $ hg add
182 $ hg add
183 adding bar/bar
183 adding bar/bar
184 adding foo/foo
184 adding foo/foo
185 $ HGEDITOR=cat hg ci -e -m commit-subdir-1 foo
185 $ HGEDITOR=cat hg ci -e -m commit-subdir-1 foo
186 commit-subdir-1
186 commit-subdir-1
187
187
188
188
189 HG: Enter commit message. Lines beginning with 'HG:' are removed.
189 HG: Enter commit message. Lines beginning with 'HG:' are removed.
190 HG: Leave message empty to abort commit.
190 HG: Leave message empty to abort commit.
191 HG: --
191 HG: --
192 HG: user: test
192 HG: user: test
193 HG: branch 'default'
193 HG: branch 'default'
194 HG: added foo/foo
194 HG: added foo/foo
195
195
196
196
197 $ hg ci -m commit-subdir-2 bar
197 $ hg ci -m commit-subdir-2 bar
198
198
199 subdir log 1
199 subdir log 1
200
200
201 $ hg log -v foo
201 $ hg log -v foo
202 changeset: 0:f97e73a25882
202 changeset: 0:f97e73a25882
203 user: test
203 user: test
204 date: Thu Jan 01 00:00:00 1970 +0000
204 date: Thu Jan 01 00:00:00 1970 +0000
205 files: foo/foo
205 files: foo/foo
206 description:
206 description:
207 commit-subdir-1
207 commit-subdir-1
208
208
209
209
210
210
211 subdir log 2
211 subdir log 2
212
212
213 $ hg log -v bar
213 $ hg log -v bar
214 changeset: 1:aa809156d50d
214 changeset: 1:aa809156d50d
215 tag: tip
215 tag: tip
216 user: test
216 user: test
217 date: Thu Jan 01 00:00:00 1970 +0000
217 date: Thu Jan 01 00:00:00 1970 +0000
218 files: bar/bar
218 files: bar/bar
219 description:
219 description:
220 commit-subdir-2
220 commit-subdir-2
221
221
222
222
223
223
224 full log
224 full log
225
225
226 $ hg log -v
226 $ hg log -v
227 changeset: 1:aa809156d50d
227 changeset: 1:aa809156d50d
228 tag: tip
228 tag: tip
229 user: test
229 user: test
230 date: Thu Jan 01 00:00:00 1970 +0000
230 date: Thu Jan 01 00:00:00 1970 +0000
231 files: bar/bar
231 files: bar/bar
232 description:
232 description:
233 commit-subdir-2
233 commit-subdir-2
234
234
235
235
236 changeset: 0:f97e73a25882
236 changeset: 0:f97e73a25882
237 user: test
237 user: test
238 date: Thu Jan 01 00:00:00 1970 +0000
238 date: Thu Jan 01 00:00:00 1970 +0000
239 files: foo/foo
239 files: foo/foo
240 description:
240 description:
241 commit-subdir-1
241 commit-subdir-1
242
242
243
243
244 $ cd ..
244 $ cd ..
245
245
246
246
247 dot and subdir commit test
247 dot and subdir commit test
248
248
249 $ hg init test3
249 $ hg init test3
250 $ echo commit-foo-subdir > commit-log-test
250 $ echo commit-foo-subdir > commit-log-test
251 $ cd test3
251 $ cd test3
252 $ mkdir foo
252 $ mkdir foo
253 $ echo foo content > foo/plain-file
253 $ echo foo content > foo/plain-file
254 $ hg add foo/plain-file
254 $ hg add foo/plain-file
255 $ HGEDITOR=cat hg ci --edit -l ../commit-log-test foo
255 $ HGEDITOR=cat hg ci --edit -l ../commit-log-test foo
256 commit-foo-subdir
256 commit-foo-subdir
257
257
258
258
259 HG: Enter commit message. Lines beginning with 'HG:' are removed.
259 HG: Enter commit message. Lines beginning with 'HG:' are removed.
260 HG: Leave message empty to abort commit.
260 HG: Leave message empty to abort commit.
261 HG: --
261 HG: --
262 HG: user: test
262 HG: user: test
263 HG: branch 'default'
263 HG: branch 'default'
264 HG: added foo/plain-file
264 HG: added foo/plain-file
265
265
266
266
267 $ echo modified foo content > foo/plain-file
267 $ echo modified foo content > foo/plain-file
268 $ hg ci -m commit-foo-dot .
268 $ hg ci -m commit-foo-dot .
269
269
270 full log
270 full log
271
271
272 $ hg log -v
272 $ hg log -v
273 changeset: 1:95b38e3a5b2e
273 changeset: 1:95b38e3a5b2e
274 tag: tip
274 tag: tip
275 user: test
275 user: test
276 date: Thu Jan 01 00:00:00 1970 +0000
276 date: Thu Jan 01 00:00:00 1970 +0000
277 files: foo/plain-file
277 files: foo/plain-file
278 description:
278 description:
279 commit-foo-dot
279 commit-foo-dot
280
280
281
281
282 changeset: 0:65d4e9386227
282 changeset: 0:65d4e9386227
283 user: test
283 user: test
284 date: Thu Jan 01 00:00:00 1970 +0000
284 date: Thu Jan 01 00:00:00 1970 +0000
285 files: foo/plain-file
285 files: foo/plain-file
286 description:
286 description:
287 commit-foo-subdir
287 commit-foo-subdir
288
288
289
289
290
290
291 subdir log
291 subdir log
292
292
293 $ cd foo
293 $ cd foo
294 $ hg log .
294 $ hg log .
295 changeset: 1:95b38e3a5b2e
295 changeset: 1:95b38e3a5b2e
296 tag: tip
296 tag: tip
297 user: test
297 user: test
298 date: Thu Jan 01 00:00:00 1970 +0000
298 date: Thu Jan 01 00:00:00 1970 +0000
299 summary: commit-foo-dot
299 summary: commit-foo-dot
300
300
301 changeset: 0:65d4e9386227
301 changeset: 0:65d4e9386227
302 user: test
302 user: test
303 date: Thu Jan 01 00:00:00 1970 +0000
303 date: Thu Jan 01 00:00:00 1970 +0000
304 summary: commit-foo-subdir
304 summary: commit-foo-subdir
305
305
306 $ cd ..
306 $ cd ..
307 $ cd ..
307 $ cd ..
308
308
309 Issue1049: Hg permits partial commit of merge without warning
309 Issue1049: Hg permits partial commit of merge without warning
310
310
311 $ hg init issue1049
311 $ hg init issue1049
312 $ cd issue1049
312 $ cd issue1049
313 $ echo a > a
313 $ echo a > a
314 $ hg ci -Ama
314 $ hg ci -Ama
315 adding a
315 adding a
316 $ echo a >> a
316 $ echo a >> a
317 $ hg ci -mb
317 $ hg ci -mb
318 $ hg up 0
318 $ hg up 0
319 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
319 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
320 $ echo b >> a
320 $ echo b >> a
321 $ hg ci -mc
321 $ hg ci -mc
322 created new head
322 created new head
323 $ HGMERGE=true hg merge
323 $ HGMERGE=true hg merge
324 merging a
324 merging a
325 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
325 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
326 (branch merge, don't forget to commit)
326 (branch merge, don't forget to commit)
327
327
328 should fail because we are specifying a file name
328 should fail because we are specifying a file name
329
329
330 $ hg ci -mmerge a
330 $ hg ci -mmerge a
331 abort: cannot partially commit a merge (do not specify files or patterns)
331 abort: cannot partially commit a merge (do not specify files or patterns)
332 [255]
332 [255]
333
333
334 should fail because we are specifying a pattern
334 should fail because we are specifying a pattern
335
335
336 $ hg ci -mmerge -I a
336 $ hg ci -mmerge -I a
337 abort: cannot partially commit a merge (do not specify files or patterns)
337 abort: cannot partially commit a merge (do not specify files or patterns)
338 [255]
338 [255]
339
339
340 should succeed
340 should succeed
341
341
342 $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg ci -mmerge --edit
342 $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg ci -mmerge --edit
343 HGEDITFORM=commit.normal.merge
343 HGEDITFORM=commit.normal.merge
344 $ cd ..
344 $ cd ..
345
345
346
346
347 test commit message content
347 test commit message content
348
348
349 $ hg init commitmsg
349 $ hg init commitmsg
350 $ cd commitmsg
350 $ cd commitmsg
351 $ echo changed > changed
351 $ echo changed > changed
352 $ echo removed > removed
352 $ echo removed > removed
353 $ hg book activebookmark
353 $ hg book activebookmark
354 $ hg ci -qAm init
354 $ hg ci -qAm init
355
355
356 $ hg rm removed
356 $ hg rm removed
357 $ echo changed >> changed
357 $ echo changed >> changed
358 $ echo added > added
358 $ echo added > added
359 $ hg add added
359 $ hg add added
360 $ HGEDITOR=cat hg ci -A
360 $ HGEDITOR=cat hg ci -A
361
361
362
362
363 HG: Enter commit message. Lines beginning with 'HG:' are removed.
363 HG: Enter commit message. Lines beginning with 'HG:' are removed.
364 HG: Leave message empty to abort commit.
364 HG: Leave message empty to abort commit.
365 HG: --
365 HG: --
366 HG: user: test
366 HG: user: test
367 HG: branch 'default'
367 HG: branch 'default'
368 HG: bookmark 'activebookmark'
368 HG: bookmark 'activebookmark'
369 HG: added added
369 HG: added added
370 HG: changed changed
370 HG: changed changed
371 HG: removed removed
371 HG: removed removed
372 abort: empty commit message
372 abort: empty commit message
373 [10]
373 [10]
374
374
375 test saving last-message.txt
375 test saving last-message.txt
376
376
377 $ hg init sub
377 $ hg init sub
378 $ echo a > sub/a
378 $ echo a > sub/a
379 $ hg -R sub add sub/a
379 $ hg -R sub add sub/a
380 $ cat > sub/.hg/hgrc <<EOF
380 $ cat > sub/.hg/hgrc <<EOF
381 > [hooks]
381 > [hooks]
382 > precommit.test-saving-last-message = false
382 > precommit.test-saving-last-message = false
383 > EOF
383 > EOF
384
384
385 $ echo 'sub = sub' > .hgsub
385 $ echo 'sub = sub' > .hgsub
386 $ hg add .hgsub
386 $ hg add .hgsub
387
387
388 $ cat > $TESTTMP/editor.sh <<EOF
388 $ cat > $TESTTMP/editor.sh <<EOF
389 > echo "==== before editing:"
389 > echo "==== before editing:"
390 > cat \$1
390 > cat \$1
391 > echo "===="
391 > echo "===="
392 > echo "test saving last-message.txt" >> \$1
392 > echo "test saving last-message.txt" >> \$1
393 > EOF
393 > EOF
394
394
395 $ rm -f .hg/last-message.txt
395 $ rm -f .hg/last-message.txt
396 $ HGEDITOR="sh $TESTTMP/editor.sh" hg commit -S -q
396 $ HGEDITOR="sh $TESTTMP/editor.sh" hg commit -S -q
397 ==== before editing:
397 ==== before editing:
398
398
399
399
400 HG: Enter commit message. Lines beginning with 'HG:' are removed.
400 HG: Enter commit message. Lines beginning with 'HG:' are removed.
401 HG: Leave message empty to abort commit.
401 HG: Leave message empty to abort commit.
402 HG: --
402 HG: --
403 HG: user: test
403 HG: user: test
404 HG: branch 'default'
404 HG: branch 'default'
405 HG: bookmark 'activebookmark'
405 HG: bookmark 'activebookmark'
406 HG: subrepo sub
406 HG: subrepo sub
407 HG: added .hgsub
407 HG: added .hgsub
408 HG: added added
408 HG: added added
409 HG: changed .hgsubstate
409 HG: changed .hgsubstate
410 HG: changed changed
410 HG: changed changed
411 HG: removed removed
411 HG: removed removed
412 ====
412 ====
413 abort: precommit.test-saving-last-message hook exited with status 1 (in subrepository "sub")
413 abort: precommit.test-saving-last-message hook exited with status 1 (in subrepository "sub")
414 [255]
414 [255]
415 $ cat .hg/last-message.txt
415 $ cat .hg/last-message.txt
416
416
417
417
418 test saving last-message.txt
418 test saving last-message.txt
419
419
420 test that '[committemplate] changeset' definition and commit log
420 test that '[committemplate] changeset' definition and commit log
421 specific template keywords work well
421 specific template keywords work well
422
422
423 $ cat >> .hg/hgrc <<EOF
423 $ cat >> .hg/hgrc <<EOF
424 > [committemplate]
424 > [committemplate]
425 > changeset.commit.normal = 'HG: this is "commit.normal" template
425 > changeset.commit.normal = 'HG: this is "commit.normal" template
426 > HG: {extramsg}
426 > HG: {extramsg}
427 > {if(activebookmark,
427 > {if(activebookmark,
428 > "HG: bookmark '{activebookmark}' is activated\n",
428 > "HG: bookmark '{activebookmark}' is activated\n",
429 > "HG: no bookmark is activated\n")}{subrepos %
429 > "HG: no bookmark is activated\n")}{subrepos %
430 > "HG: subrepo '{subrepo}' is changed\n"}'
430 > "HG: subrepo '{subrepo}' is changed\n"}'
431 >
431 >
432 > changeset.commit = HG: this is "commit" template
432 > changeset.commit = HG: this is "commit" template
433 > HG: {extramsg}
433 > HG: {extramsg}
434 > {if(activebookmark,
434 > {if(activebookmark,
435 > "HG: bookmark '{activebookmark}' is activated\n",
435 > "HG: bookmark '{activebookmark}' is activated\n",
436 > "HG: no bookmark is activated\n")}{subrepos %
436 > "HG: no bookmark is activated\n")}{subrepos %
437 > "HG: subrepo '{subrepo}' is changed\n"}
437 > "HG: subrepo '{subrepo}' is changed\n"}
438 >
438 >
439 > changeset = HG: this is customized commit template
439 > changeset = HG: this is customized commit template
440 > HG: {extramsg}
440 > HG: {extramsg}
441 > {if(activebookmark,
441 > {if(activebookmark,
442 > "HG: bookmark '{activebookmark}' is activated\n",
442 > "HG: bookmark '{activebookmark}' is activated\n",
443 > "HG: no bookmark is activated\n")}{subrepos %
443 > "HG: no bookmark is activated\n")}{subrepos %
444 > "HG: subrepo '{subrepo}' is changed\n"}
444 > "HG: subrepo '{subrepo}' is changed\n"}
445 > EOF
445 > EOF
446
446
447 $ hg init sub2
447 $ hg init sub2
448 $ echo a > sub2/a
448 $ echo a > sub2/a
449 $ hg -R sub2 add sub2/a
449 $ hg -R sub2 add sub2/a
450 $ echo 'sub2 = sub2' >> .hgsub
450 $ echo 'sub2 = sub2' >> .hgsub
451
451
452 $ HGEDITOR=cat hg commit -S -q
452 $ HGEDITOR=cat hg commit -S -q
453 HG: this is "commit.normal" template
453 HG: this is "commit.normal" template
454 HG: Leave message empty to abort commit.
454 HG: Leave message empty to abort commit.
455 HG: bookmark 'activebookmark' is activated
455 HG: bookmark 'activebookmark' is activated
456 HG: subrepo 'sub' is changed
456 HG: subrepo 'sub' is changed
457 HG: subrepo 'sub2' is changed
457 HG: subrepo 'sub2' is changed
458 abort: empty commit message
458 abort: empty commit message
459 [10]
459 [10]
460
460
461 $ cat >> .hg/hgrc <<EOF
461 $ cat >> .hg/hgrc <<EOF
462 > [committemplate]
462 > [committemplate]
463 > changeset.commit.normal =
463 > changeset.commit.normal =
464 > # now, "changeset.commit" should be chosen for "hg commit"
464 > # now, "changeset.commit" should be chosen for "hg commit"
465 > EOF
465 > EOF
466
466
467 $ hg bookmark --inactive activebookmark
467 $ hg bookmark --inactive activebookmark
468 $ hg forget .hgsub
468 $ hg forget .hgsub
469 $ HGEDITOR=cat hg commit -q
469 $ HGEDITOR=cat hg commit -q
470 HG: this is "commit" template
470 HG: this is "commit" template
471 HG: Leave message empty to abort commit.
471 HG: Leave message empty to abort commit.
472 HG: no bookmark is activated
472 HG: no bookmark is activated
473 abort: empty commit message
473 abort: empty commit message
474 [10]
474 [10]
475
475
476 $ cat >> .hg/hgrc <<EOF
476 $ cat >> .hg/hgrc <<EOF
477 > [committemplate]
477 > [committemplate]
478 > changeset.commit =
478 > changeset.commit =
479 > # now, "changeset" should be chosen for "hg commit"
479 > # now, "changeset" should be chosen for "hg commit"
480 > EOF
480 > EOF
481
481
482 $ HGEDITOR=cat hg commit -q
482 $ HGEDITOR=cat hg commit -q
483 HG: this is customized commit template
483 HG: this is customized commit template
484 HG: Leave message empty to abort commit.
484 HG: Leave message empty to abort commit.
485 HG: no bookmark is activated
485 HG: no bookmark is activated
486 abort: empty commit message
486 abort: empty commit message
487 [10]
487 [10]
488
488
489 $ cat >> .hg/hgrc <<EOF
489 $ cat >> .hg/hgrc <<EOF
490 > [committemplate]
490 > [committemplate]
491 > changeset = {desc}
491 > changeset = {desc}
492 > HG: mods={file_mods}
492 > HG: mods={file_mods}
493 > HG: adds={file_adds}
493 > HG: adds={file_adds}
494 > HG: dels={file_dels}
494 > HG: dels={file_dels}
495 > HG: files={files}
495 > HG: files={files}
496 > HG:
496 > HG:
497 > {splitlines(diff()) % 'HG: {line}\n'
497 > {splitlines(diff()) % 'HG: {line}\n'
498 > }HG:
498 > }HG:
499 > HG: mods={file_mods}
499 > HG: mods={file_mods}
500 > HG: adds={file_adds}
500 > HG: adds={file_adds}
501 > HG: dels={file_dels}
501 > HG: dels={file_dels}
502 > HG: files={files}\n
502 > HG: files={files}\n
503 > EOF
503 > EOF
504 $ hg status -amr
504 $ hg status -amr
505 M changed
505 M changed
506 A added
506 A added
507 R removed
507 R removed
508 $ HGEDITOR=cat hg commit -q -e -m "foo bar" changed
508 $ HGEDITOR=cat hg commit -q -e -m "foo bar" changed
509 foo bar
509 foo bar
510 HG: mods=changed
510 HG: mods=changed
511 HG: adds=
511 HG: adds=
512 HG: dels=
512 HG: dels=
513 HG: files=changed
513 HG: files=changed
514 HG:
514 HG:
515 HG: diff -r d2313f97106f changed
515 HG: diff -r d2313f97106f changed
516 HG: --- a/changed Thu Jan 01 00:00:00 1970 +0000
516 HG: --- a/changed Thu Jan 01 00:00:00 1970 +0000
517 HG: +++ b/changed Thu Jan 01 00:00:00 1970 +0000
517 HG: +++ b/changed Thu Jan 01 00:00:00 1970 +0000
518 HG: @@ -1,1 +1,2 @@
518 HG: @@ -1,1 +1,2 @@
519 HG: changed
519 HG: changed
520 HG: +changed
520 HG: +changed
521 HG:
521 HG:
522 HG: mods=changed
522 HG: mods=changed
523 HG: adds=
523 HG: adds=
524 HG: dels=
524 HG: dels=
525 HG: files=changed
525 HG: files=changed
526 $ hg status -amr
526 $ hg status -amr
527 A added
527 A added
528 R removed
528 R removed
529 $ hg parents --template "M {file_mods}\nA {file_adds}\nR {file_dels}\n"
529 $ hg parents --template "M {file_mods}\nA {file_adds}\nR {file_dels}\n"
530 M changed
530 M changed
531 A
531 A
532 R
532 R
533 $ hg rollback -q
533 $ hg rollback -q
534
534
535 $ cat >> .hg/hgrc <<EOF
535 $ cat >> .hg/hgrc <<EOF
536 > [committemplate]
536 > [committemplate]
537 > changeset = {desc}
537 > changeset = {desc}
538 > HG: mods={file_mods}
538 > HG: mods={file_mods}
539 > HG: adds={file_adds}
539 > HG: adds={file_adds}
540 > HG: dels={file_dels}
540 > HG: dels={file_dels}
541 > HG: files={files}
541 > HG: files={files}
542 > HG:
542 > HG:
543 > {splitlines(diff("changed")) % 'HG: {line}\n'
543 > {splitlines(diff("changed")) % 'HG: {line}\n'
544 > }HG:
544 > }HG:
545 > HG: mods={file_mods}
545 > HG: mods={file_mods}
546 > HG: adds={file_adds}
546 > HG: adds={file_adds}
547 > HG: dels={file_dels}
547 > HG: dels={file_dels}
548 > HG: files={files}
548 > HG: files={files}
549 > HG:
549 > HG:
550 > {splitlines(diff("added")) % 'HG: {line}\n'
550 > {splitlines(diff("added")) % 'HG: {line}\n'
551 > }HG:
551 > }HG:
552 > HG: mods={file_mods}
552 > HG: mods={file_mods}
553 > HG: adds={file_adds}
553 > HG: adds={file_adds}
554 > HG: dels={file_dels}
554 > HG: dels={file_dels}
555 > HG: files={files}
555 > HG: files={files}
556 > HG:
556 > HG:
557 > {splitlines(diff("removed")) % 'HG: {line}\n'
557 > {splitlines(diff("removed")) % 'HG: {line}\n'
558 > }HG:
558 > }HG:
559 > HG: mods={file_mods}
559 > HG: mods={file_mods}
560 > HG: adds={file_adds}
560 > HG: adds={file_adds}
561 > HG: dels={file_dels}
561 > HG: dels={file_dels}
562 > HG: files={files}\n
562 > HG: files={files}\n
563 > EOF
563 > EOF
564 $ HGEDITOR=cat hg commit -q -e -m "foo bar" added removed
564 $ HGEDITOR=cat hg commit -q -e -m "foo bar" added removed
565 foo bar
565 foo bar
566 HG: mods=
566 HG: mods=
567 HG: adds=added
567 HG: adds=added
568 HG: dels=removed
568 HG: dels=removed
569 HG: files=added removed
569 HG: files=added removed
570 HG:
570 HG:
571 HG:
571 HG:
572 HG: mods=
572 HG: mods=
573 HG: adds=added
573 HG: adds=added
574 HG: dels=removed
574 HG: dels=removed
575 HG: files=added removed
575 HG: files=added removed
576 HG:
576 HG:
577 HG: diff -r d2313f97106f added
577 HG: diff -r d2313f97106f added
578 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
578 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
579 HG: +++ b/added Thu Jan 01 00:00:00 1970 +0000
579 HG: +++ b/added Thu Jan 01 00:00:00 1970 +0000
580 HG: @@ -0,0 +1,1 @@
580 HG: @@ -0,0 +1,1 @@
581 HG: +added
581 HG: +added
582 HG:
582 HG:
583 HG: mods=
583 HG: mods=
584 HG: adds=added
584 HG: adds=added
585 HG: dels=removed
585 HG: dels=removed
586 HG: files=added removed
586 HG: files=added removed
587 HG:
587 HG:
588 HG: diff -r d2313f97106f removed
588 HG: diff -r d2313f97106f removed
589 HG: --- a/removed Thu Jan 01 00:00:00 1970 +0000
589 HG: --- a/removed Thu Jan 01 00:00:00 1970 +0000
590 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
590 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
591 HG: @@ -1,1 +0,0 @@
591 HG: @@ -1,1 +0,0 @@
592 HG: -removed
592 HG: -removed
593 HG:
593 HG:
594 HG: mods=
594 HG: mods=
595 HG: adds=added
595 HG: adds=added
596 HG: dels=removed
596 HG: dels=removed
597 HG: files=added removed
597 HG: files=added removed
598 $ hg status -amr
598 $ hg status -amr
599 M changed
599 M changed
600 $ hg parents --template "M {file_mods}\nA {file_adds}\nR {file_dels}\n"
600 $ hg parents --template "M {file_mods}\nA {file_adds}\nR {file_dels}\n"
601 M
601 M
602 A added
602 A added
603 R removed
603 R removed
604 $ hg rollback -q
604 $ hg rollback -q
605
605
606 $ cat >> .hg/hgrc <<EOF
606 $ cat >> .hg/hgrc <<EOF
607 > # disable customizing for subsequent tests
607 > # disable customizing for subsequent tests
608 > [committemplate]
608 > [committemplate]
609 > changeset =
609 > changeset =
610 > EOF
610 > EOF
611
611
612 $ cd ..
612 $ cd ..
613
613
614
614
615 commit copy
615 commit copy
616
616
617 $ hg init dir2
617 $ hg init dir2
618 $ cd dir2
618 $ cd dir2
619 $ echo bleh > bar
619 $ echo bleh > bar
620 $ hg add bar
620 $ hg add bar
621 $ hg ci -m 'add bar'
621 $ hg ci -m 'add bar'
622
622
623 $ hg cp bar foo
623 $ hg cp bar foo
624 $ echo >> bar
624 $ echo >> bar
625 $ hg ci -m 'cp bar foo; change bar'
625 $ hg ci -m 'cp bar foo; change bar'
626
626
627 $ hg debugrename foo
627 $ hg debugrename foo
628 foo renamed from bar:26d3ca0dfd18e44d796b564e38dd173c9668d3a9
628 foo renamed from bar:26d3ca0dfd18e44d796b564e38dd173c9668d3a9
629 $ hg debugindex bar
629 $ hg debugindex bar
630 rev linkrev nodeid p1 p2
630 rev linkrev nodeid p1 p2
631 0 0 26d3ca0dfd18 000000000000 000000000000
631 0 0 26d3ca0dfd18 000000000000 000000000000
632 1 1 d267bddd54f7 26d3ca0dfd18 000000000000
632 1 1 d267bddd54f7 26d3ca0dfd18 000000000000
633
633
634 Test making empty commits
634 Test making empty commits
635 $ hg commit --config ui.allowemptycommit=True -m "empty commit"
635 $ hg commit --config ui.allowemptycommit=True -m "empty commit"
636 $ hg log -r . -v --stat
636 $ hg log -r . -v --stat
637 changeset: 2:d809f3644287
637 changeset: 2:d809f3644287
638 tag: tip
638 tag: tip
639 user: test
639 user: test
640 date: Thu Jan 01 00:00:00 1970 +0000
640 date: Thu Jan 01 00:00:00 1970 +0000
641 description:
641 description:
642 empty commit
642 empty commit
643
643
644
644
645
645
646 verify pathauditor blocks evil filepaths
646 verify pathauditor blocks evil filepaths
647 $ cat > evil-commit.py <<EOF
647 $ cat > evil-commit.py <<EOF
648 > from __future__ import absolute_import
648 > from __future__ import absolute_import
649 > from mercurial import context, hg, ui as uimod
649 > from mercurial import context, hg, ui as uimod
650 > notrc = u".h\u200cg".encode('utf-8') + b'/hgrc'
650 > notrc = u".h\u200cg".encode('utf-8') + b'/hgrc'
651 > u = uimod.ui.load()
651 > u = uimod.ui.load()
652 > r = hg.repository(u, b'.')
652 > r = hg.repository(u, b'.')
653 > def filectxfn(repo, memctx, path):
653 > def filectxfn(repo, memctx, path):
654 > return context.memfilectx(repo, memctx, path,
654 > return context.memfilectx(repo, memctx, path,
655 > b'[hooks]\nupdate = echo owned')
655 > b'[hooks]\nupdate = echo owned')
656 > c = context.memctx(r, [r.changelog.tip(), r.nullid],
656 > c = context.memctx(r, [r.changelog.tip(), r.nullid],
657 > b'evil', [notrc], filectxfn, 0)
657 > b'evil', [notrc], filectxfn, 0)
658 > r.commitctx(c)
658 > r.commitctx(c)
659 > EOF
659 > EOF
660 $ "$PYTHON" evil-commit.py
660 $ "$PYTHON" evil-commit.py
661 #if windows
661 #if windows
662 $ hg co --clean tip
662 $ hg co --clean tip
663 abort: path contains illegal component: .h\xe2\x80\x8cg\\hgrc (esc)
663 abort: path contains illegal component: .h\xe2\x80\x8cg\\hgrc (esc)
664 [10]
664 [10]
665 #else
665 #else
666 $ hg co --clean tip
666 $ hg co --clean tip
667 abort: path contains illegal component: .h\xe2\x80\x8cg/hgrc (esc)
667 abort: path contains illegal component: .h\xe2\x80\x8cg/hgrc (esc)
668 [10]
668 [10]
669 #endif
669 #endif
670
670
671 $ hg rollback -f
671 $ hg rollback -f
672 repository tip rolled back to revision 2 (undo commit)
672 repository tip rolled back to revision 2 (undo commit)
673 $ cat > evil-commit.py <<EOF
673 $ cat > evil-commit.py <<EOF
674 > from __future__ import absolute_import
674 > from __future__ import absolute_import
675 > from mercurial import context, hg, ui as uimod
675 > from mercurial import context, hg, ui as uimod
676 > notrc = b"HG~1/hgrc"
676 > notrc = b"HG~1/hgrc"
677 > u = uimod.ui.load()
677 > u = uimod.ui.load()
678 > r = hg.repository(u, b'.')
678 > r = hg.repository(u, b'.')
679 > def filectxfn(repo, memctx, path):
679 > def filectxfn(repo, memctx, path):
680 > return context.memfilectx(repo, memctx, path,
680 > return context.memfilectx(repo, memctx, path,
681 > b'[hooks]\nupdate = echo owned')
681 > b'[hooks]\nupdate = echo owned')
682 > c = context.memctx(r, [r[b'tip'].node(), r.nullid],
682 > c = context.memctx(r, [r[b'tip'].node(), r.nullid],
683 > b'evil', [notrc], filectxfn, 0)
683 > b'evil', [notrc], filectxfn, 0)
684 > r.commitctx(c)
684 > r.commitctx(c)
685 > EOF
685 > EOF
686 $ "$PYTHON" evil-commit.py
686 $ "$PYTHON" evil-commit.py
687 $ hg co --clean tip
687 $ hg co --clean tip
688 abort: path contains illegal component: HG~1/hgrc
688 abort: path contains illegal component: HG~1/hgrc
689 [10]
689 [10]
690
690
691 $ hg rollback -f
691 $ hg rollback -f
692 repository tip rolled back to revision 2 (undo commit)
692 repository tip rolled back to revision 2 (undo commit)
693 $ cat > evil-commit.py <<EOF
693 $ cat > evil-commit.py <<EOF
694 > from __future__ import absolute_import
694 > from __future__ import absolute_import
695 > from mercurial import context, hg, ui as uimod
695 > from mercurial import context, hg, ui as uimod
696 > notrc = b"HG8B6C~2/hgrc"
696 > notrc = b"HG8B6C~2/hgrc"
697 > u = uimod.ui.load()
697 > u = uimod.ui.load()
698 > r = hg.repository(u, b'.')
698 > r = hg.repository(u, b'.')
699 > def filectxfn(repo, memctx, path):
699 > def filectxfn(repo, memctx, path):
700 > return context.memfilectx(repo, memctx, path,
700 > return context.memfilectx(repo, memctx, path,
701 > b'[hooks]\nupdate = echo owned')
701 > b'[hooks]\nupdate = echo owned')
702 > c = context.memctx(r, [r[b'tip'].node(), r.nullid],
702 > c = context.memctx(r, [r[b'tip'].node(), r.nullid],
703 > b'evil', [notrc], filectxfn, 0)
703 > b'evil', [notrc], filectxfn, 0)
704 > r.commitctx(c)
704 > r.commitctx(c)
705 > EOF
705 > EOF
706 $ "$PYTHON" evil-commit.py
706 $ "$PYTHON" evil-commit.py
707 $ hg co --clean tip
707 $ hg co --clean tip
708 abort: path contains illegal component: HG8B6C~2/hgrc
708 abort: path contains illegal component: HG8B6C~2/hgrc
709 [10]
709 [10]
710
710
711 $ cd ..
711 $ cd ..
712
712
713 # test that an unmodified commit template message aborts
713 # test that an unmodified commit template message aborts
714
714
715 $ hg init unmodified_commit_template
715 $ hg init unmodified_commit_template
716 $ cd unmodified_commit_template
716 $ cd unmodified_commit_template
717 $ echo foo > foo
717 $ echo foo > foo
718 $ hg add foo
718 $ hg add foo
719 $ hg commit -m "foo"
719 $ hg commit -m "foo"
720 $ cat >> .hg/hgrc <<EOF
720 $ cat >> .hg/hgrc <<EOF
721 > [committemplate]
721 > [committemplate]
722 > changeset.commit = HI THIS IS NOT STRIPPED
722 > changeset.commit = HI THIS IS NOT STRIPPED
723 > HG: this is customized commit template
723 > HG: this is customized commit template
724 > HG: {extramsg}
724 > HG: {extramsg}
725 > {if(activebookmark,
725 > {if(activebookmark,
726 > "HG: bookmark '{activebookmark}' is activated\n",
726 > "HG: bookmark '{activebookmark}' is activated\n",
727 > "HG: no bookmark is activated\n")}{subrepos %
727 > "HG: no bookmark is activated\n")}{subrepos %
728 > "HG: subrepo '{subrepo}' is changed\n"}
728 > "HG: subrepo '{subrepo}' is changed\n"}
729 > EOF
729 > EOF
730 $ cat > $TESTTMP/notouching.sh <<EOF
730 $ cat > $TESTTMP/notouching.sh <<EOF
731 > true
731 > true
732 > EOF
732 > EOF
733 $ echo foo2 > foo2
733 $ echo foo2 > foo2
734 $ hg add foo2
734 $ hg add foo2
735 $ HGEDITOR="sh $TESTTMP/notouching.sh" hg commit
735 $ HGEDITOR="sh $TESTTMP/notouching.sh" hg commit
736 abort: commit message unchanged
736 abort: commit message unchanged
737 [10]
737 [10]
738
738
739 $ cd ..
739 $ cd ..
740
740
741 test that text below the --- >8 --- special string is ignored
741 test that text below the --- >8 --- special string is ignored
742
742
743 $ cat <<'EOF' > $TESTTMP/lowercaseline.sh
743 $ cat <<'EOF' > $TESTTMP/lowercaseline.sh
744 > cat $1 | sed s/LINE/line/ | tee $1.new
744 > cat $1 | sed s/LINE/line/ | tee $1.new
745 > mv $1.new $1
745 > mv $1.new $1
746 > EOF
746 > EOF
747
747
748 $ hg init ignore_below_special_string
748 $ hg init ignore_below_special_string
749 $ cd ignore_below_special_string
749 $ cd ignore_below_special_string
750 $ echo foo > foo
750 $ echo foo > foo
751 $ hg add foo
751 $ hg add foo
752 $ hg commit -m "foo"
752 $ hg commit -m "foo"
753 $ cat >> .hg/hgrc <<EOF
753 $ cat >> .hg/hgrc <<EOF
754 > [committemplate]
754 > [committemplate]
755 > changeset.commit = first LINE
755 > changeset.commit = first LINE
756 > HG: this is customized commit template
756 > HG: this is customized commit template
757 > HG: {extramsg}
757 > HG: {extramsg}
758 > HG: ------------------------ >8 ------------------------
758 > HG: ------------------------ >8 ------------------------
759 > {diff()}
759 > {diff()}
760 > EOF
760 > EOF
761 $ echo foo2 > foo2
761 $ echo foo2 > foo2
762 $ hg add foo2
762 $ hg add foo2
763 $ HGEDITOR="sh $TESTTMP/notouching.sh" hg ci
763 $ HGEDITOR="sh $TESTTMP/notouching.sh" hg ci
764 abort: commit message unchanged
764 abort: commit message unchanged
765 [10]
765 [10]
766 $ HGEDITOR="sh $TESTTMP/lowercaseline.sh" hg ci
766 $ HGEDITOR="sh $TESTTMP/lowercaseline.sh" hg ci
767 first line
767 first line
768 HG: this is customized commit template
768 HG: this is customized commit template
769 HG: Leave message empty to abort commit.
769 HG: Leave message empty to abort commit.
770 HG: ------------------------ >8 ------------------------
770 HG: ------------------------ >8 ------------------------
771 diff -r e63c23eaa88a foo2
771 diff -r e63c23eaa88a foo2
772 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
772 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
773 +++ b/foo2 Thu Jan 01 00:00:00 1970 +0000
773 +++ b/foo2 Thu Jan 01 00:00:00 1970 +0000
774 @@ -0,0 +1,1 @@
774 @@ -0,0 +1,1 @@
775 +foo2
775 +foo2
776 $ hg log -T '{desc}\n' -r .
776 $ hg log -T '{desc}\n' -r .
777 first line
777 first line
778
778
779 test that the special string --- >8 --- isn't used when not at the beginning of
779 test that the special string --- >8 --- isn't used when not at the beginning of
780 a line
780 a line
781
781
782 $ cat >> .hg/hgrc <<EOF
782 $ cat >> .hg/hgrc <<EOF
783 > [committemplate]
783 > [committemplate]
784 > changeset.commit = first LINE2
784 > changeset.commit = first LINE2
785 > another line HG: ------------------------ >8 ------------------------
785 > another line HG: ------------------------ >8 ------------------------
786 > HG: this is customized commit template
786 > HG: this is customized commit template
787 > HG: {extramsg}
787 > HG: {extramsg}
788 > HG: ------------------------ >8 ------------------------
788 > HG: ------------------------ >8 ------------------------
789 > {diff()}
789 > {diff()}
790 > EOF
790 > EOF
791 $ echo foo >> foo
791 $ echo foo >> foo
792 $ HGEDITOR="sh $TESTTMP/lowercaseline.sh" hg ci
792 $ HGEDITOR="sh $TESTTMP/lowercaseline.sh" hg ci
793 first line2
793 first line2
794 another line HG: ------------------------ >8 ------------------------
794 another line HG: ------------------------ >8 ------------------------
795 HG: this is customized commit template
795 HG: this is customized commit template
796 HG: Leave message empty to abort commit.
796 HG: Leave message empty to abort commit.
797 HG: ------------------------ >8 ------------------------
797 HG: ------------------------ >8 ------------------------
798 diff -r 3661b22b0702 foo
798 diff -r 3661b22b0702 foo
799 --- a/foo Thu Jan 01 00:00:00 1970 +0000
799 --- a/foo Thu Jan 01 00:00:00 1970 +0000
800 +++ b/foo Thu Jan 01 00:00:00 1970 +0000
800 +++ b/foo Thu Jan 01 00:00:00 1970 +0000
801 @@ -1,1 +1,2 @@
801 @@ -1,1 +1,2 @@
802 foo
802 foo
803 +foo
803 +foo
804 $ hg log -T '{desc}\n' -r .
804 $ hg log -T '{desc}\n' -r .
805 first line2
805 first line2
806 another line HG: ------------------------ >8 ------------------------
806 another line HG: ------------------------ >8 ------------------------
807
807
808 also test that this special string isn't accepted when there is some extra text
808 also test that this special string isn't accepted when there is some extra text
809 at the end
809 at the end
810
810
811 $ cat >> .hg/hgrc <<EOF
811 $ cat >> .hg/hgrc <<EOF
812 > [committemplate]
812 > [committemplate]
813 > changeset.commit = first LINE3
813 > changeset.commit = first LINE3
814 > HG: ------------------------ >8 ------------------------foobar
814 > HG: ------------------------ >8 ------------------------foobar
815 > second line
815 > second line
816 > HG: this is customized commit template
816 > HG: this is customized commit template
817 > HG: {extramsg}
817 > HG: {extramsg}
818 > HG: ------------------------ >8 ------------------------
818 > HG: ------------------------ >8 ------------------------
819 > {diff()}
819 > {diff()}
820 > EOF
820 > EOF
821 $ echo foo >> foo
821 $ echo foo >> foo
822 $ HGEDITOR="sh $TESTTMP/lowercaseline.sh" hg ci
822 $ HGEDITOR="sh $TESTTMP/lowercaseline.sh" hg ci
823 first line3
823 first line3
824 HG: ------------------------ >8 ------------------------foobar
824 HG: ------------------------ >8 ------------------------foobar
825 second line
825 second line
826 HG: this is customized commit template
826 HG: this is customized commit template
827 HG: Leave message empty to abort commit.
827 HG: Leave message empty to abort commit.
828 HG: ------------------------ >8 ------------------------
828 HG: ------------------------ >8 ------------------------
829 diff -r ce648f5f066f foo
829 diff -r ce648f5f066f foo
830 --- a/foo Thu Jan 01 00:00:00 1970 +0000
830 --- a/foo Thu Jan 01 00:00:00 1970 +0000
831 +++ b/foo Thu Jan 01 00:00:00 1970 +0000
831 +++ b/foo Thu Jan 01 00:00:00 1970 +0000
832 @@ -1,2 +1,3 @@
832 @@ -1,2 +1,3 @@
833 foo
833 foo
834 foo
834 foo
835 +foo
835 +foo
836 $ hg log -T '{desc}\n' -r .
836 $ hg log -T '{desc}\n' -r .
837 first line3
837 first line3
838 second line
838 second line
839
839
840 $ cd ..
840 $ cd ..
841
841
842 testing commands.commit.post-status config option
842 testing commands.commit.post-status config option
843
843
844 $ hg init ci-post-st
844 $ hg init ci-post-st
845 $ cd ci-post-st
845 $ cd ci-post-st
846 $ echo '[commands]' > .hg/hgrc
846 $ echo '[commands]' > .hg/hgrc
847 $ echo 'commit.post-status = 1' >> .hg/hgrc
847 $ echo 'commit.post-status = 1' >> .hg/hgrc
848
848
849 $ echo 'ignored-file' > .hgignore
849 $ echo 'ignored-file' > .hgignore
850 $ hg ci -qAm 0
850 $ hg ci -qAm 0
851
851
852 $ echo 'c' > clean-file
852 $ echo 'c' > clean-file
853 $ echo 'a' > added-file
853 $ echo 'a' > added-file
854 $ echo '?' > unknown-file
854 $ echo '?' > unknown-file
855 $ echo 'i' > ignored-file
855 $ echo 'i' > ignored-file
856 $ hg add clean-file added-file
856 $ hg add clean-file added-file
857 $ hg ci -m 1 clean-file
857 $ hg ci -m 1 clean-file
858 A added-file
858 A added-file
859 ? unknown-file
859 ? unknown-file
860 $ hg st -mardu
860 $ hg st -mardu
861 A added-file
861 A added-file
862 ? unknown-file
862 ? unknown-file
863
863
864 $ touch modified-file
864 $ touch modified-file
865 $ hg add modified-file
865 $ hg add modified-file
866 $ hg ci -m 2 modified-file -q
866 $ hg ci -m 2 modified-file -q
867
867
868 $ echo 'm' > modified-file
868 $ echo 'm' > modified-file
869 $ hg ci --amend -m 'reworded' -X 're:'
869 $ hg ci --amend -m 'reworded' -X 're:'
870 saved backup bundle to $TESTTMP/ci-post-st/.hg/strip-backup/*-amend.hg (glob)
870 saved backup bundle to $TESTTMP/ci-post-st/.hg/strip-backup/*-amend.hg (glob)
871 M modified-file
871 M modified-file
872 A added-file
872 A added-file
873 ? unknown-file
873 ? unknown-file
874 $ hg st -mardu
874 $ hg st -mardu
875 M modified-file
875 M modified-file
876 A added-file
876 A added-file
877 ? unknown-file
877 ? unknown-file
878
878
879 $ cd ..
879 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now