Show More
@@ -727,6 +727,11 def changebranch(ui, repo, revs, label): | |||
|
727 | 727 | if len(roots) > 1: |
|
728 | 728 | raise error.Abort(_("cannot change branch of non-linear revisions")) |
|
729 | 729 | rewriteutil.precheck(repo, revs, 'change branch of') |
|
730 | ||
|
731 | root = repo[roots.first()] | |
|
732 | if not root.p1().branch() == label and label in repo.branchmap(): | |
|
733 | raise error.Abort(_("a branch of the same name already exists")) | |
|
734 | ||
|
730 | 735 | if repo.revs('merge() and %ld', revs): |
|
731 | 736 | raise error.Abort(_("cannot change branch of a merge commit")) |
|
732 | 737 | if repo.revs('obsolete() and %ld', revs): |
@@ -1055,11 +1055,6 def branch(ui, repo, label=None, **opts) | |||
|
1055 | 1055 | |
|
1056 | 1056 | scmutil.checknewlabel(repo, label, 'branch') |
|
1057 | 1057 | if revs: |
|
1058 | # XXX: we should allow setting name to existing branch if the | |
|
1059 | # branch of root of the revs is same as the new branch name | |
|
1060 | if label in repo.branchmap(): | |
|
1061 | raise error.Abort(_('a branch of the same' | |
|
1062 | ' name already exists')) | |
|
1063 | 1058 | return cmdutil.changebranch(ui, repo, revs, label) |
|
1064 | 1059 | |
|
1065 | 1060 | if not opts.get('force') and label in repo.branchmap(): |
@@ -267,15 +267,49 Changing branch on multiple heads at onc | |||
|
267 | 267 | $ hg branch |
|
268 | 268 | stable |
|
269 | 269 | |
|
270 |
Changing to same branch |
|
|
270 | Changing to same branch is no-op | |
|
271 | 271 | |
|
272 | 272 | $ hg branch -r 19::21 stable |
|
273 | abort: a branch of the same name already exists | |
|
274 | [255] | |
|
273 | changed branch on 0 changesets | |
|
274 | ||
|
275 | Changing branch name to existing branch name if the branch of parent of root of | |
|
276 | revs is same as the new branch name | |
|
277 | ||
|
278 | $ hg branch -r 20::21 bugfix | |
|
279 | changed branch on 2 changesets | |
|
280 | $ hg glog | |
|
281 | o 25:714defe1cf34 Added d | |
|
282 | | bugfix () | |
|
283 | o 24:98394def28fc Added c | |
|
284 | | bugfix () | |
|
285 | | @ 23:6a5ddbcfb870 added bar | |
|
286 | | | stable (b1) | |
|
287 | | o 22:baedc6e98a67 Added e | |
|
288 | |/ stable () | |
|
289 | o 19:fd45b986b109 Added b | |
|
290 | | stable () | |
|
291 | o 18:204d2769eca2 Added a | |
|
292 | stable () | |
|
293 | ||
|
294 | $ hg branch -r 24:25 stable | |
|
295 | changed branch on 2 changesets | |
|
296 | $ hg glog | |
|
297 | o 27:4ec342341562 Added d | |
|
298 | | stable () | |
|
299 | o 26:83f48859c2de Added c | |
|
300 | | stable () | |
|
301 | | @ 23:6a5ddbcfb870 added bar | |
|
302 | | | stable (b1) | |
|
303 | | o 22:baedc6e98a67 Added e | |
|
304 | |/ stable () | |
|
305 | o 19:fd45b986b109 Added b | |
|
306 | | stable () | |
|
307 | o 18:204d2769eca2 Added a | |
|
308 | stable () | |
|
275 | 309 | |
|
276 | 310 | Testing on merge |
|
277 | 311 | |
|
278 |
$ hg merge -r 2 |
|
|
312 | $ hg merge -r 26 | |
|
279 | 313 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
280 | 314 | (branch merge, don't forget to commit) |
|
281 | 315 | |
@@ -289,8 +323,8 Testing on merge | |||
|
289 | 323 | |
|
290 | 324 | Changing branch on public changeset |
|
291 | 325 | |
|
292 |
$ hg phase -r 2 |
|
|
293 |
$ hg branch -r 2 |
|
|
326 | $ hg phase -r 27 -p | |
|
327 | $ hg branch -r 27 def | |
|
294 | 328 | abort: cannot change branch of public changesets |
|
295 | 329 | (see 'hg help phases' for details) |
|
296 | 330 | [255] |
General Comments 0
You need to be logged in to leave comments.
Login now