# HG changeset patch # User Idan Kamara # Date 1334847563 -10800 # Node ID 85c7602e283a91db86448a02c5ae16ed5a699d60 # Parent b2e1da5db6df1e625a1a847e35075c3673cebff9 commands: add missing wlock to branch diff -r b2e1da5db6df -r 85c7602e283a mercurial/commands.py --- a/mercurial/commands.py Thu Apr 19 17:59:23 2012 +0300 +++ b/mercurial/commands.py Thu Apr 19 17:59:23 2012 +0300 @@ -863,23 +863,29 @@ Returns 0 on success. """ - - if opts.get('clean'): - label = repo[None].p1().branch() - repo.dirstate.setbranch(label) - ui.status(_('reset working directory to branch %s\n') % label) - elif label: - if not opts.get('force') and label in repo.branchtags(): - if label not in [p.branch() for p in repo.parents()]: - raise util.Abort(_('a branch of the same name already exists'), - # i18n: "it" refers to an existing branch - hint=_("use 'hg update' to switch to it")) - repo.dirstate.setbranch(label) - ui.status(_('marked working directory as branch %s\n') % label) - ui.status(_('(branches are permanent and global, ' - 'did you want a bookmark?)\n')) - else: + if not opts.get('clean') and not label: ui.write("%s\n" % repo.dirstate.branch()) + return + + wlock = repo.wlock() + try: + if opts.get('clean'): + label = repo[None].p1().branch() + repo.dirstate.setbranch(label) + ui.status(_('reset working directory to branch %s\n') % label) + elif label: + if not opts.get('force') and label in repo.branchtags(): + if label not in [p.branch() for p in repo.parents()]: + raise util.Abort(_('a branch of the same name already' + ' exists'), + # i18n: "it" refers to an existing branch + hint=_("use 'hg update' to switch to it")) + repo.dirstate.setbranch(label) + ui.status(_('marked working directory as branch %s\n') % label) + ui.status(_('(branches are permanent and global, ' + 'did you want a bookmark?)\n')) + finally: + wlock.release() @command('branches', [('a', 'active', False, _('show only branches that have unmerged heads')),