Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 7948:de377b1a9a84
move encoding bits from util to encoding
In addition to cleaning up util, this gets rid of some circular dependencies.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 03 Apr 2009 14:51:48 -0500 |
parents | 553cef16031f |
children | a8a719ff150a |
comparison
equal
deleted
inserted
replaced
7947:a454eeb1b827 | 7948:de377b1a9a84 |
---|---|
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 |
880 return name | 880 return name |
881 | 881 |
882 problems = 0 | 882 problems = 0 |
883 | 883 |
884 # encoding | 884 # encoding |
885 ui.status(_("Checking encoding (%s)...\n") % util._encoding) | 885 ui.status(_("Checking encoding (%s)...\n") % encoding.encoding) |
886 try: | 886 try: |
887 util.fromlocal("test") | 887 encoding.fromlocal("test") |
888 except util.Abort, inst: | 888 except util.Abort, inst: |
889 ui.write(" %s\n" % inst) | 889 ui.write(" %s\n" % inst) |
890 ui.write(_(" (check that your locale is properly set)\n")) | 890 ui.write(_(" (check that your locale is properly set)\n")) |
891 problems += 1 | 891 problems += 1 |
892 | 892 |
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)) |
2853 hn = hexfunc(n) | 2853 hn = hexfunc(n) |
2854 r = "%5d:%s" % (repo.changelog.rev(n), hn) | 2854 r = "%5d:%s" % (repo.changelog.rev(n), hn) |
2855 except error.LookupError: | 2855 except error.LookupError: |
2856 r = " ?:%s" % hn | 2856 r = " ?:%s" % hn |
2857 else: | 2857 else: |
2858 spaces = " " * (30 - util.colwidth(t)) | 2858 spaces = " " * (30 - encoding.colwidth(t)) |
2859 if ui.verbose: | 2859 if ui.verbose: |
2860 if repo.tagtype(t) == 'local': | 2860 if repo.tagtype(t) == 'local': |
2861 tagtype = " local" | 2861 tagtype = " local" |
2862 else: | 2862 else: |
2863 tagtype = "" | 2863 tagtype = "" |
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')), |