comparison mercurial/commands.py @ 4209:dbc3846c09a1

Merge with -stable, fix small test failure
author Matt Mackall <mpm@selenic.com>
date Wed, 14 Mar 2007 01:26:09 -0500
parents 7ca05d29c1f0 7e1c8a565a4f
children 5ccbc0be6cdb
comparison
equal deleted inserted replaced
4203:bd9b84b9a84b 4209:dbc3846c09a1
255 255
256 Unless --force is specified, branch will not let you set a 256 Unless --force is specified, branch will not let you set a
257 branch name that shadows an existing branch. 257 branch name that shadows an existing branch.
258 """ 258 """
259 259
260 if label is not None: 260 if label:
261 if not opts.get('force') and label in repo.branchtags(): 261 if not opts.get('force') and label in repo.branchtags():
262 if label not in [p.branch() for p in repo.workingctx().parents()]: 262 if label not in [p.branch() for p in repo.workingctx().parents()]:
263 raise util.Abort(_('a branch of the same name already exists' 263 raise util.Abort(_('a branch of the same name already exists'
264 ' (use --force to override)')) 264 ' (use --force to override)'))
265 repo.opener("branch", "w").write(util.fromlocal(label) + '\n') 265 repo.dirstate.setbranch(util.fromlocal(label))
266 else: 266 else:
267 b = util.tolocal(repo.workingctx().branch()) 267 ui.write("%s\n" % util.tolocal(repo.dirstate.branch()))
268 if b:
269 ui.write("%s\n" % b)
270 268
271 def branches(ui, repo): 269 def branches(ui, repo):
272 """list repository named branches 270 """list repository named branches
273 271
274 List the repository's named branches. 272 List the repository's named branches.
1444 (modified or added or removed or deleted) and "+" or "")] 1442 (modified or added or removed or deleted) and "+" or "")]
1445 1443
1446 if not ui.quiet: 1444 if not ui.quiet:
1447 1445
1448 branch = util.tolocal(repo.workingctx().branch()) 1446 branch = util.tolocal(repo.workingctx().branch())
1449 if branch: 1447 if branch != 'default':
1450 output.append("(%s)" % branch) 1448 output.append("(%s)" % branch)
1451 1449
1452 # multiple tags for a single parent separated by '/' 1450 # multiple tags for a single parent separated by '/'
1453 parenttags = ['/'.join(tags) 1451 parenttags = ['/'.join(tags)
1454 for tags in map(repo.nodetags, parents) if tags] 1452 for tags in map(repo.nodetags, parents) if tags]