mercurial/commands.py
changeset 27167 3fe8cb40c9c5
parent 27148 39163708825c
child 27172 4d61c847e06c
equal deleted inserted replaced
27166:263db31329a6 27167:3fe8cb40c9c5
  1188             label = repo[None].p1().branch()
  1188             label = repo[None].p1().branch()
  1189             repo.dirstate.setbranch(label)
  1189             repo.dirstate.setbranch(label)
  1190             ui.status(_('reset working directory to branch %s\n') % label)
  1190             ui.status(_('reset working directory to branch %s\n') % label)
  1191         elif label:
  1191         elif label:
  1192             if not opts.get('force') and label in repo.branchmap():
  1192             if not opts.get('force') and label in repo.branchmap():
  1193                 if label not in [p.branch() for p in repo.parents()]:
  1193                 if label not in [p.branch() for p in repo[None].parents()]:
  1194                     raise error.Abort(_('a branch of the same name already'
  1194                     raise error.Abort(_('a branch of the same name already'
  1195                                        ' exists'),
  1195                                        ' exists'),
  1196                                      # i18n: "it" refers to an existing branch
  1196                                      # i18n: "it" refers to an existing branch
  1197                                      hint=_("use 'hg update' to switch to it"))
  1197                                      hint=_("use 'hg update' to switch to it"))
  1198             scmutil.checknewlabel(repo, label, 'branch')
  1198             scmutil.checknewlabel(repo, label, 'branch')
  1598         extra['close'] = 1
  1598         extra['close'] = 1
  1599 
  1599 
  1600         if not bheads:
  1600         if not bheads:
  1601             raise error.Abort(_('can only close branch heads'))
  1601             raise error.Abort(_('can only close branch heads'))
  1602         elif opts.get('amend'):
  1602         elif opts.get('amend'):
  1603             if repo.parents()[0].p1().branch() != branch and \
  1603             if repo[None].parents()[0].p1().branch() != branch and \
  1604                     repo.parents()[0].p2().branch() != branch:
  1604                     repo[None].parents()[0].p2().branch() != branch:
  1605                 raise error.Abort(_('can only close branch heads'))
  1605                 raise error.Abort(_('can only close branch heads'))
  1606 
  1606 
  1607     if opts.get('amend'):
  1607     if opts.get('amend'):
  1608         if ui.configbool('ui', 'commitsubrepos'):
  1608         if ui.configbool('ui', 'commitsubrepos'):
  1609             raise error.Abort(_('cannot amend with ui.commitsubrepos enabled'))
  1609             raise error.Abort(_('cannot amend with ui.commitsubrepos enabled'))
  4543             if not opts.get('no_commit'):
  4543             if not opts.get('no_commit'):
  4544                 lock = repo.lock()
  4544                 lock = repo.lock()
  4545                 tr = repo.transaction('import')
  4545                 tr = repo.transaction('import')
  4546             else:
  4546             else:
  4547                 dsguard = cmdutil.dirstateguard(repo, 'import')
  4547                 dsguard = cmdutil.dirstateguard(repo, 'import')
  4548             parents = repo.parents()
  4548             parents = repo[None].parents()
  4549             for patchurl in patches:
  4549             for patchurl in patches:
  4550                 if patchurl == '-':
  4550                 if patchurl == '-':
  4551                     ui.status(_('applying patch from stdin\n'))
  4551                     ui.status(_('applying patch from stdin\n'))
  4552                     patchfile = ui.fin
  4552                     patchfile = ui.fin
  4553                     patchurl = 'stdin'      # for error message
  4553                     patchurl = 'stdin'      # for error message
  4563                                                             msgs, hg.clean)
  4563                                                             msgs, hg.clean)
  4564                     if msg:
  4564                     if msg:
  4565                         haspatch = True
  4565                         haspatch = True
  4566                         ui.note(msg + '\n')
  4566                         ui.note(msg + '\n')
  4567                     if update or opts.get('exact'):
  4567                     if update or opts.get('exact'):
  4568                         parents = repo.parents()
  4568                         parents = repo[None].parents()
  4569                     else:
  4569                     else:
  4570                         parents = [repo[node]]
  4570                         parents = [repo[node]]
  4571                     if rej:
  4571                     if rej:
  4572                         ui.write_err(_("patch applied partially\n"))
  4572                         ui.write_err(_("patch applied partially\n"))
  4573                         ui.write_err(_("(fix the .rej files and run "
  4573                         ui.write_err(_("(fix the .rej files and run "