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