test-metaedit.t 8.4 KB
Newer Older
1
2
  $ . $TESTDIR/testlib/common.sh

3
4
  $ cat >> $HGRCPATH <<EOF
  > [alias]
5
  > glog = log -GT "{rev}:{node|short}@{branch}({phase}) {desc|firstline}"
6
  > gluf = log -GT "{separate(' ', rev, bookmarks)}: {desc|firstline} - {author|user} ({files})"
7
  > [extensions]
8
  > evolve =
9
10
11
12
13
14
15
16
  > EOF

##########################
importing Parren test
##########################

  $ cat << EOF >> $HGRCPATH
  > [ui]
17
  > logtemplate = "{separate(' ', rev, bookmarks)}: {desc|firstline} - {author|user}\n"
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  > EOF

HG METAEDIT
===============================

Setup the Base Repo
-------------------

We start with a plain base repo::

  $ hg init $TESTTMP/metaedit; cd $TESTTMP/metaedit
  $ mkcommit "ROOT"
  $ hg phase --public "desc(ROOT)"
  $ mkcommit "A"
  $ mkcommit "B"
  $ hg up "desc(A)"
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ mkcommit "C"
  created new head
  $ mkcommit "D"
  $ echo "D'" > D
39
  $ hg bookmark bookmark-D
40
41
42
  $ hg amend -m "D2"
  $ hg up "desc(C)"
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
43
  (leaving bookmark bookmark-D)
44
45
46
47
48
49
50
51
  $ mkcommit "E"
  created new head
  $ mkcommit "F"

Test
----

  $ hg log -G
52
  @  7: F - test
53
  |
54
  o  6: E - test
55
  |
56
  | o  5 bookmark-D: D2 - test
57
  |/
58
  o  3: C - test
59
  |
60
  | o  2: B - test
61
  |/
62
  o  1: A - test
63
  |
64
  o  0: ROOT - test
65
66
67
68
69
70
71
72
73
74
  
  $ hg update --clean .
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg metaedit -r 0
  abort: cannot edit commit information for public revisions
  [255]
  $ hg metaedit --fold
  abort: revisions must be specified with --fold
  [255]
  $ hg metaedit -r 0 --fold
75
  abort: cannot fold public changesets: ea207398892e
76
  (see 'hg help phases' for details)
77
  [10]
78
79
80
81
82
83
84
85
86
87
88
89
  $ hg metaedit 'desc(C) + desc(F)' --fold
  abort: cannot fold non-linear revisions (multiple roots given)
  [255]
  $ hg metaedit "desc(C)::desc(D2) + desc(E)" --fold
  abort: cannot fold non-linear revisions (multiple heads given)
  [255]
check that metaedit respects allowunstable
  $ hg metaedit '.^' --config 'experimental.evolution=createmarkers, allnewcommands'
  abort: cannot edit commit information in the middle of a stack
  (587528abfffe will become unstable and new unstable changes are not allowed)
  [255]
  $ hg metaedit 'desc(A)::desc(B)' --fold --config 'experimental.evolution=createmarkers, allnewcommands'
90
  abort: cannot fold changeset, as that will orphan 4 descendants
91
  (see 'hg help evolution.instability')
92
  [10]
93
94
95
96
  $ hg metaedit --user foobar
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg log --template '{rev}: {author}\n' -r 'desc(F):' --hidden
  7: test
97
  8: foobar
98
  $ hg log --template '{rev}: {author}\n' -r .
99
  8: foobar
100
101
102
103
104
105

TODO: support this
  $ hg metaedit '.^::.'
  abort: editing multiple revisions without --fold is not currently supported
  [255]

106
107
108
109
  $ HGEDITOR=cat hg metaedit '.^::.' --fold --note 'folding changesets using metaedit,
  > and newlines'
  abort: note cannot contain a newline
  [255]
110
  $ HGEDITOR=cat hg metaedit '.^::.' --fold --note "folding changesets using metaedit"
111
  HG: This is a fold of 2 changesets.
112
  HG: Commit message of changeset 6.
113
114
115
  
  E
  
116
  HG: Commit message of changeset 8.
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
  
  F
  
  
  
  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
  HG: Leave message empty to abort commit.
  HG: --
  HG: user: test
  HG: branch 'default'
  HG: added E
  HG: added F
  2 changesets folded
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved

132
  $ hg glog -r .
133
  @  9:a08d35fd7d9d@default(draft) E
134
135
136
  |
  ~

137
138
139
140
141
  $ hg debugobsolete
  e2abbe8ca2ec6ffca6fd7a19d4158c58ff461723 f3d001339afd30d27fcd91e713274a78233528c8 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'amend', 'user': 'test'}
  587528abfffe33d49f94f9d6223dbbd58d6197c6 212b2a2b87cdbae992f001e9baba64db389fbce7 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'metaedit', 'user': 'test'}
  c2bd843aa2468b30bb56d69d4f5fef95b85986f2 a08d35fd7d9d0f8cb33d5bd2074e9bafb5cbc70f 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'fold-id': 'c5832a81', 'fold-idx': '1', 'fold-size': '2', 'note': 'folding changesets using metaedit', 'operation': 'metaedit', 'user': 'test'}
  212b2a2b87cdbae992f001e9baba64db389fbce7 a08d35fd7d9d0f8cb33d5bd2074e9bafb5cbc70f 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '29', 'fold-id': 'c5832a81', 'fold-idx': '2', 'fold-size': '2', 'note': 'folding changesets using metaedit', 'operation': 'metaedit', 'user': 'test'}
