##// END OF EJS Templates
rewriteutil: add pointer to help text when rewrite would cause divergence...
Martin von Zweigbergk -
r48045:055f7b9f default
parent child Browse files
Show More
@@ -1,238 +1,242 b''
1 # rewriteutil.py - utility functions for rewriting changesets
1 # rewriteutil.py - utility functions for rewriting changesets
2 #
2 #
3 # Copyright 2017 Octobus <contact@octobus.net>
3 # Copyright 2017 Octobus <contact@octobus.net>
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 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import re
10 import re
11
11
12 from .i18n import _
12 from .i18n import _
13 from .node import (
13 from .node import (
14 hex,
14 hex,
15 nullrev,
15 nullrev,
16 )
16 )
17
17
18 from . import (
18 from . import (
19 error,
19 error,
20 node,
20 node,
21 obsolete,
21 obsolete,
22 obsutil,
22 obsutil,
23 revset,
23 revset,
24 scmutil,
24 scmutil,
25 util,
25 util,
26 )
26 )
27
27
28
28
29 NODE_RE = re.compile(br'\b[0-9a-f]{6,64}\b')
29 NODE_RE = re.compile(br'\b[0-9a-f]{6,64}\b')
30
30
31
31
32 def _formatrevs(repo, revs, maxrevs=4):
32 def _formatrevs(repo, revs, maxrevs=4):
33 """returns a string summarizing revisions in a decent size
33 """returns a string summarizing revisions in a decent size
34
34
35 If there are few enough revisions, we list them all. Otherwise we display a
35 If there are few enough revisions, we list them all. Otherwise we display a
36 summary of the form:
36 summary of the form:
37
37
38 1ea73414a91b and 5 others
38 1ea73414a91b and 5 others
39 """
39 """
40 tonode = repo.changelog.node
40 tonode = repo.changelog.node
41 numrevs = len(revs)
41 numrevs = len(revs)
42 if numrevs < maxrevs:
42 if numrevs < maxrevs:
43 shorts = [node.short(tonode(r)) for r in revs]
43 shorts = [node.short(tonode(r)) for r in revs]
44 summary = b', '.join(shorts)
44 summary = b', '.join(shorts)
45 else:
45 else:
46 first = revs.first()
46 first = revs.first()
47 summary = _(b'%s and %d others')
47 summary = _(b'%s and %d others')
48 summary %= (node.short(tonode(first)), numrevs - 1)
48 summary %= (node.short(tonode(first)), numrevs - 1)
49 return summary
49 return summary
50
50
51
51
52 def precheck(repo, revs, action=b'rewrite'):
52 def precheck(repo, revs, action=b'rewrite'):
53 """check if revs can be rewritten
53 """check if revs can be rewritten
54 action is used to control the error message.
54 action is used to control the error message.
55
55
56 Make sure this function is called after taking the lock.
56 Make sure this function is called after taking the lock.
57 """
57 """
58 if nullrev in revs:
58 if nullrev in revs:
59 msg = _(b"cannot %s the null revision") % action
59 msg = _(b"cannot %s the null revision") % action
60 hint = _(b"no changeset checked out")
60 hint = _(b"no changeset checked out")
61 raise error.InputError(msg, hint=hint)
61 raise error.InputError(msg, hint=hint)
62
62
63 if any(util.safehasattr(r, 'rev') for r in revs):
63 if any(util.safehasattr(r, 'rev') for r in revs):
64 repo.ui.develwarn(b"rewriteutil.precheck called with ctx not revs")
64 repo.ui.develwarn(b"rewriteutil.precheck called with ctx not revs")
65 revs = (r.rev() for r in revs)
65 revs = (r.rev() for r in revs)
66
66
67 if len(repo[None].parents()) > 1:
67 if len(repo[None].parents()) > 1:
68 raise error.StateError(
68 raise error.StateError(
69 _(b"cannot %s changesets while merging") % action
69 _(b"cannot %s changesets while merging") % action
70 )
70 )
71
71
72 publicrevs = repo.revs(b'%ld and public()', revs)
72 publicrevs = repo.revs(b'%ld and public()', revs)
73 if publicrevs:
73 if publicrevs:
74 summary = _formatrevs(repo, publicrevs)
74 summary = _formatrevs(repo, publicrevs)
75 msg = _(b"cannot %s public changesets: %s") % (action, summary)
75 msg = _(b"cannot %s public changesets: %s") % (action, summary)
76 hint = _(b"see 'hg help phases' for details")
76 hint = _(b"see 'hg help phases' for details")
77 raise error.InputError(msg, hint=hint)
77 raise error.InputError(msg, hint=hint)
78
78
79 newunstable = disallowednewunstable(repo, revs)
79 newunstable = disallowednewunstable(repo, revs)
80 if newunstable:
80 if newunstable:
81 hint = _(b"see 'hg help evolution.instability'")
81 hint = _(b"see 'hg help evolution.instability'")
82 raise error.InputError(
82 raise error.InputError(
83 _(b"cannot %s changeset, as that will orphan %d descendants")
83 _(b"cannot %s changeset, as that will orphan %d descendants")
84 % (action, len(newunstable)),
84 % (action, len(newunstable)),
85 hint=hint,
85 hint=hint,
86 )
86 )
87
87
88 if not obsolete.isenabled(repo, obsolete.allowdivergenceopt):
88 if not obsolete.isenabled(repo, obsolete.allowdivergenceopt):
89 new_divergence = _find_new_divergence(repo, revs)
89 new_divergence = _find_new_divergence(repo, revs)
90 if new_divergence:
90 if new_divergence:
91 local_ctx, other_ctx, base_ctx = new_divergence
91 local_ctx, other_ctx, base_ctx = new_divergence
92 msg = _(
92 msg = _(
93 b'cannot %s %s, as that creates content-divergence with %s'
93 b'cannot %s %s, as that creates content-divergence with %s'
94 ) % (
94 ) % (
95 action,
95 action,
96 local_ctx,
96 local_ctx,
97 other_ctx,
97 other_ctx,
98 )
98 )
99 if local_ctx.rev() != base_ctx.rev():
99 if local_ctx.rev() != base_ctx.rev():
100 msg += _(b', from %s') % base_ctx
100 msg += _(b', from %s') % base_ctx
101 if repo.ui.verbose:
101 if repo.ui.verbose:
102 if local_ctx.rev() != base_ctx.rev():
102 if local_ctx.rev() != base_ctx.rev():
103 msg += _(
103 msg += _(
104 b'\n changeset %s is a successor of ' b'changeset %s'
104 b'\n changeset %s is a successor of ' b'changeset %s'
105 ) % (local_ctx, base_ctx)
105 ) % (local_ctx, base_ctx)
106 msg += _(
106 msg += _(
107 b'\n changeset %s already has a successor in '
107 b'\n changeset %s already has a successor in '
108 b'changeset %s\n'
108 b'changeset %s\n'
109 b' rewriting changeset %s would create '
109 b' rewriting changeset %s would create '
110 b'"content-divergence"\n'
110 b'"content-divergence"\n'
111 b' set experimental.evolution.allowdivergence=True to '
111 b' set experimental.evolution.allowdivergence=True to '
112 b'skip this check'
112 b'skip this check'
113 ) % (base_ctx, other_ctx, local_ctx)
113 ) % (base_ctx, other_ctx, local_ctx)
114 raise error.InputError(msg)
114 raise error.InputError(msg)
115 else:
115 else:
116 raise error.InputError(
116 raise error.InputError(
117 msg, hint=_(b"add --verbose for details")
117 msg,
118 hint=_(
119 b"add --verbose for details or see "
120 b"'hg help evolution.instability'"
121 ),
118 )
122 )
119
123
120
124
121 def disallowednewunstable(repo, revs):
125 def disallowednewunstable(repo, revs):
122 """Checks whether editing the revs will create new unstable changesets and
126 """Checks whether editing the revs will create new unstable changesets and
123 are we allowed to create them.
127 are we allowed to create them.
124
128
125 To allow new unstable changesets, set the config:
129 To allow new unstable changesets, set the config:
126 `experimental.evolution.allowunstable=True`
130 `experimental.evolution.allowunstable=True`
127 """
131 """
128 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
132 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
129 if allowunstable:
133 if allowunstable:
130 return revset.baseset()
134 return revset.baseset()
131 return repo.revs(b"(%ld::) - %ld", revs, revs)
135 return repo.revs(b"(%ld::) - %ld", revs, revs)
132
136
133
137
134 def _find_new_divergence(repo, revs):
138 def _find_new_divergence(repo, revs):
135 obsrevs = repo.revs(b'%ld and obsolete()', revs)
139 obsrevs = repo.revs(b'%ld and obsolete()', revs)
136 for r in obsrevs:
140 for r in obsrevs:
137 div = find_new_divergence_from(repo, repo[r])
141 div = find_new_divergence_from(repo, repo[r])
138 if div:
142 if div:
139 return (repo[r], repo[div[0]], repo[div[1]])
143 return (repo[r], repo[div[0]], repo[div[1]])
140 return None
144 return None
141
145
142
146
143 def find_new_divergence_from(repo, ctx):
147 def find_new_divergence_from(repo, ctx):
144 """return divergent revision if rewriting an obsolete cset (ctx) will
148 """return divergent revision if rewriting an obsolete cset (ctx) will
145 create divergence
149 create divergence
146
150
147 Returns (<other node>, <common ancestor node>) or None
151 Returns (<other node>, <common ancestor node>) or None
148 """
152 """
149 if not ctx.obsolete():
153 if not ctx.obsolete():
150 return None
154 return None
151 # We need to check two cases that can cause divergence:
155 # We need to check two cases that can cause divergence:
152 # case 1: the rev being rewritten has a non-obsolete successor (easily
156 # case 1: the rev being rewritten has a non-obsolete successor (easily
153 # detected by successorssets)
157 # detected by successorssets)
154 sset = obsutil.successorssets(repo, ctx.node())
158 sset = obsutil.successorssets(repo, ctx.node())
155 if sset:
159 if sset:
156 return (sset[0][0], ctx.node())
160 return (sset[0][0], ctx.node())
157 else:
161 else:
158 # case 2: one of the precursors of the rev being revived has a
162 # case 2: one of the precursors of the rev being revived has a
159 # non-obsolete successor (we need divergentsets for this)
163 # non-obsolete successor (we need divergentsets for this)
160 divsets = obsutil.divergentsets(repo, ctx)
164 divsets = obsutil.divergentsets(repo, ctx)
161 if divsets:
165 if divsets:
162 nsuccset = divsets[0][b'divergentnodes']
166 nsuccset = divsets[0][b'divergentnodes']
163 prec = divsets[0][b'commonpredecessor']
167 prec = divsets[0][b'commonpredecessor']
164 return (nsuccset[0], prec)
168 return (nsuccset[0], prec)
165 return None
169 return None
166
170
167
171
168 def skip_empty_successor(ui, command):
172 def skip_empty_successor(ui, command):
169 empty_successor = ui.config(b'rewrite', b'empty-successor')
173 empty_successor = ui.config(b'rewrite', b'empty-successor')
170 if empty_successor == b'skip':
174 if empty_successor == b'skip':
171 return True
175 return True
172 elif empty_successor == b'keep':
176 elif empty_successor == b'keep':
173 return False
177 return False
174 else:
178 else:
175 raise error.ConfigError(
179 raise error.ConfigError(
176 _(
180 _(
177 b"%s doesn't know how to handle config "
181 b"%s doesn't know how to handle config "
178 b"rewrite.empty-successor=%s (only 'skip' and 'keep' are "
182 b"rewrite.empty-successor=%s (only 'skip' and 'keep' are "
179 b"supported)"
183 b"supported)"
180 )
184 )
181 % (command, empty_successor)
185 % (command, empty_successor)
182 )
186 )
183
187
184
188
185 def update_hash_refs(repo, commitmsg, pending=None):
189 def update_hash_refs(repo, commitmsg, pending=None):
186 """Replace all obsolete commit hashes in the message with the current hash.
190 """Replace all obsolete commit hashes in the message with the current hash.
187
191
188 If the obsolete commit was split or is divergent, the hash is not replaced
192 If the obsolete commit was split or is divergent, the hash is not replaced
189 as there's no way to know which successor to choose.
193 as there's no way to know which successor to choose.
190
194
191 For commands that update a series of commits in the current transaction, the
195 For commands that update a series of commits in the current transaction, the
192 new obsolete markers can be considered by setting ``pending`` to a mapping
196 new obsolete markers can be considered by setting ``pending`` to a mapping
193 of ``pending[oldnode] = [successor_node1, successor_node2,..]``.
197 of ``pending[oldnode] = [successor_node1, successor_node2,..]``.
194 """
198 """
195 if not pending:
199 if not pending:
196 pending = {}
200 pending = {}
197 cache = {}
201 cache = {}
198 hashes = re.findall(NODE_RE, commitmsg)
202 hashes = re.findall(NODE_RE, commitmsg)
199 unfi = repo.unfiltered()
203 unfi = repo.unfiltered()
200 for h in hashes:
204 for h in hashes:
201 fullnode = scmutil.resolvehexnodeidprefix(unfi, h)
205 fullnode = scmutil.resolvehexnodeidprefix(unfi, h)
202 if fullnode is None:
206 if fullnode is None:
203 continue
207 continue
204 ctx = unfi[fullnode]
208 ctx = unfi[fullnode]
205 if not ctx.obsolete():
209 if not ctx.obsolete():
206 successors = pending.get(fullnode)
210 successors = pending.get(fullnode)
207 if successors is None:
211 if successors is None:
208 continue
212 continue
209 # obsutil.successorssets() returns a list of list of nodes
213 # obsutil.successorssets() returns a list of list of nodes
210 successors = [successors]
214 successors = [successors]
211 else:
215 else:
212 successors = obsutil.successorssets(repo, ctx.node(), cache=cache)
216 successors = obsutil.successorssets(repo, ctx.node(), cache=cache)
213
217
214 # We can't make any assumptions about how to update the hash if the
218 # We can't make any assumptions about how to update the hash if the
215 # cset in question was split or diverged.
219 # cset in question was split or diverged.
216 if len(successors) == 1 and len(successors[0]) == 1:
220 if len(successors) == 1 and len(successors[0]) == 1:
217 successor = successors[0][0]
221 successor = successors[0][0]
218 if successor is not None:
222 if successor is not None:
219 newhash = hex(successor)
223 newhash = hex(successor)
220 commitmsg = commitmsg.replace(h, newhash[: len(h)])
224 commitmsg = commitmsg.replace(h, newhash[: len(h)])
221 else:
225 else:
222 repo.ui.note(
226 repo.ui.note(
223 _(
227 _(
224 b'The stale commit message reference to %s could '
228 b'The stale commit message reference to %s could '
225 b'not be updated\n(The referenced commit was dropped)\n'
229 b'not be updated\n(The referenced commit was dropped)\n'
226 )
230 )
227 % h
231 % h
228 )
232 )
229 else:
233 else:
230 repo.ui.note(
234 repo.ui.note(
231 _(
235 _(
232 b'The stale commit message reference to %s could '
236 b'The stale commit message reference to %s could '
233 b'not be updated\n'
237 b'not be updated\n'
234 )
238 )
235 % h
239 % h
236 )
240 )
237
241
238 return commitmsg
242 return commitmsg
@@ -1,543 +1,543 b''
1 #testcases obsstore-off obsstore-on
1 #testcases obsstore-off obsstore-on
2
2
3 $ cat << EOF >> $HGRCPATH
3 $ cat << EOF >> $HGRCPATH
4 > [extensions]
4 > [extensions]
5 > amend=
5 > amend=
6 > debugdrawdag=$TESTDIR/drawdag.py
6 > debugdrawdag=$TESTDIR/drawdag.py
7 > [diff]
7 > [diff]
8 > git=1
8 > git=1
9 > EOF
9 > EOF
10
10
11 #if obsstore-on
11 #if obsstore-on
12 $ cat << EOF >> $HGRCPATH
12 $ cat << EOF >> $HGRCPATH
13 > [experimental]
13 > [experimental]
14 > evolution.createmarkers=True
14 > evolution.createmarkers=True
15 > EOF
15 > EOF
16 #endif
16 #endif
17
17
18 Basic amend
18 Basic amend
19
19
20 $ hg init repo1
20 $ hg init repo1
21 $ cd repo1
21 $ cd repo1
22 $ hg debugdrawdag <<'EOS'
22 $ hg debugdrawdag <<'EOS'
23 > B
23 > B
24 > |
24 > |
25 > A
25 > A
26 > EOS
26 > EOS
27
27
28 $ hg update B -q
28 $ hg update B -q
29 $ echo 2 >> B
29 $ echo 2 >> B
30
30
31 $ hg amend
31 $ hg amend
32 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/112478962961-7e959a55-amend.hg (obsstore-off !)
32 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/112478962961-7e959a55-amend.hg (obsstore-off !)
33 #if obsstore-off
33 #if obsstore-off
34 $ hg log -p -G --hidden -T '{rev} {node|short} {desc}\n'
34 $ hg log -p -G --hidden -T '{rev} {node|short} {desc}\n'
35 @ 1 be169c7e8dbe B
35 @ 1 be169c7e8dbe B
36 | diff --git a/B b/B
36 | diff --git a/B b/B
37 | new file mode 100644
37 | new file mode 100644
38 | --- /dev/null
38 | --- /dev/null
39 | +++ b/B
39 | +++ b/B
40 | @@ -0,0 +1,1 @@
40 | @@ -0,0 +1,1 @@
41 | +B2
41 | +B2
42 |
42 |
43 o 0 426bada5c675 A
43 o 0 426bada5c675 A
44 diff --git a/A b/A
44 diff --git a/A b/A
45 new file mode 100644
45 new file mode 100644
46 --- /dev/null
46 --- /dev/null
47 +++ b/A
47 +++ b/A
48 @@ -0,0 +1,1 @@
48 @@ -0,0 +1,1 @@
49 +A
49 +A
50 \ No newline at end of file
50 \ No newline at end of file
51
51
52 #else
52 #else
53 $ hg log -p -G --hidden -T '{rev} {node|short} {desc}\n'
53 $ hg log -p -G --hidden -T '{rev} {node|short} {desc}\n'
54 @ 2 be169c7e8dbe B
54 @ 2 be169c7e8dbe B
55 | diff --git a/B b/B
55 | diff --git a/B b/B
56 | new file mode 100644
56 | new file mode 100644
57 | --- /dev/null
57 | --- /dev/null
58 | +++ b/B
58 | +++ b/B
59 | @@ -0,0 +1,1 @@
59 | @@ -0,0 +1,1 @@
60 | +B2
60 | +B2
61 |
61 |
62 | x 1 112478962961 B
62 | x 1 112478962961 B
63 |/ diff --git a/B b/B
63 |/ diff --git a/B b/B
64 | new file mode 100644
64 | new file mode 100644
65 | --- /dev/null
65 | --- /dev/null
66 | +++ b/B
66 | +++ b/B
67 | @@ -0,0 +1,1 @@
67 | @@ -0,0 +1,1 @@
68 | +B
68 | +B
69 | \ No newline at end of file
69 | \ No newline at end of file
70 |
70 |
71 o 0 426bada5c675 A
71 o 0 426bada5c675 A
72 diff --git a/A b/A
72 diff --git a/A b/A
73 new file mode 100644
73 new file mode 100644
74 --- /dev/null
74 --- /dev/null
75 +++ b/A
75 +++ b/A
76 @@ -0,0 +1,1 @@
76 @@ -0,0 +1,1 @@
77 +A
77 +A
78 \ No newline at end of file
78 \ No newline at end of file
79
79
80 #endif
80 #endif
81
81
82 Nothing changed
82 Nothing changed
83
83
84 $ hg amend
84 $ hg amend
85 nothing changed
85 nothing changed
86 [1]
86 [1]
87
87
88 $ hg amend -d "0 0"
88 $ hg amend -d "0 0"
89 nothing changed
89 nothing changed
90 [1]
90 [1]
91
91
92 $ hg amend -d "Thu Jan 01 00:00:00 1970 UTC"
92 $ hg amend -d "Thu Jan 01 00:00:00 1970 UTC"
93 nothing changed
93 nothing changed
94 [1]
94 [1]
95
95
96 #if obsstore-on
96 #if obsstore-on
97 $ hg init repo-merge-state
97 $ hg init repo-merge-state
98 $ cd repo-merge-state
98 $ cd repo-merge-state
99 $ echo a > f
99 $ echo a > f
100 $ hg ci -Aqm a
100 $ hg ci -Aqm a
101 $ echo b > f
101 $ echo b > f
102 $ hg ci -Aqm b
102 $ hg ci -Aqm b
103 $ echo c > f
103 $ echo c > f
104 $ hg co -m '.^'
104 $ hg co -m '.^'
105 merging f
105 merging f
106 warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
106 warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
107 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
107 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
108 use 'hg resolve' to retry unresolved file merges
108 use 'hg resolve' to retry unresolved file merges
109 [1]
109 [1]
110 $ echo d > f
110 $ echo d > f
111 $ hg resolve -m f
111 $ hg resolve -m f
112 (no more unresolved files)
112 (no more unresolved files)
113 $ hg ci --amend --config experimental.evolution.allowunstable=True
113 $ hg ci --amend --config experimental.evolution.allowunstable=True
114 1 new orphan changesets
114 1 new orphan changesets
115 $ hg resolve -l
115 $ hg resolve -l
116 $ cd ..
116 $ cd ..
117 #endif
117 #endif
118
118
119 Matcher and metadata options
119 Matcher and metadata options
120
120
121 $ echo 3 > C
121 $ echo 3 > C
122 $ echo 4 > D
122 $ echo 4 > D
123 $ hg add C D
123 $ hg add C D
124 $ hg amend -m NEWMESSAGE -I C
124 $ hg amend -m NEWMESSAGE -I C
125 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/be169c7e8dbe-7684ddc5-amend.hg (obsstore-off !)
125 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/be169c7e8dbe-7684ddc5-amend.hg (obsstore-off !)
126 $ hg log -r . -T '{node|short} {desc} {files}\n'
126 $ hg log -r . -T '{node|short} {desc} {files}\n'
127 c7ba14d9075b NEWMESSAGE B C
127 c7ba14d9075b NEWMESSAGE B C
128 $ echo 5 > E
128 $ echo 5 > E
129 $ rm C
129 $ rm C
130 $ hg amend -d '2000 1000' -u 'Foo <foo@example.com>' -A C D
130 $ hg amend -d '2000 1000' -u 'Foo <foo@example.com>' -A C D
131 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/c7ba14d9075b-b3e76daa-amend.hg (obsstore-off !)
131 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/c7ba14d9075b-b3e76daa-amend.hg (obsstore-off !)
132 $ hg log -r . -T '{node|short} {desc} {files} {author} {date}\n'
132 $ hg log -r . -T '{node|short} {desc} {files} {author} {date}\n'
133 14f6c4bcc865 NEWMESSAGE B D Foo <foo@example.com> 2000.01000
133 14f6c4bcc865 NEWMESSAGE B D Foo <foo@example.com> 2000.01000
134
134
135 Amend with editor
135 Amend with editor
136
136
137 $ cat > $TESTTMP/prefix.sh <<'EOF'
137 $ cat > $TESTTMP/prefix.sh <<'EOF'
138 > printf 'EDITED: ' > $TESTTMP/msg
138 > printf 'EDITED: ' > $TESTTMP/msg
139 > cat "$1" >> $TESTTMP/msg
139 > cat "$1" >> $TESTTMP/msg
140 > mv $TESTTMP/msg "$1"
140 > mv $TESTTMP/msg "$1"
141 > EOF
141 > EOF
142 $ chmod +x $TESTTMP/prefix.sh
142 $ chmod +x $TESTTMP/prefix.sh
143
143
144 $ HGEDITOR="sh $TESTTMP/prefix.sh" hg amend --edit
144 $ HGEDITOR="sh $TESTTMP/prefix.sh" hg amend --edit
145 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/14f6c4bcc865-6591f15d-amend.hg (obsstore-off !)
145 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/14f6c4bcc865-6591f15d-amend.hg (obsstore-off !)
146 $ hg log -r . -T '{node|short} {desc}\n'
146 $ hg log -r . -T '{node|short} {desc}\n'
147 298f085230c3 EDITED: NEWMESSAGE
147 298f085230c3 EDITED: NEWMESSAGE
148 $ HGEDITOR="sh $TESTTMP/prefix.sh" hg amend -e -m MSG
148 $ HGEDITOR="sh $TESTTMP/prefix.sh" hg amend -e -m MSG
149 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/298f085230c3-d81a6ad3-amend.hg (obsstore-off !)
149 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/298f085230c3-d81a6ad3-amend.hg (obsstore-off !)
150 $ hg log -r . -T '{node|short} {desc}\n'
150 $ hg log -r . -T '{node|short} {desc}\n'
151 974f07f28537 EDITED: MSG
151 974f07f28537 EDITED: MSG
152
152
153 $ echo FOO > $TESTTMP/msg
153 $ echo FOO > $TESTTMP/msg
154 $ hg amend -l $TESTTMP/msg -m BAR
154 $ hg amend -l $TESTTMP/msg -m BAR
155 abort: cannot specify both --message and --logfile
155 abort: cannot specify both --message and --logfile
156 [10]
156 [10]
157 $ hg amend -l $TESTTMP/msg
157 $ hg amend -l $TESTTMP/msg
158 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/974f07f28537-edb6470a-amend.hg (obsstore-off !)
158 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/974f07f28537-edb6470a-amend.hg (obsstore-off !)
159 $ hg log -r . -T '{node|short} {desc}\n'
159 $ hg log -r . -T '{node|short} {desc}\n'
160 507be9bdac71 FOO
160 507be9bdac71 FOO
161
161
162 Interactive mode
162 Interactive mode
163
163
164 $ touch F G
164 $ touch F G
165 $ hg add F G
165 $ hg add F G
166 $ cat <<EOS | hg amend -i --config ui.interactive=1
166 $ cat <<EOS | hg amend -i --config ui.interactive=1
167 > y
167 > y
168 > n
168 > n
169 > EOS
169 > EOS
170 diff --git a/F b/F
170 diff --git a/F b/F
171 new file mode 100644
171 new file mode 100644
172 examine changes to 'F'?
172 examine changes to 'F'?
173 (enter ? for help) [Ynesfdaq?] y
173 (enter ? for help) [Ynesfdaq?] y
174
174
175 diff --git a/G b/G
175 diff --git a/G b/G
176 new file mode 100644
176 new file mode 100644
177 examine changes to 'G'?
177 examine changes to 'G'?
178 (enter ? for help) [Ynesfdaq?] n
178 (enter ? for help) [Ynesfdaq?] n
179
179
180 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/507be9bdac71-c8077452-amend.hg (obsstore-off !)
180 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/507be9bdac71-c8077452-amend.hg (obsstore-off !)
181 $ hg log -r . -T '{files}\n'
181 $ hg log -r . -T '{files}\n'
182 B D F
182 B D F
183
183
184 Amend in the middle of a stack
184 Amend in the middle of a stack
185
185
186 $ hg init $TESTTMP/repo2
186 $ hg init $TESTTMP/repo2
187 $ cd $TESTTMP/repo2
187 $ cd $TESTTMP/repo2
188 $ hg debugdrawdag <<'EOS'
188 $ hg debugdrawdag <<'EOS'
189 > C
189 > C
190 > |
190 > |
191 > B
191 > B
192 > |
192 > |
193 > A
193 > A
194 > EOS
194 > EOS
195
195
196 $ hg update -q B
196 $ hg update -q B
197 $ echo 2 >> B
197 $ echo 2 >> B
198 $ hg amend
198 $ hg amend
199 abort: cannot amend changeset, as that will orphan 1 descendants
199 abort: cannot amend changeset, as that will orphan 1 descendants
200 (see 'hg help evolution.instability')
200 (see 'hg help evolution.instability')
201 [10]
201 [10]
202
202
203 #if obsstore-on
203 #if obsstore-on
204
204
205 With allowunstable, amend could work in the middle of a stack
205 With allowunstable, amend could work in the middle of a stack
206
206
207 $ cat >> $HGRCPATH <<EOF
207 $ cat >> $HGRCPATH <<EOF
208 > [experimental]
208 > [experimental]
209 > evolution.createmarkers=True
209 > evolution.createmarkers=True
210 > evolution.allowunstable=True
210 > evolution.allowunstable=True
211 > EOF
211 > EOF
212
212
213 $ hg amend
213 $ hg amend
214 1 new orphan changesets
214 1 new orphan changesets
215 $ hg log -T '{rev} {node|short} {desc}\n' -G
215 $ hg log -T '{rev} {node|short} {desc}\n' -G
216 @ 3 be169c7e8dbe B
216 @ 3 be169c7e8dbe B
217 |
217 |
218 | * 2 26805aba1e60 C
218 | * 2 26805aba1e60 C
219 | |
219 | |
220 | x 1 112478962961 B
220 | x 1 112478962961 B
221 |/
221 |/
222 o 0 426bada5c675 A
222 o 0 426bada5c675 A
223
223
224 Checking the note stored in the obsmarker
224 Checking the note stored in the obsmarker
225
225
226 $ echo foo > bar
226 $ echo foo > bar
227 $ hg add bar
227 $ hg add bar
228 $ hg amend --note 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
228 $ hg amend --note 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
229 abort: cannot store a note of more than 255 bytes
229 abort: cannot store a note of more than 255 bytes
230 [10]
230 [10]
231 $ hg amend --note "adding bar"
231 $ hg amend --note "adding bar"
232 $ hg debugobsolete -r .
232 $ hg debugobsolete -r .
233 112478962961147124edd43549aedd1a335e44bf be169c7e8dbe21cd10b3d79691cbe7f241e3c21c 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
233 112478962961147124edd43549aedd1a335e44bf be169c7e8dbe21cd10b3d79691cbe7f241e3c21c 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
234 be169c7e8dbe21cd10b3d79691cbe7f241e3c21c 16084da537dd8f84cfdb3055c633772269d62e1b 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'note': 'adding bar', 'operation': 'amend', 'user': 'test'}
234 be169c7e8dbe21cd10b3d79691cbe7f241e3c21c 16084da537dd8f84cfdb3055c633772269d62e1b 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'note': 'adding bar', 'operation': 'amend', 'user': 'test'}
235
235
236 Cannot cause divergence by default
236 Cannot cause divergence by default
237
237
238 $ hg co --hidden 1
238 $ hg co --hidden 1
239 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
239 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
240 $ hg amend -m divergent
240 $ hg amend -m divergent
241 abort: cannot amend 112478962961, as that creates content-divergence with 16084da537dd
241 abort: cannot amend 112478962961, as that creates content-divergence with 16084da537dd
242 (add --verbose for details)
242 (add --verbose for details or see 'hg help evolution.instability')
243 [10]
243 [10]
244 $ hg amend -m divergent --config experimental.evolution.allowdivergence=true
244 $ hg amend -m divergent --config experimental.evolution.allowdivergence=true
245 2 new content-divergent changesets
245 2 new content-divergent changesets
246 #endif
246 #endif
247
247
248 Cannot amend public changeset
248 Cannot amend public changeset
249
249
250 $ hg phase -r A --public
250 $ hg phase -r A --public
251 $ hg update -C -q A
251 $ hg update -C -q A
252 $ hg amend -m AMEND
252 $ hg amend -m AMEND
253 abort: cannot amend public changesets: 426bada5c675
253 abort: cannot amend public changesets: 426bada5c675
254 (see 'hg help phases' for details)
254 (see 'hg help phases' for details)
255 [10]
255 [10]
256
256
257 Amend a merge changeset
257 Amend a merge changeset
258
258
259 $ hg init $TESTTMP/repo3
259 $ hg init $TESTTMP/repo3
260 $ cd $TESTTMP/repo3
260 $ cd $TESTTMP/repo3
261 $ hg debugdrawdag <<'EOS'
261 $ hg debugdrawdag <<'EOS'
262 > C
262 > C
263 > /|
263 > /|
264 > A B
264 > A B
265 > EOS
265 > EOS
266 $ hg update -q C
266 $ hg update -q C
267 $ hg amend -m FOO
267 $ hg amend -m FOO
268 saved backup bundle to $TESTTMP/repo3/.hg/strip-backup/a35c07e8a2a4-15ff4612-amend.hg (obsstore-off !)
268 saved backup bundle to $TESTTMP/repo3/.hg/strip-backup/a35c07e8a2a4-15ff4612-amend.hg (obsstore-off !)
269 $ rm .hg/localtags
269 $ rm .hg/localtags
270 $ hg log -G -T '{desc}\n'
270 $ hg log -G -T '{desc}\n'
271 @ FOO
271 @ FOO
272 |\
272 |\
273 | o B
273 | o B
274 |
274 |
275 o A
275 o A
276
276
277
277
278 More complete test for status changes (issue5732)
278 More complete test for status changes (issue5732)
279 -------------------------------------------------
279 -------------------------------------------------
280
280
281 Generates history of files having 3 states, r0_r1_wc:
281 Generates history of files having 3 states, r0_r1_wc:
282
282
283 r0: ground (content/missing)
283 r0: ground (content/missing)
284 r1: old state to be amended (content/missing, where missing means removed)
284 r1: old state to be amended (content/missing, where missing means removed)
285 wc: changes to be included in r1 (content/missing-tracked/untracked)
285 wc: changes to be included in r1 (content/missing-tracked/untracked)
286
286
287 $ hg init $TESTTMP/wcstates
287 $ hg init $TESTTMP/wcstates
288 $ cd $TESTTMP/wcstates
288 $ cd $TESTTMP/wcstates
289
289
290 $ "$PYTHON" $TESTDIR/generate-working-copy-states.py state 2 1
290 $ "$PYTHON" $TESTDIR/generate-working-copy-states.py state 2 1
291 $ hg addremove -q --similarity 0
291 $ hg addremove -q --similarity 0
292 $ hg commit -m0
292 $ hg commit -m0
293
293
294 $ "$PYTHON" $TESTDIR/generate-working-copy-states.py state 2 2
294 $ "$PYTHON" $TESTDIR/generate-working-copy-states.py state 2 2
295 $ hg addremove -q --similarity 0
295 $ hg addremove -q --similarity 0
296 $ hg commit -m1
296 $ hg commit -m1
297
297
298 $ "$PYTHON" $TESTDIR/generate-working-copy-states.py state 2 wc
298 $ "$PYTHON" $TESTDIR/generate-working-copy-states.py state 2 wc
299 $ hg addremove -q --similarity 0
299 $ hg addremove -q --similarity 0
300 $ hg forget *_*_*-untracked
300 $ hg forget *_*_*-untracked
301 $ rm *_*_missing-*
301 $ rm *_*_missing-*
302
302
303 amend r1 to include wc changes
303 amend r1 to include wc changes
304
304
305 $ hg amend
305 $ hg amend
306 saved backup bundle to * (glob) (obsstore-off !)
306 saved backup bundle to * (glob) (obsstore-off !)
307
307
308 clean/modified/removed/added states of the amended revision
308 clean/modified/removed/added states of the amended revision
309
309
310 $ hg status --all --change . 'glob:content1_*_content1-tracked'
310 $ hg status --all --change . 'glob:content1_*_content1-tracked'
311 C content1_content1_content1-tracked
311 C content1_content1_content1-tracked
312 C content1_content2_content1-tracked
312 C content1_content2_content1-tracked
313 C content1_missing_content1-tracked
313 C content1_missing_content1-tracked
314 $ hg status --all --change . 'glob:content1_*_content[23]-tracked'
314 $ hg status --all --change . 'glob:content1_*_content[23]-tracked'
315 M content1_content1_content3-tracked
315 M content1_content1_content3-tracked
316 M content1_content2_content2-tracked
316 M content1_content2_content2-tracked
317 M content1_content2_content3-tracked
317 M content1_content2_content3-tracked
318 M content1_missing_content3-tracked
318 M content1_missing_content3-tracked
319 $ hg status --all --change . 'glob:content1_*_missing-tracked'
319 $ hg status --all --change . 'glob:content1_*_missing-tracked'
320 M content1_content2_missing-tracked
320 M content1_content2_missing-tracked
321 R content1_missing_missing-tracked
321 R content1_missing_missing-tracked
322 C content1_content1_missing-tracked
322 C content1_content1_missing-tracked
323 $ hg status --all --change . 'glob:content1_*_*-untracked'
323 $ hg status --all --change . 'glob:content1_*_*-untracked'
324 R content1_content1_content1-untracked
324 R content1_content1_content1-untracked
325 R content1_content1_content3-untracked
325 R content1_content1_content3-untracked
326 R content1_content1_missing-untracked
326 R content1_content1_missing-untracked
327 R content1_content2_content1-untracked
327 R content1_content2_content1-untracked
328 R content1_content2_content2-untracked
328 R content1_content2_content2-untracked
329 R content1_content2_content3-untracked
329 R content1_content2_content3-untracked
330 R content1_content2_missing-untracked
330 R content1_content2_missing-untracked
331 R content1_missing_content1-untracked
331 R content1_missing_content1-untracked
332 R content1_missing_content3-untracked
332 R content1_missing_content3-untracked
333 R content1_missing_missing-untracked
333 R content1_missing_missing-untracked
334 $ hg status --all --change . 'glob:missing_content2_*'
334 $ hg status --all --change . 'glob:missing_content2_*'
335 A missing_content2_content2-tracked
335 A missing_content2_content2-tracked
336 A missing_content2_content3-tracked
336 A missing_content2_content3-tracked
337 A missing_content2_missing-tracked
337 A missing_content2_missing-tracked
338 $ hg status --all --change . 'glob:missing_missing_*'
338 $ hg status --all --change . 'glob:missing_missing_*'
339 A missing_missing_content3-tracked
339 A missing_missing_content3-tracked
340
340
341 working directory should be all clean (with some missing/untracked files)
341 working directory should be all clean (with some missing/untracked files)
342
342
343 $ hg status --all 'glob:*_content?-tracked'
343 $ hg status --all 'glob:*_content?-tracked'
344 C content1_content1_content1-tracked
344 C content1_content1_content1-tracked
345 C content1_content1_content3-tracked
345 C content1_content1_content3-tracked
346 C content1_content2_content1-tracked
346 C content1_content2_content1-tracked
347 C content1_content2_content2-tracked
347 C content1_content2_content2-tracked
348 C content1_content2_content3-tracked
348 C content1_content2_content3-tracked
349 C content1_missing_content1-tracked
349 C content1_missing_content1-tracked
350 C content1_missing_content3-tracked
350 C content1_missing_content3-tracked
351 C missing_content2_content2-tracked
351 C missing_content2_content2-tracked
352 C missing_content2_content3-tracked
352 C missing_content2_content3-tracked
353 C missing_missing_content3-tracked
353 C missing_missing_content3-tracked
354 $ hg status --all 'glob:*_missing-tracked'
354 $ hg status --all 'glob:*_missing-tracked'
355 ! content1_content1_missing-tracked
355 ! content1_content1_missing-tracked
356 ! content1_content2_missing-tracked
356 ! content1_content2_missing-tracked
357 ! content1_missing_missing-tracked
357 ! content1_missing_missing-tracked
358 ! missing_content2_missing-tracked
358 ! missing_content2_missing-tracked
359 ! missing_missing_missing-tracked
359 ! missing_missing_missing-tracked
360 $ hg status --all 'glob:*-untracked'
360 $ hg status --all 'glob:*-untracked'
361 ? content1_content1_content1-untracked
361 ? content1_content1_content1-untracked
362 ? content1_content1_content3-untracked
362 ? content1_content1_content3-untracked
363 ? content1_content2_content1-untracked
363 ? content1_content2_content1-untracked
364 ? content1_content2_content2-untracked
364 ? content1_content2_content2-untracked
365 ? content1_content2_content3-untracked
365 ? content1_content2_content3-untracked
366 ? content1_missing_content1-untracked
366 ? content1_missing_content1-untracked
367 ? content1_missing_content3-untracked
367 ? content1_missing_content3-untracked
368 ? missing_content2_content2-untracked
368 ? missing_content2_content2-untracked
369 ? missing_content2_content3-untracked
369 ? missing_content2_content3-untracked
370 ? missing_missing_content3-untracked
370 ? missing_missing_content3-untracked
371
371
372 =================================
372 =================================
373 Test backup-bundle config option|
373 Test backup-bundle config option|
374 =================================
374 =================================
375 $ hg init $TESTTMP/repo4
375 $ hg init $TESTTMP/repo4
376 $ cd $TESTTMP/repo4
376 $ cd $TESTTMP/repo4
377 $ echo a>a
377 $ echo a>a
378 $ hg ci -Aqma
378 $ hg ci -Aqma
379 $ echo oops>b
379 $ echo oops>b
380 $ hg ci -Aqm "b"
380 $ hg ci -Aqm "b"
381 $ echo partiallyfixed > b
381 $ echo partiallyfixed > b
382
382
383 #if obsstore-off
383 #if obsstore-off
384 $ hg amend
384 $ hg amend
385 saved backup bundle to $TESTTMP/repo4/.hg/strip-backup/95e899acf2ce-f11cb050-amend.hg
385 saved backup bundle to $TESTTMP/repo4/.hg/strip-backup/95e899acf2ce-f11cb050-amend.hg
386 When backup-bundle config option is set:
386 When backup-bundle config option is set:
387 $ cat << EOF >> $HGRCPATH
387 $ cat << EOF >> $HGRCPATH
388 > [rewrite]
388 > [rewrite]
389 > backup-bundle = False
389 > backup-bundle = False
390 > EOF
390 > EOF
391 $ echo fixed > b
391 $ echo fixed > b
392 $ hg amend
392 $ hg amend
393
393
394 #else
394 #else
395 $ hg amend
395 $ hg amend
396 When backup-bundle config option is set:
396 When backup-bundle config option is set:
397 $ cat << EOF >> $HGRCPATH
397 $ cat << EOF >> $HGRCPATH
398 > [rewrite]
398 > [rewrite]
399 > backup-bundle = False
399 > backup-bundle = False
400 > EOF
400 > EOF
401 $ echo fixed > b
401 $ echo fixed > b
402 $ hg amend
402 $ hg amend
403
403
404 #endif
404 #endif
405 ==========================================
405 ==========================================
406 Test update-timestamp config option|
406 Test update-timestamp config option|
407 ==========================================
407 ==========================================
408
408
409 $ cat >> $HGRCPATH << EOF
409 $ cat >> $HGRCPATH << EOF
410 > [extensions]
410 > [extensions]
411 > amend=
411 > amend=
412 > mockmakedate = $TESTDIR/mockmakedate.py
412 > mockmakedate = $TESTDIR/mockmakedate.py
413 > EOF
413 > EOF
414
414
415 $ hg init $TESTTMP/repo5
415 $ hg init $TESTTMP/repo5
416 $ cd $TESTTMP/repo5
416 $ cd $TESTTMP/repo5
417 $ cat <<'EOF' >> .hg/hgrc
417 $ cat <<'EOF' >> .hg/hgrc
418 > [command-templates]
418 > [command-templates]
419 > log = 'user: {user}
419 > log = 'user: {user}
420 > date: {date|date}
420 > date: {date|date}
421 > summary: {desc|firstline}\n'
421 > summary: {desc|firstline}\n'
422 > EOF
422 > EOF
423
423
424 $ echo a>a
424 $ echo a>a
425 $ hg ci -Am 'commit 1'
425 $ hg ci -Am 'commit 1'
426 adding a
426 adding a
427
427
428 When updatetimestamp is False
428 When updatetimestamp is False
429
429
430 $ hg amend --date '1997-1-1 0:1'
430 $ hg amend --date '1997-1-1 0:1'
431 $ hg log --limit 1
431 $ hg log --limit 1
432 user: test
432 user: test
433 date: Wed Jan 01 00:01:00 1997 +0000
433 date: Wed Jan 01 00:01:00 1997 +0000
434 summary: commit 1
434 summary: commit 1
435
435
436 When update-timestamp is True and no other change than the date
436 When update-timestamp is True and no other change than the date
437
437
438 $ hg amend --config rewrite.update-timestamp=True
438 $ hg amend --config rewrite.update-timestamp=True
439 nothing changed
439 nothing changed
440 [1]
440 [1]
441 $ hg log --limit 1
441 $ hg log --limit 1
442 user: test
442 user: test
443 date: Wed Jan 01 00:01:00 1997 +0000
443 date: Wed Jan 01 00:01:00 1997 +0000
444 summary: commit 1
444 summary: commit 1
445
445
446 When update-timestamp is True and there is other change than the date
446 When update-timestamp is True and there is other change than the date
447 $ hg amend --user foobar --config rewrite.update-timestamp=True
447 $ hg amend --user foobar --config rewrite.update-timestamp=True
448 $ hg log --limit 1
448 $ hg log --limit 1
449 user: foobar
449 user: foobar
450 date: Thu Jan 01 00:00:02 1970 +0000
450 date: Thu Jan 01 00:00:02 1970 +0000
451 summary: commit 1
451 summary: commit 1
452
452
453 When date option is applicable and update-timestamp is True
453 When date option is applicable and update-timestamp is True
454 $ hg amend --date '1998-1-1 0:1' --config rewrite.update-timestamp=True
454 $ hg amend --date '1998-1-1 0:1' --config rewrite.update-timestamp=True
455 $ hg log --limit 1
455 $ hg log --limit 1
456 user: foobar
456 user: foobar
457 date: Thu Jan 01 00:01:00 1998 +0000
457 date: Thu Jan 01 00:01:00 1998 +0000
458 summary: commit 1
458 summary: commit 1
459
459
460 Unlike rewrite.update-timestamp, -D/--currentdate always updates the timestamp
460 Unlike rewrite.update-timestamp, -D/--currentdate always updates the timestamp
461
461
462 $ hg amend -D
462 $ hg amend -D
463 $ hg log --limit 1
463 $ hg log --limit 1
464 user: foobar
464 user: foobar
465 date: Thu Jan 01 00:00:04 1970 +0000
465 date: Thu Jan 01 00:00:04 1970 +0000
466 summary: commit 1
466 summary: commit 1
467
467
468 $ hg amend -D --config rewrite.update-timestamp=True
468 $ hg amend -D --config rewrite.update-timestamp=True
469 $ hg log --limit 1
469 $ hg log --limit 1
470 user: foobar
470 user: foobar
471 date: Thu Jan 01 00:00:05 1970 +0000
471 date: Thu Jan 01 00:00:05 1970 +0000
472 summary: commit 1
472 summary: commit 1
473
473
474 rewrite.update-timestamp can be negated by --no-currentdate
474 rewrite.update-timestamp can be negated by --no-currentdate
475
475
476 $ hg amend --config rewrite.update-timestamp=True --no-currentdate -u baz
476 $ hg amend --config rewrite.update-timestamp=True --no-currentdate -u baz
477 $ hg log --limit 1
477 $ hg log --limit 1
478 user: baz
478 user: baz
479 date: Thu Jan 01 00:00:05 1970 +0000
479 date: Thu Jan 01 00:00:05 1970 +0000
480 summary: commit 1
480 summary: commit 1
481
481
482 Bad combination of date options:
482 Bad combination of date options:
483
483
484 $ hg amend -D --date '0 0'
484 $ hg amend -D --date '0 0'
485 abort: cannot specify both --date and --currentdate
485 abort: cannot specify both --date and --currentdate
486 [10]
486 [10]
487
487
488 Close branch
488 Close branch
489
489
490 $ hg amend --secret --close-branch
490 $ hg amend --secret --close-branch
491 $ hg log --limit 1 -T 'close={get(extras, "close")}\nphase={phase}\n'
491 $ hg log --limit 1 -T 'close={get(extras, "close")}\nphase={phase}\n'
492 close=1
492 close=1
493 phase=secret
493 phase=secret
494
494
495 $ cd ..
495 $ cd ..
496
496
497 Corner case of amend from issue6157:
497 Corner case of amend from issue6157:
498 - working copy parent has a change to file `a`
498 - working copy parent has a change to file `a`
499 - working copy has the inverse change
499 - working copy has the inverse change
500 - we amend the working copy parent for files other than `a`
500 - we amend the working copy parent for files other than `a`
501 hg used to include the changes to `a` anyway.
501 hg used to include the changes to `a` anyway.
502
502
503 $ hg init 6157; cd 6157
503 $ hg init 6157; cd 6157
504 $ echo a > a; echo b > b; hg commit -qAm_
504 $ echo a > a; echo b > b; hg commit -qAm_
505 $ echo a2 > a; hg commit -qm_
505 $ echo a2 > a; hg commit -qm_
506 $ hg diff --stat -c .
506 $ hg diff --stat -c .
507 a | 2 +-
507 a | 2 +-
508 1 files changed, 1 insertions(+), 1 deletions(-)
508 1 files changed, 1 insertions(+), 1 deletions(-)
509 $ echo a > a; echo b2 > b; hg amend -q b
509 $ echo a > a; echo b2 > b; hg amend -q b
510 $ hg diff --stat -c .
510 $ hg diff --stat -c .
511 a | 2 +-
511 a | 2 +-
512 b | 2 +-
512 b | 2 +-
513 2 files changed, 2 insertions(+), 2 deletions(-)
513 2 files changed, 2 insertions(+), 2 deletions(-)
514
514
515 Modifying a file while the editor is open can cause dirstate corruption
515 Modifying a file while the editor is open can cause dirstate corruption
516 (issue6233)
516 (issue6233)
517
517
518 $ cd $TESTTMP
518 $ cd $TESTTMP
519 $ hg init modify-during-amend; cd modify-during-amend
519 $ hg init modify-during-amend; cd modify-during-amend
520 $ echo r0 > foo; hg commit -qAm "r0"
520 $ echo r0 > foo; hg commit -qAm "r0"
521 $ echo alpha > foo; hg commit -qm "alpha"
521 $ echo alpha > foo; hg commit -qm "alpha"
522 $ echo beta >> foo
522 $ echo beta >> foo
523 $ cat > $TESTTMP/touchy_editor.sh <<EOF
523 $ cat > $TESTTMP/touchy_editor.sh <<EOF
524 > sleep 1
524 > sleep 1
525 > echo delta >> "$TESTTMP/modify-during-amend/foo"
525 > echo delta >> "$TESTTMP/modify-during-amend/foo"
526 > sleep 1
526 > sleep 1
527 > echo hi > "\$1"
527 > echo hi > "\$1"
528 > sleep 1
528 > sleep 1
529 > EOF
529 > EOF
530 $ HGEDITOR="sh $TESTTMP/touchy_editor.sh" hg commit --amend
530 $ HGEDITOR="sh $TESTTMP/touchy_editor.sh" hg commit --amend
531 $ if (hg diff -c . | grep 'delta' >/dev/null) || [ -n "$(hg status)" ]; then
531 $ if (hg diff -c . | grep 'delta' >/dev/null) || [ -n "$(hg status)" ]; then
532 > echo "OK."
532 > echo "OK."
533 > else
533 > else
534 > echo "Bug detected. 'delta' is not part of the commit OR the wdir"
534 > echo "Bug detected. 'delta' is not part of the commit OR the wdir"
535 > echo "Diff and status before rebuild:"
535 > echo "Diff and status before rebuild:"
536 > hg diff
536 > hg diff
537 > hg status
537 > hg status
538 > hg debugrebuilddirstate
538 > hg debugrebuilddirstate
539 > echo "Diff and status after rebuild:"
539 > echo "Diff and status after rebuild:"
540 > hg diff
540 > hg diff
541 > hg status
541 > hg status
542 > fi
542 > fi
543 OK.
543 OK.
@@ -1,433 +1,433 b''
1 Testing changing branch on commits
1 Testing changing branch on commits
2 ==================================
2 ==================================
3
3
4 Setup
4 Setup
5
5
6 $ cat >> $HGRCPATH << EOF
6 $ cat >> $HGRCPATH << EOF
7 > [alias]
7 > [alias]
8 > glog = log -G -T "{rev}:{node|short} {desc}\n{branch} ({bookmarks})"
8 > glog = log -G -T "{rev}:{node|short} {desc}\n{branch} ({bookmarks})"
9 > [experimental]
9 > [experimental]
10 > evolution = createmarkers
10 > evolution = createmarkers
11 > [extensions]
11 > [extensions]
12 > rebase=
12 > rebase=
13 > EOF
13 > EOF
14
14
15 $ hg init repo
15 $ hg init repo
16 $ cd repo
16 $ cd repo
17 $ for ch in a b c d e; do echo foo >> $ch; hg ci -Aqm "Added "$ch; done
17 $ for ch in a b c d e; do echo foo >> $ch; hg ci -Aqm "Added "$ch; done
18 $ hg glog
18 $ hg glog
19 @ 4:aa98ab95a928 Added e
19 @ 4:aa98ab95a928 Added e
20 | default ()
20 | default ()
21 o 3:62615734edd5 Added d
21 o 3:62615734edd5 Added d
22 | default ()
22 | default ()
23 o 2:28ad74487de9 Added c
23 o 2:28ad74487de9 Added c
24 | default ()
24 | default ()
25 o 1:29becc82797a Added b
25 o 1:29becc82797a Added b
26 | default ()
26 | default ()
27 o 0:18d04c59bb5d Added a
27 o 0:18d04c59bb5d Added a
28 default ()
28 default ()
29
29
30 $ hg branches
30 $ hg branches
31 default 4:aa98ab95a928
31 default 4:aa98ab95a928
32
32
33 Try without passing a new branch name
33 Try without passing a new branch name
34
34
35 $ hg branch -r .
35 $ hg branch -r .
36 abort: no branch name specified for the revisions
36 abort: no branch name specified for the revisions
37 [10]
37 [10]
38
38
39 Setting an invalid branch name
39 Setting an invalid branch name
40
40
41 $ hg branch -r . a:b
41 $ hg branch -r . a:b
42 abort: ':' cannot be used in a name
42 abort: ':' cannot be used in a name
43 [10]
43 [10]
44 $ hg branch -r . tip
44 $ hg branch -r . tip
45 abort: the name 'tip' is reserved
45 abort: the name 'tip' is reserved
46 [10]
46 [10]
47 $ hg branch -r . 1234
47 $ hg branch -r . 1234
48 abort: cannot use an integer as a name
48 abort: cannot use an integer as a name
49 [10]
49 [10]
50
50
51 Change on non-linear set of commits
51 Change on non-linear set of commits
52
52
53 $ hg branch -r 2 -r 4 foo
53 $ hg branch -r 2 -r 4 foo
54 abort: cannot change branch of non-linear revisions
54 abort: cannot change branch of non-linear revisions
55 [10]
55 [10]
56
56
57 Change in middle of the stack (linear commits)
57 Change in middle of the stack (linear commits)
58
58
59 $ hg branch -r 1::3 foo
59 $ hg branch -r 1::3 foo
60 abort: cannot change branch of changeset, as that will orphan 1 descendants
60 abort: cannot change branch of changeset, as that will orphan 1 descendants
61 (see 'hg help evolution.instability')
61 (see 'hg help evolution.instability')
62 [10]
62 [10]
63
63
64 Change with dirty working directory
64 Change with dirty working directory
65
65
66 $ echo bar > a
66 $ echo bar > a
67 $ hg branch -r . foo
67 $ hg branch -r . foo
68 abort: uncommitted changes
68 abort: uncommitted changes
69 [20]
69 [20]
70
70
71 $ hg revert --all
71 $ hg revert --all
72 reverting a
72 reverting a
73
73
74 Change on empty revision set
74 Change on empty revision set
75
75
76 $ hg branch -r 'draft() - all()' foo
76 $ hg branch -r 'draft() - all()' foo
77 abort: empty revision set
77 abort: empty revision set
78 [10]
78 [10]
79
79
80 Changing branch on linear set of commits from head
80 Changing branch on linear set of commits from head
81
81
82 Without obsmarkers
82 Without obsmarkers
83
83
84 $ hg branch -r 3:4 foo --config experimental.evolution=!
84 $ hg branch -r 3:4 foo --config experimental.evolution=!
85 changed branch on 2 changesets
85 changed branch on 2 changesets
86 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/62615734edd5-e86bd13a-branch-change.hg
86 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/62615734edd5-e86bd13a-branch-change.hg
87 $ hg glog
87 $ hg glog
88 @ 4:3938acfb5c0f Added e
88 @ 4:3938acfb5c0f Added e
89 | foo ()
89 | foo ()
90 o 3:9435da006bdc Added d
90 o 3:9435da006bdc Added d
91 | foo ()
91 | foo ()
92 o 2:28ad74487de9 Added c
92 o 2:28ad74487de9 Added c
93 | default ()
93 | default ()
94 o 1:29becc82797a Added b
94 o 1:29becc82797a Added b
95 | default ()
95 | default ()
96 o 0:18d04c59bb5d Added a
96 o 0:18d04c59bb5d Added a
97 default ()
97 default ()
98
98
99 $ hg branches
99 $ hg branches
100 foo 4:3938acfb5c0f
100 foo 4:3938acfb5c0f
101 default 2:28ad74487de9 (inactive)
101 default 2:28ad74487de9 (inactive)
102
102
103 With obsmarkers
103 With obsmarkers
104
104
105 $ hg branch -r 3::4 bar
105 $ hg branch -r 3::4 bar
106 changed branch on 2 changesets
106 changed branch on 2 changesets
107 $ hg glog
107 $ hg glog
108 @ 6:7c1991464886 Added e
108 @ 6:7c1991464886 Added e
109 | bar ()
109 | bar ()
110 o 5:1ea05e93925f Added d
110 o 5:1ea05e93925f Added d
111 | bar ()
111 | bar ()
112 o 2:28ad74487de9 Added c
112 o 2:28ad74487de9 Added c
113 | default ()
113 | default ()
114 o 1:29becc82797a Added b
114 o 1:29becc82797a Added b
115 | default ()
115 | default ()
116 o 0:18d04c59bb5d Added a
116 o 0:18d04c59bb5d Added a
117 default ()
117 default ()
118
118
119 $ hg branches
119 $ hg branches
120 bar 6:7c1991464886
120 bar 6:7c1991464886
121 default 2:28ad74487de9 (inactive)
121 default 2:28ad74487de9 (inactive)
122
122
123 Change branch name to an existing branch
123 Change branch name to an existing branch
124
124
125 $ hg branch -r . default
125 $ hg branch -r . default
126 abort: a branch of the same name already exists
126 abort: a branch of the same name already exists
127 [10]
127 [10]
128
128
129 Changing on a branch head which is not topological head
129 Changing on a branch head which is not topological head
130
130
131 $ hg branch -r 2 stable
131 $ hg branch -r 2 stable
132 abort: cannot change branch of changeset, as that will orphan 2 descendants
132 abort: cannot change branch of changeset, as that will orphan 2 descendants
133 (see 'hg help evolution.instability')
133 (see 'hg help evolution.instability')
134 [10]
134 [10]
135
135
136 Enabling the allowunstable config and trying to change branch on a branch head
136 Enabling the allowunstable config and trying to change branch on a branch head
137 which is not a topological head
137 which is not a topological head
138
138
139 $ echo "[experimental]" >> .hg/hgrc
139 $ echo "[experimental]" >> .hg/hgrc
140 $ echo "evolution.allowunstable=yes" >> .hg/hgrc
140 $ echo "evolution.allowunstable=yes" >> .hg/hgrc
141 $ hg branch -r 2 foo
141 $ hg branch -r 2 foo
142 changed branch on 1 changesets
142 changed branch on 1 changesets
143 2 new orphan changesets
143 2 new orphan changesets
144
144
145 Changing branch of an obsoleted changeset
145 Changing branch of an obsoleted changeset
146
146
147 $ hg branch -r 4 foobar
147 $ hg branch -r 4 foobar
148 abort: hidden revision '4' was rewritten as: 7c1991464886
148 abort: hidden revision '4' was rewritten as: 7c1991464886
149 (use --hidden to access hidden revisions)
149 (use --hidden to access hidden revisions)
150 [255]
150 [255]
151
151
152 $ hg branch -r 4 --hidden foobar
152 $ hg branch -r 4 --hidden foobar
153 abort: cannot change branch of 3938acfb5c0f, as that creates content-divergence with 7c1991464886
153 abort: cannot change branch of 3938acfb5c0f, as that creates content-divergence with 7c1991464886
154 (add --verbose for details)
154 (add --verbose for details or see 'hg help evolution.instability')
155 [10]
155 [10]
156
156
157 Make sure bookmark movement is correct
157 Make sure bookmark movement is correct
158
158
159 $ hg bookmark b1
159 $ hg bookmark b1
160 $ hg glog -r '.^::'
160 $ hg glog -r '.^::'
161 @ 6:7c1991464886 Added e
161 @ 6:7c1991464886 Added e
162 | bar (b1)
162 | bar (b1)
163 * 5:1ea05e93925f Added d
163 * 5:1ea05e93925f Added d
164 | bar ()
164 | bar ()
165 ~
165 ~
166
166
167 $ hg branch -r '(.^)::' wat --debug
167 $ hg branch -r '(.^)::' wat --debug
168 changing branch of '1ea05e93925f806d875a2163f9b76764be644636' from 'bar' to 'wat'
168 changing branch of '1ea05e93925f806d875a2163f9b76764be644636' from 'bar' to 'wat'
169 committing files:
169 committing files:
170 d
170 d
171 committing manifest
171 committing manifest
172 committing changelog
172 committing changelog
173 new node id is 343660ccab7400da637bd6a211d07f413536d718
173 new node id is 343660ccab7400da637bd6a211d07f413536d718
174 changing branch of '7c19914648869f5b02fc7fed31ddee9783fdd680' from 'bar' to 'wat'
174 changing branch of '7c19914648869f5b02fc7fed31ddee9783fdd680' from 'bar' to 'wat'
175 committing files:
175 committing files:
176 e
176 e
177 committing manifest
177 committing manifest
178 committing changelog
178 committing changelog
179 new node id is de1404b45a69f8cc6437d7679033ee33e9efb4ba
179 new node id is de1404b45a69f8cc6437d7679033ee33e9efb4ba
180 moving bookmarks ['b1'] from 7c19914648869f5b02fc7fed31ddee9783fdd680 to de1404b45a69f8cc6437d7679033ee33e9efb4ba
180 moving bookmarks ['b1'] from 7c19914648869f5b02fc7fed31ddee9783fdd680 to de1404b45a69f8cc6437d7679033ee33e9efb4ba
181 resolving manifests
181 resolving manifests
182 branchmerge: False, force: False, partial: False
182 branchmerge: False, force: False, partial: False
183 ancestor: 7c1991464886, local: 7c1991464886+, remote: de1404b45a69
183 ancestor: 7c1991464886, local: 7c1991464886+, remote: de1404b45a69
184 starting 4 threads for background file closing (?)
184 starting 4 threads for background file closing (?)
185 changed branch on 2 changesets
185 changed branch on 2 changesets
186 updating the branch cache
186 updating the branch cache
187 invalid branch cache (served): tip differs
187 invalid branch cache (served): tip differs
188
188
189 $ hg glog -r '(.^)::'
189 $ hg glog -r '(.^)::'
190 @ 9:de1404b45a69 Added e
190 @ 9:de1404b45a69 Added e
191 | wat (b1)
191 | wat (b1)
192 * 8:343660ccab74 Added d
192 * 8:343660ccab74 Added d
193 | wat ()
193 | wat ()
194 ~
194 ~
195
195
196 Make sure phase handling is correct
196 Make sure phase handling is correct
197
197
198 $ echo foo >> bar
198 $ echo foo >> bar
199 $ hg ci -Aqm "added bar" --secret
199 $ hg ci -Aqm "added bar" --secret
200 1 new orphan changesets
200 1 new orphan changesets
201 $ hg glog -r .
201 $ hg glog -r .
202 @ 10:8ad1294c1660 added bar
202 @ 10:8ad1294c1660 added bar
203 | wat (b1)
203 | wat (b1)
204 ~
204 ~
205 $ hg branch -r . secret
205 $ hg branch -r . secret
206 changed branch on 1 changesets
206 changed branch on 1 changesets
207 $ hg phase -r .
207 $ hg phase -r .
208 11: secret
208 11: secret
209
209
210 $ hg branches
210 $ hg branches
211 secret 11:38a9b2d53f98
211 secret 11:38a9b2d53f98
212 foo 7:8a4729a5e2b8
212 foo 7:8a4729a5e2b8
213 wat 9:de1404b45a69 (inactive)
213 wat 9:de1404b45a69 (inactive)
214 default 2:28ad74487de9 (inactive)
214 default 2:28ad74487de9 (inactive)
215 $ hg branch
215 $ hg branch
216 secret
216 secret
217
217
218 Changing branch of another head, different from one on which we are
218 Changing branch of another head, different from one on which we are
219
219
220 $ hg glog
220 $ hg glog
221 @ 11:38a9b2d53f98 added bar
221 @ 11:38a9b2d53f98 added bar
222 | secret (b1)
222 | secret (b1)
223 * 9:de1404b45a69 Added e
223 * 9:de1404b45a69 Added e
224 | wat ()
224 | wat ()
225 * 8:343660ccab74 Added d
225 * 8:343660ccab74 Added d
226 | wat ()
226 | wat ()
227 | o 7:8a4729a5e2b8 Added c
227 | o 7:8a4729a5e2b8 Added c
228 | | foo ()
228 | | foo ()
229 x | 2:28ad74487de9 Added c
229 x | 2:28ad74487de9 Added c
230 |/ default ()
230 |/ default ()
231 o 1:29becc82797a Added b
231 o 1:29becc82797a Added b
232 | default ()
232 | default ()
233 o 0:18d04c59bb5d Added a
233 o 0:18d04c59bb5d Added a
234 default ()
234 default ()
235
235
236 $ hg branch
236 $ hg branch
237 secret
237 secret
238
238
239 $ hg branch -r 7 foobar
239 $ hg branch -r 7 foobar
240 changed branch on 1 changesets
240 changed branch on 1 changesets
241
241
242 The current branch must be preserved
242 The current branch must be preserved
243 $ hg branch
243 $ hg branch
244 secret
244 secret
245
245
246 Changing branch on multiple heads at once
246 Changing branch on multiple heads at once
247
247
248 $ hg rebase -s 8 -d 12 --keepbranches -q
248 $ hg rebase -s 8 -d 12 --keepbranches -q
249
249
250 $ hg rebase -s 14 -d 1 --keepbranches -q
250 $ hg rebase -s 14 -d 1 --keepbranches -q
251
251
252 $ hg branch -r 0: stable
252 $ hg branch -r 0: stable
253 changed branch on 6 changesets
253 changed branch on 6 changesets
254 $ hg glog
254 $ hg glog
255 @ 23:6a5ddbcfb870 added bar
255 @ 23:6a5ddbcfb870 added bar
256 | stable (b1)
256 | stable (b1)
257 o 22:baedc6e98a67 Added e
257 o 22:baedc6e98a67 Added e
258 | stable ()
258 | stable ()
259 | o 21:99ac7bf8aad1 Added d
259 | o 21:99ac7bf8aad1 Added d
260 | | stable ()
260 | | stable ()
261 | o 20:0ecb4d39c4bd Added c
261 | o 20:0ecb4d39c4bd Added c
262 |/ stable ()
262 |/ stable ()
263 o 19:fd45b986b109 Added b
263 o 19:fd45b986b109 Added b
264 | stable ()
264 | stable ()
265 o 18:204d2769eca2 Added a
265 o 18:204d2769eca2 Added a
266 stable ()
266 stable ()
267
267
268 $ hg branches
268 $ hg branches
269 stable 23:6a5ddbcfb870
269 stable 23:6a5ddbcfb870
270
270
271 $ hg branch
271 $ hg branch
272 stable
272 stable
273
273
274 Changing to same branch is no-op
274 Changing to same branch is no-op
275
275
276 $ hg branch -r 19::21 stable
276 $ hg branch -r 19::21 stable
277 changed branch on 0 changesets
277 changed branch on 0 changesets
278
278
279 Changing branch name to existing branch name if the branch of parent of root of
279 Changing branch name to existing branch name if the branch of parent of root of
280 revs is same as the new branch name
280 revs is same as the new branch name
281
281
282 $ hg branch -r 20::21 bugfix
282 $ hg branch -r 20::21 bugfix
283 changed branch on 2 changesets
283 changed branch on 2 changesets
284 $ hg glog
284 $ hg glog
285 o 25:714defe1cf34 Added d
285 o 25:714defe1cf34 Added d
286 | bugfix ()
286 | bugfix ()
287 o 24:98394def28fc Added c
287 o 24:98394def28fc Added c
288 | bugfix ()
288 | bugfix ()
289 | @ 23:6a5ddbcfb870 added bar
289 | @ 23:6a5ddbcfb870 added bar
290 | | stable (b1)
290 | | stable (b1)
291 | o 22:baedc6e98a67 Added e
291 | o 22:baedc6e98a67 Added e
292 |/ stable ()
292 |/ stable ()
293 o 19:fd45b986b109 Added b
293 o 19:fd45b986b109 Added b
294 | stable ()
294 | stable ()
295 o 18:204d2769eca2 Added a
295 o 18:204d2769eca2 Added a
296 stable ()
296 stable ()
297
297
298 $ hg branch -r 24:25 stable
298 $ hg branch -r 24:25 stable
299 changed branch on 2 changesets
299 changed branch on 2 changesets
300 $ hg glog
300 $ hg glog
301 o 27:4ec342341562 Added d
301 o 27:4ec342341562 Added d
302 | stable ()
302 | stable ()
303 o 26:83f48859c2de Added c
303 o 26:83f48859c2de Added c
304 | stable ()
304 | stable ()
305 | @ 23:6a5ddbcfb870 added bar
305 | @ 23:6a5ddbcfb870 added bar
306 | | stable (b1)
306 | | stable (b1)
307 | o 22:baedc6e98a67 Added e
307 | o 22:baedc6e98a67 Added e
308 |/ stable ()
308 |/ stable ()
309 o 19:fd45b986b109 Added b
309 o 19:fd45b986b109 Added b
310 | stable ()
310 | stable ()
311 o 18:204d2769eca2 Added a
311 o 18:204d2769eca2 Added a
312 stable ()
312 stable ()
313
313
314 Changing branch of a merge commit
314 Changing branch of a merge commit
315
315
316 $ hg branch -q ghi
316 $ hg branch -q ghi
317 $ echo f > f
317 $ echo f > f
318 $ hg ci -qAm 'Added f'
318 $ hg ci -qAm 'Added f'
319 $ hg up -q 27
319 $ hg up -q 27
320 $ hg branch -q jkl
320 $ hg branch -q jkl
321 $ echo g > g
321 $ echo g > g
322 $ hg ci -qAm 'Added g'
322 $ hg ci -qAm 'Added g'
323 $ hg glog -r 'heads(:)'
323 $ hg glog -r 'heads(:)'
324 @ 29:6bc1c6c2c9da Added g
324 @ 29:6bc1c6c2c9da Added g
325 | jkl ()
325 | jkl ()
326 ~
326 ~
327 o 28:2f1019bd29d2 Added f
327 o 28:2f1019bd29d2 Added f
328 | ghi (b1)
328 | ghi (b1)
329 ~
329 ~
330
330
331 $ hg branch -q default
331 $ hg branch -q default
332 $ hg merge -r 28
332 $ hg merge -r 28
333 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
333 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
334 (branch merge, don't forget to commit)
334 (branch merge, don't forget to commit)
335 $ hg branch -r . abcd
335 $ hg branch -r . abcd
336 abort: outstanding uncommitted merge
336 abort: outstanding uncommitted merge
337 [20]
337 [20]
338
338
339 $ hg ci -m "Merge commit"
339 $ hg ci -m "Merge commit"
340 $ hg glog -r 'parents(.)::'
340 $ hg glog -r 'parents(.)::'
341 @ 30:4d56e6b1eb6b Merge commit
341 @ 30:4d56e6b1eb6b Merge commit
342 |\ default ()
342 |\ default ()
343 | o 29:6bc1c6c2c9da Added g
343 | o 29:6bc1c6c2c9da Added g
344 | | jkl ()
344 | | jkl ()
345 | ~
345 | ~
346 o 28:2f1019bd29d2 Added f
346 o 28:2f1019bd29d2 Added f
347 | ghi (b1)
347 | ghi (b1)
348 ~
348 ~
349
349
350 $ hg branch -r . ghi
350 $ hg branch -r . ghi
351 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
351 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
352 changed branch on 1 changesets
352 changed branch on 1 changesets
353 $ hg branch -r . jkl
353 $ hg branch -r . jkl
354 changed branch on 1 changesets
354 changed branch on 1 changesets
355 $ hg branch -r . default
355 $ hg branch -r . default
356 changed branch on 1 changesets
356 changed branch on 1 changesets
357 $ hg branch -r . stable
357 $ hg branch -r . stable
358 abort: a branch of the same name already exists
358 abort: a branch of the same name already exists
359 [10]
359 [10]
360
360
361 $ hg branch -r . stable --force
361 $ hg branch -r . stable --force
362 changed branch on 1 changesets
362 changed branch on 1 changesets
363 $ hg branches
363 $ hg branches
364 stable 34:d1c2addda4a2
364 stable 34:d1c2addda4a2
365 jkl 29:6bc1c6c2c9da (inactive)
365 jkl 29:6bc1c6c2c9da (inactive)
366 ghi 28:2f1019bd29d2 (inactive)
366 ghi 28:2f1019bd29d2 (inactive)
367
367
368 Changing branch on public changeset
368 Changing branch on public changeset
369
369
370 $ hg phase -r . -p
370 $ hg phase -r . -p
371 $ hg branch -r . def
371 $ hg branch -r . def
372 abort: cannot change branch of public changesets: d1c2addda4a2
372 abort: cannot change branch of public changesets: d1c2addda4a2
373 (see 'hg help phases' for details)
373 (see 'hg help phases' for details)
374 [10]
374 [10]
375
375
376 Merge commit with conflicts, with evolution and without
376 Merge commit with conflicts, with evolution and without
377
377
378 $ mklozenge() {
378 $ mklozenge() {
379 > echo foo > a
379 > echo foo > a
380 > hg ci -qAm foo
380 > hg ci -qAm foo
381 > echo bar > a
381 > echo bar > a
382 > hg ci -qm bar
382 > hg ci -qm bar
383 > hg up -q '.^'
383 > hg up -q '.^'
384 > echo baz > a
384 > echo baz > a
385 > hg ci -qm baz
385 > hg ci -qm baz
386 > hg merge -q -t :local
386 > hg merge -q -t :local
387 > echo neither > a
387 > echo neither > a
388 > hg ci -qm neither
388 > hg ci -qm neither
389 > }
389 > }
390
390
391 $ cd ..
391 $ cd ..
392 $ hg init merge-with-evolution
392 $ hg init merge-with-evolution
393 $ cd merge-with-evolution
393 $ cd merge-with-evolution
394 $ mklozenge
394 $ mklozenge
395
395
396 $ hg branch -r '(.^)::' abc
396 $ hg branch -r '(.^)::' abc
397 changed branch on 2 changesets
397 changed branch on 2 changesets
398 $ hg glog
398 $ hg glog
399 @ 5:c07fa8b34d54 neither
399 @ 5:c07fa8b34d54 neither
400 |\ abc ()
400 |\ abc ()
401 | o 4:f2aa51777cc9 baz
401 | o 4:f2aa51777cc9 baz
402 | | abc ()
402 | | abc ()
403 o | 1:2e33c4f0856b bar
403 o | 1:2e33c4f0856b bar
404 |/ default ()
404 |/ default ()
405 o 0:91cfb6004abf foo
405 o 0:91cfb6004abf foo
406 default ()
406 default ()
407 $ hg cat a
407 $ hg cat a
408 neither
408 neither
409
409
410 $ cd ..
410 $ cd ..
411 $ hg init merge-without-evolution
411 $ hg init merge-without-evolution
412 $ cd merge-without-evolution
412 $ cd merge-without-evolution
413 $ mklozenge
413 $ mklozenge
414 $ cat > .hg/hgrc << EOF
414 $ cat > .hg/hgrc << EOF
415 > [experimental]
415 > [experimental]
416 > evolution = no
416 > evolution = no
417 > evolution.allowunstable = no
417 > evolution.allowunstable = no
418 > EOF
418 > EOF
419
419
420 $ hg branch -r '(.^)::' abc
420 $ hg branch -r '(.^)::' abc
421 changed branch on 2 changesets
421 changed branch on 2 changesets
422 saved backup bundle to $TESTTMP/merge-without-evolution/.hg/strip-backup/9a3a2af368f4-8db1a361-branch-change.hg
422 saved backup bundle to $TESTTMP/merge-without-evolution/.hg/strip-backup/9a3a2af368f4-8db1a361-branch-change.hg
423 $ hg glog
423 $ hg glog
424 @ 3:c07fa8b34d54 neither
424 @ 3:c07fa8b34d54 neither
425 |\ abc ()
425 |\ abc ()
426 | o 2:f2aa51777cc9 baz
426 | o 2:f2aa51777cc9 baz
427 | | abc ()
427 | | abc ()
428 o | 1:2e33c4f0856b bar
428 o | 1:2e33c4f0856b bar
429 |/ default ()
429 |/ default ()
430 o 0:91cfb6004abf foo
430 o 0:91cfb6004abf foo
431 default ()
431 default ()
432 $ hg cat a
432 $ hg cat a
433 neither
433 neither
General Comments 0
You need to be logged in to leave comments. Login now