comparison mercurial/commands.py @ 16471:85c7602e283a stable

commands: add missing wlock to branch
author Idan Kamara <idankk86@gmail.com>
date Thu, 19 Apr 2012 17:59:23 +0300
parents b2e1da5db6df
children 7adc521259d4
comparison
equal deleted inserted replaced
16470:b2e1da5db6df 16471:85c7602e283a
861 Use the command :hg:`update` to switch to an existing branch. Use 861 Use the command :hg:`update` to switch to an existing branch. Use
862 :hg:`commit --close-branch` to mark this branch as closed. 862 :hg:`commit --close-branch` to mark this branch as closed.
863 863
864 Returns 0 on success. 864 Returns 0 on success.
865 """ 865 """
866 866 if not opts.get('clean') and not label:
867 if opts.get('clean'):
868 label = repo[None].p1().branch()
869 repo.dirstate.setbranch(label)
870 ui.status(_('reset working directory to branch %s\n') % label)
871 elif label:
872 if not opts.get('force') and label in repo.branchtags():
873 if label not in [p.branch() for p in repo.parents()]:
874 raise util.Abort(_('a branch of the same name already exists'),
875 # i18n: "it" refers to an existing branch
876 hint=_("use 'hg update' to switch to it"))
877 repo.dirstate.setbranch(label)
878 ui.status(_('marked working directory as branch %s\n') % label)
879 ui.status(_('(branches are permanent and global, '
880 'did you want a bookmark?)\n'))
881 else:
882 ui.write("%s\n" % repo.dirstate.branch()) 867 ui.write("%s\n" % repo.dirstate.branch())
868 return
869
870 wlock = repo.wlock()
871 try:
872 if opts.get('clean'):
873 label = repo[None].p1().branch()
874 repo.dirstate.setbranch(label)
875 ui.status(_('reset working directory to branch %s\n') % label)
876 elif label:
877 if not opts.get('force') and label in repo.branchtags():
878 if label not in [p.branch() for p in repo.parents()]:
879 raise util.Abort(_('a branch of the same name already'
880 ' exists'),
881 # i18n: "it" refers to an existing branch
882 hint=_("use 'hg update' to switch to it"))
883 repo.dirstate.setbranch(label)
884 ui.status(_('marked working directory as branch %s\n') % label)
885 ui.status(_('(branches are permanent and global, '
886 'did you want a bookmark?)\n'))
887 finally:
888 wlock.release()
883 889
884 @command('branches', 890 @command('branches',
885 [('a', 'active', False, _('show only branches that have unmerged heads')), 891 [('a', 'active', False, _('show only branches that have unmerged heads')),
886 ('c', 'closed', False, _('show normal and closed branches'))], 892 ('c', 'closed', False, _('show normal and closed branches'))],
887 _('[-ac]')) 893 _('[-ac]'))