142
  $ hg obslog -r . --no-origin
143
144
145
  @    a08d35fd7d9d (9) E
  |\
  x |  212b2a2b87cd (8) F
146
  | |    folded(description, user, parent, content) as a08d35fd7d9d using metaedit by test (Thu Jan 01 00:00:00 1970 +0000)
147
  | |      note: folding changesets using metaedit
148
149
  | |
  | x  c2bd843aa246 (6) E
150
  |      folded(description, content) as a08d35fd7d9d using metaedit by test (Thu Jan 01 00:00:00 1970 +0000)
151
  |        note: folding changesets using metaedit
152
153
  |
  x  587528abfffe (7) F
154
       reauthored(user) as 212b2a2b87cd using metaedit by test (Thu Jan 01 00:00:00 1970 +0000)
155
  
156
157
158
159
160
161
162
163
164
165
166
167
  $ hg obslog -r .
  @    a08d35fd7d9d (9) E
  |\     folded(description, user, parent, content) from 212b2a2b87cd, c2bd843aa246 using metaedit by test (Thu Jan 01 00:00:00 1970 +0000)
  | |      note: folding changesets using metaedit
  | |
  x |  212b2a2b87cd (8) F
  | |    reauthored(user) from 587528abfffe using metaedit by test (Thu Jan 01 00:00:00 1970 +0000)
  | |
  | x  c2bd843aa246 (6) E
  |
  x  587528abfffe (7) F
  
168
169
170
  $ hg debugobsolete --rev . --exclusive
  212b2a2b87cdbae992f001e9baba64db389fbce7 a08d35fd7d9d0f8cb33d5bd2074e9bafb5cbc70f 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '29', 'fold-id': 'c5832a81', 'fold-idx': '2', 'fold-size': '2', 'note': 'folding changesets using metaedit', 'operation': 'metaedit', 'user': 'test'}
  c2bd843aa2468b30bb56d69d4f5fef95b85986f2 a08d35fd7d9d0f8cb33d5bd2074e9bafb5cbc70f 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'fold-id': 'c5832a81', 'fold-idx': '1', 'fold-size': '2', 'note': 'folding changesets using metaedit', 'operation': 'metaedit', 'user': 'test'}
171

172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
no new commit is created here because the date is the same
  $ HGEDITOR=cat hg metaedit
  E
  
  
  F
  
  
  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
  HG: Leave message empty to abort commit.
  HG: --
  HG: user: test
  HG: branch 'default'
  HG: added E
  HG: added F
  nothing changed

189
  $ hg glog -r '.^::.'
190
  @  9:a08d35fd7d9d@default(draft) E
191
192
193
194
195
  |
  o  3:3260958f1169@default(draft) C
  |
  ~

196
197
198
199
200
201
202
203
204
205
206
207
208
209
metaedit should preserve the original date of the edited commit (issue5994)

  $ hg metaedit --config devel.default-date=
  nothing changed

metaedit doesn't create new commit if message and user aren't changed

  $ hg metaedit --config devel.default-date= --user test --message 'E
  > 
  > 
  > F'
  nothing changed

  $ hg metaedit --config devel.default-date= --date "42 0"
210
211
212
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg log -r '.^::.' --template '{rev}: {desc|firstline}\n'
  3: C
213
  10: E
214
215
216
217
218

  $ hg up .^
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  $ hg metaedit --user foobar2 tip
  $ hg log --template '{rev}: {author}\n' -r "user(foobar):" --hidden
219
220
  8: foobar
  9: test
221
  10: test
222
  11: foobar2
223
224
225
  $ hg diff -r "10" -r "11" --hidden

'fold' one commit
226
  $ HGUSER=foobar3 hg metaedit "desc(D2)" --fold -U
227
228
  1 changesets folded
  $ hg log -r "tip" --template '{rev}: {author}\n'
229
  12: foobar3
230
231
  $ hg debugobsolete --rev 'tip' --exclusive
  f3d001339afd30d27fcd91e713274a78233528c8 07a6525ddaf5de1ab33352806abb5724a0954f3f 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'metaedit', 'user': 'foobar3'}
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246

working on merge commits too

  $ hg up -q 11
  $ hg merge -q 12
  $ hg ci -m 'merge commit'
  $ hg st --change .
  A D
  $ hg metaedit --user someone-else
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg st --change .
  A D
  $ hg gluf
  @    14: merge commit - someone-else ()
  |\
247
  | o  12 bookmark-D: D2 - foobar3 (D)
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
  | |
  o |  11: E - foobar2 (E F)
  |/
  o  3: C - test (C)
  |
  | o  2: B - test (B)
  |/
  o  1: A - test (A)
  |
  o  0: ROOT - test (ROOT)
  
  $ hg metaedit --user mr-squasher -r 3:14 --fold --message squashed
  4 changesets folded
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg st --change .
  A C
  A D
  A E
  A F
  $ hg gluf
268
  @  15 bookmark-D: squashed - mr-squasher (C D E F)
269
270
271
272
273
274
275
276
277
278
279
280
281
282
  |
  | o  2: B - test (B)
  |/
  o  1: A - test (A)
  |
  o  0: ROOT - test (ROOT)
  
  $ hg files
  A
  C
  D
  E
  F
  ROOT