Mercurial > hg-stable
changeset 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 | 14a4e17f0817 |
files | mercurial/commands.py |
diffstat | 1 files changed, 22 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- 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')),