Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 4601:e69da61e467e
Notify the user that hg branch does not create a branch until commit
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Mon, 18 Jun 2007 10:44:43 -0700 |
parents | 2937d0dbfab0 |
children | a8be3c875988 |
comparison
equal
deleted
inserted
replaced
4600:64c415d2553a | 4601:e69da61e467e |
---|---|
217 'if you want to auto-merge)\n')) | 217 'if you want to auto-merge)\n')) |
218 | 218 |
219 def branch(ui, repo, label=None, **opts): | 219 def branch(ui, repo, label=None, **opts): |
220 """set or show the current branch name | 220 """set or show the current branch name |
221 | 221 |
222 With <name>, set the current branch name. Otherwise, show the | 222 With no argument, show the current branch name. With one argument, |
223 current branch name. | 223 set the working directory branch name (the branch does not exist in |
224 the repository until the next commit). | |
224 | 225 |
225 Unless --force is specified, branch will not let you set a | 226 Unless --force is specified, branch will not let you set a |
226 branch name that shadows an existing branch. | 227 branch name that shadows an existing branch. |
227 """ | 228 """ |
228 | 229 |
230 if not opts.get('force') and label in repo.branchtags(): | 231 if not opts.get('force') and label in repo.branchtags(): |
231 if label not in [p.branch() for p in repo.workingctx().parents()]: | 232 if label not in [p.branch() for p in repo.workingctx().parents()]: |
232 raise util.Abort(_('a branch of the same name already exists' | 233 raise util.Abort(_('a branch of the same name already exists' |
233 ' (use --force to override)')) | 234 ' (use --force to override)')) |
234 repo.dirstate.setbranch(util.fromlocal(label)) | 235 repo.dirstate.setbranch(util.fromlocal(label)) |
236 ui.status(_('marked working directory as branch %s\n') % label) | |
235 else: | 237 else: |
236 ui.write("%s\n" % util.tolocal(repo.dirstate.branch())) | 238 ui.write("%s\n" % util.tolocal(repo.dirstate.branch())) |
237 | 239 |
238 def branches(ui, repo): | 240 def branches(ui, repo): |
239 """list repository named branches | 241 """list repository named branches |