486 if opts.get('clean'): |
486 if opts.get('clean'): |
487 label = repo[None].parents()[0].branch() |
487 label = repo[None].parents()[0].branch() |
488 repo.dirstate.setbranch(label) |
488 repo.dirstate.setbranch(label) |
489 ui.status(_('reset working directory to branch %s\n') % label) |
489 ui.status(_('reset working directory to branch %s\n') % label) |
490 elif label: |
490 elif label: |
491 utflabel = encoding.fromlocal(label) |
491 if not opts.get('force') and label in repo.branchtags(): |
492 if not opts.get('force') and utflabel in repo.branchtags(): |
|
493 if label not in [p.branch() for p in repo.parents()]: |
492 if label not in [p.branch() for p in repo.parents()]: |
494 raise util.Abort(_('a branch of the same name already exists' |
493 raise util.Abort(_('a branch of the same name already exists' |
495 " (use 'hg update' to switch to it)")) |
494 " (use 'hg update' to switch to it)")) |
496 repo.dirstate.setbranch(utflabel) |
495 repo.dirstate.setbranch(label) |
497 ui.status(_('marked working directory as branch %s\n') % label) |
496 ui.status(_('marked working directory as branch %s\n') % label) |
498 else: |
497 else: |
499 ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch())) |
498 ui.write("%s\n" % repo.dirstate.branch()) |
500 |
499 |
501 def branches(ui, repo, active=False, closed=False): |
500 def branches(ui, repo, active=False, closed=False): |
502 """list repository named branches |
501 """list repository named branches |
503 |
502 |
504 List the repository's named branches, indicating which ones are |
503 List the repository's named branches, indicating which ones are |
523 for tag, node in repo.branchtags().items()], |
522 for tag, node in repo.branchtags().items()], |
524 reverse=True) |
523 reverse=True) |
525 |
524 |
526 for isactive, node, tag in branches: |
525 for isactive, node, tag in branches: |
527 if (not active) or isactive: |
526 if (not active) or isactive: |
528 encodedtag = encoding.tolocal(tag) |
|
529 if ui.quiet: |
527 if ui.quiet: |
530 ui.write("%s\n" % encodedtag) |
528 ui.write("%s\n" % tag) |
531 else: |
529 else: |
532 hn = repo.lookup(node) |
530 hn = repo.lookup(node) |
533 if isactive: |
531 if isactive: |
534 label = 'branches.active' |
532 label = 'branches.active' |
535 notice = '' |
533 notice = '' |
541 else: |
539 else: |
542 label = 'branches.inactive' |
540 label = 'branches.inactive' |
543 notice = _(' (inactive)') |
541 notice = _(' (inactive)') |
544 if tag == repo.dirstate.branch(): |
542 if tag == repo.dirstate.branch(): |
545 label = 'branches.current' |
543 label = 'branches.current' |
546 rev = str(node).rjust(31 - encoding.colwidth(encodedtag)) |
544 rev = str(node).rjust(31 - encoding.colwidth(tag)) |
547 rev = ui.label('%s:%s' % (rev, hexfunc(hn)), 'log.changeset') |
545 rev = ui.label('%s:%s' % (rev, hexfunc(hn)), 'log.changeset') |
548 encodedtag = ui.label(encodedtag, label) |
546 tag = ui.label(tag, label) |
549 ui.write("%s %s%s\n" % (encodedtag, rev, notice)) |
547 ui.write("%s %s%s\n" % (tag, rev, notice)) |
550 |
548 |
551 def bundle(ui, repo, fname, dest=None, **opts): |
549 def bundle(ui, repo, fname, dest=None, **opts): |
552 """create a changegroup file |
550 """create a changegroup file |
553 |
551 |
554 Generate a compressed changegroup file collecting changesets not |
552 Generate a compressed changegroup file collecting changesets not |
1828 descendants.add(startrev) |
1826 descendants.add(startrev) |
1829 rev = repo.changelog.rev |
1827 rev = repo.changelog.rev |
1830 heads += [repo[h] for h in ls if rev(h) in descendants] |
1828 heads += [repo[h] for h in ls if rev(h) in descendants] |
1831 |
1829 |
1832 if branchrevs: |
1830 if branchrevs: |
1833 decode, encode = encoding.fromlocal, encoding.tolocal |
1831 branches = set(repo[br].branch() for br in branchrevs) |
1834 branches = set(repo[decode(br)].branch() for br in branchrevs) |
|
1835 heads = [h for h in heads if h.branch() in branches] |
1832 heads = [h for h in heads if h.branch() in branches] |
1836 |
1833 |
1837 if not opts.get('closed'): |
1834 if not opts.get('closed'): |
1838 heads = [h for h in heads if not h.extra().get('close')] |
1835 heads = [h for h in heads if not h.extra().get('close')] |
1839 |
1836 |
1842 heads = [h for h in heads if h.node() in dagheads] |
1839 heads = [h for h in heads if h.node() in dagheads] |
1843 |
1840 |
1844 if branchrevs: |
1841 if branchrevs: |
1845 haveheads = set(h.branch() for h in heads) |
1842 haveheads = set(h.branch() for h in heads) |
1846 if branches - haveheads: |
1843 if branches - haveheads: |
1847 headless = ', '.join(encode(b) for b in branches - haveheads) |
1844 headless = ', '.join(b for b in branches - haveheads) |
1848 msg = _('no open branch heads found on branches %s') |
1845 msg = _('no open branch heads found on branches %s') |
1849 if opts.get('rev'): |
1846 if opts.get('rev'): |
1850 msg += _(' (started at %s)' % opts['rev']) |
1847 msg += _(' (started at %s)' % opts['rev']) |
1851 ui.warn((msg + '\n') % headless) |
1848 ui.warn((msg + '\n') % headless) |
1852 |
1849 |
2207 output = [hexfunc(ctx.node())] |
2204 output = [hexfunc(ctx.node())] |
2208 if num: |
2205 if num: |
2209 output.append(str(ctx.rev())) |
2206 output.append(str(ctx.rev())) |
2210 |
2207 |
2211 if repo.local() and default and not ui.quiet: |
2208 if repo.local() and default and not ui.quiet: |
2212 b = encoding.tolocal(ctx.branch()) |
2209 b = ctx.branch() |
2213 if b != 'default': |
2210 if b != 'default': |
2214 output.append("(%s)" % b) |
2211 output.append("(%s)" % b) |
2215 |
2212 |
2216 # multiple tags for a single parent separated by '/' |
2213 # multiple tags for a single parent separated by '/' |
2217 t = "/".join(ctx.tags()) |
2214 t = "/".join(ctx.tags()) |
2218 if t: |
2215 if t: |
2219 output.append(t) |
2216 output.append(t) |
2220 |
2217 |
2221 if branch: |
2218 if branch: |
2222 output.append(encoding.tolocal(ctx.branch())) |
2219 output.append(ctx.branch()) |
2223 |
2220 |
2224 if tags: |
2221 if tags: |
2225 output.extend(ctx.tags()) |
2222 output.extend(ctx.tags()) |
2226 |
2223 |
2227 ui.write("%s\n" % ' '.join(output)) |
2224 ui.write("%s\n" % ' '.join(output)) |
2621 raise util.Abort(_("please specify just one revision")) |
2618 raise util.Abort(_("please specify just one revision")) |
2622 if not node: |
2619 if not node: |
2623 node = opts.get('rev') |
2620 node = opts.get('rev') |
2624 |
2621 |
2625 if not node: |
2622 if not node: |
2626 branch = repo.changectx(None).branch() |
2623 branch = repo[None].branch() |
2627 bheads = repo.branchheads(branch) |
2624 bheads = repo.branchheads(branch) |
2628 if len(bheads) > 2: |
2625 if len(bheads) > 2: |
2629 raise util.Abort(_( |
2626 raise util.Abort(_( |
2630 'branch \'%s\' has %d heads - ' |
2627 'branch \'%s\' has %d heads - ' |
2631 'please merge with an explicit rev\n' |
2628 'please merge with an explicit rev\n' |