mercurial/cmdutil.py
changeset 40666 69268a13ffa5
parent 40367 824b687ff6af
child 41120 79f8f032c706
equal deleted inserted replaced
40665:fb379b78b93e 40666:69268a13ffa5
   730         if len(roots) > 1:
   730         if len(roots) > 1:
   731             raise error.Abort(_("cannot change branch of non-linear revisions"))
   731             raise error.Abort(_("cannot change branch of non-linear revisions"))
   732         rewriteutil.precheck(repo, revs, 'change branch of')
   732         rewriteutil.precheck(repo, revs, 'change branch of')
   733 
   733 
   734         root = repo[roots.first()]
   734         root = repo[roots.first()]
   735         if not root.p1().branch() == label and label in repo.branchmap():
   735         rpb = {parent.branch() for parent in root.parents()}
       
   736         if label not in rpb and label in repo.branchmap():
   736             raise error.Abort(_("a branch of the same name already exists"))
   737             raise error.Abort(_("a branch of the same name already exists"))
   737 
   738 
   738         if repo.revs('merge() and %ld', revs):
       
   739             raise error.Abort(_("cannot change branch of a merge commit"))
       
   740         if repo.revs('obsolete() and %ld', revs):
   739         if repo.revs('obsolete() and %ld', revs):
   741             raise error.Abort(_("cannot change branch of a obsolete changeset"))
   740             raise error.Abort(_("cannot change branch of a obsolete changeset"))
   742 
   741 
   743         # make sure only topological heads
   742         # make sure only topological heads
   744         if repo.revs('heads(%ld) - head()', revs):
   743         if repo.revs('heads(%ld) - head()', revs):