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