7 |
7 |
8 from node import hex, nullid, nullrev, short |
8 from node import hex, nullid, nullrev, short |
9 from i18n import _, gettext |
9 from i18n import _, gettext |
10 import os, re, sys |
10 import os, re, sys |
11 import hg, util, revlog, bundlerepo, extensions, copies, context, error |
11 import hg, util, revlog, bundlerepo, extensions, copies, context, error |
12 import difflib, patch, time, help, mdiff, tempfile, url |
12 import difflib, patch, time, help, mdiff, tempfile, url, encoding |
13 import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect |
13 import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect |
14 import merge as merge_ |
14 import merge as merge_ |
15 |
15 |
16 # Commands start here, listed alphabetically |
16 # Commands start here, listed alphabetically |
17 |
17 |
413 elif label: |
413 elif label: |
414 if not opts.get('force') and label in repo.branchtags(): |
414 if not opts.get('force') and label in repo.branchtags(): |
415 if label not in [p.branch() for p in repo.parents()]: |
415 if label not in [p.branch() for p in repo.parents()]: |
416 raise util.Abort(_('a branch of the same name already exists' |
416 raise util.Abort(_('a branch of the same name already exists' |
417 ' (use --force to override)')) |
417 ' (use --force to override)')) |
418 repo.dirstate.setbranch(util.fromlocal(label)) |
418 repo.dirstate.setbranch(encoding.fromlocal(label)) |
419 ui.status(_('marked working directory as branch %s\n') % label) |
419 ui.status(_('marked working directory as branch %s\n') % label) |
420 else: |
420 else: |
421 ui.write("%s\n" % util.tolocal(repo.dirstate.branch())) |
421 ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch())) |
422 |
422 |
423 def branches(ui, repo, active=False): |
423 def branches(ui, repo, active=False): |
424 """list repository named branches |
424 """list repository named branches |
425 |
425 |
426 List the repository's named branches, indicating which ones are |
426 List the repository's named branches, indicating which ones are |
429 A branch is considered active if it contains repository heads. |
429 A branch is considered active if it contains repository heads. |
430 |
430 |
431 Use the command 'hg update' to switch to an existing branch. |
431 Use the command 'hg update' to switch to an existing branch. |
432 """ |
432 """ |
433 hexfunc = ui.debugflag and hex or short |
433 hexfunc = ui.debugflag and hex or short |
434 activebranches = [util.tolocal(repo[n].branch()) |
434 activebranches = [encoding.tolocal(repo[n].branch()) |
435 for n in repo.heads(closed=False)] |
435 for n in repo.heads(closed=False)] |
436 branches = util.sort([(tag in activebranches, repo.changelog.rev(node), tag) |
436 branches = util.sort([(tag in activebranches, repo.changelog.rev(node), tag) |
437 for tag, node in repo.branchtags().items()]) |
437 for tag, node in repo.branchtags().items()]) |
438 branches.reverse() |
438 branches.reverse() |
439 |
439 |
447 notice = '' |
447 notice = '' |
448 elif hn not in repo.branchheads(tag, closed=False): |
448 elif hn not in repo.branchheads(tag, closed=False): |
449 notice = ' (closed)' |
449 notice = ' (closed)' |
450 else: |
450 else: |
451 notice = ' (inactive)' |
451 notice = ' (inactive)' |
452 rev = str(node).rjust(31 - util.colwidth(tag)) |
452 rev = str(node).rjust(31 - encoding.colwidth(tag)) |
453 data = tag, rev, hexfunc(hn), notice |
453 data = tag, rev, hexfunc(hn), notice |
454 ui.write("%s %s:%s%s\n" % data) |
454 ui.write("%s %s:%s%s\n" % data) |
455 |
455 |
456 def bundle(ui, repo, fname, dest=None, **opts): |
456 def bundle(ui, repo, fname, dest=None, **opts): |
457 """create a changegroup file |
457 """create a changegroup file |
1577 output = [hexfunc(ctx.node())] |
1577 output = [hexfunc(ctx.node())] |
1578 if num: |
1578 if num: |
1579 output.append(str(ctx.rev())) |
1579 output.append(str(ctx.rev())) |
1580 |
1580 |
1581 if repo.local() and default and not ui.quiet: |
1581 if repo.local() and default and not ui.quiet: |
1582 b = util.tolocal(ctx.branch()) |
1582 b = encoding.tolocal(ctx.branch()) |
1583 if b != 'default': |
1583 if b != 'default': |
1584 output.append("(%s)" % b) |
1584 output.append("(%s)" % b) |
1585 |
1585 |
1586 # multiple tags for a single parent separated by '/' |
1586 # multiple tags for a single parent separated by '/' |
1587 t = "/".join(ctx.tags()) |
1587 t = "/".join(ctx.tags()) |
1588 if t: |
1588 if t: |
1589 output.append(t) |
1589 output.append(t) |
1590 |
1590 |
1591 if branch: |
1591 if branch: |
1592 output.append(util.tolocal(ctx.branch())) |
1592 output.append(encoding.tolocal(ctx.branch())) |
1593 |
1593 |
1594 if tags: |
1594 if tags: |
1595 output.extend(ctx.tags()) |
1595 output.extend(ctx.tags()) |
1596 |
1596 |
1597 ui.write("%s\n" % ' '.join(output)) |
1597 ui.write("%s\n" % ' '.join(output)) |
2974 ('q', 'quiet', None, _('suppress output')), |
2974 ('q', 'quiet', None, _('suppress output')), |
2975 ('v', 'verbose', None, _('enable additional output')), |
2975 ('v', 'verbose', None, _('enable additional output')), |
2976 ('', 'config', [], _('set/override config option')), |
2976 ('', 'config', [], _('set/override config option')), |
2977 ('', 'debug', None, _('enable debugging output')), |
2977 ('', 'debug', None, _('enable debugging output')), |
2978 ('', 'debugger', None, _('start debugger')), |
2978 ('', 'debugger', None, _('start debugger')), |
2979 ('', 'encoding', util._encoding, _('set the charset encoding')), |
2979 ('', 'encoding', encoding.encoding, _('set the charset encoding')), |
2980 ('', 'encodingmode', util._encodingmode, _('set the charset encoding mode')), |
2980 ('', 'encodingmode', encoding.encodingmode, |
|
2981 _('set the charset encoding mode')), |
2981 ('', 'lsprof', None, _('print improved command execution profile')), |
2982 ('', 'lsprof', None, _('print improved command execution profile')), |
2982 ('', 'traceback', None, _('print traceback on exception')), |
2983 ('', 'traceback', None, _('print traceback on exception')), |
2983 ('', 'time', None, _('time how long the command takes')), |
2984 ('', 'time', None, _('time how long the command takes')), |
2984 ('', 'profile', None, _('print command execution profile')), |
2985 ('', 'profile', None, _('print command execution profile')), |
2985 ('', 'version', None, _('output version information and exit')), |
2986 ('', 'version', None, _('output version information and exit')), |