Show More
@@ -1,146 +1,146 b'' | |||
|
1 | 1 | # rewriteutil.py - utility functions for rewriting changesets |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2017 Octobus <contact@octobus.net> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | 10 | import re |
|
11 | 11 | |
|
12 | 12 | from .i18n import _ |
|
13 | 13 | from .node import ( |
|
14 | 14 | hex, |
|
15 | 15 | nullrev, |
|
16 | 16 | ) |
|
17 | 17 | |
|
18 | 18 | from . import ( |
|
19 | 19 | error, |
|
20 | 20 | obsolete, |
|
21 | 21 | obsutil, |
|
22 | 22 | revset, |
|
23 | 23 | scmutil, |
|
24 | 24 | util, |
|
25 | 25 | ) |
|
26 | 26 | |
|
27 | 27 | |
|
28 | 28 | NODE_RE = re.compile(br'\b[0-9a-f]{6,64}\b') |
|
29 | 29 | |
|
30 | 30 | |
|
31 | 31 | def precheck(repo, revs, action=b'rewrite'): |
|
32 | 32 | """check if revs can be rewritten |
|
33 | 33 | action is used to control the error message. |
|
34 | 34 | |
|
35 | 35 | Make sure this function is called after taking the lock. |
|
36 | 36 | """ |
|
37 | 37 | if nullrev in revs: |
|
38 | 38 | msg = _(b"cannot %s the null revision") % action |
|
39 | 39 | hint = _(b"no changeset checked out") |
|
40 | 40 | raise error.InputError(msg, hint=hint) |
|
41 | 41 | |
|
42 | 42 | if any(util.safehasattr(r, 'rev') for r in revs): |
|
43 | 43 | repo.ui.develwarn(b"rewriteutil.precheck called with ctx not revs") |
|
44 | 44 | revs = (r.rev() for r in revs) |
|
45 | 45 | |
|
46 | 46 | if len(repo[None].parents()) > 1: |
|
47 | raise error.StateError(_(b"cannot %s while merging") % action) | |
|
47 | raise error.StateError(_(b"cannot %s changesets while merging") % action) | |
|
48 | 48 | |
|
49 | 49 | publicrevs = repo.revs(b'%ld and public()', revs) |
|
50 | 50 | if publicrevs: |
|
51 | 51 | msg = _(b"cannot %s public changesets") % action |
|
52 | 52 | hint = _(b"see 'hg help phases' for details") |
|
53 | 53 | raise error.InputError(msg, hint=hint) |
|
54 | 54 | |
|
55 | 55 | newunstable = disallowednewunstable(repo, revs) |
|
56 | 56 | if newunstable: |
|
57 | 57 | hint = _(b"see 'hg help evolution.instability'") |
|
58 | 58 | raise error.InputError( |
|
59 | 59 | _(b"cannot %s changeset with children") % action, hint=hint |
|
60 | 60 | ) |
|
61 | 61 | |
|
62 | 62 | |
|
63 | 63 | def disallowednewunstable(repo, revs): |
|
64 | 64 | """Checks whether editing the revs will create new unstable changesets and |
|
65 | 65 | are we allowed to create them. |
|
66 | 66 | |
|
67 | 67 | To allow new unstable changesets, set the config: |
|
68 | 68 | `experimental.evolution.allowunstable=True` |
|
69 | 69 | """ |
|
70 | 70 | allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt) |
|
71 | 71 | if allowunstable: |
|
72 | 72 | return revset.baseset() |
|
73 | 73 | return repo.revs(b"(%ld::) - %ld", revs, revs) |
|
74 | 74 | |
|
75 | 75 | |
|
76 | 76 | def skip_empty_successor(ui, command): |
|
77 | 77 | empty_successor = ui.config(b'rewrite', b'empty-successor') |
|
78 | 78 | if empty_successor == b'skip': |
|
79 | 79 | return True |
|
80 | 80 | elif empty_successor == b'keep': |
|
81 | 81 | return False |
|
82 | 82 | else: |
|
83 | 83 | raise error.ConfigError( |
|
84 | 84 | _( |
|
85 | 85 | b"%s doesn't know how to handle config " |
|
86 | 86 | b"rewrite.empty-successor=%s (only 'skip' and 'keep' are " |
|
87 | 87 | b"supported)" |
|
88 | 88 | ) |
|
89 | 89 | % (command, empty_successor) |
|
90 | 90 | ) |
|
91 | 91 | |
|
92 | 92 | |
|
93 | 93 | def update_hash_refs(repo, commitmsg, pending=None): |
|
94 | 94 | """Replace all obsolete commit hashes in the message with the current hash. |
|
95 | 95 | |
|
96 | 96 | If the obsolete commit was split or is divergent, the hash is not replaced |
|
97 | 97 | as there's no way to know which successor to choose. |
|
98 | 98 | |
|
99 | 99 | For commands that update a series of commits in the current transaction, the |
|
100 | 100 | new obsolete markers can be considered by setting ``pending`` to a mapping |
|
101 | 101 | of ``pending[oldnode] = [successor_node1, successor_node2,..]``. |
|
102 | 102 | """ |
|
103 | 103 | if not pending: |
|
104 | 104 | pending = {} |
|
105 | 105 | cache = {} |
|
106 | 106 | hashes = re.findall(NODE_RE, commitmsg) |
|
107 | 107 | unfi = repo.unfiltered() |
|
108 | 108 | for h in hashes: |
|
109 | 109 | fullnode = scmutil.resolvehexnodeidprefix(unfi, h) |
|
110 | 110 | if fullnode is None: |
|
111 | 111 | continue |
|
112 | 112 | ctx = unfi[fullnode] |
|
113 | 113 | if not ctx.obsolete(): |
|
114 | 114 | successors = pending.get(fullnode) |
|
115 | 115 | if successors is None: |
|
116 | 116 | continue |
|
117 | 117 | # obsutil.successorssets() returns a list of list of nodes |
|
118 | 118 | successors = [successors] |
|
119 | 119 | else: |
|
120 | 120 | successors = obsutil.successorssets(repo, ctx.node(), cache=cache) |
|
121 | 121 | |
|
122 | 122 | # We can't make any assumptions about how to update the hash if the |
|
123 | 123 | # cset in question was split or diverged. |
|
124 | 124 | if len(successors) == 1 and len(successors[0]) == 1: |
|
125 | 125 | successor = successors[0][0] |
|
126 | 126 | if successor is not None: |
|
127 | 127 | newhash = hex(successor) |
|
128 | 128 | commitmsg = commitmsg.replace(h, newhash[: len(h)]) |
|
129 | 129 | else: |
|
130 | 130 | repo.ui.note( |
|
131 | 131 | _( |
|
132 | 132 | b'The stale commit message reference to %s could ' |
|
133 | 133 | b'not be updated\n(The referenced commit was dropped)\n' |
|
134 | 134 | ) |
|
135 | 135 | % h |
|
136 | 136 | ) |
|
137 | 137 | else: |
|
138 | 138 | repo.ui.note( |
|
139 | 139 | _( |
|
140 | 140 | b'The stale commit message reference to %s could ' |
|
141 | 141 | b'not be updated\n' |
|
142 | 142 | ) |
|
143 | 143 | % h |
|
144 | 144 | ) |
|
145 | 145 | |
|
146 | 146 | return commitmsg |
@@ -1,1319 +1,1319 b'' | |||
|
1 | 1 | $ hg init |
|
2 | 2 | |
|
3 | 3 | Setup: |
|
4 | 4 | |
|
5 | 5 | $ echo a >> a |
|
6 | 6 | $ hg ci -Am 'base' |
|
7 | 7 | adding a |
|
8 | 8 | |
|
9 | 9 | Refuse to amend public csets: |
|
10 | 10 | |
|
11 | 11 | $ hg phase -r . -p |
|
12 | 12 | $ hg ci --amend |
|
13 | 13 | abort: cannot amend public changesets |
|
14 | 14 | (see 'hg help phases' for details) |
|
15 | 15 | [10] |
|
16 | 16 | $ hg phase -r . -f -d |
|
17 | 17 | |
|
18 | 18 | $ echo a >> a |
|
19 | 19 | $ hg ci -Am 'base1' |
|
20 | 20 | |
|
21 | 21 | Nothing to amend: |
|
22 | 22 | |
|
23 | 23 | $ hg ci --amend -m 'base1' |
|
24 | 24 | nothing changed |
|
25 | 25 | [1] |
|
26 | 26 | |
|
27 | 27 | $ cat >> $HGRCPATH <<EOF |
|
28 | 28 | > [hooks] |
|
29 | 29 | > pretxncommit.foo = sh -c "echo \\"pretxncommit \$HG_NODE\\"; hg id -r \$HG_NODE" |
|
30 | 30 | > EOF |
|
31 | 31 | |
|
32 | 32 | Amending changeset with changes in working dir: |
|
33 | 33 | (and check that --message does not trigger an editor) |
|
34 | 34 | |
|
35 | 35 | $ echo a >> a |
|
36 | 36 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -m 'amend base1' |
|
37 | 37 | pretxncommit 43f1ba15f28a50abf0aae529cf8a16bfced7b149 |
|
38 | 38 | 43f1ba15f28a tip |
|
39 | 39 | saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-5ab4f721-amend.hg |
|
40 | 40 | $ echo 'pretxncommit.foo = ' >> $HGRCPATH |
|
41 | 41 | $ hg diff -c . |
|
42 | 42 | diff -r ad120869acf0 -r 43f1ba15f28a a |
|
43 | 43 | --- a/a Thu Jan 01 00:00:00 1970 +0000 |
|
44 | 44 | +++ b/a Thu Jan 01 00:00:00 1970 +0000 |
|
45 | 45 | @@ -1,1 +1,3 @@ |
|
46 | 46 | a |
|
47 | 47 | +a |
|
48 | 48 | +a |
|
49 | 49 | $ hg log |
|
50 | 50 | changeset: 1:43f1ba15f28a |
|
51 | 51 | tag: tip |
|
52 | 52 | user: test |
|
53 | 53 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
54 | 54 | summary: amend base1 |
|
55 | 55 | |
|
56 | 56 | changeset: 0:ad120869acf0 |
|
57 | 57 | user: test |
|
58 | 58 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
59 | 59 | summary: base |
|
60 | 60 | |
|
61 | 61 | |
|
62 | 62 | Check proper abort for empty message |
|
63 | 63 | |
|
64 | 64 | $ cat > editor.sh << '__EOF__' |
|
65 | 65 | > #!/bin/sh |
|
66 | 66 | > echo "" > "$1" |
|
67 | 67 | > __EOF__ |
|
68 | 68 | |
|
69 | 69 | Update the existing file to ensure that the dirstate is not in pending state |
|
70 | 70 | (where the status of some files in the working copy is not known yet). This in |
|
71 | 71 | turn ensures that when the transaction is aborted due to an empty message during |
|
72 | 72 | the amend, there should be no rollback. |
|
73 | 73 | $ echo a >> a |
|
74 | 74 | |
|
75 | 75 | $ echo b > b |
|
76 | 76 | $ hg add b |
|
77 | 77 | $ hg summary |
|
78 | 78 | parent: 1:43f1ba15f28a tip |
|
79 | 79 | amend base1 |
|
80 | 80 | branch: default |
|
81 | 81 | commit: 1 modified, 1 added, 1 unknown |
|
82 | 82 | update: (current) |
|
83 | 83 | phases: 2 draft |
|
84 | 84 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend |
|
85 | 85 | abort: empty commit message |
|
86 | 86 | [10] |
|
87 | 87 | $ hg summary |
|
88 | 88 | parent: 1:43f1ba15f28a tip |
|
89 | 89 | amend base1 |
|
90 | 90 | branch: default |
|
91 | 91 | commit: 1 modified, 1 added, 1 unknown |
|
92 | 92 | update: (current) |
|
93 | 93 | phases: 2 draft |
|
94 | 94 | |
|
95 | 95 | Add new file along with modified existing file: |
|
96 | 96 | $ hg ci --amend -m 'amend base1 new file' |
|
97 | 97 | saved backup bundle to $TESTTMP/.hg/strip-backup/43f1ba15f28a-007467c2-amend.hg |
|
98 | 98 | |
|
99 | 99 | Remove file that was added in amended commit: |
|
100 | 100 | (and test logfile option) |
|
101 | 101 | (and test that logfile option do not trigger an editor) |
|
102 | 102 | |
|
103 | 103 | $ hg rm b |
|
104 | 104 | $ echo 'amend base1 remove new file' > ../logfile |
|
105 | 105 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg ci --amend --logfile ../logfile |
|
106 | 106 | saved backup bundle to $TESTTMP/.hg/strip-backup/c16295aaf401-1ada9901-amend.hg |
|
107 | 107 | |
|
108 | 108 | $ hg cat b |
|
109 | 109 | b: no such file in rev 47343646fa3d |
|
110 | 110 | [1] |
|
111 | 111 | |
|
112 | 112 | No changes, just a different message: |
|
113 | 113 | |
|
114 | 114 | $ hg ci -v --amend -m 'no changes, new message' |
|
115 | 115 | amending changeset 47343646fa3d |
|
116 | 116 | copying changeset 47343646fa3d to ad120869acf0 |
|
117 | 117 | committing files: |
|
118 | 118 | a |
|
119 | 119 | committing manifest |
|
120 | 120 | committing changelog |
|
121 | 121 | 1 changesets found |
|
122 | 122 | uncompressed size of bundle content: |
|
123 | 123 | 254 (changelog) |
|
124 | 124 | 163 (manifests) |
|
125 | 125 | 131 a |
|
126 | 126 | saved backup bundle to $TESTTMP/.hg/strip-backup/47343646fa3d-c2758885-amend.hg |
|
127 | 127 | 1 changesets found |
|
128 | 128 | uncompressed size of bundle content: |
|
129 | 129 | 250 (changelog) |
|
130 | 130 | 163 (manifests) |
|
131 | 131 | 131 a |
|
132 | 132 | adding branch |
|
133 | 133 | adding changesets |
|
134 | 134 | adding manifests |
|
135 | 135 | adding file changes |
|
136 | 136 | added 1 changesets with 1 changes to 1 files |
|
137 | 137 | committed changeset 1:401431e913a1 |
|
138 | 138 | $ hg diff -c . |
|
139 | 139 | diff -r ad120869acf0 -r 401431e913a1 a |
|
140 | 140 | --- a/a Thu Jan 01 00:00:00 1970 +0000 |
|
141 | 141 | +++ b/a Thu Jan 01 00:00:00 1970 +0000 |
|
142 | 142 | @@ -1,1 +1,4 @@ |
|
143 | 143 | a |
|
144 | 144 | +a |
|
145 | 145 | +a |
|
146 | 146 | +a |
|
147 | 147 | $ hg log |
|
148 | 148 | changeset: 1:401431e913a1 |
|
149 | 149 | tag: tip |
|
150 | 150 | user: test |
|
151 | 151 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
152 | 152 | summary: no changes, new message |
|
153 | 153 | |
|
154 | 154 | changeset: 0:ad120869acf0 |
|
155 | 155 | user: test |
|
156 | 156 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
157 | 157 | summary: base |
|
158 | 158 | |
|
159 | 159 | |
|
160 | 160 | Disable default date on commit so when -d isn't given, the old date is preserved: |
|
161 | 161 | |
|
162 | 162 | $ echo '[defaults]' >> $HGRCPATH |
|
163 | 163 | $ echo 'commit=' >> $HGRCPATH |
|
164 | 164 | |
|
165 | 165 | Test -u/-d: |
|
166 | 166 | |
|
167 | 167 | $ cat > .hg/checkeditform.sh <<EOF |
|
168 | 168 | > env | grep HGEDITFORM |
|
169 | 169 | > true |
|
170 | 170 | > EOF |
|
171 | 171 | $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -u foo -d '1 0' |
|
172 | 172 | HGEDITFORM=commit.amend.normal |
|
173 | 173 | saved backup bundle to $TESTTMP/.hg/strip-backup/401431e913a1-5e8e532c-amend.hg |
|
174 | 174 | $ echo a >> a |
|
175 | 175 | $ hg ci --amend -u foo -d '1 0' |
|
176 | 176 | saved backup bundle to $TESTTMP/.hg/strip-backup/d96b1d28ae33-677e0afb-amend.hg |
|
177 | 177 | $ hg log -r . |
|
178 | 178 | changeset: 1:a9a13940fc03 |
|
179 | 179 | tag: tip |
|
180 | 180 | user: foo |
|
181 | 181 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
182 | 182 | summary: no changes, new message |
|
183 | 183 | |
|
184 | 184 | |
|
185 | 185 | Open editor with old commit message if a message isn't given otherwise: |
|
186 | 186 | |
|
187 | 187 | $ cat > editor.sh << '__EOF__' |
|
188 | 188 | > #!/bin/sh |
|
189 | 189 | > cat $1 |
|
190 | 190 | > echo "another precious commit message" > "$1" |
|
191 | 191 | > __EOF__ |
|
192 | 192 | |
|
193 | 193 | at first, test saving last-message.txt |
|
194 | 194 | |
|
195 | 195 | $ cat > .hg/hgrc << '__EOF__' |
|
196 | 196 | > [hooks] |
|
197 | 197 | > pretxncommit.test-saving-last-message = false |
|
198 | 198 | > __EOF__ |
|
199 | 199 | |
|
200 | 200 | $ rm -f .hg/last-message.txt |
|
201 | 201 | $ hg commit --amend -v -m "message given from command line" |
|
202 | 202 | amending changeset a9a13940fc03 |
|
203 | 203 | copying changeset a9a13940fc03 to ad120869acf0 |
|
204 | 204 | committing files: |
|
205 | 205 | a |
|
206 | 206 | committing manifest |
|
207 | 207 | committing changelog |
|
208 | 208 | running hook pretxncommit.test-saving-last-message: false |
|
209 | 209 | transaction abort! |
|
210 | 210 | rollback completed |
|
211 | 211 | abort: pretxncommit.test-saving-last-message hook exited with status 1 |
|
212 | 212 | [40] |
|
213 | 213 | $ cat .hg/last-message.txt |
|
214 | 214 | message given from command line (no-eol) |
|
215 | 215 | |
|
216 | 216 | $ rm -f .hg/last-message.txt |
|
217 | 217 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v |
|
218 | 218 | amending changeset a9a13940fc03 |
|
219 | 219 | copying changeset a9a13940fc03 to ad120869acf0 |
|
220 | 220 | no changes, new message |
|
221 | 221 | |
|
222 | 222 | |
|
223 | 223 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
224 | 224 | HG: Leave message empty to abort commit. |
|
225 | 225 | HG: -- |
|
226 | 226 | HG: user: foo |
|
227 | 227 | HG: branch 'default' |
|
228 | 228 | HG: changed a |
|
229 | 229 | committing files: |
|
230 | 230 | a |
|
231 | 231 | committing manifest |
|
232 | 232 | committing changelog |
|
233 | 233 | running hook pretxncommit.test-saving-last-message: false |
|
234 | 234 | transaction abort! |
|
235 | 235 | rollback completed |
|
236 | 236 | abort: pretxncommit.test-saving-last-message hook exited with status 1 |
|
237 | 237 | [40] |
|
238 | 238 | |
|
239 | 239 | $ cat .hg/last-message.txt |
|
240 | 240 | another precious commit message |
|
241 | 241 | |
|
242 | 242 | $ cat > .hg/hgrc << '__EOF__' |
|
243 | 243 | > [hooks] |
|
244 | 244 | > pretxncommit.test-saving-last-message = |
|
245 | 245 | > __EOF__ |
|
246 | 246 | |
|
247 | 247 | then, test editing custom commit message |
|
248 | 248 | |
|
249 | 249 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v |
|
250 | 250 | amending changeset a9a13940fc03 |
|
251 | 251 | copying changeset a9a13940fc03 to ad120869acf0 |
|
252 | 252 | no changes, new message |
|
253 | 253 | |
|
254 | 254 | |
|
255 | 255 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
256 | 256 | HG: Leave message empty to abort commit. |
|
257 | 257 | HG: -- |
|
258 | 258 | HG: user: foo |
|
259 | 259 | HG: branch 'default' |
|
260 | 260 | HG: changed a |
|
261 | 261 | committing files: |
|
262 | 262 | a |
|
263 | 263 | committing manifest |
|
264 | 264 | committing changelog |
|
265 | 265 | 1 changesets found |
|
266 | 266 | uncompressed size of bundle content: |
|
267 | 267 | 249 (changelog) |
|
268 | 268 | 163 (manifests) |
|
269 | 269 | 133 a |
|
270 | 270 | saved backup bundle to $TESTTMP/.hg/strip-backup/a9a13940fc03-7c2e8674-amend.hg |
|
271 | 271 | 1 changesets found |
|
272 | 272 | uncompressed size of bundle content: |
|
273 | 273 | 257 (changelog) |
|
274 | 274 | 163 (manifests) |
|
275 | 275 | 133 a |
|
276 | 276 | adding branch |
|
277 | 277 | adding changesets |
|
278 | 278 | adding manifests |
|
279 | 279 | adding file changes |
|
280 | 280 | added 1 changesets with 1 changes to 1 files |
|
281 | 281 | committed changeset 1:64a124ba1b44 |
|
282 | 282 | |
|
283 | 283 | Same, but with changes in working dir (different code path): |
|
284 | 284 | |
|
285 | 285 | $ echo a >> a |
|
286 | 286 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v |
|
287 | 287 | amending changeset 64a124ba1b44 |
|
288 | 288 | another precious commit message |
|
289 | 289 | |
|
290 | 290 | |
|
291 | 291 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
292 | 292 | HG: Leave message empty to abort commit. |
|
293 | 293 | HG: -- |
|
294 | 294 | HG: user: foo |
|
295 | 295 | HG: branch 'default' |
|
296 | 296 | HG: changed a |
|
297 | 297 | committing files: |
|
298 | 298 | a |
|
299 | 299 | committing manifest |
|
300 | 300 | committing changelog |
|
301 | 301 | 1 changesets found |
|
302 | 302 | uncompressed size of bundle content: |
|
303 | 303 | 257 (changelog) |
|
304 | 304 | 163 (manifests) |
|
305 | 305 | 133 a |
|
306 | 306 | saved backup bundle to $TESTTMP/.hg/strip-backup/64a124ba1b44-10374b8f-amend.hg |
|
307 | 307 | 1 changesets found |
|
308 | 308 | uncompressed size of bundle content: |
|
309 | 309 | 257 (changelog) |
|
310 | 310 | 163 (manifests) |
|
311 | 311 | 135 a |
|
312 | 312 | adding branch |
|
313 | 313 | adding changesets |
|
314 | 314 | adding manifests |
|
315 | 315 | adding file changes |
|
316 | 316 | added 1 changesets with 1 changes to 1 files |
|
317 | 317 | committed changeset 1:7892795b8e38 |
|
318 | 318 | |
|
319 | 319 | $ rm editor.sh |
|
320 | 320 | $ hg log -r . |
|
321 | 321 | changeset: 1:7892795b8e38 |
|
322 | 322 | tag: tip |
|
323 | 323 | user: foo |
|
324 | 324 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
325 | 325 | summary: another precious commit message |
|
326 | 326 | |
|
327 | 327 | |
|
328 | 328 | Moving bookmarks, preserve active bookmark: |
|
329 | 329 | |
|
330 | 330 | $ hg book book1 |
|
331 | 331 | $ hg book book2 |
|
332 | 332 | $ hg ci --amend -m 'move bookmarks' |
|
333 | 333 | saved backup bundle to $TESTTMP/.hg/strip-backup/7892795b8e38-3fb46217-amend.hg |
|
334 | 334 | $ hg book |
|
335 | 335 | book1 1:8311f17e2616 |
|
336 | 336 | * book2 1:8311f17e2616 |
|
337 | 337 | $ echo a >> a |
|
338 | 338 | $ hg ci --amend -m 'move bookmarks' |
|
339 | 339 | saved backup bundle to $TESTTMP/.hg/strip-backup/8311f17e2616-f0504fe3-amend.hg |
|
340 | 340 | $ hg book |
|
341 | 341 | book1 1:a3b65065808c |
|
342 | 342 | * book2 1:a3b65065808c |
|
343 | 343 | |
|
344 | 344 | abort does not loose bookmarks |
|
345 | 345 | |
|
346 | 346 | $ cat > editor.sh << '__EOF__' |
|
347 | 347 | > #!/bin/sh |
|
348 | 348 | > echo "" > "$1" |
|
349 | 349 | > __EOF__ |
|
350 | 350 | $ echo a >> a |
|
351 | 351 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend |
|
352 | 352 | abort: empty commit message |
|
353 | 353 | [10] |
|
354 | 354 | $ hg book |
|
355 | 355 | book1 1:a3b65065808c |
|
356 | 356 | * book2 1:a3b65065808c |
|
357 | 357 | $ hg revert -Caq |
|
358 | 358 | $ rm editor.sh |
|
359 | 359 | |
|
360 | 360 | $ echo '[defaults]' >> $HGRCPATH |
|
361 | 361 | $ echo "commit=-d '0 0'" >> $HGRCPATH |
|
362 | 362 | |
|
363 | 363 | Moving branches: |
|
364 | 364 | |
|
365 | 365 | $ hg branch foo |
|
366 | 366 | marked working directory as branch foo |
|
367 | 367 | (branches are permanent and global, did you want a bookmark?) |
|
368 | 368 | $ echo a >> a |
|
369 | 369 | $ hg ci -m 'branch foo' |
|
370 | 370 | $ hg branch default -f |
|
371 | 371 | marked working directory as branch default |
|
372 | 372 | $ hg ci --amend -m 'back to default' |
|
373 | 373 | saved backup bundle to $TESTTMP/.hg/strip-backup/f8339a38efe1-c18453c9-amend.hg |
|
374 | 374 | $ hg branches |
|
375 | 375 | default 2:9c07515f2650 |
|
376 | 376 | |
|
377 | 377 | Close branch: |
|
378 | 378 | |
|
379 | 379 | $ hg up -q 0 |
|
380 | 380 | $ echo b >> b |
|
381 | 381 | $ hg branch foo |
|
382 | 382 | marked working directory as branch foo |
|
383 | 383 | (branches are permanent and global, did you want a bookmark?) |
|
384 | 384 | $ hg ci -Am 'fork' |
|
385 | 385 | adding b |
|
386 | 386 | $ echo b >> b |
|
387 | 387 | $ hg ci -mb |
|
388 | 388 | $ hg ci --amend --close-branch -m 'closing branch foo' |
|
389 | 389 | saved backup bundle to $TESTTMP/.hg/strip-backup/c962248fa264-54245dc7-amend.hg |
|
390 | 390 | |
|
391 | 391 | Same thing, different code path: |
|
392 | 392 | |
|
393 | 393 | $ echo b >> b |
|
394 | 394 | $ hg ci -m 'reopen branch' |
|
395 | 395 | reopening closed branch head 4 |
|
396 | 396 | $ echo b >> b |
|
397 | 397 | $ hg ci --amend --close-branch |
|
398 | 398 | saved backup bundle to $TESTTMP/.hg/strip-backup/027371728205-b900d9fa-amend.hg |
|
399 | 399 | $ hg branches |
|
400 | 400 | default 2:9c07515f2650 |
|
401 | 401 | |
|
402 | 402 | Refuse to amend during a merge: |
|
403 | 403 | |
|
404 | 404 | $ hg up -q default |
|
405 | 405 | $ hg merge foo |
|
406 | 406 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
407 | 407 | (branch merge, don't forget to commit) |
|
408 | 408 | $ hg ci --amend |
|
409 | abort: cannot amend while merging | |
|
409 | abort: cannot amend changesets while merging | |
|
410 | 410 | [20] |
|
411 | 411 | $ hg ci -m 'merge' |
|
412 | 412 | |
|
413 | 413 | Refuse to amend if there is a merge conflict (issue5805): |
|
414 | 414 | |
|
415 | 415 | $ hg up -q foo |
|
416 | 416 | $ echo c > a |
|
417 | 417 | $ hg up default -t :fail |
|
418 | 418 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
419 | 419 | use 'hg resolve' to retry unresolved file merges |
|
420 | 420 | [1] |
|
421 | 421 | $ hg resolve -l |
|
422 | 422 | U a |
|
423 | 423 | |
|
424 | 424 | $ hg ci --amend |
|
425 | 425 | abort: unresolved merge conflicts (see 'hg help resolve') |
|
426 | 426 | [20] |
|
427 | 427 | |
|
428 | 428 | $ hg up -qC . |
|
429 | 429 | |
|
430 | 430 | Follow copies/renames: |
|
431 | 431 | |
|
432 | 432 | $ hg mv b c |
|
433 | 433 | $ hg ci -m 'b -> c' |
|
434 | 434 | $ hg mv c d |
|
435 | 435 | $ hg ci --amend -m 'b -> d' |
|
436 | 436 | saved backup bundle to $TESTTMP/.hg/strip-backup/42f3f27a067d-f23cc9f7-amend.hg |
|
437 | 437 | $ hg st --rev '.^' --copies d |
|
438 | 438 | A d |
|
439 | 439 | b |
|
440 | 440 | $ hg cp d e |
|
441 | 441 | $ hg ci -m 'e = d' |
|
442 | 442 | $ hg cp e f |
|
443 | 443 | $ hg ci --amend -m 'f = d' |
|
444 | 444 | saved backup bundle to $TESTTMP/.hg/strip-backup/9198f73182d5-251d584a-amend.hg |
|
445 | 445 | $ hg st --rev '.^' --copies f |
|
446 | 446 | A f |
|
447 | 447 | d |
|
448 | 448 | |
|
449 | 449 | $ mv f f.orig |
|
450 | 450 | $ hg rm -A f |
|
451 | 451 | $ hg ci -m removef |
|
452 | 452 | $ hg cp a f |
|
453 | 453 | $ mv f.orig f |
|
454 | 454 | $ hg ci --amend -m replacef |
|
455 | 455 | saved backup bundle to $TESTTMP/.hg/strip-backup/f0993ab6b482-eda301bf-amend.hg |
|
456 | 456 | $ hg st --change . --copies |
|
457 | 457 | $ hg log -r . --template "{file_copies}\n" |
|
458 | 458 | |
|
459 | 459 | |
|
460 | 460 | Move added file (issue3410): |
|
461 | 461 | |
|
462 | 462 | $ echo g >> g |
|
463 | 463 | $ hg ci -Am g |
|
464 | 464 | adding g |
|
465 | 465 | $ hg mv g h |
|
466 | 466 | $ hg ci --amend |
|
467 | 467 | saved backup bundle to $TESTTMP/.hg/strip-backup/58585e3f095c-0f5ebcda-amend.hg |
|
468 | 468 | $ hg st --change . --copies h |
|
469 | 469 | A h |
|
470 | 470 | $ hg log -r . --template "{file_copies}\n" |
|
471 | 471 | |
|
472 | 472 | |
|
473 | 473 | Can't rollback an amend: |
|
474 | 474 | |
|
475 | 475 | $ hg rollback |
|
476 | 476 | no rollback information available |
|
477 | 477 | [1] |
|
478 | 478 | |
|
479 | 479 | Preserve extra dict (issue3430): |
|
480 | 480 | |
|
481 | 481 | $ hg branch a |
|
482 | 482 | marked working directory as branch a |
|
483 | 483 | (branches are permanent and global, did you want a bookmark?) |
|
484 | 484 | $ echo a >> a |
|
485 | 485 | $ hg ci -ma |
|
486 | 486 | $ hg ci --amend -m "a'" |
|
487 | 487 | saved backup bundle to $TESTTMP/.hg/strip-backup/39a162f1d65e-9dfe13d8-amend.hg |
|
488 | 488 | $ hg log -r . --template "{branch}\n" |
|
489 | 489 | a |
|
490 | 490 | $ hg ci --amend -m "a''" |
|
491 | 491 | saved backup bundle to $TESTTMP/.hg/strip-backup/d5ca7b1ac72b-0b4c1a34-amend.hg |
|
492 | 492 | $ hg log -r . --template "{branch}\n" |
|
493 | 493 | a |
|
494 | 494 | |
|
495 | 495 | Also preserve other entries in the dict that are in the old commit, |
|
496 | 496 | first graft something so there's an additional entry: |
|
497 | 497 | |
|
498 | 498 | $ hg up 0 -q |
|
499 | 499 | $ echo z > z |
|
500 | 500 | $ hg ci -Am 'fork' |
|
501 | 501 | adding z |
|
502 | 502 | created new head |
|
503 | 503 | $ hg up 11 |
|
504 | 504 | 5 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
505 | 505 | $ hg graft 12 |
|
506 | 506 | grafting 12:2647734878ef "fork" (tip) |
|
507 | 507 | $ hg ci --amend -m 'graft amend' |
|
508 | 508 | saved backup bundle to $TESTTMP/.hg/strip-backup/fe8c6f7957ca-25638666-amend.hg |
|
509 | 509 | $ hg log -r . --debug | grep extra |
|
510 | 510 | extra: amend_source=fe8c6f7957ca1665ed77496ed7a07657d469ac60 |
|
511 | 511 | extra: branch=a |
|
512 | 512 | extra: source=2647734878ef0236dda712fae9c1651cf694ea8a |
|
513 | 513 | |
|
514 | 514 | Preserve phase |
|
515 | 515 | |
|
516 | 516 | $ hg phase '.^::.' |
|
517 | 517 | 11: draft |
|
518 | 518 | 13: draft |
|
519 | 519 | $ hg phase --secret --force . |
|
520 | 520 | $ hg phase '.^::.' |
|
521 | 521 | 11: draft |
|
522 | 522 | 13: secret |
|
523 | 523 | $ hg commit --amend -m 'amend for phase' -q |
|
524 | 524 | $ hg phase '.^::.' |
|
525 | 525 | 11: draft |
|
526 | 526 | 13: secret |
|
527 | 527 | |
|
528 | 528 | Test amend with obsolete |
|
529 | 529 | --------------------------- |
|
530 | 530 | |
|
531 | 531 | Enable obsolete |
|
532 | 532 | |
|
533 | 533 | $ cat >> $HGRCPATH << EOF |
|
534 | 534 | > [experimental] |
|
535 | 535 | > evolution.createmarkers=True |
|
536 | 536 | > evolution.allowunstable=True |
|
537 | 537 | > EOF |
|
538 | 538 | |
|
539 | 539 | Amend with no files changes |
|
540 | 540 | |
|
541 | 541 | $ hg id -n |
|
542 | 542 | 13 |
|
543 | 543 | $ hg ci --amend -m 'babar' |
|
544 | 544 | $ hg id -n |
|
545 | 545 | 14 |
|
546 | 546 | $ hg log -Gl 3 --style=compact |
|
547 | 547 | @ 14[tip]:11 682950e85999 1970-01-01 00:00 +0000 test |
|
548 | 548 | | babar |
|
549 | 549 | | |
|
550 | 550 | | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test |
|
551 | 551 | | | fork |
|
552 | 552 | | ~ |
|
553 | 553 | o 11 0ddb275cfad1 1970-01-01 00:00 +0000 test |
|
554 | 554 | | a'' |
|
555 | 555 | ~ |
|
556 | 556 | $ hg log -Gl 4 --hidden --style=compact |
|
557 | 557 | @ 14[tip]:11 682950e85999 1970-01-01 00:00 +0000 test |
|
558 | 558 | | babar |
|
559 | 559 | | |
|
560 | 560 | | x 13:11 5167600b0f7a 1970-01-01 00:00 +0000 test |
|
561 | 561 | |/ amend for phase |
|
562 | 562 | | |
|
563 | 563 | | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test |
|
564 | 564 | | | fork |
|
565 | 565 | | ~ |
|
566 | 566 | o 11 0ddb275cfad1 1970-01-01 00:00 +0000 test |
|
567 | 567 | | a'' |
|
568 | 568 | ~ |
|
569 | 569 | |
|
570 | 570 | Amend with files changes |
|
571 | 571 | |
|
572 | 572 | (note: the extra commit over 15 is a temporary junk I would be happy to get |
|
573 | 573 | ride of) |
|
574 | 574 | |
|
575 | 575 | $ echo 'babar' >> a |
|
576 | 576 | $ hg commit --amend |
|
577 | 577 | $ hg log -Gl 6 --hidden --style=compact |
|
578 | 578 | @ 15[tip]:11 a5b42b49b0d5 1970-01-01 00:00 +0000 test |
|
579 | 579 | | babar |
|
580 | 580 | | |
|
581 | 581 | | x 14:11 682950e85999 1970-01-01 00:00 +0000 test |
|
582 | 582 | |/ babar |
|
583 | 583 | | |
|
584 | 584 | | x 13:11 5167600b0f7a 1970-01-01 00:00 +0000 test |
|
585 | 585 | |/ amend for phase |
|
586 | 586 | | |
|
587 | 587 | | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test |
|
588 | 588 | | | fork |
|
589 | 589 | | ~ |
|
590 | 590 | o 11 0ddb275cfad1 1970-01-01 00:00 +0000 test |
|
591 | 591 | | a'' |
|
592 | 592 | | |
|
593 | 593 | o 10 5fa75032e226 1970-01-01 00:00 +0000 test |
|
594 | 594 | | g |
|
595 | 595 | ~ |
|
596 | 596 | |
|
597 | 597 | |
|
598 | 598 | Test that amend does not make it easy to create obsolescence cycle |
|
599 | 599 | --------------------------------------------------------------------- |
|
600 | 600 | |
|
601 | 601 | $ hg id -r 14 --hidden |
|
602 | 602 | 682950e85999 (a) |
|
603 | 603 | $ hg revert -ar 14 --hidden |
|
604 | 604 | reverting a |
|
605 | 605 | $ hg commit --amend |
|
606 | 606 | $ hg id |
|
607 | 607 | 37973c7e0b61 (a) tip |
|
608 | 608 | |
|
609 | 609 | Test that rewriting leaving instability behind is allowed |
|
610 | 610 | --------------------------------------------------------------------- |
|
611 | 611 | |
|
612 | 612 | $ hg up '.^' |
|
613 | 613 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
614 | 614 | $ echo 'b' >> a |
|
615 | 615 | $ hg log --style compact -r 'children(.)' |
|
616 | 616 | 16[tip]:11 37973c7e0b61 1970-01-01 00:00 +0000 test |
|
617 | 617 | babar |
|
618 | 618 | |
|
619 | 619 | $ hg commit --amend |
|
620 | 620 | 1 new orphan changesets |
|
621 | 621 | $ hg log -r 'orphan()' |
|
622 | 622 | changeset: 16:37973c7e0b61 |
|
623 | 623 | branch: a |
|
624 | 624 | parent: 11:0ddb275cfad1 |
|
625 | 625 | user: test |
|
626 | 626 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
627 | 627 | instability: orphan |
|
628 | 628 | summary: babar |
|
629 | 629 | |
|
630 | 630 | |
|
631 | 631 | Amend a merge changeset (with renames and conflicts from the second parent): |
|
632 | 632 | |
|
633 | 633 | $ hg up -q default |
|
634 | 634 | $ hg branch -q bar |
|
635 | 635 | $ hg cp a aa |
|
636 | 636 | $ hg mv z zz |
|
637 | 637 | $ echo cc > cc |
|
638 | 638 | $ hg add cc |
|
639 | 639 | $ hg ci -m aazzcc |
|
640 | 640 | $ hg up -q default |
|
641 | 641 | $ echo a >> a |
|
642 | 642 | $ echo dd > cc |
|
643 | 643 | $ hg add cc |
|
644 | 644 | $ hg ci -m aa |
|
645 | 645 | $ hg merge -q bar |
|
646 | 646 | warning: conflicts while merging cc! (edit, then use 'hg resolve --mark') |
|
647 | 647 | [1] |
|
648 | 648 | $ hg resolve -m cc |
|
649 | 649 | (no more unresolved files) |
|
650 | 650 | $ hg ci -m 'merge bar' |
|
651 | 651 | $ hg log --config diff.git=1 -pr . |
|
652 | 652 | changeset: 20:5aba7f3726e6 |
|
653 | 653 | tag: tip |
|
654 | 654 | parent: 19:30d96aeaf27b |
|
655 | 655 | parent: 18:1aa437659d19 |
|
656 | 656 | user: test |
|
657 | 657 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
658 | 658 | summary: merge bar |
|
659 | 659 | |
|
660 | 660 | diff --git a/a b/aa |
|
661 | 661 | copy from a |
|
662 | 662 | copy to aa |
|
663 | 663 | diff --git a/cc b/cc |
|
664 | 664 | --- a/cc |
|
665 | 665 | +++ b/cc |
|
666 | 666 | @@ -1,1 +1,5 @@ |
|
667 | 667 | +<<<<<<< working copy: 30d96aeaf27b - test: aa |
|
668 | 668 | dd |
|
669 | 669 | +======= |
|
670 | 670 | +cc |
|
671 | 671 | +>>>>>>> merge rev: 1aa437659d19 bar - test: aazzcc |
|
672 | 672 | diff --git a/z b/zz |
|
673 | 673 | rename from z |
|
674 | 674 | rename to zz |
|
675 | 675 | |
|
676 | 676 | $ hg debugrename aa |
|
677 | 677 | aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e |
|
678 | 678 | $ hg debugrename zz |
|
679 | 679 | zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a |
|
680 | 680 | $ hg debugrename cc |
|
681 | 681 | cc not renamed |
|
682 | 682 | $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -m 'merge bar (amend message)' --edit |
|
683 | 683 | HGEDITFORM=commit.amend.merge |
|
684 | 684 | $ hg log --config diff.git=1 -pr . |
|
685 | 685 | changeset: 21:4b0631ef043e |
|
686 | 686 | tag: tip |
|
687 | 687 | parent: 19:30d96aeaf27b |
|
688 | 688 | parent: 18:1aa437659d19 |
|
689 | 689 | user: test |
|
690 | 690 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
691 | 691 | summary: merge bar (amend message) |
|
692 | 692 | |
|
693 | 693 | diff --git a/a b/aa |
|
694 | 694 | copy from a |
|
695 | 695 | copy to aa |
|
696 | 696 | diff --git a/cc b/cc |
|
697 | 697 | --- a/cc |
|
698 | 698 | +++ b/cc |
|
699 | 699 | @@ -1,1 +1,5 @@ |
|
700 | 700 | +<<<<<<< working copy: 30d96aeaf27b - test: aa |
|
701 | 701 | dd |
|
702 | 702 | +======= |
|
703 | 703 | +cc |
|
704 | 704 | +>>>>>>> merge rev: 1aa437659d19 bar - test: aazzcc |
|
705 | 705 | diff --git a/z b/zz |
|
706 | 706 | rename from z |
|
707 | 707 | rename to zz |
|
708 | 708 | |
|
709 | 709 | $ hg debugrename aa |
|
710 | 710 | aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e |
|
711 | 711 | $ hg debugrename zz |
|
712 | 712 | zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a |
|
713 | 713 | $ hg debugrename cc |
|
714 | 714 | cc not renamed |
|
715 | 715 | $ hg mv zz z |
|
716 | 716 | $ hg ci --amend -m 'merge bar (undo rename)' |
|
717 | 717 | $ hg log --config diff.git=1 -pr . |
|
718 | 718 | changeset: 22:06423be42d60 |
|
719 | 719 | tag: tip |
|
720 | 720 | parent: 19:30d96aeaf27b |
|
721 | 721 | parent: 18:1aa437659d19 |
|
722 | 722 | user: test |
|
723 | 723 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
724 | 724 | summary: merge bar (undo rename) |
|
725 | 725 | |
|
726 | 726 | diff --git a/a b/aa |
|
727 | 727 | copy from a |
|
728 | 728 | copy to aa |
|
729 | 729 | diff --git a/cc b/cc |
|
730 | 730 | --- a/cc |
|
731 | 731 | +++ b/cc |
|
732 | 732 | @@ -1,1 +1,5 @@ |
|
733 | 733 | +<<<<<<< working copy: 30d96aeaf27b - test: aa |
|
734 | 734 | dd |
|
735 | 735 | +======= |
|
736 | 736 | +cc |
|
737 | 737 | +>>>>>>> merge rev: 1aa437659d19 bar - test: aazzcc |
|
738 | 738 | |
|
739 | 739 | $ hg debugrename z |
|
740 | 740 | z not renamed |
|
741 | 741 | |
|
742 | 742 | Amend a merge changeset (with renames during the merge): |
|
743 | 743 | |
|
744 | 744 | $ hg up -q bar |
|
745 | 745 | $ echo x > x |
|
746 | 746 | $ hg add x |
|
747 | 747 | $ hg ci -m x |
|
748 | 748 | $ hg up -q default |
|
749 | 749 | $ hg merge -q bar |
|
750 | 750 | $ hg mv aa aaa |
|
751 | 751 | $ echo aa >> aaa |
|
752 | 752 | $ hg ci -m 'merge bar again' |
|
753 | 753 | $ hg log --config diff.git=1 -pr . |
|
754 | 754 | changeset: 24:a89974a20457 |
|
755 | 755 | tag: tip |
|
756 | 756 | parent: 22:06423be42d60 |
|
757 | 757 | parent: 23:4c94d5bc65f5 |
|
758 | 758 | user: test |
|
759 | 759 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
760 | 760 | summary: merge bar again |
|
761 | 761 | |
|
762 | 762 | diff --git a/aa b/aa |
|
763 | 763 | deleted file mode 100644 |
|
764 | 764 | --- a/aa |
|
765 | 765 | +++ /dev/null |
|
766 | 766 | @@ -1,2 +0,0 @@ |
|
767 | 767 | -a |
|
768 | 768 | -a |
|
769 | 769 | diff --git a/aaa b/aaa |
|
770 | 770 | new file mode 100644 |
|
771 | 771 | --- /dev/null |
|
772 | 772 | +++ b/aaa |
|
773 | 773 | @@ -0,0 +1,3 @@ |
|
774 | 774 | +a |
|
775 | 775 | +a |
|
776 | 776 | +aa |
|
777 | 777 | diff --git a/x b/x |
|
778 | 778 | new file mode 100644 |
|
779 | 779 | --- /dev/null |
|
780 | 780 | +++ b/x |
|
781 | 781 | @@ -0,0 +1,1 @@ |
|
782 | 782 | +x |
|
783 | 783 | |
|
784 | 784 | $ hg debugrename aaa |
|
785 | 785 | aaa renamed from aa:37d9b5d994eab34eda9c16b195ace52c7b129980 |
|
786 | 786 | |
|
787 | 787 | Update to p1 with 'aaa' modified. 'aaa' was renamed from 'aa' in p2. 'aa' exists |
|
788 | 788 | in p1 too, but it was recorded as copied from p2. |
|
789 | 789 | $ echo modified >> aaa |
|
790 | 790 | $ hg co -m '.^' -t :merge3 |
|
791 | 791 | file 'aaa' was deleted in other [destination] but was modified in local [working copy]. |
|
792 | 792 | You can use (c)hanged version, (d)elete, or leave (u)nresolved. |
|
793 | 793 | What do you want to do? u |
|
794 | 794 | 1 files updated, 0 files merged, 1 files removed, 1 files unresolved |
|
795 | 795 | use 'hg resolve' to retry unresolved file merges |
|
796 | 796 | [1] |
|
797 | 797 | $ hg co -C tip |
|
798 | 798 | 2 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
799 | 799 | |
|
800 | 800 | $ hg mv aaa aa |
|
801 | 801 | $ hg ci --amend -m 'merge bar again (undo rename)' |
|
802 | 802 | $ hg log --config diff.git=1 -pr . |
|
803 | 803 | changeset: 25:282080768800 |
|
804 | 804 | tag: tip |
|
805 | 805 | parent: 22:06423be42d60 |
|
806 | 806 | parent: 23:4c94d5bc65f5 |
|
807 | 807 | user: test |
|
808 | 808 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
809 | 809 | summary: merge bar again (undo rename) |
|
810 | 810 | |
|
811 | 811 | diff --git a/aa b/aa |
|
812 | 812 | --- a/aa |
|
813 | 813 | +++ b/aa |
|
814 | 814 | @@ -1,2 +1,3 @@ |
|
815 | 815 | a |
|
816 | 816 | a |
|
817 | 817 | +aa |
|
818 | 818 | diff --git a/x b/x |
|
819 | 819 | new file mode 100644 |
|
820 | 820 | --- /dev/null |
|
821 | 821 | +++ b/x |
|
822 | 822 | @@ -0,0 +1,1 @@ |
|
823 | 823 | +x |
|
824 | 824 | |
|
825 | 825 | $ hg debugrename aa |
|
826 | 826 | aa not renamed |
|
827 | 827 | $ hg debugrename -r '.^' aa |
|
828 | 828 | aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e |
|
829 | 829 | |
|
830 | 830 | Amend a merge changeset (with manifest-level conflicts): |
|
831 | 831 | |
|
832 | 832 | $ hg up -q bar |
|
833 | 833 | $ hg rm aa |
|
834 | 834 | $ hg ci -m 'rm aa' |
|
835 | 835 | $ hg up -q default |
|
836 | 836 | $ echo aa >> aa |
|
837 | 837 | $ hg ci -m aa |
|
838 | 838 | $ hg merge -q bar --config ui.interactive=True << EOF |
|
839 | 839 | > c |
|
840 | 840 | > EOF |
|
841 | 841 | file 'aa' was deleted in other [merge rev] but was modified in local [working copy]. |
|
842 | 842 | You can use (c)hanged version, (d)elete, or leave (u)nresolved. |
|
843 | 843 | What do you want to do? c |
|
844 | 844 | $ hg ci -m 'merge bar (with conflicts)' |
|
845 | 845 | $ hg log --config diff.git=1 -pr . |
|
846 | 846 | changeset: 28:ed15db12298d |
|
847 | 847 | tag: tip |
|
848 | 848 | parent: 27:eb5adec0b43b |
|
849 | 849 | parent: 26:67db8847a540 |
|
850 | 850 | user: test |
|
851 | 851 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
852 | 852 | summary: merge bar (with conflicts) |
|
853 | 853 | |
|
854 | 854 | |
|
855 | 855 | $ hg rm aa |
|
856 | 856 | $ hg ci --amend -m 'merge bar (with conflicts, amended)' |
|
857 | 857 | $ hg log --config diff.git=1 -pr . |
|
858 | 858 | changeset: 29:0eeafd043f63 |
|
859 | 859 | tag: tip |
|
860 | 860 | parent: 27:eb5adec0b43b |
|
861 | 861 | parent: 26:67db8847a540 |
|
862 | 862 | user: test |
|
863 | 863 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
864 | 864 | summary: merge bar (with conflicts, amended) |
|
865 | 865 | |
|
866 | 866 | diff --git a/aa b/aa |
|
867 | 867 | deleted file mode 100644 |
|
868 | 868 | --- a/aa |
|
869 | 869 | +++ /dev/null |
|
870 | 870 | @@ -1,4 +0,0 @@ |
|
871 | 871 | -a |
|
872 | 872 | -a |
|
873 | 873 | -aa |
|
874 | 874 | -aa |
|
875 | 875 | |
|
876 | 876 | Issue 3445: amending with --close-branch a commit that created a new head should fail |
|
877 | 877 | This shouldn't be possible: |
|
878 | 878 | |
|
879 | 879 | $ hg up -q default |
|
880 | 880 | $ hg branch closewithamend |
|
881 | 881 | marked working directory as branch closewithamend |
|
882 | 882 | $ echo foo > foo |
|
883 | 883 | $ hg add foo |
|
884 | 884 | $ hg ci -m.. |
|
885 | 885 | $ hg ci --amend --close-branch -m 'closing' |
|
886 | 886 | abort: can only close branch heads |
|
887 | 887 | [10] |
|
888 | 888 | |
|
889 | 889 | This silliness fails: |
|
890 | 890 | |
|
891 | 891 | $ hg branch silliness |
|
892 | 892 | marked working directory as branch silliness |
|
893 | 893 | $ echo b >> b |
|
894 | 894 | $ hg ci --close-branch -m'open and close' |
|
895 | 895 | abort: branch "silliness" has no heads to close |
|
896 | 896 | [10] |
|
897 | 897 | |
|
898 | 898 | Test that amend with --secret creates new secret changeset forcibly |
|
899 | 899 | --------------------------------------------------------------------- |
|
900 | 900 | |
|
901 | 901 | $ hg phase '.^::.' |
|
902 | 902 | 29: draft |
|
903 | 903 | 30: draft |
|
904 | 904 | $ hg commit --amend --secret -m 'amend as secret' -q |
|
905 | 905 | $ hg phase '.^::.' |
|
906 | 906 | 29: draft |
|
907 | 907 | 31: secret |
|
908 | 908 | |
|
909 | 909 | Test that amend with --edit invokes editor forcibly |
|
910 | 910 | --------------------------------------------------- |
|
911 | 911 | |
|
912 | 912 | $ hg parents --template "{desc}\n" |
|
913 | 913 | amend as secret |
|
914 | 914 | $ HGEDITOR=cat hg commit --amend -m "editor should be suppressed" |
|
915 | 915 | $ hg parents --template "{desc}\n" |
|
916 | 916 | editor should be suppressed |
|
917 | 917 | |
|
918 | 918 | $ hg status --rev '.^1::.' |
|
919 | 919 | A foo |
|
920 | 920 | $ HGEDITOR=cat hg commit --amend -m "editor should be invoked" --edit |
|
921 | 921 | editor should be invoked |
|
922 | 922 | |
|
923 | 923 | |
|
924 | 924 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
925 | 925 | HG: Leave message empty to abort commit. |
|
926 | 926 | HG: -- |
|
927 | 927 | HG: user: test |
|
928 | 928 | HG: branch 'silliness' |
|
929 | 929 | HG: added foo |
|
930 | 930 | $ hg parents --template "{desc}\n" |
|
931 | 931 | editor should be invoked |
|
932 | 932 | |
|
933 | 933 | Test that amend with --no-edit avoids the editor |
|
934 | 934 | ------------------------------------------------ |
|
935 | 935 | |
|
936 | 936 | $ hg commit --amend -m "before anything happens" |
|
937 | 937 | $ hg parents --template "{desc}\n" |
|
938 | 938 | before anything happens |
|
939 | 939 | $ HGEDITOR=cat hg commit --amend --no-edit -m "editor should be suppressed" |
|
940 | 940 | $ hg parents --template "{desc}\n" |
|
941 | 941 | editor should be suppressed |
|
942 | 942 | |
|
943 | 943 | (We need a file change here since we won't have a message change) |
|
944 | 944 | $ cp foo foo.orig |
|
945 | 945 | $ echo hi >> foo |
|
946 | 946 | $ HGEDITOR=cat hg commit --amend --no-edit |
|
947 | 947 | $ hg parents --template "{desc}\n" |
|
948 | 948 | editor should be suppressed |
|
949 | 949 | $ hg status -mar |
|
950 | 950 | (Let's undo adding that "hi" so later tests don't need to be adjusted) |
|
951 | 951 | $ mv foo.orig foo |
|
952 | 952 | $ hg commit --amend --no-edit |
|
953 | 953 | |
|
954 | 954 | Test that "diff()" in committemplate works correctly for amending |
|
955 | 955 | ----------------------------------------------------------------- |
|
956 | 956 | |
|
957 | 957 | $ cat >> .hg/hgrc <<EOF |
|
958 | 958 | > [committemplate] |
|
959 | 959 | > changeset.commit.amend = {desc}\n |
|
960 | 960 | > HG: M: {file_mods} |
|
961 | 961 | > HG: A: {file_adds} |
|
962 | 962 | > HG: R: {file_dels} |
|
963 | 963 | > {splitlines(diff()) % 'HG: {line}\n'} |
|
964 | 964 | > EOF |
|
965 | 965 | |
|
966 | 966 | $ hg parents --template "M: {file_mods}\nA: {file_adds}\nR: {file_dels}\n" |
|
967 | 967 | M: |
|
968 | 968 | A: foo |
|
969 | 969 | R: |
|
970 | 970 | $ hg status -amr |
|
971 | 971 | $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of foo" |
|
972 | 972 | expecting diff of foo |
|
973 | 973 | |
|
974 | 974 | HG: M: |
|
975 | 975 | HG: A: foo |
|
976 | 976 | HG: R: |
|
977 | 977 | HG: diff -r 0eeafd043f63 foo |
|
978 | 978 | HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
979 | 979 | HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000 |
|
980 | 980 | HG: @@ -0,0 +1,1 @@ |
|
981 | 981 | HG: +foo |
|
982 | 982 | |
|
983 | 983 | $ echo y > y |
|
984 | 984 | $ hg add y |
|
985 | 985 | $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of foo and y" |
|
986 | 986 | expecting diff of foo and y |
|
987 | 987 | |
|
988 | 988 | HG: M: |
|
989 | 989 | HG: A: foo y |
|
990 | 990 | HG: R: |
|
991 | 991 | HG: diff -r 0eeafd043f63 foo |
|
992 | 992 | HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
993 | 993 | HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000 |
|
994 | 994 | HG: @@ -0,0 +1,1 @@ |
|
995 | 995 | HG: +foo |
|
996 | 996 | HG: diff -r 0eeafd043f63 y |
|
997 | 997 | HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
998 | 998 | HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000 |
|
999 | 999 | HG: @@ -0,0 +1,1 @@ |
|
1000 | 1000 | HG: +y |
|
1001 | 1001 | |
|
1002 | 1002 | $ hg rm a |
|
1003 | 1003 | $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of a, foo and y" |
|
1004 | 1004 | expecting diff of a, foo and y |
|
1005 | 1005 | |
|
1006 | 1006 | HG: M: |
|
1007 | 1007 | HG: A: foo y |
|
1008 | 1008 | HG: R: a |
|
1009 | 1009 | HG: diff -r 0eeafd043f63 a |
|
1010 | 1010 | HG: --- a/a Thu Jan 01 00:00:00 1970 +0000 |
|
1011 | 1011 | HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
1012 | 1012 | HG: @@ -1,2 +0,0 @@ |
|
1013 | 1013 | HG: -a |
|
1014 | 1014 | HG: -a |
|
1015 | 1015 | HG: diff -r 0eeafd043f63 foo |
|
1016 | 1016 | HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
1017 | 1017 | HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000 |
|
1018 | 1018 | HG: @@ -0,0 +1,1 @@ |
|
1019 | 1019 | HG: +foo |
|
1020 | 1020 | HG: diff -r 0eeafd043f63 y |
|
1021 | 1021 | HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
1022 | 1022 | HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000 |
|
1023 | 1023 | HG: @@ -0,0 +1,1 @@ |
|
1024 | 1024 | HG: +y |
|
1025 | 1025 | |
|
1026 | 1026 | $ hg rm x |
|
1027 | 1027 | $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of a, foo, x and y" |
|
1028 | 1028 | expecting diff of a, foo, x and y |
|
1029 | 1029 | |
|
1030 | 1030 | HG: M: |
|
1031 | 1031 | HG: A: foo y |
|
1032 | 1032 | HG: R: a x |
|
1033 | 1033 | HG: diff -r 0eeafd043f63 a |
|
1034 | 1034 | HG: --- a/a Thu Jan 01 00:00:00 1970 +0000 |
|
1035 | 1035 | HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
1036 | 1036 | HG: @@ -1,2 +0,0 @@ |
|
1037 | 1037 | HG: -a |
|
1038 | 1038 | HG: -a |
|
1039 | 1039 | HG: diff -r 0eeafd043f63 foo |
|
1040 | 1040 | HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
1041 | 1041 | HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000 |
|
1042 | 1042 | HG: @@ -0,0 +1,1 @@ |
|
1043 | 1043 | HG: +foo |
|
1044 | 1044 | HG: diff -r 0eeafd043f63 x |
|
1045 | 1045 | HG: --- a/x Thu Jan 01 00:00:00 1970 +0000 |
|
1046 | 1046 | HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
1047 | 1047 | HG: @@ -1,1 +0,0 @@ |
|
1048 | 1048 | HG: -x |
|
1049 | 1049 | HG: diff -r 0eeafd043f63 y |
|
1050 | 1050 | HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
1051 | 1051 | HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000 |
|
1052 | 1052 | HG: @@ -0,0 +1,1 @@ |
|
1053 | 1053 | HG: +y |
|
1054 | 1054 | |
|
1055 | 1055 | $ echo cccc >> cc |
|
1056 | 1056 | $ hg status -amr |
|
1057 | 1057 | M cc |
|
1058 | 1058 | $ HGEDITOR=cat hg commit --amend -e -m "cc should be excluded" -X cc |
|
1059 | 1059 | cc should be excluded |
|
1060 | 1060 | |
|
1061 | 1061 | HG: M: |
|
1062 | 1062 | HG: A: foo y |
|
1063 | 1063 | HG: R: a x |
|
1064 | 1064 | HG: diff -r 0eeafd043f63 a |
|
1065 | 1065 | HG: --- a/a Thu Jan 01 00:00:00 1970 +0000 |
|
1066 | 1066 | HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
1067 | 1067 | HG: @@ -1,2 +0,0 @@ |
|
1068 | 1068 | HG: -a |
|
1069 | 1069 | HG: -a |
|
1070 | 1070 | HG: diff -r 0eeafd043f63 foo |
|
1071 | 1071 | HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
1072 | 1072 | HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000 |
|
1073 | 1073 | HG: @@ -0,0 +1,1 @@ |
|
1074 | 1074 | HG: +foo |
|
1075 | 1075 | HG: diff -r 0eeafd043f63 x |
|
1076 | 1076 | HG: --- a/x Thu Jan 01 00:00:00 1970 +0000 |
|
1077 | 1077 | HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
1078 | 1078 | HG: @@ -1,1 +0,0 @@ |
|
1079 | 1079 | HG: -x |
|
1080 | 1080 | HG: diff -r 0eeafd043f63 y |
|
1081 | 1081 | HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
1082 | 1082 | HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000 |
|
1083 | 1083 | HG: @@ -0,0 +1,1 @@ |
|
1084 | 1084 | HG: +y |
|
1085 | 1085 | |
|
1086 | 1086 | Check for issue4405 |
|
1087 | 1087 | ------------------- |
|
1088 | 1088 | |
|
1089 | 1089 | Setup the repo with a file that gets moved in a second commit. |
|
1090 | 1090 | $ hg init repo |
|
1091 | 1091 | $ cd repo |
|
1092 | 1092 | $ touch a0 |
|
1093 | 1093 | $ hg add a0 |
|
1094 | 1094 | $ hg commit -m a0 |
|
1095 | 1095 | $ hg mv a0 a1 |
|
1096 | 1096 | $ hg commit -m a1 |
|
1097 | 1097 | $ hg up -q 0 |
|
1098 | 1098 | $ hg log -G --template '{rev} {desc}' |
|
1099 | 1099 | o 1 a1 |
|
1100 | 1100 | | |
|
1101 | 1101 | @ 0 a0 |
|
1102 | 1102 | |
|
1103 | 1103 | |
|
1104 | 1104 | Now we branch the repro, but re-use the file contents, so we have a divergence |
|
1105 | 1105 | in the file revlog topology and the changelog topology. |
|
1106 | 1106 | $ hg revert --rev 1 --all |
|
1107 | 1107 | removing a0 |
|
1108 | 1108 | adding a1 |
|
1109 | 1109 | $ hg ci -qm 'a1-amend' |
|
1110 | 1110 | $ hg log -G --template '{rev} {desc}' |
|
1111 | 1111 | @ 2 a1-amend |
|
1112 | 1112 | | |
|
1113 | 1113 | | o 1 a1 |
|
1114 | 1114 | |/ |
|
1115 | 1115 | o 0 a0 |
|
1116 | 1116 | |
|
1117 | 1117 | |
|
1118 | 1118 | The way mercurial does amends is by folding the working copy and old commit |
|
1119 | 1119 | together into another commit (rev 3). During this process, _findlimit is called |
|
1120 | 1120 | to check how far back to look for the transitive closure of file copy |
|
1121 | 1121 | information, but due to the divergence of the filelog and changelog graph |
|
1122 | 1122 | topologies, before _findlimit was fixed, it returned a rev which was not far |
|
1123 | 1123 | enough back in this case. |
|
1124 | 1124 | $ hg mv a1 a2 |
|
1125 | 1125 | $ hg status --copies --rev 0 |
|
1126 | 1126 | A a2 |
|
1127 | 1127 | a0 |
|
1128 | 1128 | R a0 |
|
1129 | 1129 | $ hg ci --amend -q |
|
1130 | 1130 | $ hg log -G --template '{rev} {desc}' |
|
1131 | 1131 | @ 3 a1-amend |
|
1132 | 1132 | | |
|
1133 | 1133 | | o 1 a1 |
|
1134 | 1134 | |/ |
|
1135 | 1135 | o 0 a0 |
|
1136 | 1136 | |
|
1137 | 1137 | |
|
1138 | 1138 | Before the fix, the copy information was lost. |
|
1139 | 1139 | $ hg status --copies --rev 0 |
|
1140 | 1140 | A a2 |
|
1141 | 1141 | a0 |
|
1142 | 1142 | R a0 |
|
1143 | 1143 | $ cd .. |
|
1144 | 1144 | |
|
1145 | 1145 | Check that amend properly preserve rename from directory rename (issue-4516) |
|
1146 | 1146 | |
|
1147 | 1147 | If a parent of the merge renames a full directory, any files added to the old |
|
1148 | 1148 | directory in the other parent will be renamed to the new directory. For some |
|
1149 | 1149 | reason, the rename metadata was when amending such merge. This test ensure we |
|
1150 | 1150 | do not regress. We have a dedicated repo because it needs a setup with renamed |
|
1151 | 1151 | directory) |
|
1152 | 1152 | |
|
1153 | 1153 | $ hg init issue4516 |
|
1154 | 1154 | $ cd issue4516 |
|
1155 | 1155 | $ mkdir olddirname |
|
1156 | 1156 | $ echo line1 > olddirname/commonfile.py |
|
1157 | 1157 | $ hg add olddirname/commonfile.py |
|
1158 | 1158 | $ hg ci -m first |
|
1159 | 1159 | |
|
1160 | 1160 | $ hg branch newdirname |
|
1161 | 1161 | marked working directory as branch newdirname |
|
1162 | 1162 | (branches are permanent and global, did you want a bookmark?) |
|
1163 | 1163 | $ hg mv olddirname newdirname |
|
1164 | 1164 | moving olddirname/commonfile.py to newdirname/commonfile.py |
|
1165 | 1165 | $ hg ci -m rename |
|
1166 | 1166 | |
|
1167 | 1167 | $ hg update default |
|
1168 | 1168 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1169 | 1169 | $ echo line1 > olddirname/newfile.py |
|
1170 | 1170 | $ hg add olddirname/newfile.py |
|
1171 | 1171 | $ hg ci -m log |
|
1172 | 1172 | |
|
1173 | 1173 | $ hg up newdirname |
|
1174 | 1174 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
1175 | 1175 | $ # create newdirname/newfile.py |
|
1176 | 1176 | $ hg merge default |
|
1177 | 1177 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1178 | 1178 | (branch merge, don't forget to commit) |
|
1179 | 1179 | $ hg ci -m add |
|
1180 | 1180 | $ |
|
1181 | 1181 | $ hg debugrename newdirname/newfile.py |
|
1182 | 1182 | newdirname/newfile.py renamed from olddirname/newfile.py:690b295714aed510803d3020da9c70fca8336def |
|
1183 | 1183 | $ hg status -C --change . |
|
1184 | 1184 | A newdirname/newfile.py |
|
1185 | 1185 | $ hg status -C --rev 1 |
|
1186 | 1186 | A newdirname/newfile.py |
|
1187 | 1187 | $ hg status -C --rev 2 |
|
1188 | 1188 | A newdirname/commonfile.py |
|
1189 | 1189 | olddirname/commonfile.py |
|
1190 | 1190 | A newdirname/newfile.py |
|
1191 | 1191 | olddirname/newfile.py |
|
1192 | 1192 | R olddirname/commonfile.py |
|
1193 | 1193 | R olddirname/newfile.py |
|
1194 | 1194 | $ hg debugindex newdirname/newfile.py |
|
1195 | 1195 | rev linkrev nodeid p1 p2 |
|
1196 | 1196 | 0 3 34a4d536c0c0 000000000000 000000000000 |
|
1197 | 1197 | |
|
1198 | 1198 | $ echo a >> newdirname/commonfile.py |
|
1199 | 1199 | $ hg ci --amend -m bug |
|
1200 | 1200 | $ hg debugrename newdirname/newfile.py |
|
1201 | 1201 | newdirname/newfile.py renamed from olddirname/newfile.py:690b295714aed510803d3020da9c70fca8336def |
|
1202 | 1202 | $ hg debugindex newdirname/newfile.py |
|
1203 | 1203 | rev linkrev nodeid p1 p2 |
|
1204 | 1204 | 0 3 34a4d536c0c0 000000000000 000000000000 |
|
1205 | 1205 | |
|
1206 | 1206 | #if execbit |
|
1207 | 1207 | |
|
1208 | 1208 | Test if amend preserves executable bit changes |
|
1209 | 1209 | $ chmod +x newdirname/commonfile.py |
|
1210 | 1210 | $ hg ci -m chmod |
|
1211 | 1211 | $ hg ci --amend -m "chmod amended" |
|
1212 | 1212 | $ hg ci --amend -m "chmod amended second time" |
|
1213 | 1213 | $ hg log -p --git -r . |
|
1214 | 1214 | changeset: 7:b1326f52dddf |
|
1215 | 1215 | branch: newdirname |
|
1216 | 1216 | tag: tip |
|
1217 | 1217 | parent: 4:7fd235f7cb2f |
|
1218 | 1218 | user: test |
|
1219 | 1219 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1220 | 1220 | summary: chmod amended second time |
|
1221 | 1221 | |
|
1222 | 1222 | diff --git a/newdirname/commonfile.py b/newdirname/commonfile.py |
|
1223 | 1223 | old mode 100644 |
|
1224 | 1224 | new mode 100755 |
|
1225 | 1225 | |
|
1226 | 1226 | #endif |
|
1227 | 1227 | |
|
1228 | 1228 | Test amend with file inclusion options |
|
1229 | 1229 | -------------------------------------- |
|
1230 | 1230 | |
|
1231 | 1231 | These tests ensure that we are always amending some files that were part of the |
|
1232 | 1232 | pre-amend commit. We want to test that the remaining files in the pre-amend |
|
1233 | 1233 | commit were not changed in the amended commit. We do so by performing a diff of |
|
1234 | 1234 | the amended commit against its parent commit. |
|
1235 | 1235 | $ cd .. |
|
1236 | 1236 | $ hg init testfileinclusions |
|
1237 | 1237 | $ cd testfileinclusions |
|
1238 | 1238 | $ echo a > a |
|
1239 | 1239 | $ echo b > b |
|
1240 | 1240 | $ hg commit -Aqm "Adding a and b" |
|
1241 | 1241 | |
|
1242 | 1242 | Only add changes to a particular file |
|
1243 | 1243 | $ echo a >> a |
|
1244 | 1244 | $ echo b >> b |
|
1245 | 1245 | $ hg commit --amend -I a |
|
1246 | 1246 | $ hg diff --git -r null -r . |
|
1247 | 1247 | diff --git a/a b/a |
|
1248 | 1248 | new file mode 100644 |
|
1249 | 1249 | --- /dev/null |
|
1250 | 1250 | +++ b/a |
|
1251 | 1251 | @@ -0,0 +1,2 @@ |
|
1252 | 1252 | +a |
|
1253 | 1253 | +a |
|
1254 | 1254 | diff --git a/b b/b |
|
1255 | 1255 | new file mode 100644 |
|
1256 | 1256 | --- /dev/null |
|
1257 | 1257 | +++ b/b |
|
1258 | 1258 | @@ -0,0 +1,1 @@ |
|
1259 | 1259 | +b |
|
1260 | 1260 | |
|
1261 | 1261 | $ echo a >> a |
|
1262 | 1262 | $ hg commit --amend b |
|
1263 | 1263 | $ hg diff --git -r null -r . |
|
1264 | 1264 | diff --git a/a b/a |
|
1265 | 1265 | new file mode 100644 |
|
1266 | 1266 | --- /dev/null |
|
1267 | 1267 | +++ b/a |
|
1268 | 1268 | @@ -0,0 +1,2 @@ |
|
1269 | 1269 | +a |
|
1270 | 1270 | +a |
|
1271 | 1271 | diff --git a/b b/b |
|
1272 | 1272 | new file mode 100644 |
|
1273 | 1273 | --- /dev/null |
|
1274 | 1274 | +++ b/b |
|
1275 | 1275 | @@ -0,0 +1,2 @@ |
|
1276 | 1276 | +b |
|
1277 | 1277 | +b |
|
1278 | 1278 | |
|
1279 | 1279 | Exclude changes to a particular file |
|
1280 | 1280 | $ echo b >> b |
|
1281 | 1281 | $ hg commit --amend -X a |
|
1282 | 1282 | $ hg diff --git -r null -r . |
|
1283 | 1283 | diff --git a/a b/a |
|
1284 | 1284 | new file mode 100644 |
|
1285 | 1285 | --- /dev/null |
|
1286 | 1286 | +++ b/a |
|
1287 | 1287 | @@ -0,0 +1,2 @@ |
|
1288 | 1288 | +a |
|
1289 | 1289 | +a |
|
1290 | 1290 | diff --git a/b b/b |
|
1291 | 1291 | new file mode 100644 |
|
1292 | 1292 | --- /dev/null |
|
1293 | 1293 | +++ b/b |
|
1294 | 1294 | @@ -0,0 +1,3 @@ |
|
1295 | 1295 | +b |
|
1296 | 1296 | +b |
|
1297 | 1297 | +b |
|
1298 | 1298 | |
|
1299 | 1299 | Check the addremove flag |
|
1300 | 1300 | $ echo c > c |
|
1301 | 1301 | $ rm a |
|
1302 | 1302 | $ hg commit --amend -A |
|
1303 | 1303 | removing a |
|
1304 | 1304 | adding c |
|
1305 | 1305 | $ hg diff --git -r null -r . |
|
1306 | 1306 | diff --git a/b b/b |
|
1307 | 1307 | new file mode 100644 |
|
1308 | 1308 | --- /dev/null |
|
1309 | 1309 | +++ b/b |
|
1310 | 1310 | @@ -0,0 +1,3 @@ |
|
1311 | 1311 | +b |
|
1312 | 1312 | +b |
|
1313 | 1313 | +b |
|
1314 | 1314 | diff --git a/c b/c |
|
1315 | 1315 | new file mode 100644 |
|
1316 | 1316 | --- /dev/null |
|
1317 | 1317 | +++ b/c |
|
1318 | 1318 | @@ -0,0 +1,1 @@ |
|
1319 | 1319 | +c |
@@ -1,596 +1,596 b'' | |||
|
1 | 1 | Test uncommit - set up the config |
|
2 | 2 | |
|
3 | 3 | $ cat >> $HGRCPATH <<EOF |
|
4 | 4 | > [experimental] |
|
5 | 5 | > evolution.createmarkers=True |
|
6 | 6 | > evolution.allowunstable=True |
|
7 | 7 | > [extensions] |
|
8 | 8 | > uncommit = |
|
9 | 9 | > drawdag=$TESTDIR/drawdag.py |
|
10 | 10 | > EOF |
|
11 | 11 | |
|
12 | 12 | Build up a repo |
|
13 | 13 | |
|
14 | 14 | $ hg init repo |
|
15 | 15 | $ cd repo |
|
16 | 16 | $ hg bookmark foo |
|
17 | 17 | |
|
18 | 18 | Help for uncommit |
|
19 | 19 | |
|
20 | 20 | $ hg help uncommit |
|
21 | 21 | hg uncommit [OPTION]... [FILE]... |
|
22 | 22 | |
|
23 | 23 | uncommit part or all of a local changeset |
|
24 | 24 | |
|
25 | 25 | This command undoes the effect of a local commit, returning the affected |
|
26 | 26 | files to their uncommitted state. This means that files modified or |
|
27 | 27 | deleted in the changeset will be left unchanged, and so will remain |
|
28 | 28 | modified in the working directory. |
|
29 | 29 | |
|
30 | 30 | If no files are specified, the commit will be pruned, unless --keep is |
|
31 | 31 | given. |
|
32 | 32 | |
|
33 | 33 | (use 'hg help -e uncommit' to show help for the uncommit extension) |
|
34 | 34 | |
|
35 | 35 | options ([+] can be repeated): |
|
36 | 36 | |
|
37 | 37 | --keep allow an empty commit after uncommitting |
|
38 | 38 | --allow-dirty-working-copy allow uncommit with outstanding changes |
|
39 | 39 | -n --note TEXT store a note on uncommit |
|
40 | 40 | -I --include PATTERN [+] include names matching the given patterns |
|
41 | 41 | -X --exclude PATTERN [+] exclude names matching the given patterns |
|
42 | 42 | -m --message TEXT use text as commit message |
|
43 | 43 | -l --logfile FILE read commit message from file |
|
44 | 44 | -d --date DATE record the specified date as commit date |
|
45 | 45 | -u --user USER record the specified user as committer |
|
46 | 46 | -D --currentdate record the current date as commit date |
|
47 | 47 | -U --currentuser record the current user as committer |
|
48 | 48 | |
|
49 | 49 | (some details hidden, use --verbose to show complete help) |
|
50 | 50 | |
|
51 | 51 | Uncommit with no commits should fail |
|
52 | 52 | |
|
53 | 53 | $ hg uncommit |
|
54 | 54 | abort: cannot uncommit the null revision |
|
55 | 55 | (no changeset checked out) |
|
56 | 56 | [10] |
|
57 | 57 | |
|
58 | 58 | Create some commits |
|
59 | 59 | |
|
60 | 60 | $ touch files |
|
61 | 61 | $ hg add files |
|
62 | 62 | $ for i in a ab abc abcd abcde; do echo $i > files; echo $i > file-$i; hg add file-$i; hg commit -m "added file-$i"; done |
|
63 | 63 | $ ls -A |
|
64 | 64 | .hg |
|
65 | 65 | file-a |
|
66 | 66 | file-ab |
|
67 | 67 | file-abc |
|
68 | 68 | file-abcd |
|
69 | 69 | file-abcde |
|
70 | 70 | files |
|
71 | 71 | |
|
72 | 72 | $ hg log -G -T '{rev}:{node} {desc}' --hidden |
|
73 | 73 | @ 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde |
|
74 | 74 | | |
|
75 | 75 | o 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd |
|
76 | 76 | | |
|
77 | 77 | o 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc |
|
78 | 78 | | |
|
79 | 79 | o 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab |
|
80 | 80 | | |
|
81 | 81 | o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a |
|
82 | 82 | |
|
83 | 83 | Simple uncommit off the top, also moves bookmark |
|
84 | 84 | |
|
85 | 85 | $ hg bookmark |
|
86 | 86 | * foo 4:6c4fd43ed714 |
|
87 | 87 | $ hg uncommit |
|
88 | 88 | $ hg status |
|
89 | 89 | M files |
|
90 | 90 | A file-abcde |
|
91 | 91 | $ hg bookmark |
|
92 | 92 | * foo 3:6db330d65db4 |
|
93 | 93 | |
|
94 | 94 | $ hg log -G -T '{rev}:{node} {desc}' --hidden |
|
95 | 95 | x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde |
|
96 | 96 | | |
|
97 | 97 | @ 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd |
|
98 | 98 | | |
|
99 | 99 | o 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc |
|
100 | 100 | | |
|
101 | 101 | o 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab |
|
102 | 102 | | |
|
103 | 103 | o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a |
|
104 | 104 | |
|
105 | 105 | |
|
106 | 106 | Recommit |
|
107 | 107 | |
|
108 | 108 | $ hg commit -m 'new change abcde' |
|
109 | 109 | $ hg status |
|
110 | 110 | $ hg heads -T '{rev}:{node} {desc}' |
|
111 | 111 | 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde (no-eol) |
|
112 | 112 | |
|
113 | 113 | Uncommit of non-existent and unchanged files aborts |
|
114 | 114 | $ hg uncommit nothinghere |
|
115 | 115 | abort: cannot uncommit "nothinghere" |
|
116 | 116 | (file does not exist) |
|
117 | 117 | [10] |
|
118 | 118 | $ hg status |
|
119 | 119 | $ hg uncommit file-abc |
|
120 | 120 | abort: cannot uncommit "file-abc" |
|
121 | 121 | (file was not changed in working directory parent) |
|
122 | 122 | [10] |
|
123 | 123 | $ hg status |
|
124 | 124 | |
|
125 | 125 | Try partial uncommit, also moves bookmark |
|
126 | 126 | |
|
127 | 127 | $ hg bookmark |
|
128 | 128 | * foo 5:0c07a3ccda77 |
|
129 | 129 | $ hg uncommit files |
|
130 | 130 | $ hg status |
|
131 | 131 | M files |
|
132 | 132 | $ hg bookmark |
|
133 | 133 | * foo 6:3727deee06f7 |
|
134 | 134 | $ hg heads -T '{rev}:{node} {desc}' |
|
135 | 135 | 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde (no-eol) |
|
136 | 136 | $ hg log -r . -p -T '{rev}:{node} {desc}' |
|
137 | 137 | 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcdediff -r 6db330d65db4 -r 3727deee06f7 file-abcde |
|
138 | 138 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
139 | 139 | +++ b/file-abcde Thu Jan 01 00:00:00 1970 +0000 |
|
140 | 140 | @@ -0,0 +1,1 @@ |
|
141 | 141 | +abcde |
|
142 | 142 | |
|
143 | 143 | $ hg log -G -T '{rev}:{node} {desc}' --hidden |
|
144 | 144 | @ 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde |
|
145 | 145 | | |
|
146 | 146 | | x 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde |
|
147 | 147 | |/ |
|
148 | 148 | | x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde |
|
149 | 149 | |/ |
|
150 | 150 | o 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd |
|
151 | 151 | | |
|
152 | 152 | o 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc |
|
153 | 153 | | |
|
154 | 154 | o 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab |
|
155 | 155 | | |
|
156 | 156 | o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a |
|
157 | 157 | |
|
158 | 158 | $ hg commit -m 'update files for abcde' |
|
159 | 159 | |
|
160 | 160 | Uncommit with dirty state |
|
161 | 161 | |
|
162 | 162 | $ echo "foo" >> files |
|
163 | 163 | $ cat files |
|
164 | 164 | abcde |
|
165 | 165 | foo |
|
166 | 166 | $ hg status |
|
167 | 167 | M files |
|
168 | 168 | $ hg uncommit |
|
169 | 169 | abort: uncommitted changes |
|
170 | 170 | (requires --allow-dirty-working-copy to uncommit) |
|
171 | 171 | [20] |
|
172 | 172 | $ hg uncommit files |
|
173 | 173 | abort: uncommitted changes |
|
174 | 174 | (requires --allow-dirty-working-copy to uncommit) |
|
175 | 175 | [20] |
|
176 | 176 | $ cat files |
|
177 | 177 | abcde |
|
178 | 178 | foo |
|
179 | 179 | $ hg commit --amend -m "files abcde + foo" |
|
180 | 180 | |
|
181 | 181 | Testing the 'experimental.uncommitondirtywdir' config |
|
182 | 182 | |
|
183 | 183 | $ echo "bar" >> files |
|
184 | 184 | $ hg uncommit |
|
185 | 185 | abort: uncommitted changes |
|
186 | 186 | (requires --allow-dirty-working-copy to uncommit) |
|
187 | 187 | [20] |
|
188 | 188 | $ hg uncommit --config experimental.uncommitondirtywdir=True |
|
189 | 189 | $ hg commit -m "files abcde + foo" |
|
190 | 190 | |
|
191 | 191 | Uncommit in the middle of a stack, does not move bookmark |
|
192 | 192 | |
|
193 | 193 | $ hg checkout '.^^^' |
|
194 | 194 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
195 | 195 | (leaving bookmark foo) |
|
196 | 196 | $ hg log -r . -p -T '{rev}:{node} {desc}' |
|
197 | 197 | 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abcdiff -r 69a232e754b0 -r abf2df566fc1 file-abc |
|
198 | 198 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
199 | 199 | +++ b/file-abc Thu Jan 01 00:00:00 1970 +0000 |
|
200 | 200 | @@ -0,0 +1,1 @@ |
|
201 | 201 | +abc |
|
202 | 202 | diff -r 69a232e754b0 -r abf2df566fc1 files |
|
203 | 203 | --- a/files Thu Jan 01 00:00:00 1970 +0000 |
|
204 | 204 | +++ b/files Thu Jan 01 00:00:00 1970 +0000 |
|
205 | 205 | @@ -1,1 +1,1 @@ |
|
206 | 206 | -ab |
|
207 | 207 | +abc |
|
208 | 208 | |
|
209 | 209 | $ hg bookmark |
|
210 | 210 | foo 9:48e5bd7cd583 |
|
211 | 211 | $ hg uncommit |
|
212 | 212 | 3 new orphan changesets |
|
213 | 213 | $ hg status |
|
214 | 214 | M files |
|
215 | 215 | A file-abc |
|
216 | 216 | $ hg heads -T '{rev}:{node} {desc}' |
|
217 | 217 | 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo (no-eol) |
|
218 | 218 | $ hg bookmark |
|
219 | 219 | foo 9:48e5bd7cd583 |
|
220 | 220 | $ hg commit -m 'new abc' |
|
221 | 221 | created new head |
|
222 | 222 | |
|
223 | 223 | Partial uncommit in the middle, does not move bookmark |
|
224 | 224 | |
|
225 | 225 | $ hg checkout '.^' |
|
226 | 226 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
227 | 227 | $ hg log -r . -p -T '{rev}:{node} {desc}' |
|
228 | 228 | 1:69a232e754b08d568c4899475faf2eb44b857802 added file-abdiff -r 3004d2d9b508 -r 69a232e754b0 file-ab |
|
229 | 229 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
230 | 230 | +++ b/file-ab Thu Jan 01 00:00:00 1970 +0000 |
|
231 | 231 | @@ -0,0 +1,1 @@ |
|
232 | 232 | +ab |
|
233 | 233 | diff -r 3004d2d9b508 -r 69a232e754b0 files |
|
234 | 234 | --- a/files Thu Jan 01 00:00:00 1970 +0000 |
|
235 | 235 | +++ b/files Thu Jan 01 00:00:00 1970 +0000 |
|
236 | 236 | @@ -1,1 +1,1 @@ |
|
237 | 237 | -a |
|
238 | 238 | +ab |
|
239 | 239 | |
|
240 | 240 | $ hg bookmark |
|
241 | 241 | foo 9:48e5bd7cd583 |
|
242 | 242 | $ hg uncommit file-ab |
|
243 | 243 | 1 new orphan changesets |
|
244 | 244 | $ hg status |
|
245 | 245 | A file-ab |
|
246 | 246 | |
|
247 | 247 | $ hg heads -T '{rev}:{node} {desc}\n' |
|
248 | 248 | 11:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab |
|
249 | 249 | 10:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc |
|
250 | 250 | 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo |
|
251 | 251 | |
|
252 | 252 | $ hg bookmark |
|
253 | 253 | foo 9:48e5bd7cd583 |
|
254 | 254 | $ hg commit -m 'update ab' |
|
255 | 255 | $ hg status |
|
256 | 256 | $ hg heads -T '{rev}:{node} {desc}\n' |
|
257 | 257 | 12:f21039c59242b085491bb58f591afc4ed1c04c09 update ab |
|
258 | 258 | 10:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc |
|
259 | 259 | 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo |
|
260 | 260 | |
|
261 | 261 | $ hg log -G -T '{rev}:{node} {desc}' --hidden |
|
262 | 262 | @ 12:f21039c59242b085491bb58f591afc4ed1c04c09 update ab |
|
263 | 263 | | |
|
264 | 264 | o 11:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab |
|
265 | 265 | | |
|
266 | 266 | | * 10:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc |
|
267 | 267 | | | |
|
268 | 268 | | | * 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo |
|
269 | 269 | | | | |
|
270 | 270 | | | | x 8:84beeba0ac30e19521c036e4d2dd3a5fa02586ff files abcde + foo |
|
271 | 271 | | | |/ |
|
272 | 272 | | | | x 7:0977fa602c2fd7d8427ed4e7ee15ea13b84c9173 update files for abcde |
|
273 | 273 | | | |/ |
|
274 | 274 | | | * 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde |
|
275 | 275 | | | | |
|
276 | 276 | | | | x 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde |
|
277 | 277 | | | |/ |
|
278 | 278 | | | | x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde |
|
279 | 279 | | | |/ |
|
280 | 280 | | | * 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd |
|
281 | 281 | | | | |
|
282 | 282 | | | x 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc |
|
283 | 283 | | |/ |
|
284 | 284 | | x 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab |
|
285 | 285 | |/ |
|
286 | 286 | o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a |
|
287 | 287 | |
|
288 | 288 | Uncommit with draft parent |
|
289 | 289 | |
|
290 | 290 | $ hg uncommit |
|
291 | 291 | $ hg phase -r . |
|
292 | 292 | 11: draft |
|
293 | 293 | $ hg commit -m 'update ab again' |
|
294 | 294 | |
|
295 | 295 | Phase is preserved |
|
296 | 296 | |
|
297 | 297 | $ hg uncommit --keep --config phases.new-commit=secret |
|
298 | 298 | note: keeping empty commit |
|
299 | 299 | $ hg phase -r . |
|
300 | 300 | 14: draft |
|
301 | 301 | $ hg commit --amend -m 'update ab again' |
|
302 | 302 | |
|
303 | 303 | Uncommit with public parent |
|
304 | 304 | |
|
305 | 305 | $ hg phase -p "::.^" |
|
306 | 306 | $ hg uncommit |
|
307 | 307 | $ hg phase -r . |
|
308 | 308 | 11: public |
|
309 | 309 | |
|
310 | 310 | Partial uncommit with public parent |
|
311 | 311 | |
|
312 | 312 | $ echo xyz > xyz |
|
313 | 313 | $ hg add xyz |
|
314 | 314 | $ hg commit -m "update ab and add xyz" |
|
315 | 315 | $ hg uncommit xyz |
|
316 | 316 | $ hg status |
|
317 | 317 | A xyz |
|
318 | 318 | $ hg phase -r . |
|
319 | 319 | 17: draft |
|
320 | 320 | $ hg phase -r ".^" |
|
321 | 321 | 11: public |
|
322 | 322 | |
|
323 | 323 | Uncommit with --keep or experimental.uncommit.keep leaves an empty changeset |
|
324 | 324 | |
|
325 | 325 | $ cd $TESTTMP |
|
326 | 326 | $ hg init repo1 |
|
327 | 327 | $ cd repo1 |
|
328 | 328 | $ hg debugdrawdag <<'EOS' |
|
329 | 329 | > Q |
|
330 | 330 | > | |
|
331 | 331 | > P |
|
332 | 332 | > EOS |
|
333 | 333 | $ hg up Q -q |
|
334 | 334 | $ hg uncommit --keep |
|
335 | 335 | note: keeping empty commit |
|
336 | 336 | $ hg log -G -T '{desc} FILES: {files}' |
|
337 | 337 | @ Q FILES: |
|
338 | 338 | | |
|
339 | 339 | | x Q FILES: Q |
|
340 | 340 | |/ |
|
341 | 341 | o P FILES: P |
|
342 | 342 | |
|
343 | 343 | $ cat >> .hg/hgrc <<EOF |
|
344 | 344 | > [experimental] |
|
345 | 345 | > uncommit.keep=True |
|
346 | 346 | > EOF |
|
347 | 347 | $ hg ci --amend |
|
348 | 348 | $ hg uncommit |
|
349 | 349 | note: keeping empty commit |
|
350 | 350 | $ hg log -G -T '{desc} FILES: {files}' |
|
351 | 351 | @ Q FILES: |
|
352 | 352 | | |
|
353 | 353 | | x Q FILES: Q |
|
354 | 354 | |/ |
|
355 | 355 | o P FILES: P |
|
356 | 356 | |
|
357 | 357 | $ hg status |
|
358 | 358 | A Q |
|
359 | 359 | $ hg ci --amend |
|
360 | 360 | $ hg uncommit --no-keep |
|
361 | 361 | $ hg log -G -T '{desc} FILES: {files}' |
|
362 | 362 | x Q FILES: Q |
|
363 | 363 | | |
|
364 | 364 | @ P FILES: P |
|
365 | 365 | |
|
366 | 366 | $ hg status |
|
367 | 367 | A Q |
|
368 | 368 | $ cd .. |
|
369 | 369 | $ rm -rf repo1 |
|
370 | 370 | |
|
371 | 371 | Testing uncommit while merge |
|
372 | 372 | |
|
373 | 373 | $ hg init repo2 |
|
374 | 374 | $ cd repo2 |
|
375 | 375 | |
|
376 | 376 | Create some history |
|
377 | 377 | |
|
378 | 378 | $ touch a |
|
379 | 379 | $ hg add a |
|
380 | 380 | $ for i in 1 2 3; do echo $i > a; hg commit -m "a $i"; done |
|
381 | 381 | $ hg checkout 0 |
|
382 | 382 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
383 | 383 | $ touch b |
|
384 | 384 | $ hg add b |
|
385 | 385 | $ for i in 1 2 3; do echo $i > b; hg commit -m "b $i"; done |
|
386 | 386 | created new head |
|
387 | 387 | $ hg log -G -T '{rev}:{node} {desc}' --hidden |
|
388 | 388 | @ 5:2cd56cdde163ded2fbb16ba2f918c96046ab0bf2 b 3 |
|
389 | 389 | | |
|
390 | 390 | o 4:c3a0d5bb3b15834ffd2ef9ef603e93ec65cf2037 b 2 |
|
391 | 391 | | |
|
392 | 392 | o 3:49bb009ca26078726b8870f1edb29fae8f7618f5 b 1 |
|
393 | 393 | | |
|
394 | 394 | | o 2:990982b7384266e691f1bc08ca36177adcd1c8a9 a 3 |
|
395 | 395 | | | |
|
396 | 396 | | o 1:24d38e3cf160c7b6f5ffe82179332229886a6d34 a 2 |
|
397 | 397 | |/ |
|
398 | 398 | o 0:ea4e33293d4d274a2ba73150733c2612231f398c a 1 |
|
399 | 399 | |
|
400 | 400 | |
|
401 | 401 | Add and expect uncommit to fail on both merge working dir and merge changeset |
|
402 | 402 | |
|
403 | 403 | $ hg merge 2 |
|
404 | 404 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
405 | 405 | (branch merge, don't forget to commit) |
|
406 | 406 | |
|
407 | 407 | $ hg uncommit |
|
408 | 408 | abort: outstanding uncommitted merge |
|
409 | 409 | (requires --allow-dirty-working-copy to uncommit) |
|
410 | 410 | [20] |
|
411 | 411 | |
|
412 | 412 | $ hg uncommit --config experimental.uncommitondirtywdir=True |
|
413 | abort: cannot uncommit while merging | |
|
413 | abort: cannot uncommit changesets while merging | |
|
414 | 414 | [20] |
|
415 | 415 | |
|
416 | 416 | $ hg status |
|
417 | 417 | M a |
|
418 | 418 | $ hg commit -m 'merge a and b' |
|
419 | 419 | |
|
420 | 420 | $ hg uncommit |
|
421 | 421 | abort: cannot uncommit merge changeset |
|
422 | 422 | [10] |
|
423 | 423 | |
|
424 | 424 | $ hg status |
|
425 | 425 | $ hg log -G -T '{rev}:{node} {desc}' --hidden |
|
426 | 426 | @ 6:c03b9c37bc67bf504d4912061cfb527b47a63c6e merge a and b |
|
427 | 427 | |\ |
|
428 | 428 | | o 5:2cd56cdde163ded2fbb16ba2f918c96046ab0bf2 b 3 |
|
429 | 429 | | | |
|
430 | 430 | | o 4:c3a0d5bb3b15834ffd2ef9ef603e93ec65cf2037 b 2 |
|
431 | 431 | | | |
|
432 | 432 | | o 3:49bb009ca26078726b8870f1edb29fae8f7618f5 b 1 |
|
433 | 433 | | | |
|
434 | 434 | o | 2:990982b7384266e691f1bc08ca36177adcd1c8a9 a 3 |
|
435 | 435 | | | |
|
436 | 436 | o | 1:24d38e3cf160c7b6f5ffe82179332229886a6d34 a 2 |
|
437 | 437 | |/ |
|
438 | 438 | o 0:ea4e33293d4d274a2ba73150733c2612231f398c a 1 |
|
439 | 439 | |
|
440 | 440 | |
|
441 | 441 | Rename a->b, then remove b in working copy. Result should remove a. |
|
442 | 442 | |
|
443 | 443 | $ hg co -q 0 |
|
444 | 444 | $ hg mv a b |
|
445 | 445 | $ hg ci -qm 'move a to b' |
|
446 | 446 | $ hg rm b |
|
447 | 447 | $ hg uncommit --config experimental.uncommitondirtywdir=True |
|
448 | 448 | $ hg st --copies |
|
449 | 449 | R a |
|
450 | 450 | $ hg revert a |
|
451 | 451 | |
|
452 | 452 | Rename a->b, then rename b->c in working copy. Result should rename a->c. |
|
453 | 453 | |
|
454 | 454 | $ hg co -q 0 |
|
455 | 455 | $ hg mv a b |
|
456 | 456 | $ hg ci -qm 'move a to b' |
|
457 | 457 | $ hg mv b c |
|
458 | 458 | $ hg uncommit --config experimental.uncommitondirtywdir=True |
|
459 | 459 | $ hg st --copies |
|
460 | 460 | A c |
|
461 | 461 | a |
|
462 | 462 | R a |
|
463 | 463 | $ hg revert a |
|
464 | 464 | $ hg forget c |
|
465 | 465 | $ rm c |
|
466 | 466 | |
|
467 | 467 | Copy a->b1 and a->b2, then rename b1->c in working copy. Result should copy a->b2 and a->c. |
|
468 | 468 | |
|
469 | 469 | $ hg co -q 0 |
|
470 | 470 | $ hg cp a b1 |
|
471 | 471 | $ hg cp a b2 |
|
472 | 472 | $ hg ci -qm 'move a to b1 and b2' |
|
473 | 473 | $ hg mv b1 c |
|
474 | 474 | $ hg uncommit --config experimental.uncommitondirtywdir=True |
|
475 | 475 | $ hg st --copies |
|
476 | 476 | A b2 |
|
477 | 477 | a |
|
478 | 478 | A c |
|
479 | 479 | a |
|
480 | 480 | $ cd .. |
|
481 | 481 | |
|
482 | 482 | --allow-dirty-working-copy should also work on a dirty PATH |
|
483 | 483 | |
|
484 | 484 | $ hg init issue5977 |
|
485 | 485 | $ cd issue5977 |
|
486 | 486 | $ echo 'super critical info!' > a |
|
487 | 487 | $ hg ci -Am 'add a' |
|
488 | 488 | adding a |
|
489 | 489 | $ echo 'foo' > b |
|
490 | 490 | $ hg add b |
|
491 | 491 | $ hg status |
|
492 | 492 | A b |
|
493 | 493 | $ hg uncommit a |
|
494 | 494 | note: keeping empty commit |
|
495 | 495 | $ cat a |
|
496 | 496 | super critical info! |
|
497 | 497 | $ hg log |
|
498 | 498 | changeset: 1:656ba143d384 |
|
499 | 499 | tag: tip |
|
500 | 500 | parent: -1:000000000000 |
|
501 | 501 | user: test |
|
502 | 502 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
503 | 503 | summary: add a |
|
504 | 504 | |
|
505 | 505 | $ hg ci -Am 'add b' |
|
506 | 506 | $ echo 'foo bar' > b |
|
507 | 507 | $ hg uncommit b |
|
508 | 508 | abort: uncommitted changes |
|
509 | 509 | (requires --allow-dirty-working-copy to uncommit) |
|
510 | 510 | [20] |
|
511 | 511 | $ hg uncommit --allow-dirty-working-copy b |
|
512 | 512 | $ hg log |
|
513 | 513 | changeset: 3:30fa958635b2 |
|
514 | 514 | tag: tip |
|
515 | 515 | parent: 1:656ba143d384 |
|
516 | 516 | user: test |
|
517 | 517 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
518 | 518 | summary: add b |
|
519 | 519 | |
|
520 | 520 | changeset: 1:656ba143d384 |
|
521 | 521 | parent: -1:000000000000 |
|
522 | 522 | user: test |
|
523 | 523 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
524 | 524 | summary: add a |
|
525 | 525 | |
|
526 | 526 | Removes can be uncommitted |
|
527 | 527 | |
|
528 | 528 | $ hg ci -m 'modified b' |
|
529 | 529 | $ hg rm b |
|
530 | 530 | $ hg ci -m 'remove b' |
|
531 | 531 | $ hg uncommit b |
|
532 | 532 | note: keeping empty commit |
|
533 | 533 | $ hg status |
|
534 | 534 | R b |
|
535 | 535 | |
|
536 | 536 | Uncommitting a directory won't run afoul of the checks that an explicit file |
|
537 | 537 | can be uncommitted. |
|
538 | 538 | |
|
539 | 539 | $ mkdir dir |
|
540 | 540 | $ echo 1 > dir/file.txt |
|
541 | 541 | $ hg ci -Aqm 'add file in directory' |
|
542 | 542 | $ hg uncommit dir -m 'uncommit with message' -u 'different user' \ |
|
543 | 543 | > -d 'Jun 30 12:12:12 1980 +0000' |
|
544 | 544 | $ hg status |
|
545 | 545 | A dir/file.txt |
|
546 | 546 | $ hg log -r . |
|
547 | 547 | changeset: 8:b4dd26dc42e0 |
|
548 | 548 | tag: tip |
|
549 | 549 | parent: 6:2278a4c24330 |
|
550 | 550 | user: different user |
|
551 | 551 | date: Mon Jun 30 12:12:12 1980 +0000 |
|
552 | 552 | summary: uncommit with message |
|
553 | 553 | |
|
554 | 554 | Bad option combinations |
|
555 | 555 | |
|
556 | 556 | $ hg rollback -q --config ui.rollback=True |
|
557 | 557 | $ hg uncommit -U --user 'user' |
|
558 | 558 | abort: cannot specify both --user and --currentuser |
|
559 | 559 | [10] |
|
560 | 560 | $ hg uncommit -D --date today |
|
561 | 561 | abort: cannot specify both --date and --currentdate |
|
562 | 562 | [10] |
|
563 | 563 | |
|
564 | 564 | `uncommit <dir>` and `cd <dir> && uncommit .` behave the same... |
|
565 | 565 | |
|
566 | 566 | $ echo 2 > dir/file2.txt |
|
567 | 567 | $ hg ci -Aqm 'add file2 in directory' |
|
568 | 568 | $ hg uncommit dir |
|
569 | 569 | note: keeping empty commit |
|
570 | 570 | $ hg status |
|
571 | 571 | A dir/file2.txt |
|
572 | 572 | |
|
573 | 573 | $ hg rollback -q --config ui.rollback=True |
|
574 | 574 | $ cd dir |
|
575 | 575 | $ hg uncommit . -n 'this is a note' |
|
576 | 576 | note: keeping empty commit |
|
577 | 577 | $ hg status |
|
578 | 578 | A dir/file2.txt |
|
579 | 579 | $ cd .. |
|
580 | 580 | |
|
581 | 581 | ... and errors out the same way when nothing can be uncommitted |
|
582 | 582 | |
|
583 | 583 | $ hg rollback -q --config ui.rollback=True |
|
584 | 584 | $ mkdir emptydir |
|
585 | 585 | $ hg uncommit emptydir |
|
586 | 586 | abort: cannot uncommit "emptydir" |
|
587 | 587 | (file was untracked in working directory parent) |
|
588 | 588 | [10] |
|
589 | 589 | |
|
590 | 590 | $ cd emptydir |
|
591 | 591 | $ hg uncommit . |
|
592 | 592 | abort: cannot uncommit "emptydir" |
|
593 | 593 | (file was untracked in working directory parent) |
|
594 | 594 | [10] |
|
595 | 595 | $ hg status |
|
596 | 596 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now