comparison mercurial/commands.py @ 1402:9d2c2e6b32b5

i18n part2: use '_' for all strings who are part of the user interface
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Tue, 18 Oct 2005 18:38:39 -0700
parents cf9a1233738a
children 67e20e27d8df
comparison
equal deleted inserted replaced
1401:fbf2b10011aa 1402:9d2c2e6b32b5
177 num = repo.changelog.rev(repo.lookup(val)) 177 num = repo.changelog.rev(repo.lookup(val))
178 except KeyError: 178 except KeyError:
179 try: 179 try:
180 num = revlog.rev(revlog.lookup(val)) 180 num = revlog.rev(revlog.lookup(val))
181 except KeyError: 181 except KeyError:
182 raise util.Abort('invalid revision identifier %s', val) 182 raise util.Abort(_('invalid revision identifier %s'), val)
183 return num 183 return num
184 seen = {} 184 seen = {}
185 for spec in revs: 185 for spec in revs:
186 if spec.find(revrangesep) >= 0: 186 if spec.find(revrangesep) >= 0:
187 start, end = spec.split(revrangesep, 1) 187 start, end = spec.split(revrangesep, 1)
237 c = expander[c]() 237 c = expander[c]()
238 newname.append(c) 238 newname.append(c)
239 i += 1 239 i += 1
240 return ''.join(newname) 240 return ''.join(newname)
241 except KeyError, inst: 241 except KeyError, inst:
242 raise util.Abort("invalid format spec '%%%s' in output file name", 242 raise util.Abort(_("invalid format spec '%%%s' in output file name"),
243 inst.args[0]) 243 inst.args[0])
244 244
245 def make_file(repo, r, pat, node=None, 245 def make_file(repo, r, pat, node=None,
246 total=None, seqno=None, revwidth=None, mode='wb', pathname=None): 246 total=None, seqno=None, revwidth=None, mode='wb', pathname=None):
247 if not pat or pat == '-': 247 if not pat or pat == '-':
331 if ui.debugflag or p != nullid] 331 if ui.debugflag or p != nullid]
332 if not ui.debugflag and len(parents) == 1 and parents[0][0] == rev-1: 332 if not ui.debugflag and len(parents) == 1 and parents[0][0] == rev-1:
333 parents = [] 333 parents = []
334 334
335 if ui.verbose: 335 if ui.verbose:
336 ui.write("changeset: %d:%s\n" % (rev, hex(changenode))) 336 ui.write(_("changeset: %d:%s\n") % (rev, hex(changenode)))
337 else: 337 else:
338 ui.write("changeset: %d:%s\n" % (rev, short(changenode))) 338 ui.write(_("changeset: %d:%s\n") % (rev, short(changenode)))
339 339
340 for tag in repo.nodetags(changenode): 340 for tag in repo.nodetags(changenode):
341 ui.status("tag: %s\n" % tag) 341 ui.status(_("tag: %s\n") % tag)
342 for parent in parents: 342 for parent in parents:
343 ui.write("parent: %d:%s\n" % parent) 343 ui.write(_("parent: %d:%s\n") % parent)
344 344
345 if brinfo and changenode in brinfo: 345 if brinfo and changenode in brinfo:
346 br = brinfo[changenode] 346 br = brinfo[changenode]
347 ui.write("branch: %s\n" % " ".join(br)) 347 ui.write(_("branch: %s\n") % " ".join(br))
348 348
349 ui.debug("manifest: %d:%s\n" % (repo.manifest.rev(changes[0]), 349 ui.debug(_("manifest: %d:%s\n") % (repo.manifest.rev(changes[0]),
350 hex(changes[0]))) 350 hex(changes[0])))
351 ui.status("user: %s\n" % changes[1]) 351 ui.status(_("user: %s\n") % changes[1])
352 ui.status("date: %s\n" % date) 352 ui.status(_("date: %s\n") % date)
353 353
354 if ui.debugflag: 354 if ui.debugflag:
355 files = repo.changes(log.parents(changenode)[0], changenode) 355 files = repo.changes(log.parents(changenode)[0], changenode)
356 for key, value in zip(["files:", "files+:", "files-:"], files): 356 for key, value in zip([_("files:"), _("files+:"), _("files-:")], files):
357 if value: 357 if value:
358 ui.note("%-12s %s\n" % (key, " ".join(value))) 358 ui.note("%-12s %s\n" % (key, " ".join(value)))
359 else: 359 else:
360 ui.note("files: %s\n" % " ".join(changes[3])) 360 ui.note(_("files: %s\n") % " ".join(changes[3]))
361 361
362 description = changes[4].strip() 362 description = changes[4].strip()
363 if description: 363 if description:
364 if ui.verbose: 364 if ui.verbose:
365 ui.status("description:\n") 365 ui.status(_("description:\n"))
366 ui.status(description) 366 ui.status(description)
367 ui.status("\n\n") 367 ui.status("\n\n")
368 else: 368 else:
369 ui.status("summary: %s\n" % description.splitlines()[0]) 369 ui.status(_("summary: %s\n") % description.splitlines()[0])
370 ui.status("\n") 370 ui.status("\n")
371 371
372 def show_version(ui): 372 def show_version(ui):
373 """output version and copyright information""" 373 """output version and copyright information"""
374 ui.write("Mercurial Distributed SCM (version %s)\n" 374 ui.write(_("Mercurial Distributed SCM (version %s)\n")
375 % version.get_version()) 375 % version.get_version())
376 ui.status( 376 ui.status(_(
377 "\nCopyright (C) 2005 Matt Mackall <mpm@selenic.com>\n" 377 "\nCopyright (C) 2005 Matt Mackall <mpm@selenic.com>\n"
378 "This is free software; see the source for copying conditions. " 378 "This is free software; see the source for copying conditions. "
379 "There is NO\nwarranty; " 379 "There is NO\nwarranty; "
380 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" 380 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
381 ) 381 ))
382 382
383 def help_(ui, cmd=None, with_version=False): 383 def help_(ui, cmd=None, with_version=False):
384 """show help for a given command or all commands""" 384 """show help for a given command or all commands"""
385 option_lists = [] 385 option_lists = []
386 if cmd and cmd != 'shortlist': 386 if cmd and cmd != 'shortlist':
399 399
400 if not ui.quiet: 400 if not ui.quiet:
401 # aliases 401 # aliases
402 aliases = ', '.join(key.split('|')[1:]) 402 aliases = ', '.join(key.split('|')[1:])
403 if aliases: 403 if aliases:
404 ui.write("\naliases: %s\n" % aliases) 404 ui.write(_("\naliases: %s\n") % aliases)
405 405
406 # options 406 # options
407 if i[1]: 407 if i[1]:
408 option_lists.append(("options", i[1])) 408 option_lists.append(("options", i[1]))
409 409
410 else: 410 else:
411 # program name 411 # program name
412 if ui.verbose or with_version: 412 if ui.verbose or with_version:
413 show_version(ui) 413 show_version(ui)
414 else: 414 else:
415 ui.status("Mercurial Distributed SCM\n") 415 ui.status(_("Mercurial Distributed SCM\n"))
416 ui.status('\n') 416 ui.status('\n')
417 417
418 # list of commands 418 # list of commands
419 if cmd == "shortlist": 419 if cmd == "shortlist":
420 ui.status('basic commands (use "hg help" ' 420 ui.status(_('basic commands (use "hg help" '
421 'for the full list or option "-v" for details):\n\n') 421 'for the full list or option "-v" for details):\n\n'))
422 elif ui.verbose: 422 elif ui.verbose:
423 ui.status('list of commands:\n\n') 423 ui.status(_('list of commands:\n\n'))
424 else: 424 else:
425 ui.status('list of commands (use "hg help -v" ' 425 ui.status(_('list of commands (use "hg help -v" '
426 'to show aliases and global options):\n\n') 426 'to show aliases and global options):\n\n'))
427 427
428 h = {} 428 h = {}
429 cmds = {} 429 cmds = {}
430 for c, e in table.items(): 430 for c, e in table.items():
431 f = c.split("|")[0] 431 f = c.split("|")[0]
460 opt_output.append(("\n%s:\n" % title, None)) 460 opt_output.append(("\n%s:\n" % title, None))
461 for shortopt, longopt, default, desc in options: 461 for shortopt, longopt, default, desc in options:
462 opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt, 462 opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt,
463 longopt and " --%s" % longopt), 463 longopt and " --%s" % longopt),
464 "%s%s" % (desc, 464 "%s%s" % (desc,
465 default and " (default: %s)" % default 465 default and _(" (default: %s)") % default
466 or ""))) 466 or "")))
467 467
468 if opt_output: 468 if opt_output:
469 opts_len = max([len(line[0]) for line in opt_output if line[1]]) 469 opts_len = max([len(line[0]) for line in opt_output if line[1]])
470 for first, second in opt_output: 470 for first, second in opt_output:
478 def add(ui, repo, *pats, **opts): 478 def add(ui, repo, *pats, **opts):
479 '''add the specified files on the next commit''' 479 '''add the specified files on the next commit'''
480 names = [] 480 names = []
481 for src, abs, rel, exact in walk(repo, pats, opts): 481 for src, abs, rel, exact in walk(repo, pats, opts):
482 if exact: 482 if exact:
483 if ui.verbose: ui.status('adding %s\n' % rel) 483 if ui.verbose: ui.status(_('adding %s\n') % rel)
484 names.append(abs) 484 names.append(abs)
485 elif repo.dirstate.state(abs) == '?': 485 elif repo.dirstate.state(abs) == '?':
486 ui.status('adding %s\n' % rel) 486 ui.status(_('adding %s\n') % rel)
487 names.append(abs) 487 names.append(abs)
488 repo.add(names) 488 repo.add(names)
489 489
490 def addremove(ui, repo, *pats, **opts): 490 def addremove(ui, repo, *pats, **opts):
491 """add all new files, delete all missing files""" 491 """add all new files, delete all missing files"""
492 add, remove = [], [] 492 add, remove = [], []
493 for src, abs, rel, exact in walk(repo, pats, opts): 493 for src, abs, rel, exact in walk(repo, pats, opts):
494 if src == 'f' and repo.dirstate.state(abs) == '?': 494 if src == 'f' and repo.dirstate.state(abs) == '?':
495 add.append(abs) 495 add.append(abs)
496 if ui.verbose or not exact: 496 if ui.verbose or not exact:
497 ui.status('adding ', rel, '\n') 497 ui.status(_('adding %s\n') % rel)
498 if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel): 498 if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel):
499 remove.append(abs) 499 remove.append(abs)
500 if ui.verbose or not exact: 500 if ui.verbose or not exact:
501 ui.status('removing ', rel, '\n') 501 ui.status(_('removing %s\n') % rel)
502 repo.add(add) 502 repo.add(add)
503 repo.remove(remove) 503 repo.remove(remove)
504 504
505 def annotate(ui, repo, *pats, **opts): 505 def annotate(ui, repo, *pats, **opts):
506 """show changeset information per file line""" 506 """show changeset information per file line"""
511 def getname(rev): 511 def getname(rev):
512 cl = repo.changelog.read(repo.changelog.node(rev)) 512 cl = repo.changelog.read(repo.changelog.node(rev))
513 return trimuser(ui, cl[1], rev, ucache) 513 return trimuser(ui, cl[1], rev, ucache)
514 514
515 if not pats: 515 if not pats:
516 raise util.Abort('at least one file name or pattern required') 516 raise util.Abort(_('at least one file name or pattern required'))
517 517
518 opmap = [['user', getname], ['number', str], ['changeset', getnode]] 518 opmap = [['user', getname], ['number', str], ['changeset', getnode]]
519 if not opts['user'] and not opts['changeset']: 519 if not opts['user'] and not opts['changeset']:
520 opts['number'] = 1 520 opts['number'] = 1
521 521
526 change = repo.changelog.read(node) 526 change = repo.changelog.read(node)
527 mmap = repo.manifest.read(change[0]) 527 mmap = repo.manifest.read(change[0])
528 528
529 for src, abs, rel, exact in walk(repo, pats, opts): 529 for src, abs, rel, exact in walk(repo, pats, opts):
530 if abs not in mmap: 530 if abs not in mmap:
531 ui.warn("warning: %s is not in the repository!\n" % rel) 531 ui.warn(_("warning: %s is not in the repository!\n") % rel)
532 continue 532 continue
533 533
534 f = repo.file(abs) 534 f = repo.file(abs)
535 if not opts['text'] and util.binary(f.read(mmap[abs])): 535 if not opts['text'] and util.binary(f.read(mmap[abs])):
536 ui.write("%s: binary file\n" % rel) 536 ui.write(_("%s: binary file\n") % rel)
537 continue 537 continue
538 538
539 lines = f.annotate(mmap[abs]) 539 lines = f.annotate(mmap[abs])
540 pieces = [] 540 pieces = []
541 541
584 n = mf[abs] 584 n = mf[abs]
585 except (hg.RepoError, KeyError): 585 except (hg.RepoError, KeyError):
586 try: 586 try:
587 n = r.lookup(rev) 587 n = r.lookup(rev)
588 except KeyError, inst: 588 except KeyError, inst:
589 raise util.Abort('cannot find file %s in rev %s', rel, rev) 589 raise util.Abort(_('cannot find file %s in rev %s'), rel, rev)
590 else: 590 else:
591 n = r.tip() 591 n = r.tip()
592 fp = make_file(repo, r, opts['output'], node=n, pathname=abs) 592 fp = make_file(repo, r, opts['output'], node=n, pathname=abs)
593 fp.write(r.read(n)) 593 fp.write(r.read(n))
594 594
596 """make a copy of an existing repository""" 596 """make a copy of an existing repository"""
597 if dest is None: 597 if dest is None:
598 dest = os.path.basename(os.path.normpath(source)) 598 dest = os.path.basename(os.path.normpath(source))
599 599
600 if os.path.exists(dest): 600 if os.path.exists(dest):
601 raise util.Abort("destination '%s' already exists", dest) 601 raise util.Abort(_("destination '%s' already exists"), dest)
602 602
603 dest = os.path.realpath(dest) 603 dest = os.path.realpath(dest)
604 604
605 class Dircleanup: 605 class Dircleanup:
606 def __init__(self, dir_): 606 def __init__(self, dir_):
668 d.close() 668 d.close()
669 669
670 def commit(ui, repo, *pats, **opts): 670 def commit(ui, repo, *pats, **opts):
671 """commit the specified files or all outstanding changes""" 671 """commit the specified files or all outstanding changes"""
672 if opts['text']: 672 if opts['text']:
673 ui.warn("Warning: -t and --text is deprecated," 673 ui.warn(_("Warning: -t and --text is deprecated,"
674 " please use -m or --message instead.\n") 674 " please use -m or --message instead.\n"))
675 message = opts['message'] or opts['text'] 675 message = opts['message'] or opts['text']
676 logfile = opts['logfile'] 676 logfile = opts['logfile']
677 677
678 if message and logfile: 678 if message and logfile:
679 raise util.Abort('options --message and --logfile are mutually ' 679 raise util.Abort(_('options --message and --logfile are mutually '
680 'exclusive') 680 'exclusive'))
681 if not message and logfile: 681 if not message and logfile:
682 try: 682 try:
683 if logfile == '-': 683 if logfile == '-':
684 message = sys.stdin.read() 684 message = sys.stdin.read()
685 else: 685 else:
686 message = open(logfile).read() 686 message = open(logfile).read()
687 except IOError, inst: 687 except IOError, inst:
688 raise util.Abort("can't read commit message '%s': %s" % 688 raise util.Abort(_("can't read commit message '%s': %s") %
689 (logfile, inst.strerror)) 689 (logfile, inst.strerror))
690 690
691 if opts['addremove']: 691 if opts['addremove']:
692 addremove(ui, repo, *pats, **opts) 692 addremove(ui, repo, *pats, **opts)
693 cwd = repo.getcwd() 693 cwd = repo.getcwd()
706 except ValueError, inst: 706 except ValueError, inst:
707 raise util.Abort(str(inst)) 707 raise util.Abort(str(inst))
708 708
709 def docopy(ui, repo, pats, opts): 709 def docopy(ui, repo, pats, opts):
710 if not pats: 710 if not pats:
711 raise util.Abort('no source or destination specified') 711 raise util.Abort(_('no source or destination specified'))
712 elif len(pats) == 1: 712 elif len(pats) == 1:
713 raise util.Abort('no destination specified') 713 raise util.Abort(_('no destination specified'))
714 pats = list(pats) 714 pats = list(pats)
715 dest = pats.pop() 715 dest = pats.pop()
716 sources = [] 716 sources = []
717 717
718 def okaytocopy(abs, rel, exact): 718 def okaytocopy(abs, rel, exact):
719 reasons = {'?': 'is not managed', 719 reasons = {'?': _('is not managed'),
720 'a': 'has been marked for add'} 720 'a': _('has been marked for add')}
721 reason = reasons.get(repo.dirstate.state(abs)) 721 reason = reasons.get(repo.dirstate.state(abs))
722 if reason: 722 if reason:
723 if exact: ui.warn('%s: not copying - file %s\n' % (rel, reason)) 723 if exact: ui.warn(_('%s: not copying - file %s\n') % (rel, reason))
724 else: 724 else:
725 return True 725 return True
726 726
727 for src, abs, rel, exact in walk(repo, pats, opts): 727 for src, abs, rel, exact in walk(repo, pats, opts):
728 if okaytocopy(abs, rel, exact): 728 if okaytocopy(abs, rel, exact):
729 sources.append((abs, rel, exact)) 729 sources.append((abs, rel, exact))
730 if not sources: 730 if not sources:
731 raise util.Abort('no files to copy') 731 raise util.Abort(_('no files to copy'))
732 732
733 cwd = repo.getcwd() 733 cwd = repo.getcwd()
734 absdest = util.canonpath(repo.root, cwd, dest) 734 absdest = util.canonpath(repo.root, cwd, dest)
735 reldest = util.pathto(cwd, absdest) 735 reldest = util.pathto(cwd, absdest)
736 if os.path.exists(reldest): 736 if os.path.exists(reldest):
738 else: 738 else:
739 destisfile = len(sources) == 1 or repo.dirstate.state(absdest) != '?' 739 destisfile = len(sources) == 1 or repo.dirstate.state(absdest) != '?'
740 740
741 if destisfile: 741 if destisfile:
742 if opts['parents']: 742 if opts['parents']:
743 raise util.Abort('with --parents, destination must be a directory') 743 raise util.Abort(_('with --parents, destination must be a directory'))
744 elif len(sources) > 1: 744 elif len(sources) > 1:
745 raise util.Abort('with multiple sources, destination must be a ' 745 raise util.Abort(_('with multiple sources, destination must be a '
746 'directory') 746 'directory'))
747 errs, copied = 0, [] 747 errs, copied = 0, []
748 for abs, rel, exact in sources: 748 for abs, rel, exact in sources:
749 if opts['parents']: 749 if opts['parents']:
750 mydest = os.path.join(dest, rel) 750 mydest = os.path.join(dest, rel)
751 elif destisfile: 751 elif destisfile:
753 else: 753 else:
754 mydest = os.path.join(dest, os.path.basename(rel)) 754 mydest = os.path.join(dest, os.path.basename(rel))
755 myabsdest = util.canonpath(repo.root, cwd, mydest) 755 myabsdest = util.canonpath(repo.root, cwd, mydest)
756 myreldest = util.pathto(cwd, myabsdest) 756 myreldest = util.pathto(cwd, myabsdest)
757 if not opts['force'] and repo.dirstate.state(myabsdest) not in 'a?': 757 if not opts['force'] and repo.dirstate.state(myabsdest) not in 'a?':
758 ui.warn('%s: not overwriting - file already managed\n' % myreldest) 758 ui.warn(_('%s: not overwriting - file already managed\n') % myreldest)
759 continue 759 continue
760 mydestdir = os.path.dirname(myreldest) or '.' 760 mydestdir = os.path.dirname(myreldest) or '.'
761 if not opts['after']: 761 if not opts['after']:
762 try: 762 try:
763 if opts['parents']: os.makedirs(mydestdir) 763 if opts['parents']: os.makedirs(mydestdir)
764 elif not destisfile: os.mkdir(mydestdir) 764 elif not destisfile: os.mkdir(mydestdir)
765 except OSError, inst: 765 except OSError, inst:
766 if inst.errno != errno.EEXIST: raise 766 if inst.errno != errno.EEXIST: raise
767 if ui.verbose or not exact: 767 if ui.verbose or not exact:
768 ui.status('copying %s to %s\n' % (rel, myreldest)) 768 ui.status(_('copying %s to %s\n') % (rel, myreldest))
769 if not opts['after']: 769 if not opts['after']:
770 try: 770 try:
771 shutil.copyfile(rel, myreldest) 771 shutil.copyfile(rel, myreldest)
772 shutil.copymode(rel, myreldest) 772 shutil.copymode(rel, myreldest)
773 except shutil.Error, inst: 773 except shutil.Error, inst:
774 raise util.Abort(str(inst)) 774 raise util.Abort(str(inst))
775 except IOError, inst: 775 except IOError, inst:
776 if inst.errno == errno.ENOENT: 776 if inst.errno == errno.ENOENT:
777 ui.warn('%s: deleted in working copy\n' % rel) 777 ui.warn(_('%s: deleted in working copy\n') % rel)
778 else: 778 else:
779 ui.warn('%s: cannot copy - %s\n' % (rel, inst.strerror)) 779 ui.warn(_('%s: cannot copy - %s\n') % (rel, inst.strerror))
780 errs += 1 780 errs += 1
781 continue 781 continue
782 repo.copy(abs, myabsdest) 782 repo.copy(abs, myabsdest)
783 copied.append((abs, rel, exact)) 783 copied.append((abs, rel, exact))
784 if errs: 784 if errs:
785 ui.warn('(consider using --after)\n') 785 ui.warn(_('(consider using --after)\n'))
786 return errs, copied 786 return errs, copied
787 787
788 def copy(ui, repo, *pats, **opts): 788 def copy(ui, repo, *pats, **opts):
789 """mark files as copied for the next commit""" 789 """mark files as copied for the next commit"""
790 errs, copied = docopy(ui, repo, pats, opts) 790 errs, copied = docopy(ui, repo, pats, opts)
809 m2 = repo.manifest.read(m2n) 809 m2 = repo.manifest.read(m2n)
810 errors = 0 810 errors = 0
811 for f in dc: 811 for f in dc:
812 state = repo.dirstate.state(f) 812 state = repo.dirstate.state(f)
813 if state in "nr" and f not in m1: 813 if state in "nr" and f not in m1:
814 ui.warn("%s in state %s, but not in manifest1\n" % (f, state)) 814 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
815 errors += 1 815 errors += 1
816 if state in "a" and f in m1: 816 if state in "a" and f in m1:
817 ui.warn("%s in state %s, but also in manifest1\n" % (f, state)) 817 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
818 errors += 1 818 errors += 1
819 if state in "m" and f not in m1 and f not in m2: 819 if state in "m" and f not in m1 and f not in m2:
820 ui.warn("%s in state %s, but not in either manifest\n" % 820 ui.warn(_("%s in state %s, but not in either manifest\n") %
821 (f, state)) 821 (f, state))
822 errors += 1 822 errors += 1
823 for f in m1: 823 for f in m1:
824 state = repo.dirstate.state(f) 824 state = repo.dirstate.state(f)
825 if state not in "nrm": 825 if state not in "nrm":
826 ui.warn("%s in manifest1, but listed as state %s" % (f, state)) 826 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
827 errors += 1 827 errors += 1
828 if errors: 828 if errors:
829 raise util.Abort(".hg/dirstate inconsistent with current parent's manifest") 829 raise util.Abort(_(".hg/dirstate inconsistent with current parent's manifest"))
830 830
831 def debugconfig(ui): 831 def debugconfig(ui):
832 """show combined config settings from all hgrc files""" 832 """show combined config settings from all hgrc files"""
833 try: 833 try:
834 repo = hg.repository(ui) 834 repo = hg.repository(ui)
860 ui.write("%c %3o %10d %s %s\n" 860 ui.write("%c %3o %10d %s %s\n"
861 % (dc[file_][0], dc[file_][1] & 0777, dc[file_][2], 861 % (dc[file_][0], dc[file_][1] & 0777, dc[file_][2],
862 time.strftime("%x %X", 862 time.strftime("%x %X",
863 time.localtime(dc[file_][3])), file_)) 863 time.localtime(dc[file_][3])), file_))
864 for f in repo.dirstate.copies: 864 for f in repo.dirstate.copies:
865 ui.write("copy: %s -> %s\n" % (repo.dirstate.copies[f], f)) 865 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copies[f], f))
866 866
867 def debugdata(ui, file_, rev): 867 def debugdata(ui, file_, rev):
868 """dump the contents of an data file revision""" 868 """dump the contents of an data file revision"""
869 r = revlog.revlog(file, file_[:-2] + ".i", file_) 869 r = revlog.revlog(file, file_[:-2] + ".i", file_)
870 try: 870 try:
871 ui.write(r.revision(r.lookup(rev))) 871 ui.write(r.revision(r.lookup(rev)))
872 except KeyError: 872 except KeyError:
873 raise util.Abort('invalid revision identifier %s', rev) 873 raise util.Abort(_('invalid revision identifier %s'), rev)
874 874
875 def debugindex(ui, file_): 875 def debugindex(ui, file_):
876 """dump the contents of an index file""" 876 """dump the contents of an index file"""
877 r = revlog.revlog(file, file_, "") 877 r = revlog.revlog(file, file_, "")
878 ui.write(" rev offset length base linkrev" + 878 ui.write(" rev offset length base linkrev" +
908 n = r.lookup(rev) 908 n = r.lookup(rev)
909 else: 909 else:
910 n = r.tip() 910 n = r.tip()
911 m = r.renamed(n) 911 m = r.renamed(n)
912 if m: 912 if m:
913 ui.write("renamed from %s:%s\n" % (m[0], hex(m[1]))) 913 ui.write(_("renamed from %s:%s\n") % (m[0], hex(m[1])))
914 else: 914 else:
915 ui.write("not renamed\n") 915 ui.write(_("not renamed\n"))
916 916
917 def debugwalk(ui, repo, *pats, **opts): 917 def debugwalk(ui, repo, *pats, **opts):
918 """show how files match on given patterns""" 918 """show how files match on given patterns"""
919 items = list(walk(repo, pats, opts)) 919 items = list(walk(repo, pats, opts))
920 if not items: 920 if not items:
934 if len(revs) > 0: 934 if len(revs) > 0:
935 node1 = revs[0] 935 node1 = revs[0]
936 if len(revs) > 1: 936 if len(revs) > 1:
937 node2 = revs[1] 937 node2 = revs[1]
938 if len(revs) > 2: 938 if len(revs) > 2:
939 raise util.Abort("too many revisions to diff") 939 raise util.Abort(_("too many revisions to diff"))
940 940
941 fns, matchfn, anypats = matchpats(repo, repo.getcwd(), pats, opts) 941 fns, matchfn, anypats = matchpats(repo, repo.getcwd(), pats, opts)
942 942
943 dodiff(sys.stdout, ui, repo, node1, node2, fns, match=matchfn, 943 dodiff(sys.stdout, ui, repo, node1, node2, fns, match=matchfn,
944 text=opts['text']) 944 text=opts['text'])
968 fp.close() 968 fp.close()
969 969
970 def export(ui, repo, *changesets, **opts): 970 def export(ui, repo, *changesets, **opts):
971 """dump the header and diffs for one or more changesets""" 971 """dump the header and diffs for one or more changesets"""
972 if not changesets: 972 if not changesets:
973 raise util.Abort("export requires at least one changeset") 973 raise util.Abort(_("export requires at least one changeset"))
974 seqno = 0 974 seqno = 0
975 revs = list(revrange(ui, repo, changesets)) 975 revs = list(revrange(ui, repo, changesets))
976 total = len(revs) 976 total = len(revs)
977 revwidth = max(map(len, revs)) 977 revwidth = max(map(len, revs))
978 ui.note(len(revs) > 1 and "Exporting patches:\n" or "Exporting patch:\n") 978 ui.note(len(revs) > 1 and _("Exporting patches:\n") or _("Exporting patch:\n"))
979 for cset in revs: 979 for cset in revs:
980 seqno += 1 980 seqno += 1
981 doexport(ui, repo, cset, seqno, total, revwidth, opts) 981 doexport(ui, repo, cset, seqno, total, revwidth, opts)
982 982
983 def forget(ui, repo, *pats, **opts): 983 def forget(ui, repo, *pats, **opts):
985 forget = [] 985 forget = []
986 for src, abs, rel, exact in walk(repo, pats, opts): 986 for src, abs, rel, exact in walk(repo, pats, opts):
987 if repo.dirstate.state(abs) == 'a': 987 if repo.dirstate.state(abs) == 'a':
988 forget.append(abs) 988 forget.append(abs)
989 if ui.verbose or not exact: 989 if ui.verbose or not exact:
990 ui.status('forgetting ', rel, '\n') 990 ui.status(_('forgetting %s\n') % rel)
991 repo.forget(forget) 991 repo.forget(forget)
992 992
993 def grep(ui, repo, pattern, *pats, **opts): 993 def grep(ui, repo, pattern, *pats, **opts):
994 """search for a pattern in specified files and revisions""" 994 """search for a pattern in specified files and revisions"""
995 reflags = 0 995 reflags = 0
1120 1120
1121 def identify(ui, repo): 1121 def identify(ui, repo):
1122 """print information about the working copy""" 1122 """print information about the working copy"""
1123 parents = [p for p in repo.dirstate.parents() if p != nullid] 1123 parents = [p for p in repo.dirstate.parents() if p != nullid]
1124 if not parents: 1124 if not parents:
1125 ui.write("unknown\n") 1125 ui.write(_("unknown\n"))
1126 return 1126 return
1127 1127
1128 hexfunc = ui.verbose and hex or short 1128 hexfunc = ui.verbose and hex or short
1129 (c, a, d, u) = repo.changes() 1129 (c, a, d, u) = repo.changes()
1130 output = ["%s%s" % ('+'.join([hexfunc(parent) for parent in parents]), 1130 output = ["%s%s" % ('+'.join([hexfunc(parent) for parent in parents]),
1145 patches = (patch1,) + patches 1145 patches = (patch1,) + patches
1146 1146
1147 if not opts['force']: 1147 if not opts['force']:
1148 (c, a, d, u) = repo.changes() 1148 (c, a, d, u) = repo.changes()
1149 if c or a or d: 1149 if c or a or d:
1150 raise util.Abort("outstanding uncommitted changes") 1150 raise util.Abort(_("outstanding uncommitted changes"))
1151 1151
1152 d = opts["base"] 1152 d = opts["base"]
1153 strip = opts["strip"] 1153 strip = opts["strip"]
1154 1154
1155 mailre = re.compile(r'(?:From |[\w-]+:)') 1155 mailre = re.compile(r'(?:From |[\w-]+:)')
1159 diffre = re.compile(r'(?:Index:[ \t]|diff[ \t]|RCS file: |' + 1159 diffre = re.compile(r'(?:Index:[ \t]|diff[ \t]|RCS file: |' +
1160 'retrieving revision [0-9]+(\.[0-9]+)*$|' + 1160 'retrieving revision [0-9]+(\.[0-9]+)*$|' +
1161 '(---|\*\*\*)[ \t])') 1161 '(---|\*\*\*)[ \t])')
1162 1162
1163 for patch in patches: 1163 for patch in patches:
1164 ui.status("applying %s\n" % patch) 1164 ui.status(_("applying %s\n") % patch)
1165 pf = os.path.join(d, patch) 1165 pf = os.path.join(d, patch)
1166 1166
1167 message = [] 1167 message = []
1168 user = None 1168 user = None
1169 hgpatch = False 1169 hgpatch = False
1170 for line in file(pf): 1170 for line in file(pf):
1171 line = line.rstrip() 1171 line = line.rstrip()
1172 if (not message and not hgpatch and 1172 if (not message and not hgpatch and
1173 mailre.match(line) and not opts['force']): 1173 mailre.match(line) and not opts['force']):
1174 if len(line) > 35: line = line[:32] + '...' 1174 if len(line) > 35: line = line[:32] + '...'
1175 raise util.Abort('first line looks like a ' 1175 raise util.Abort(_('first line looks like a '
1176 'mail header: ' + line) 1176 'mail header: ') + line)
1177 if diffre.match(line): 1177 if diffre.match(line):
1178 break 1178 break
1179 elif hgpatch: 1179 elif hgpatch:
1180 # parse values when importing the result of an hg export 1180 # parse values when importing the result of an hg export
1181 if line.startswith("# User "): 1181 if line.startswith("# User "):
1182 user = line[7:] 1182 user = line[7:]
1183 ui.debug('User: %s\n' % user) 1183 ui.debug(_('User: %s\n') % user)
1184 elif not line.startswith("# ") and line: 1184 elif not line.startswith("# ") and line:
1185 message.append(line) 1185 message.append(line)
1186 hgpatch = False 1186 hgpatch = False
1187 elif line == '# HG changeset patch': 1187 elif line == '# HG changeset patch':
1188 hgpatch = True 1188 hgpatch = True
1190 else: 1190 else:
1191 message.append(line) 1191 message.append(line)
1192 1192
1193 # make sure message isn't empty 1193 # make sure message isn't empty
1194 if not message: 1194 if not message:
1195 message = "imported patch %s\n" % patch 1195 message = _("imported patch %s\n") % patch
1196 else: 1196 else:
1197 message = "%s\n" % '\n'.join(message) 1197 message = "%s\n" % '\n'.join(message)
1198 ui.debug('message:\n%s\n' % message) 1198 ui.debug(_('message:\n%s\n') % message)
1199 1199
1200 files = util.patch(strip, pf, ui) 1200 files = util.patch(strip, pf, ui)
1201 1201
1202 if len(files) > 0: 1202 if len(files) > 0:
1203 addremove(ui, repo, *files) 1203 addremove(ui, repo, *files)
1206 def incoming(ui, repo, source="default", **opts): 1206 def incoming(ui, repo, source="default", **opts):
1207 """show new changesets found in source""" 1207 """show new changesets found in source"""
1208 source = ui.expandpath(source) 1208 source = ui.expandpath(source)
1209 other = hg.repository(ui, source) 1209 other = hg.repository(ui, source)
1210 if not other.local(): 1210 if not other.local():
1211 raise util.Abort("incoming doesn't work for remote repositories yet") 1211 raise util.Abort(_("incoming doesn't work for remote repositories yet"))
1212 o = repo.findincoming(other) 1212 o = repo.findincoming(other)
1213 if not o: 1213 if not o:
1214 return 1214 return
1215 o = other.newer(o) 1215 o = other.newer(o)
1216 for n in o: 1216 for n in o:
1353 if search: 1353 if search:
1354 for name, path in ui.configitems("paths"): 1354 for name, path in ui.configitems("paths"):
1355 if name == search: 1355 if name == search:
1356 ui.write("%s\n" % path) 1356 ui.write("%s\n" % path)
1357 return 1357 return
1358 ui.warn("not found!\n") 1358 ui.warn(_("not found!\n"))
1359 return 1 1359 return 1
1360 else: 1360 else:
1361 for name, path in ui.configitems("paths"): 1361 for name, path in ui.configitems("paths"):
1362 ui.write("%s = %s\n" % (name, path)) 1362 ui.write("%s = %s\n" % (name, path))
1363 1363
1364 def pull(ui, repo, source="default", **opts): 1364 def pull(ui, repo, source="default", **opts):
1365 """pull changes from the specified source""" 1365 """pull changes from the specified source"""
1366 source = ui.expandpath(source) 1366 source = ui.expandpath(source)
1367 ui.status('pulling from %s\n' % (source)) 1367 ui.status(_('pulling from %s\n') % (source))
1368 1368
1369 if opts['ssh']: 1369 if opts['ssh']:
1370 ui.setconfig("ui", "ssh", opts['ssh']) 1370 ui.setconfig("ui", "ssh", opts['ssh'])
1371 if opts['remotecmd']: 1371 if opts['remotecmd']:
1372 ui.setconfig("ui", "remotecmd", opts['remotecmd']) 1372 ui.setconfig("ui", "remotecmd", opts['remotecmd'])
1375 r = repo.pull(other) 1375 r = repo.pull(other)
1376 if not r: 1376 if not r:
1377 if opts['update']: 1377 if opts['update']:
1378 return update(ui, repo) 1378 return update(ui, repo)
1379 else: 1379 else:
1380 ui.status("(run 'hg update' to get a working copy)\n") 1380 ui.status(_("(run 'hg update' to get a working copy)\n"))
1381 1381
1382 return r 1382 return r
1383 1383
1384 def push(ui, repo, dest="default-push", force=False, ssh=None, remotecmd=None): 1384 def push(ui, repo, dest="default-push", force=False, ssh=None, remotecmd=None):
1385 """push changes to the specified destination""" 1385 """push changes to the specified destination"""
1396 return r 1396 return r
1397 1397
1398 def rawcommit(ui, repo, *flist, **rc): 1398 def rawcommit(ui, repo, *flist, **rc):
1399 "raw commit interface" 1399 "raw commit interface"
1400 if rc['text']: 1400 if rc['text']:
1401 ui.warn("Warning: -t and --text is deprecated," 1401 ui.warn(_("Warning: -t and --text is deprecated,"
1402 " please use -m or --message instead.\n") 1402 " please use -m or --message instead.\n"))
1403 message = rc['message'] or rc['text'] 1403 message = rc['message'] or rc['text']
1404 if not message and rc['logfile']: 1404 if not message and rc['logfile']:
1405 try: 1405 try:
1406 message = open(rc['logfile']).read() 1406 message = open(rc['logfile']).read()
1407 except IOError: 1407 except IOError:
1408 pass 1408 pass
1409 if not message and not rc['logfile']: 1409 if not message and not rc['logfile']:
1410 raise util.Abort("missing commit message") 1410 raise util.Abort(_("missing commit message"))
1411 1411
1412 files = relpath(repo, list(flist)) 1412 files = relpath(repo, list(flist))
1413 if rc['files']: 1413 if rc['files']:
1414 files += open(rc['files']).read().splitlines() 1414 files += open(rc['files']).read().splitlines()
1415 1415
1428 """remove the specified files on the next commit""" 1428 """remove the specified files on the next commit"""
1429 names = [] 1429 names = []
1430 def okaytoremove(abs, rel, exact): 1430 def okaytoremove(abs, rel, exact):
1431 c, a, d, u = repo.changes(files = [abs]) 1431 c, a, d, u = repo.changes(files = [abs])
1432 reason = None 1432 reason = None
1433 if c: reason = 'is modified' 1433 if c: reason = _('is modified')
1434 elif a: reason = 'has been marked for add' 1434 elif a: reason = _('has been marked for add')
1435 elif u: reason = 'is not managed' 1435 elif u: reason = _('is not managed')
1436 if reason: 1436 if reason:
1437 if exact: ui.warn('not removing %s: file %s\n' % (rel, reason)) 1437 if exact: ui.warn(_('not removing %s: file %s\n') % (rel, reason))
1438 else: 1438 else:
1439 return True 1439 return True
1440 for src, abs, rel, exact in walk(repo, (pat,) + pats, opts): 1440 for src, abs, rel, exact in walk(repo, (pat,) + pats, opts):
1441 if okaytoremove(abs, rel, exact): 1441 if okaytoremove(abs, rel, exact):
1442 if ui.verbose or not exact: ui.status('removing %s\n' % rel) 1442 if ui.verbose or not exact: ui.status(_('removing %s\n') % rel)
1443 names.append(abs) 1443 names.append(abs)
1444 for name in names: 1444 for name in names:
1445 try: 1445 try:
1446 os.unlink(name) 1446 os.unlink(name)
1447 except OSError, inst: 1447 except OSError, inst:
1451 def rename(ui, repo, *pats, **opts): 1451 def rename(ui, repo, *pats, **opts):
1452 """rename files; equivalent of copy + remove""" 1452 """rename files; equivalent of copy + remove"""
1453 errs, copied = docopy(ui, repo, pats, opts) 1453 errs, copied = docopy(ui, repo, pats, opts)
1454 names = [] 1454 names = []
1455 for abs, rel, exact in copied: 1455 for abs, rel, exact in copied:
1456 if ui.verbose or not exact: ui.status('removing %s\n' % rel) 1456 if ui.verbose or not exact: ui.status(_('removing %s\n') % rel)
1457 try: 1457 try:
1458 os.unlink(rel) 1458 os.unlink(rel)
1459 except OSError, inst: 1459 except OSError, inst:
1460 if inst.errno != errno.ENOENT: raise 1460 if inst.errno != errno.ENOENT: raise
1461 names.append(abs) 1461 names.append(abs)
1503 return ret 1503 return ret
1504 1504
1505 r = repo.update(node, False, True, choose, False) 1505 r = repo.update(node, False, True, choose, False)
1506 for n in relnames: 1506 for n in relnames:
1507 if n not in chosen: 1507 if n not in chosen:
1508 ui.warn('error: no matches for %s\n' % n) 1508 ui.warn(_('error: no matches for %s\n') % n)
1509 r = 1 1509 r = 1
1510 sys.stdout.flush() 1510 sys.stdout.flush()
1511 return r 1511 return r
1512 1512
1513 def root(ui, repo): 1513 def root(ui, repo):
1603 try: 1603 try:
1604 addr = socket.gethostbyaddr(addr)[0] 1604 addr = socket.gethostbyaddr(addr)[0]
1605 except socket.error: 1605 except socket.error:
1606 pass 1606 pass
1607 if port != 80: 1607 if port != 80:
1608 ui.status('listening at http://%s:%d/\n' % (addr, port)) 1608 ui.status(_('listening at http://%s:%d/\n') % (addr, port))
1609 else: 1609 else:
1610 ui.status('listening at http://%s/\n' % addr) 1610 ui.status(_('listening at http://%s/\n') % addr)
1611 httpd.serve_forever() 1611 httpd.serve_forever()
1612 1612
1613 def status(ui, repo, *pats, **opts): 1613 def status(ui, repo, *pats, **opts):
1614 '''show changed files in the working directory 1614 '''show changed files in the working directory
1615 1615
1622 cwd = repo.getcwd() 1622 cwd = repo.getcwd()
1623 files, matchfn, anypats = matchpats(repo, cwd, pats, opts) 1623 files, matchfn, anypats = matchpats(repo, cwd, pats, opts)
1624 (c, a, d, u) = [[util.pathto(cwd, x) for x in n] 1624 (c, a, d, u) = [[util.pathto(cwd, x) for x in n]
1625 for n in repo.changes(files=files, match=matchfn)] 1625 for n in repo.changes(files=files, match=matchfn)]
1626 1626
1627 changetypes = [('modified', 'M', c), 1627 changetypes = [(_('modified'), 'M', c),
1628 ('added', 'A', a), 1628 (_('added'), 'A', a),
1629 ('removed', 'R', d), 1629 (_('removed'), 'R', d),
1630 ('unknown', '?', u)] 1630 (_('unknown'), '?', u)]
1631 1631
1632 end = opts['print0'] and '\0' or '\n' 1632 end = opts['print0'] and '\0' or '\n'
1633 1633
1634 for opt, char, changes in ([ct for ct in changetypes if opts[ct[0]]] 1634 for opt, char, changes in ([ct for ct in changetypes if opts[ct[0]]]
1635 or changetypes): 1635 or changetypes):
1642 ui.write(format % f) 1642 ui.write(format % f)
1643 1643
1644 def tag(ui, repo, name, rev=None, **opts): 1644 def tag(ui, repo, name, rev=None, **opts):
1645 """add a tag for the current tip or a given revision""" 1645 """add a tag for the current tip or a given revision"""
1646 if opts['text']: 1646 if opts['text']:
1647 ui.warn("Warning: -t and --text is deprecated," 1647 ui.warn(_("Warning: -t and --text is deprecated,"
1648 " please use -m or --message instead.\n") 1648 " please use -m or --message instead.\n"))
1649 if name == "tip": 1649 if name == "tip":
1650 raise util.Abort("the name 'tip' is reserved") 1650 raise util.Abort(_("the name 'tip' is reserved"))
1651 if rev: 1651 if rev:
1652 r = hex(repo.lookup(rev)) 1652 r = hex(repo.lookup(rev))
1653 else: 1653 else:
1654 r = hex(repo.changelog.tip()) 1654 r = hex(repo.changelog.tip())
1655 1655
1656 if name.find(revrangesep) >= 0: 1656 if name.find(revrangesep) >= 0:
1657 raise util.Abort("'%s' cannot be used in a tag name" % revrangesep) 1657 raise util.Abort(_("'%s' cannot be used in a tag name") % revrangesep)
1658 1658
1659 if opts['local']: 1659 if opts['local']:
1660 repo.opener("localtags", "a").write("%s %s\n" % (r, name)) 1660 repo.opener("localtags", "a").write("%s %s\n" % (r, name))
1661 return 1661 return
1662 1662
1663 (c, a, d, u) = repo.changes() 1663 (c, a, d, u) = repo.changes()
1664 for x in (c, a, d, u): 1664 for x in (c, a, d, u):
1665 if ".hgtags" in x: 1665 if ".hgtags" in x:
1666 raise util.Abort("working copy of .hgtags is changed " 1666 raise util.Abort(_("working copy of .hgtags is changed "
1667 "(please commit .hgtags manually)") 1667 "(please commit .hgtags manually)"))
1668 1668
1669 repo.wfile(".hgtags", "ab").write("%s %s\n" % (r, name)) 1669 repo.wfile(".hgtags", "ab").write("%s %s\n" % (r, name))
1670 if repo.dirstate.state(".hgtags") == '?': 1670 if repo.dirstate.state(".hgtags") == '?':
1671 repo.add([".hgtags"]) 1671 repo.add([".hgtags"])
1672 1672
1673 message = (opts['message'] or opts['text'] or 1673 message = (opts['message'] or opts['text'] or
1674 "Added tag %s for changeset %s" % (name, r)) 1674 _("Added tag %s for changeset %s") % (name, r))
1675 try: 1675 try:
1676 repo.commit([".hgtags"], message, opts['user'], opts['date']) 1676 repo.commit([".hgtags"], message, opts['user'], opts['date'])
1677 except ValueError, inst: 1677 except ValueError, inst:
1678 raise util.Abort(str(inst)) 1678 raise util.Abort(str(inst))
1679 1679
1697 def unbundle(ui, repo, fname): 1697 def unbundle(ui, repo, fname):
1698 """apply a changegroup file""" 1698 """apply a changegroup file"""
1699 f = urllib.urlopen(fname) 1699 f = urllib.urlopen(fname)
1700 1700
1701 if f.read(4) != "HG10": 1701 if f.read(4) != "HG10":
1702 raise util.Abort("%s: not a Mercurial bundle file" % fname) 1702 raise util.Abort(_("%s: not a Mercurial bundle file") % fname)
1703 1703
1704 def bzgenerator(f): 1704 def bzgenerator(f):
1705 zd = bz2.BZ2Decompressor() 1705 zd = bz2.BZ2Decompressor()
1706 for chunk in f: 1706 for chunk in f:
1707 yield zd.decompress(chunk) 1707 yield zd.decompress(chunk)
1743 found = [] 1743 found = []
1744 for x in br: 1744 for x in br:
1745 if branch in br[x]: 1745 if branch in br[x]:
1746 found.append(x) 1746 found.append(x)
1747 if len(found) > 1: 1747 if len(found) > 1:
1748 ui.warn("Found multiple heads for %s\n" % branch) 1748 ui.warn(_("Found multiple heads for %s\n") % branch)
1749 for x in found: 1749 for x in found:
1750 show_changeset(ui, repo, changenode=x, brinfo=br) 1750 show_changeset(ui, repo, changenode=x, brinfo=br)
1751 return 1 1751 return 1
1752 if len(found) == 1: 1752 if len(found) == 1:
1753 node = found[0] 1753 node = found[0]
1754 ui.warn("Using head %s for branch %s\n" % (short(node), branch)) 1754 ui.warn(_("Using head %s for branch %s\n") % (short(node), branch))
1755 else: 1755 else:
1756 ui.warn("branch %s not found\n" % (branch)) 1756 ui.warn(_("branch %s not found\n") % (branch))
1757 return 1 1757 return 1
1758 else: 1758 else:
1759 node = node and repo.lookup(node) or repo.changelog.tip() 1759 node = node and repo.lookup(node) or repo.changelog.tip()
1760 return repo.update(node, allow=merge, force=clean) 1760 return repo.update(node, allow=merge, force=clean)
1761 1761
1766 # Command options and aliases are listed here, alphabetically 1766 # Command options and aliases are listed here, alphabetically
1767 1767
1768 table = { 1768 table = {
1769 "^add": 1769 "^add":
1770 (add, 1770 (add,
1771 [('I', 'include', [], 'include path in search'), 1771 [('I', 'include', [], _('include path in search')),
1772 ('X', 'exclude', [], 'exclude path from search')], 1772 ('X', 'exclude', [], _('exclude path from search'))],
1773 "hg add [OPTION]... [FILE]..."), 1773 "hg add [OPTION]... [FILE]..."),
1774 "addremove": 1774 "addremove":
1775 (addremove, 1775 (addremove,
1776 [('I', 'include', [], 'include path in search'), 1776 [('I', 'include', [], _('include path in search')),
1777 ('X', 'exclude', [], 'exclude path from search')], 1777 ('X', 'exclude', [], _('exclude path from search'))],
1778 "hg addremove [OPTION]... [FILE]..."), 1778 _("hg addremove [OPTION]... [FILE]...")),
1779 "^annotate": 1779 "^annotate":
1780 (annotate, 1780 (annotate,
1781 [('r', 'rev', '', 'revision'), 1781 [('r', 'rev', '', _('revision')),
1782 ('a', 'text', None, 'treat all files as text'), 1782 ('a', 'text', None, _('treat all files as text')),
1783 ('u', 'user', None, 'show user'), 1783 ('u', 'user', None, _('show user')),
1784 ('n', 'number', None, 'show revision number'), 1784 ('n', 'number', None, _('show revision number')),
1785 ('c', 'changeset', None, 'show changeset'), 1785 ('c', 'changeset', None, _('show changeset')),
1786 ('I', 'include', [], 'include path in search'), 1786 ('I', 'include', [], _('include path in search')),
1787 ('X', 'exclude', [], 'exclude path from search')], 1787 ('X', 'exclude', [], _('exclude path from search'))],
1788 'hg annotate [OPTION]... FILE...'), 1788 _('hg annotate [OPTION]... FILE...')),
1789 "bundle": 1789 "bundle":
1790 (bundle, 1790 (bundle,
1791 [], 1791 [],
1792 'hg bundle FILE DEST'), 1792 _('hg bundle FILE DEST')),
1793 "cat": 1793 "cat":
1794 (cat, 1794 (cat,
1795 [('I', 'include', [], 'include path in search'), 1795 [('I', 'include', [], _('include path in search')),
1796 ('X', 'exclude', [], 'exclude path from search'), 1796 ('X', 'exclude', [], _('exclude path from search')),
1797 ('o', 'output', "", 'output to file'), 1797 ('o', 'output', "", _('output to file')),
1798 ('r', 'rev', '', 'revision')], 1798 ('r', 'rev', '', _('revision'))],
1799 'hg cat [OPTION]... FILE...'), 1799 _('hg cat [OPTION]... FILE...')),
1800 "^clone": 1800 "^clone":
1801 (clone, 1801 (clone,
1802 [('U', 'noupdate', None, 'skip update after cloning'), 1802 [('U', 'noupdate', None, _('skip update after cloning')),
1803 ('e', 'ssh', "", 'ssh command'), 1803 ('e', 'ssh', "", _('ssh command')),
1804 ('', 'pull', None, 'use pull protocol to copy metadata'), 1804 ('', 'pull', None, _('use pull protocol to copy metadata')),
1805 ('', 'remotecmd', "", 'remote hg command')], 1805 ('', 'remotecmd', "", _('remote hg command'))],
1806 'hg clone [OPTION]... SOURCE [DEST]'), 1806 _('hg clone [OPTION]... SOURCE [DEST]')),
1807 "^commit|ci": 1807 "^commit|ci":
1808 (commit, 1808 (commit,
1809 [('A', 'addremove', None, 'run add/remove during commit'), 1809 [('A', 'addremove', None, _('run add/remove during commit')),
1810 ('I', 'include', [], 'include path in search'), 1810 ('I', 'include', [], _('include path in search')),
1811 ('X', 'exclude', [], 'exclude path from search'), 1811 ('X', 'exclude', [], _('exclude path from search')),
1812 ('m', 'message', "", 'commit message'), 1812 ('m', 'message', "", _('commit message')),
1813 ('t', 'text', "", 'commit message (deprecated: use -m)'), 1813 ('t', 'text', "", _('commit message (deprecated: use -m)')),
1814 ('l', 'logfile', "", 'commit message file'), 1814 ('l', 'logfile', "", _('commit message file')),
1815 ('d', 'date', "", 'date code'), 1815 ('d', 'date', "", _('date code')),
1816 ('u', 'user', "", 'user')], 1816 ('u', 'user', "", _('user'))],
1817 'hg commit [OPTION]... [FILE]...'), 1817 _('hg commit [OPTION]... [FILE]...')),
1818 "copy|cp": (copy, 1818 "copy|cp": (copy,
1819 [('I', 'include', [], 'include path in search'), 1819 [('I', 'include', [], _('include path in search')),
1820 ('X', 'exclude', [], 'exclude path from search'), 1820 ('X', 'exclude', [], _('exclude path from search')),
1821 ('A', 'after', None, 'record a copy after it has happened'), 1821 ('A', 'after', None, _('record a copy after it has happened')),
1822 ('f', 'force', None, 'replace destination if it exists'), 1822 ('f', 'force', None, _('replace destination if it exists')),
1823 ('p', 'parents', None, 'append source path to dest')], 1823 ('p', 'parents', None, _('append source path to dest'))],
1824 'hg copy [OPTION]... [SOURCE]... DEST'), 1824 _('hg copy [OPTION]... [SOURCE]... DEST')),
1825 "debugancestor": (debugancestor, [], 'debugancestor INDEX REV1 REV2'), 1825 "debugancestor": (debugancestor, [], _('debugancestor INDEX REV1 REV2')),
1826 "debugcheckstate": (debugcheckstate, [], 'debugcheckstate'), 1826 "debugcheckstate": (debugcheckstate, [], _('debugcheckstate')),
1827 "debugconfig": (debugconfig, [], 'debugconfig'), 1827 "debugconfig": (debugconfig, [], _('debugconfig')),
1828 "debugsetparents": (debugsetparents, [], 'debugsetparents REV1 [REV2]'), 1828 "debugsetparents": (debugsetparents, [], _('debugsetparents REV1 [REV2]')),
1829 "debugstate": (debugstate, [], 'debugstate'), 1829 "debugstate": (debugstate, [], _('debugstate')),
1830 "debugdata": (debugdata, [], 'debugdata FILE REV'), 1830 "debugdata": (debugdata, [], _('debugdata FILE REV')),
1831 "debugindex": (debugindex, [], 'debugindex FILE'), 1831 "debugindex": (debugindex, [], _('debugindex FILE')),
1832 "debugindexdot": (debugindexdot, [], 'debugindexdot FILE'), 1832 "debugindexdot": (debugindexdot, [], _('debugindexdot FILE')),
1833 "debugrename": (debugrename, [], 'debugrename FILE [REV]'), 1833 "debugrename": (debugrename, [], _('debugrename FILE [REV]')),
1834 "debugwalk": 1834 "debugwalk":
1835 (debugwalk, 1835 (debugwalk,
1836 [('I', 'include', [], 'include path in search'), 1836 [('I', 'include', [], _('include path in search')),
1837 ('X', 'exclude', [], 'exclude path from search')], 1837 ('X', 'exclude', [], _('exclude path from search'))],
1838 'debugwalk [OPTION]... [FILE]...'), 1838 _('debugwalk [OPTION]... [FILE]...')),
1839 "^diff": 1839 "^diff":
1840 (diff, 1840 (diff,
1841 [('r', 'rev', [], 'revision'), 1841 [('r', 'rev', [], _('revision')),
1842 ('a', 'text', None, 'treat all files as text'), 1842 ('a', 'text', None, _('treat all files as text')),
1843 ('I', 'include', [], 'include path in search'), 1843 ('I', 'include', [], _('include path in search')),
1844 ('X', 'exclude', [], 'exclude path from search')], 1844 ('X', 'exclude', [], _('exclude path from search'))],
1845 'hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...'), 1845 _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')),
1846 "^export": 1846 "^export":
1847 (export, 1847 (export,
1848 [('o', 'output', "", 'output to file'), 1848 [('o', 'output', "", _('output to file')),
1849 ('a', 'text', None, 'treat all files as text')], 1849 ('a', 'text', None, _('treat all files as text'))],
1850 "hg export [-a] [-o OUTFILE] REV..."), 1850 _("hg export [-a] [-o OUTFILE] REV...")),
1851 "forget": 1851 "forget":
1852 (forget, 1852 (forget,
1853 [('I', 'include', [], 'include path in search'), 1853 [('I', 'include', [], _('include path in search')),
1854 ('X', 'exclude', [], 'exclude path from search')], 1854 ('X', 'exclude', [], _('exclude path from search'))],
1855 "hg forget [OPTION]... FILE..."), 1855 _("hg forget [OPTION]... FILE...")),
1856 "grep": 1856 "grep":
1857 (grep, 1857 (grep,
1858 [('0', 'print0', None, 'end fields with NUL'), 1858 [('0', 'print0', None, _('end fields with NUL')),
1859 ('I', 'include', [], 'include path in search'), 1859 ('I', 'include', [], _('include path in search')),
1860 ('X', 'exclude', [], 'include path in search'), 1860 ('X', 'exclude', [], _('include path in search')),
1861 ('', 'all', None, 'print all revisions with matches'), 1861 ('', 'all', None, _('print all revisions with matches')),
1862 ('i', 'ignore-case', None, 'ignore case when matching'), 1862 ('i', 'ignore-case', None, _('ignore case when matching')),
1863 ('l', 'files-with-matches', None, 'print names of files and revs with matches'), 1863 ('l', 'files-with-matches', None, _('print names of files and revs with matches')),
1864 ('n', 'line-number', None, 'print line numbers'), 1864 ('n', 'line-number', None, _('print line numbers')),
1865 ('r', 'rev', [], 'search in revision rev'), 1865 ('r', 'rev', [], _('search in revision rev')),
1866 ('u', 'user', None, 'print user who made change')], 1866 ('u', 'user', None, _('print user who made change'))],
1867 "hg grep [OPTION]... PATTERN [FILE]..."), 1867 _("hg grep [OPTION]... PATTERN [FILE]...")),
1868 "heads": 1868 "heads":
1869 (heads, 1869 (heads,
1870 [('b', 'branches', None, 'find branch info')], 1870 [('b', 'branches', None, _('find branch info'))],
1871 'hg heads [-b]'), 1871 _('hg heads [-b]')),
1872 "help": (help_, [], 'hg help [COMMAND]'), 1872 "help": (help_, [], _('hg help [COMMAND]')),
1873 "identify|id": (identify, [], 'hg identify'), 1873 "identify|id": (identify, [], _('hg identify')),
1874 "import|patch": 1874 "import|patch":
1875 (import_, 1875 (import_,
1876 [('p', 'strip', 1, 'path strip'), 1876 [('p', 'strip', 1, _('path strip')),
1877 ('f', 'force', None, 'skip check for outstanding changes'), 1877 ('f', 'force', None, _('skip check for outstanding changes')),
1878 ('b', 'base', "", 'base path')], 1878 ('b', 'base', "", _('base path'))],
1879 "hg import [-f] [-p NUM] [-b BASE] PATCH..."), 1879 _("hg import [-f] [-p NUM] [-b BASE] PATCH...")),
1880 "incoming|in": (incoming, 1880 "incoming|in": (incoming,
1881 [('p', 'patch', None, 'show patch')], 1881 [('p', 'patch', None, _('show patch'))],
1882 'hg incoming [-p] [SOURCE]'), 1882 _('hg incoming [-p] [SOURCE]')),
1883 "^init": (init, [], 'hg init [DEST]'), 1883 "^init": (init, [], _('hg init [DEST]')),
1884 "locate": 1884 "locate":
1885 (locate, 1885 (locate,
1886 [('r', 'rev', '', 'revision'), 1886 [('r', 'rev', '', _('revision')),
1887 ('0', 'print0', None, 'end filenames with NUL'), 1887 ('0', 'print0', None, _('end filenames with NUL')),
1888 ('f', 'fullpath', None, 'print complete paths'), 1888 ('f', 'fullpath', None, _('print complete paths')),
1889 ('I', 'include', [], 'include path in search'), 1889 ('I', 'include', [], _('include path in search')),
1890 ('X', 'exclude', [], 'exclude path from search')], 1890 ('X', 'exclude', [], _('exclude path from search'))],
1891 'hg locate [OPTION]... [PATTERN]...'), 1891 _('hg locate [OPTION]... [PATTERN]...')),
1892 "^log|history": 1892 "^log|history":
1893 (log, 1893 (log,
1894 [('I', 'include', [], 'include path in search'), 1894 [('I', 'include', [], _('include path in search')),
1895 ('X', 'exclude', [], 'exclude path from search'), 1895 ('X', 'exclude', [], _('exclude path from search')),
1896 ('b', 'branch', None, 'show branches'), 1896 ('b', 'branch', None, _('show branches')),
1897 ('k', 'keyword', [], 'search for a keyword'), 1897 ('k', 'keyword', [], _('search for a keyword')),
1898 ('r', 'rev', [], 'revision'), 1898 ('r', 'rev', [], _('revision')),
1899 ('p', 'patch', None, 'show patch')], 1899 ('p', 'patch', None, _('show patch'))],
1900 'hg log [-I] [-X] [-r REV]... [-p] [FILE]'), 1900 _('hg log [-I] [-X] [-r REV]... [-p] [FILE]')),
1901 "manifest": (manifest, [], 'hg manifest [REV]'), 1901 "manifest": (manifest, [], _('hg manifest [REV]')),
1902 "outgoing|out": (outgoing, 1902 "outgoing|out": (outgoing,
1903 [('p', 'patch', None, 'show patch')], 1903 [('p', 'patch', None, _('show patch'))],
1904 'hg outgoing [-p] [DEST]'), 1904 _('hg outgoing [-p] [DEST]')),
1905 "parents": (parents, [], 'hg parents [REV]'), 1905 "parents": (parents, [], _('hg parents [REV]')),
1906 "paths": (paths, [], 'hg paths [NAME]'), 1906 "paths": (paths, [], _('hg paths [NAME]')),
1907 "^pull": 1907 "^pull":
1908 (pull, 1908 (pull,
1909 [('u', 'update', None, 'update working directory'), 1909 [('u', 'update', None, _('update working directory')),
1910 ('e', 'ssh', "", 'ssh command'), 1910 ('e', 'ssh', "", _('ssh command')),
1911 ('', 'remotecmd', "", 'remote hg command')], 1911 ('', 'remotecmd', "", _('remote hg command'))],
1912 'hg pull [-u] [-e FILE] [--remotecmd FILE] [SOURCE]'), 1912 _('hg pull [-u] [-e FILE] [--remotecmd FILE] [SOURCE]')),
1913 "^push": 1913 "^push":
1914 (push, 1914 (push,
1915 [('f', 'force', None, 'force push'), 1915 [('f', 'force', None, _('force push')),
1916 ('e', 'ssh', "", 'ssh command'), 1916 ('e', 'ssh', "", _('ssh command')),
1917 ('', 'remotecmd', "", 'remote hg command')], 1917 ('', 'remotecmd', "", _('remote hg command'))],
1918 'hg push [-f] [-e FILE] [--remotecmd FILE] [DEST]'), 1918 _('hg push [-f] [-e FILE] [--remotecmd FILE] [DEST]')),
1919 "rawcommit": 1919 "rawcommit":
1920 (rawcommit, 1920 (rawcommit,
1921 [('p', 'parent', [], 'parent'), 1921 [('p', 'parent', [], _('parent')),
1922 ('d', 'date', "", 'date code'), 1922 ('d', 'date', "", _('date code')),
1923 ('u', 'user', "", 'user'), 1923 ('u', 'user', "", _('user')),
1924 ('F', 'files', "", 'file list'), 1924 ('F', 'files', "", _('file list')),
1925 ('m', 'message', "", 'commit message'), 1925 ('m', 'message', "", _('commit message')),
1926 ('t', 'text', "", 'commit message (deprecated: use -m)'), 1926 ('t', 'text', "", _('commit message (deprecated: use -m)')),
1927 ('l', 'logfile', "", 'commit message file')], 1927 ('l', 'logfile', "", _('commit message file'))],
1928 'hg rawcommit [OPTION]... [FILE]...'), 1928 _('hg rawcommit [OPTION]... [FILE]...')),
1929 "recover": (recover, [], "hg recover"), 1929 "recover": (recover, [], _("hg recover")),
1930 "^remove|rm": (remove, 1930 "^remove|rm": (remove,
1931 [('I', 'include', [], 'include path in search'), 1931 [('I', 'include', [], _('include path in search')),
1932 ('X', 'exclude', [], 'exclude path from search')], 1932 ('X', 'exclude', [], _('exclude path from search'))],
1933 "hg remove [OPTION]... FILE..."), 1933 _("hg remove [OPTION]... FILE...")),
1934 "rename|mv": (rename, 1934 "rename|mv": (rename,
1935 [('I', 'include', [], 'include path in search'), 1935 [('I', 'include', [], _('include path in search')),
1936 ('X', 'exclude', [], 'exclude path from search'), 1936 ('X', 'exclude', [], _('exclude path from search')),
1937 ('A', 'after', None, 'record a copy after it has happened'), 1937 ('A', 'after', None, _('record a copy after it has happened')),
1938 ('f', 'force', None, 'replace destination if it exists'), 1938 ('f', 'force', None, _('replace destination if it exists')),
1939 ('p', 'parents', None, 'append source path to dest')], 1939 ('p', 'parents', None, _('append source path to dest'))],
1940 'hg rename [OPTION]... [SOURCE]... DEST'), 1940 _('hg rename [OPTION]... [SOURCE]... DEST')),
1941 "^revert": 1941 "^revert":
1942 (revert, 1942 (revert,
1943 [("n", "nonrecursive", None, "don't recurse into subdirs"), 1943 [("n", "nonrecursive", None, _("don't recurse into subdirs")),
1944 ("r", "rev", "", "revision")], 1944 ("r", "rev", "", _("revision"))],
1945 "hg revert [-n] [-r REV] [NAME]..."), 1945 _("hg revert [-n] [-r REV] [NAME]...")),
1946 "root": (root, [], "hg root"), 1946 "root": (root, [], _("hg root")),
1947 "^serve": 1947 "^serve":
1948 (serve, 1948 (serve,
1949 [('A', 'accesslog', '', 'access log file'), 1949 [('A', 'accesslog', '', _('access log file')),
1950 ('E', 'errorlog', '', 'error log file'), 1950 ('E', 'errorlog', '', _('error log file')),
1951 ('p', 'port', 0, 'listen port'), 1951 ('p', 'port', 0, _('listen port')),
1952 ('a', 'address', '', 'interface address'), 1952 ('a', 'address', '', _('interface address')),
1953 ('n', 'name', "", 'repository name'), 1953 ('n', 'name', "", _('repository name')),
1954 ('', 'stdio', None, 'for remote clients'), 1954 ('', 'stdio', None, _('for remote clients')),
1955 ('t', 'templates', "", 'template directory'), 1955 ('t', 'templates', "", _('template directory')),
1956 ('', 'style', "", 'template style'), 1956 ('', 'style', "", _('template style')),
1957 ('6', 'ipv6', None, 'use IPv6 in addition to IPv4')], 1957 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4'))],
1958 "hg serve [OPTION]..."), 1958 _("hg serve [OPTION]...")),
1959 "^status": 1959 "^status":
1960 (status, 1960 (status,
1961 [('m', 'modified', None, 'show only modified files'), 1961 [('m', 'modified', None, _('show only modified files')),
1962 ('a', 'added', None, 'show only added files'), 1962 ('a', 'added', None, _('show only added files')),
1963 ('r', 'removed', None, 'show only removed files'), 1963 ('r', 'removed', None, _('show only removed files')),
1964 ('u', 'unknown', None, 'show only unknown (not tracked) files'), 1964 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
1965 ('n', 'no-status', None, 'hide status prefix'), 1965 ('n', 'no-status', None, _('hide status prefix')),
1966 ('0', 'print0', None, 'end filenames with NUL'), 1966 ('0', 'print0', None, _('end filenames with NUL')),
1967 ('I', 'include', [], 'include path in search'), 1967 ('I', 'include', [], _('include path in search')),
1968 ('X', 'exclude', [], 'exclude path from search')], 1968 ('X', 'exclude', [], _('exclude path from search'))],
1969 "hg status [OPTION]... [FILE]..."), 1969 _("hg status [OPTION]... [FILE]...")),
1970 "tag": 1970 "tag":
1971 (tag, 1971 (tag,
1972 [('l', 'local', None, 'make the tag local'), 1972 [('l', 'local', None, _('make the tag local')),
1973 ('m', 'message', "", 'commit message'), 1973 ('m', 'message', "", _('commit message')),
1974 ('t', 'text', "", 'commit message (deprecated: use -m)'), 1974 ('t', 'text', "", _('commit message (deprecated: use -m)')),
1975 ('d', 'date', "", 'date code'), 1975 ('d', 'date', "", _('date code')),
1976 ('u', 'user', "", 'user')], 1976 ('u', 'user', "", _('user'))],
1977 'hg tag [OPTION]... NAME [REV]'), 1977 _('hg tag [OPTION]... NAME [REV]')),
1978 "tags": (tags, [], 'hg tags'), 1978 "tags": (tags, [], _('hg tags')),
1979 "tip": (tip, [], 'hg tip'), 1979 "tip": (tip, [], _('hg tip')),
1980 "unbundle": 1980 "unbundle":
1981 (unbundle, 1981 (unbundle,
1982 [], 1982 [],
1983 'hg unbundle FILE'), 1983 _('hg unbundle FILE')),
1984 "undo": (undo, [], 'hg undo'), 1984 "undo": (undo, [], _('hg undo')),
1985 "^update|up|checkout|co": 1985 "^update|up|checkout|co":
1986 (update, 1986 (update,
1987 [('b', 'branch', "", 'checkout the head of a specific branch'), 1987 [('b', 'branch', "", _('checkout the head of a specific branch')),
1988 ('m', 'merge', None, 'allow merging of conflicts'), 1988 ('m', 'merge', None, _('allow merging of conflicts')),
1989 ('C', 'clean', None, 'overwrite locally modified files')], 1989 ('C', 'clean', None, _('overwrite locally modified files'))],
1990 'hg update [-b TAG] [-m] [-C] [REV]'), 1990 _('hg update [-b TAG] [-m] [-C] [REV]')),
1991 "verify": (verify, [], 'hg verify'), 1991 "verify": (verify, [], _('hg verify')),
1992 "version": (show_version, [], 'hg version'), 1992 "version": (show_version, [], _('hg version')),
1993 } 1993 }
1994 1994
1995 globalopts = [ 1995 globalopts = [
1996 ('R', 'repository', "", 'repository root directory'), 1996 ('R', 'repository', "", _('repository root directory')),
1997 ('', 'cwd', '', 'change working directory'), 1997 ('', 'cwd', '', _('change working directory')),
1998 ('y', 'noninteractive', None, 'run non-interactively'), 1998 ('y', 'noninteractive', None, _('run non-interactively')),
1999 ('q', 'quiet', None, 'quiet mode'), 1999 ('q', 'quiet', None, _('quiet mode')),
2000 ('v', 'verbose', None, 'verbose mode'), 2000 ('v', 'verbose', None, _('verbose mode')),
2001 ('', 'debug', None, 'debug mode'), 2001 ('', 'debug', None, _('debug mode')),
2002 ('', 'debugger', None, 'start debugger'), 2002 ('', 'debugger', None, _('start debugger')),
2003 ('', 'traceback', None, 'print traceback on exception'), 2003 ('', 'traceback', None, _('print traceback on exception')),
2004 ('', 'time', None, 'time how long the command takes'), 2004 ('', 'time', None, _('time how long the command takes')),
2005 ('', 'profile', None, 'profile'), 2005 ('', 'profile', None, _('profile')),
2006 ('', 'version', None, 'output version information and exit'), 2006 ('', 'version', None, _('output version information and exit')),
2007 ('h', 'help', None, 'display help and exit'), 2007 ('h', 'help', None, _('display help and exit')),
2008 ] 2008 ]
2009 2009
2010 norepo = ("clone init version help debugancestor debugconfig debugdata" 2010 norepo = ("clone init version help debugancestor debugconfig debugdata"
2011 " debugindex debugindexdot paths") 2011 " debugindex debugindexdot paths")
2012 2012
2075 for x in u.extensions(): 2075 for x in u.extensions():
2076 if x[1]: 2076 if x[1]:
2077 try: 2077 try:
2078 mod = imp.load_source(x[0], x[1]) 2078 mod = imp.load_source(x[0], x[1])
2079 except: 2079 except:
2080 u.warn("*** failed to import extension %s\n" % x[1]) 2080 u.warn(_("*** failed to import extension %s\n") % x[1])
2081 continue 2081 continue
2082 else: 2082 else:
2083 def importh(name): 2083 def importh(name):
2084 mod = __import__(name) 2084 mod = __import__(name)
2085 components = name.split('.') 2085 components = name.split('.')
2087 mod = getattr(mod, comp) 2087 mod = getattr(mod, comp)
2088 return mod 2088 return mod
2089 try: 2089 try:
2090 mod = importh(x[0]) 2090 mod = importh(x[0])
2091 except: 2091 except:
2092 u.warn("failed to import extension %s\n" % x[0]) 2092 u.warn(_("failed to import extension %s\n") % x[0])
2093 continue 2093 continue
2094 2094
2095 external.append(mod) 2095 external.append(mod)
2096 for x in external: 2096 for x in external:
2097 cmdtable = getattr(x, 'cmdtable', {}) 2097 cmdtable = getattr(x, 'cmdtable', {})
2098 for t in cmdtable: 2098 for t in cmdtable:
2099 if t in table: 2099 if t in table:
2100 u.warn("module %s overrides %s\n" % (x.__name__, t)) 2100 u.warn(_("module %s overrides %s\n") % (x.__name__, t))
2101 table.update(cmdtable) 2101 table.update(cmdtable)
2102 2102
2103 try: 2103 try:
2104 cmd, func, args, options, cmdoptions = parse(args) 2104 cmd, func, args, options, cmdoptions = parse(args)
2105 except ParseError, inst: 2105 except ParseError, inst:
2106 if inst.args[0]: 2106 if inst.args[0]:
2107 u.warn("hg %s: %s\n" % (inst.args[0], inst.args[1])) 2107 u.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1]))
2108 help_(u, inst.args[0]) 2108 help_(u, inst.args[0])
2109 else: 2109 else:
2110 u.warn("hg: %s\n" % inst.args[1]) 2110 u.warn(_("hg: %s\n") % inst.args[1])
2111 help_(u, 'shortlist') 2111 help_(u, 'shortlist')
2112 sys.exit(-1) 2112 sys.exit(-1)
2113 except UnknownCommand, inst: 2113 except UnknownCommand, inst:
2114 u.warn("hg: unknown command '%s'\n" % inst.args[0]) 2114 u.warn(_("hg: unknown command '%s'\n") % inst.args[0])
2115 help_(u, 'shortlist') 2115 help_(u, 'shortlist')
2116 sys.exit(1) 2116 sys.exit(1)
2117 2117
2118 if options["time"]: 2118 if options["time"]:
2119 def get_times(): 2119 def get_times():
2122 t = (t[0], t[1], t[2], t[3], time.clock()) 2122 t = (t[0], t[1], t[2], t[3], time.clock())
2123 return t 2123 return t
2124 s = get_times() 2124 s = get_times()
2125 def print_time(): 2125 def print_time():
2126 t = get_times() 2126 t = get_times()
2127 u.warn("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n" % 2127 u.warn(_("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") %
2128 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3])) 2128 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3]))
2129 atexit.register(print_time) 2129 atexit.register(print_time)
2130 2130
2131 u.updateopts(options["verbose"], options["debug"], options["quiet"], 2131 u.updateopts(options["verbose"], options["debug"], options["quiet"],
2132 not options["noninteractive"]) 2132 not options["noninteractive"])
2181 pdb.post_mortem(sys.exc_info()[2]) 2181 pdb.post_mortem(sys.exc_info()[2])
2182 if options['traceback']: 2182 if options['traceback']:
2183 traceback.print_exc() 2183 traceback.print_exc()
2184 raise 2184 raise
2185 except hg.RepoError, inst: 2185 except hg.RepoError, inst:
2186 u.warn("abort: ", inst, "!\n") 2186 u.warn(_("abort: "), inst, "!\n")
2187 except revlog.RevlogError, inst: 2187 except revlog.RevlogError, inst:
2188 u.warn("abort: ", inst, "!\n") 2188 u.warn(_("abort: "), inst, "!\n")
2189 except SignalInterrupt: 2189 except SignalInterrupt:
2190 u.warn("killed!\n") 2190 u.warn(_("killed!\n"))
2191 except KeyboardInterrupt: 2191 except KeyboardInterrupt:
2192 try: 2192 try:
2193 u.warn("interrupted!\n") 2193 u.warn(_("interrupted!\n"))
2194 except IOError, inst: 2194 except IOError, inst:
2195 if inst.errno == errno.EPIPE: 2195 if inst.errno == errno.EPIPE:
2196 if u.debugflag: 2196 if u.debugflag:
2197 u.warn("\nbroken pipe\n") 2197 u.warn(_("\nbroken pipe\n"))
2198 else: 2198 else:
2199 raise 2199 raise
2200 except IOError, inst: 2200 except IOError, inst:
2201 if hasattr(inst, "code"): 2201 if hasattr(inst, "code"):
2202 u.warn("abort: %s\n" % inst) 2202 u.warn(_("abort: %s\n") % inst)
2203 elif hasattr(inst, "reason"): 2203 elif hasattr(inst, "reason"):
2204 u.warn("abort: error: %s\n" % inst.reason[1]) 2204 u.warn(_("abort: error: %s\n") % inst.reason[1])
2205 elif hasattr(inst, "args") and inst[0] == errno.EPIPE: 2205 elif hasattr(inst, "args") and inst[0] == errno.EPIPE:
2206 if u.debugflag: 2206 if u.debugflag:
2207 u.warn("broken pipe\n") 2207 u.warn(_("broken pipe\n"))
2208 elif getattr(inst, "strerror", None): 2208 elif getattr(inst, "strerror", None):
2209 if getattr(inst, "filename", None): 2209 if getattr(inst, "filename", None):
2210 u.warn("abort: %s - %s\n" % (inst.strerror, inst.filename)) 2210 u.warn(_("abort: %s - %s\n") % (inst.strerror, inst.filename))
2211 else: 2211 else:
2212 u.warn("abort: %s\n" % inst.strerror) 2212 u.warn(_("abort: %s\n") % inst.strerror)
2213 else: 2213 else:
2214 raise 2214 raise
2215 except OSError, inst: 2215 except OSError, inst:
2216 if hasattr(inst, "filename"): 2216 if hasattr(inst, "filename"):
2217 u.warn("abort: %s: %s\n" % (inst.strerror, inst.filename)) 2217 u.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename))
2218 else: 2218 else:
2219 u.warn("abort: %s\n" % inst.strerror) 2219 u.warn(_("abort: %s\n") % inst.strerror)
2220 except util.Abort, inst: 2220 except util.Abort, inst:
2221 u.warn('abort: ', inst.args[0] % inst.args[1:], '\n') 2221 u.warn(_('abort: '), inst.args[0] % inst.args[1:], '\n')
2222 sys.exit(1) 2222 sys.exit(1)
2223 except TypeError, inst: 2223 except TypeError, inst:
2224 # was this an argument error? 2224 # was this an argument error?
2225 tb = traceback.extract_tb(sys.exc_info()[2]) 2225 tb = traceback.extract_tb(sys.exc_info()[2])
2226 if len(tb) > 2: # no 2226 if len(tb) > 2: # no
2227 raise 2227 raise
2228 u.debug(inst, "\n") 2228 u.debug(inst, "\n")
2229 u.warn("%s: invalid arguments\n" % cmd) 2229 u.warn(_("%s: invalid arguments\n") % cmd)
2230 help_(u, cmd) 2230 help_(u, cmd)
2231 except UnknownCommand, inst: 2231 except UnknownCommand, inst:
2232 u.warn("hg: unknown command '%s'\n" % inst.args[0]) 2232 u.warn(_("hg: unknown command '%s'\n") % inst.args[0])
2233 help_(u, 'shortlist') 2233 help_(u, 'shortlist')
2234 except SystemExit: 2234 except SystemExit:
2235 # don't catch this in the catch-all below 2235 # don't catch this in the catch-all below
2236 raise 2236 raise
2237 except: 2237 except:
2238 u.warn("** unknown exception encountered, details follow\n") 2238 u.warn(_("** unknown exception encountered, details follow\n"))
2239 u.warn("** report bug details to mercurial@selenic.com\n") 2239 u.warn(_("** report bug details to mercurial@selenic.com\n"))
2240 raise 2240 raise
2241 2241
2242 sys.exit(-1) 2242 sys.exit(-1)