mercurial/commands.py
changeset 4016 a195f11ed1a2
parent 3990 96e21337dc03
parent 4014 509342f95564
child 4045 1bd6868b0b11
equal deleted inserted replaced
4007:20da40cc1c73 4016:a195f11ed1a2
     9 from node import *
     9 from node import *
    10 from i18n import _
    10 from i18n import _
    11 import bisect, os, re, sys, signal, imp, urllib, pdb, shlex, stat
    11 import bisect, os, re, sys, signal, imp, urllib, pdb, shlex, stat
    12 import fancyopts, ui, hg, util, lock, revlog, bundlerepo
    12 import fancyopts, ui, hg, util, lock, revlog, bundlerepo
    13 import difflib, patch, time, help, mdiff, tempfile
    13 import difflib, patch, time, help, mdiff, tempfile
    14 import traceback, errno, version, atexit
    14 import traceback, errno, version, atexit, socket
    15 import archival, changegroup, cmdutil, hgweb.server, sshserver
    15 import archival, changegroup, cmdutil, hgweb.server, sshserver
    16 
    16 
    17 class UnknownCommand(Exception):
    17 class UnknownCommand(Exception):
    18     """Exception raised if command is not in the command table."""
    18     """Exception raised if command is not in the command table."""
    19 class AmbiguousCommand(Exception):
    19 class AmbiguousCommand(Exception):
  1335         ui.write(_('%s extension - %s\n') % (name.split('.')[-1], doc[0]))
  1335         ui.write(_('%s extension - %s\n') % (name.split('.')[-1], doc[0]))
  1336         for d in doc[1:]:
  1336         for d in doc[1:]:
  1337             ui.write(d, '\n')
  1337             ui.write(d, '\n')
  1338 
  1338 
  1339         ui.status('\n')
  1339         ui.status('\n')
       
  1340 
       
  1341         try:
       
  1342             ct = mod.cmdtable
       
  1343         except AttributeError:
       
  1344             ui.status(_('no commands defined\n'))
       
  1345             return
       
  1346 
  1340         if ui.verbose:
  1347         if ui.verbose:
  1341             ui.status(_('list of commands:\n\n'))
  1348             ui.status(_('list of commands:\n\n'))
  1342         else:
  1349         else:
  1343             ui.status(_('list of commands (use "hg help -v %s" '
  1350             ui.status(_('list of commands (use "hg help -v %s" '
  1344                         'to show aliases and global options):\n\n') % name)
  1351                         'to show aliases and global options):\n\n') % name)
  1345 
  1352 
  1346         modcmds = dict.fromkeys([c.split('|', 1)[0] for c in mod.cmdtable])
  1353         modcmds = dict.fromkeys([c.split('|', 1)[0] for c in ct])
  1347         helplist(modcmds.has_key)
  1354         helplist(modcmds.has_key)
  1348 
  1355 
  1349     if name and name != 'shortlist':
  1356     if name and name != 'shortlist':
  1350         i = None
  1357         i = None
  1351         for f in (helpcmd, helptopic, helpext):
  1358         for f in (helpcmd, helptopic, helpext):
  1759         if ui.verbose:
  1766         if ui.verbose:
  1760             ui.write("%3s " % (m.execf(f) and "755" or "644"))
  1767             ui.write("%3s " % (m.execf(f) and "755" or "644"))
  1761         ui.write("%s\n" % f)
  1768         ui.write("%s\n" % f)
  1762 
  1769 
  1763 def merge(ui, repo, node=None, force=None):
  1770 def merge(ui, repo, node=None, force=None):
  1764     """Merge working directory with another revision
  1771     """merge working directory with another revision
  1765 
  1772 
  1766     Merge the contents of the current working directory and the
  1773     Merge the contents of the current working directory and the
  1767     requested revision. Files that changed between either parent are
  1774     requested revision. Files that changed between either parent are
  1768     marked as changed for the next commit and a commit must be
  1775     marked as changed for the next commit and a commit must be
  1769     performed before any further updates are allowed.
  1776     performed before any further updates are allowed.
  2475     gen = changegroup.readbundle(urllib.urlopen(fname), fname)
  2482     gen = changegroup.readbundle(urllib.urlopen(fname), fname)
  2476     modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
  2483     modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
  2477     return postincoming(ui, repo, modheads, opts['update'])
  2484     return postincoming(ui, repo, modheads, opts['update'])
  2478 
  2485 
  2479 def update(ui, repo, node=None, clean=False, date=None):
  2486 def update(ui, repo, node=None, clean=False, date=None):
  2480     """update or merge working directory
  2487     """update working directory
  2481 
  2488 
  2482     Update the working directory to the specified revision.
  2489     Update the working directory to the specified revision.
  2483 
  2490 
  2484     If there are no outstanding changes in the working directory and
  2491     If there are no outstanding changes in the working directory and
  2485     there is a linear relationship between the current version and the
  2492     there is a linear relationship between the current version and the
  2487 
  2494 
  2488     To merge the working directory with another revision, use the
  2495     To merge the working directory with another revision, use the
  2489     merge command.
  2496     merge command.
  2490 
  2497 
  2491     By default, update will refuse to run if doing so would require
  2498     By default, update will refuse to run if doing so would require
  2492     merging or discarding local changes.
  2499     discarding local changes.
  2493     """
  2500     """
  2494     if date:
  2501     if date:
  2495         if node:
  2502         if node:
  2496             raise util.Abort(_("you can't specify a revision and a date"))
  2503             raise util.Abort(_("you can't specify a revision and a date"))
  2497         node = cmdutil.finddate(ui, repo, date)
  2504         node = cmdutil.finddate(ui, repo, date)
  2766           ('P', 'prune', [], _('do not display revision or any of its ancestors')),
  2773           ('P', 'prune', [], _('do not display revision or any of its ancestors')),
  2767           ('', 'template', '', _('display with template')),
  2774           ('', 'template', '', _('display with template')),
  2768          ] + walkopts,
  2775          ] + walkopts,
  2769          _('hg log [OPTION]... [FILE]')),
  2776          _('hg log [OPTION]... [FILE]')),
  2770     "manifest": (manifest, [], _('hg manifest [REV]')),
  2777     "manifest": (manifest, [], _('hg manifest [REV]')),
  2771     "merge":
  2778     "^merge":
  2772         (merge,
  2779         (merge,
  2773          [('f', 'force', None, _('force a merge with outstanding changes'))],
  2780          [('f', 'force', None, _('force a merge with outstanding changes'))],
  2774          _('hg merge [-f] [REV]')),
  2781          _('hg merge [-f] [REV]')),
  2775     "outgoing|out": (outgoing,
  2782     "outgoing|out": (outgoing,
  2776          [('M', 'no-merges', None, _('do not show merges')),
  2783          [('M', 'no-merges', None, _('do not show merges')),
  3228             if inst.errno == errno.EPIPE:
  3235             if inst.errno == errno.EPIPE:
  3229                 if u.debugflag:
  3236                 if u.debugflag:
  3230                     u.warn(_("\nbroken pipe\n"))
  3237                     u.warn(_("\nbroken pipe\n"))
  3231             else:
  3238             else:
  3232                 raise
  3239                 raise
       
  3240     except socket.error, inst:
       
  3241         u.warn(_("abort: %s\n") % inst[1])
  3233     except IOError, inst:
  3242     except IOError, inst:
  3234         if hasattr(inst, "code"):
  3243         if hasattr(inst, "code"):
  3235             u.warn(_("abort: %s\n") % inst)
  3244             u.warn(_("abort: %s\n") % inst)
  3236         elif hasattr(inst, "reason"):
  3245         elif hasattr(inst, "reason"):
  3237             u.warn(_("abort: error: %s\n") % inst.reason[1])
  3246             try: # usually it is in the form (errno, strerror)
       
  3247                 reason = inst.reason.args[1]
       
  3248             except: # it might be anything, for example a string
       
  3249                 reason = inst.reason
       
  3250             u.warn(_("abort: error: %s\n") % reason)
  3238         elif hasattr(inst, "args") and inst[0] == errno.EPIPE:
  3251         elif hasattr(inst, "args") and inst[0] == errno.EPIPE:
  3239             if u.debugflag:
  3252             if u.debugflag:
  3240                 u.warn(_("broken pipe\n"))
  3253                 u.warn(_("broken pipe\n"))
  3241         elif getattr(inst, "strerror", None):
  3254         elif getattr(inst, "strerror", None):
  3242             if getattr(inst, "filename", None):
  3255             if getattr(inst, "filename", None):