comparison tests/test-update-branches.t @ 28385:3f9e25a42e69

destutil: choose non-closed branch head at first (BC) Before this patch, destupdate() returns the tipmost (descendant) branch head regardless of closed or not. But updating to closed branch head isn't reasonable for ordinary workflow, because: - "hg heads" doesn't show closed heads (= updated parent itself) by default - subsequent committing on it re-opens closed branch even if inactivation of closed head is needed, update destination isn't it, because it should be merged into to another branch in such case. This patch chooses non-closed descendant branch head as default update destination at first. If all descendant branch heads are closed, destupdate() returns the tipmost closed branch head. For simplicity, this patch chooses adding _destupdatebranchfallback() instead largely changing _destupdatebranch(). This patch changes not only normal lookup code path, but also the "no default branch" code path, for consistency.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Mon, 07 Mar 2016 03:14:19 +0900
parents de8b09482fb7
children d0210a35c81a
comparison
equal deleted inserted replaced
28384:3356bf61fa25 28385:3f9e25a42e69
184 $ cd closed-heads 184 $ cd closed-heads
185 185
186 Test updating if at least one non-closed branch head exists 186 Test updating if at least one non-closed branch head exists
187 187
188 if on the closed branch head: 188 if on the closed branch head:
189 - updating is no-op 189 - update to "."
190 - "updated to a closed branch head ...." message is displayed
190 - "N other heads for ...." message is displayed 191 - "N other heads for ...." message is displayed
191 192
192 $ hg update -q -C 3 193 $ hg update -q -C 3
193 $ hg commit --close-branch -m 6 194 $ hg commit --close-branch -m 6
194 $ norevtest "on closed branch head" clean 6 195 $ norevtest "on closed branch head" clean 6
195 0 files updated, 0 files merged, 0 files removed, 0 files unresolved 196 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
197 updated to a closed branch head, because all descendant heads are closed.
198 beware of re-opening closed head by subsequent commit here.
196 1 other heads for branch "default" 199 1 other heads for branch "default"
197 parent=6 200 parent=6
198 201
202 if descendant non-closed branch head exists, and it is only one branch head:
203 - update to it, even if its revision is less than closed one
204 - "N other heads for ...." message isn't displayed
205
206 $ norevtest "non-closed 2 should be chosen" clean 1
207 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
208 parent=2
209
210 if all descendant branch heads are closed, but there is another branch head:
211 - update to the tipmost descendant head
212 - "updated to a closed branch head ...." message is displayed
213 - "N other heads for ...." message is displayed
214
215 $ norevtest "all descendant branch heads are closed" clean 3
216 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
217 updated to a closed branch head, because all descendant heads are closed.
218 beware of re-opening closed head by subsequent commit here.
219 1 other heads for branch "default"
220 parent=6
221
199 Test updating if all branch heads are closed 222 Test updating if all branch heads are closed
200 223
201 if on the closed branch head: 224 if on the closed branch head:
202 - updating is no-op 225 - update to "."
203 - "N other heads for ...." message isn't displayed 226 - "updated to a closed branch head ...." message is displayed
227 - "all heads of branch ...." message is displayed
204 228
205 $ hg update -q -C 2 229 $ hg update -q -C 2
206 $ hg commit --close-branch -m 7 230 $ hg commit --close-branch -m 7
207 $ norevtest "all heads of branch default are closed" clean 6 231 $ norevtest "all heads of branch default are closed" clean 6
208 0 files updated, 0 files merged, 0 files removed, 0 files unresolved 232 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
233 updated to a closed branch head, because all descendant heads are closed.
234 beware of re-opening closed head by subsequent commit here.
235 all heads for branch "default" are closed.
209 parent=6 236 parent=6
237
238 if not on the closed branch head:
239 - update to the tipmost descendant (closed) head
240 - "updated to a closed branch head ...." message is displayed
241 - "all heads of branch ...." message is displayed
242
243 $ norevtest "all heads of branch default are closed" clean 1
244 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
245 updated to a closed branch head, because all descendant heads are closed.
246 beware of re-opening closed head by subsequent commit here.
247 all heads for branch "default" are closed.
248 parent=7
249
250 $ cd ..
251
252 Test updating if "default" branch doesn't exist and no revision is
253 checked out (= "default" is used as current branch)
254
255 $ hg init no-default-branch
256 $ cd no-default-branch
257
258 $ hg branch foobar
259 marked working directory as branch foobar
260 (branches are permanent and global, did you want a bookmark?)
261 $ echo a > a
262 $ hg commit -m "#0" -A
263 adding a
264 $ echo 1 >> a
265 $ hg commit -m "#1"
266 $ hg update -q 0
267 $ echo 3 >> a
268 $ hg commit -m "#2"
269 created new head
270 $ hg commit --close-branch -m "#3"
271
272 if there is at least one non-closed branch head:
273 - update to the tipmost branch head
274
275 $ norevtest "non-closed 1 should be chosen" clean null
276 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
277 parent=1
278
279 if all branch heads are closed
280 - update to "tip"
281 - "updated to a closed branch head ...." message is displayed
282 - "all heads for branch "XXXX" are closed" message is displayed
283
284 $ hg update -q -C 1
285 $ hg commit --close-branch -m "#4"
286
287 $ norevtest "all branches are closed" clean null
288 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
289 updated to a closed branch head, because all descendant heads are closed.
290 beware of re-opening closed head by subsequent commit here.
291 all heads for branch "foobar" are closed.
292 parent=4
210 293
211 $ cd ../b1 294 $ cd ../b1
212 295
213 Test obsolescence behavior 296 Test obsolescence behavior
214 --------------------------------------------------------------------- 297 ---------------------------------------------------------------------