424 if opts.get('clean'): |
424 if opts.get('clean'): |
425 label = repo[None].parents()[0].branch() |
425 label = repo[None].parents()[0].branch() |
426 repo.dirstate.setbranch(label) |
426 repo.dirstate.setbranch(label) |
427 ui.status(_('reset working directory to branch %s\n') % label) |
427 ui.status(_('reset working directory to branch %s\n') % label) |
428 elif label: |
428 elif label: |
429 if not opts.get('force') and label in repo.branchtags(): |
429 utflabel = encoding.fromlocal(label) |
|
430 if not opts.get('force') and utflabel in repo.branchtags(): |
430 if label not in [p.branch() for p in repo.parents()]: |
431 if label not in [p.branch() for p in repo.parents()]: |
431 raise util.Abort(_('a branch of the same name already exists' |
432 raise util.Abort(_('a branch of the same name already exists' |
432 ' (use --force to override)')) |
433 ' (use --force to override)')) |
433 repo.dirstate.setbranch(encoding.fromlocal(label)) |
434 repo.dirstate.setbranch(utflabel) |
434 ui.status(_('marked working directory as branch %s\n') % label) |
435 ui.status(_('marked working directory as branch %s\n') % label) |
435 else: |
436 else: |
436 ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch())) |
437 ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch())) |
437 |
438 |
438 def branches(ui, repo, active=False, closed=False): |
439 def branches(ui, repo, active=False, closed=False): |