##// END OF EJS Templates
branch: allow changing branch name to existing name if possible...
Pulkit Goyal -
r35764:e5b6ba78 default
parent child Browse files
Show More
@@ -727,6 +727,11 b' def changebranch(ui, repo, revs, label):'
727 if len(roots) > 1:
727 if len(roots) > 1:
728 raise error.Abort(_("cannot change branch of non-linear revisions"))
728 raise error.Abort(_("cannot change branch of non-linear revisions"))
729 rewriteutil.precheck(repo, revs, 'change branch of')
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 if repo.revs('merge() and %ld', revs):
735 if repo.revs('merge() and %ld', revs):
731 raise error.Abort(_("cannot change branch of a merge commit"))
736 raise error.Abort(_("cannot change branch of a merge commit"))
732 if repo.revs('obsolete() and %ld', revs):
737 if repo.revs('obsolete() and %ld', revs):
@@ -1055,11 +1055,6 b' def branch(ui, repo, label=None, **opts)'
1055
1055
1056 scmutil.checknewlabel(repo, label, 'branch')
1056 scmutil.checknewlabel(repo, label, 'branch')
1057 if revs:
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 return cmdutil.changebranch(ui, repo, revs, label)
1058 return cmdutil.changebranch(ui, repo, revs, label)
1064
1059
1065 if not opts.get('force') and label in repo.branchmap():
1060 if not opts.get('force') and label in repo.branchmap():
@@ -267,15 +267,49 b' Changing branch on multiple heads at onc'
267 $ hg branch
267 $ hg branch
268 stable
268 stable
269
269
270 Changing to same branch name does not work
270 Changing to same branch is no-op
271
271
272 $ hg branch -r 19::21 stable
272 $ hg branch -r 19::21 stable
273 abort: a branch of the same name already exists
273 changed branch on 0 changesets
274 [255]
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 Testing on merge
310 Testing on merge
277
311
278 $ hg merge -r 20
312 $ hg merge -r 26
279 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
313 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
280 (branch merge, don't forget to commit)
314 (branch merge, don't forget to commit)
281
315
@@ -289,8 +323,8 b' Testing on merge'
289
323
290 Changing branch on public changeset
324 Changing branch on public changeset
291
325
292 $ hg phase -r 21 -p
326 $ hg phase -r 27 -p
293 $ hg branch -r 21 def
327 $ hg branch -r 27 def
294 abort: cannot change branch of public changesets
328 abort: cannot change branch of public changesets
295 (see 'hg help phases' for details)
329 (see 'hg help phases' for details)
296 [255]
330 [255]
General Comments 0
You need to be logged in to leave comments. Login now