changeset 4325:aa26759c6fb3

Merge with crew-stable.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Sat, 07 Apr 2007 04:45:27 -0300
parents 61ab822a9e88 (current diff) cd650cd61b06 (diff)
children 1cc5fc1d0994 f4a1eac52d43
files mercurial/commands.py mercurial/hgweb/hgweb_mod.py mercurial/patch.py mercurial/revlog.py tests/test-mq.out
diffstat 11 files changed, 89 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1268,6 +1268,23 @@ def help_(ui, name=None, with_version=Fa
     commands it provides."""
     option_lists = []
 
+    def addglobalopts(aliases):
+        if ui.verbose:
+            option_lists.append((_("global options:"), globalopts))
+            if name == 'shortlist':
+                option_lists.append((_('use "hg help" for the full list '
+                                       'of commands'), ()))
+        else:
+            if name == 'shortlist':
+                msg = _('use "hg help" for the full list of commands '
+                        'or "hg -v" for details')
+            elif aliases:
+                msg = _('use "hg -v help%s" to show aliases and '
+                        'global options') % (name and " " + name or "")
+            else:
+                msg = _('use "hg -v help %s" to show global options') % name
+            option_lists.append((msg, ()))
+
     def helpcmd(name):
         if with_version:
             version_(ui)
@@ -1291,7 +1308,9 @@ def help_(ui, name=None, with_version=Fa
 
             # options
             if i[1]:
-                option_lists.append(("options", i[1]))
+                option_lists.append((_("options:\n"), i[1]))
+
+            addglobalopts(False)
 
     def helplist(select=None):
         h = {}
@@ -1321,6 +1340,9 @@ def help_(ui, name=None, with_version=Fa
             else:
                 ui.write(' %-*s   %s\n' % (m, f, h[f]))
 
+        if not ui.quiet:
+            addglobalopts(True)
+
     def helptopic(name):
         v = None
         for i in help.helptable:
@@ -1360,12 +1382,7 @@ def help_(ui, name=None, with_version=Fa
             ui.status(_('no commands defined\n'))
             return
 
-        if ui.verbose:
-            ui.status(_('list of commands:\n\n'))
-        else:
-            ui.status(_('list of commands (use "hg help -v %s" '
-                        'to show aliases and global options):\n\n') % name)
-
+        ui.status(_('list of commands:\n\n'))
         modcmds = dict.fromkeys([c.split('|', 1)[0] for c in ct])
         helplist(modcmds.has_key)
 
@@ -1391,24 +1408,16 @@ def help_(ui, name=None, with_version=Fa
 
         # list of commands
         if name == "shortlist":
-            ui.status(_('basic commands (use "hg help" '
-                        'for the full list or option "-v" for details):\n\n'))
-        elif ui.verbose:
+            ui.status(_('basic commands:\n\n'))
+        else:
             ui.status(_('list of commands:\n\n'))
-        else:
-            ui.status(_('list of commands (use "hg help -v" '
-                        'to show aliases and global options):\n\n'))
 
         helplist()
 
-    # global options
-    if ui.verbose:
-        option_lists.append(("global options", globalopts))
-
     # list all option lists
     opt_output = []
     for title, options in option_lists:
-        opt_output.append(("\n%s:\n" % title, None))
+        opt_output.append(("\n%s" % title, None))
         for shortopt, longopt, default, desc in options:
             if "DEPRECATED" in desc and not ui.verbose: continue
             opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt,
@@ -1419,7 +1428,7 @@ def help_(ui, name=None, with_version=Fa
                                          or "")))
 
     if opt_output:
-        opts_len = max([len(line[0]) for line in opt_output if line[1]])
+        opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0])
         for first, second in opt_output:
             if second:
                 ui.write(" %-*s  %s\n" % (opts_len, first, second))
@@ -1775,7 +1784,7 @@ def log(ui, repo, *pats, **opts):
                 for k in [kw.lower() for kw in opts['keyword']]:
                     if not (k in changes[1].lower() or
                             k in changes[4].lower() or
-                            k in " ".join(changes[3][:20]).lower()):
+                            k in " ".join(changes[3]).lower()):
                         miss = 1
                         break
                 if miss:
@@ -2845,7 +2854,7 @@ table = {
            _('only follow the first parent of merge changesets')),
           ('d', 'date', '', _('show revs matching date spec')),
           ('C', 'copies', None, _('show copied files')),
-          ('k', 'keyword', [], _('search for a keyword')),
+          ('k', 'keyword', [], _('do case-insensitive search for a keyword')),
           ('l', 'limit', '', _('limit number of changes displayed')),
           ('r', 'rev', [], _('show the specified revision or range')),
           ('', 'removed', None, _('include revs where files were removed')),
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -257,7 +257,7 @@ class hgweb(object):
                 for q in qw:
                     if not (q in ctx.user().lower() or
                             q in ctx.description().lower() or
-                            q in " ".join(ctx.files()[:20]).lower()):
+                            q in " ".join(ctx.files()).lower()):
                         miss = 1
                         break
                 if miss:
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -635,6 +635,8 @@ def export(repo, revs, template='hg-%h.p
         single(rev, seqno+1, fp)
 
 def diffstat(patchlines):
+    if not util.find_in_path('diffstat', os.environ.get('PATH', '')):
+        return
     fd, name = tempfile.mkstemp(prefix="hg-patchbomb-", suffix=".txt")
     try:
         p = popen2.Popen3('diffstat -p1 -w79 2>/dev/null > ' + name)
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -210,7 +210,7 @@ class lazyparser(object):
                 end = end * self.s
                 blocksize = end - blockstart
             else:
-                blockstart = (i & ~(32)) * self.s
+                blockstart = (i & ~63) * self.s
                 blocksize = self.s * 64
                 end = blockstart + blocksize
         while blockstart < end:
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -45,6 +45,7 @@ parser.set_defaults(timeout=180)
 (options, args) = parser.parse_args()
 verbose = options.verbose
 coverage = options.cover or options.cover_stdlib or options.annotate
+python = sys.executable
 
 def vlog(*msg):
     if verbose:
@@ -115,6 +116,7 @@ def use_correct_python():
         shutil.copymode(sys.executable, my_python)
 
 def install_hg():
+    global python
     vlog("# Performing temporary installation of HG")
     installerrs = os.path.join("tests", "install.err")
 
@@ -154,6 +156,8 @@ def install_hg():
             os.path.join(BINDIR, '_hg.py')))
         f.close()
         os.chmod(os.path.join(BINDIR, 'hg'), 0700)
+        python = '"%s" "%s" -x' % (sys.executable,
+                                   os.path.join(TESTDIR,'coverage.py'))
 
 def output_coverage():
     vlog("# Producing coverage report")
@@ -163,7 +167,7 @@ def output_coverage():
         omit += [x for x in sys.path if x != '']
     omit = ','.join(omit)
     os.chdir(PYTHONDIR)
-    cmd = '"%s" "%s" -r "--omit=%s"' % (
+    cmd = '"%s" "%s" -i -r "--omit=%s"' % (
         sys.executable, os.path.join(TESTDIR, 'coverage.py'), omit)
     vlog("# Running: "+cmd)
     os.system(cmd)
@@ -171,7 +175,7 @@ def output_coverage():
         adir = os.path.join(TESTDIR, 'annotated')
         if not os.path.isdir(adir):
             os.mkdir(adir)
-        cmd = '"%s" "%s" -a "--directory=%s" "--omit=%s"' % (
+        cmd = '"%s" "%s" -i -a "--directory=%s" "--omit=%s"' % (
             sys.executable, os.path.join(TESTDIR, 'coverage.py'),
             adir, omit)
         vlog("# Running: "+cmd)
@@ -226,6 +230,7 @@ def run_one(test):
 
     err = os.path.join(TESTDIR, test+".err")
     ref = os.path.join(TESTDIR, test+".out")
+    testpath = os.path.join(TESTDIR, test)
 
     if os.path.exists(err):
         os.remove(err)       # Remove any previous output files
@@ -235,10 +240,16 @@ def run_one(test):
     os.mkdir(tmpd)
     os.chdir(tmpd)
 
+    try:
+        tf = open(testpath)
+        firstline = tf.readline().rstrip()
+        tf.close()
+    except:
+        firstline = ''
     lctest = test.lower()
 
-    if lctest.endswith('.py'):
-        cmd = '%s "%s"' % (sys.executable, os.path.join(TESTDIR, test))
+    if lctest.endswith('.py') or firstline == '#!/usr/bin/env python':
+        cmd = '%s "%s"' % (python, testpath)
     elif lctest.endswith('.bat'):
         # do not run batch scripts on non-windows
         if os.name != 'nt':
@@ -246,17 +257,17 @@ def run_one(test):
             return None
         # To reliably get the error code from batch files on WinXP,
         # the "cmd /c call" prefix is needed. Grrr
-        cmd = 'cmd /c call "%s"' % (os.path.join(TESTDIR, test))
+        cmd = 'cmd /c call "%s"' % testpath
     else:
         # do not run shell scripts on windows
         if os.name == 'nt':
             print '\nSkipping %s: shell script' % test
             return None
         # do not try to run non-executable programs
-        if not os.access(os.path.join(TESTDIR, test), os.X_OK):
+        if not os.access(testpath, os.X_OK):
             print '\nSkipping %s: not executable' % test
             return None
-        cmd = '"%s"' % (os.path.join(TESTDIR, test))
+        cmd = '"%s"' % testpath
 
     if options.timeout > 0:
         signal.alarm(options.timeout)
--- a/tests/test-bad-pull
+++ b/tests/test-bad-pull
@@ -20,6 +20,9 @@ EOF
 python dumb.py 2>/dev/null &
 echo $! >> $DAEMON_PIDS
 
+# give the server some time to start running
+sleep 1
+
 http_proxy= hg clone http://localhost:20059/foo copy2 2>&1 | \
     sed -e 's/404.*/404/' -e 's/Date:.*/Date:/'
 echo $?
--- a/tests/test-extdiff.out
+++ b/tests/test-extdiff.out
@@ -24,6 +24,8 @@ options:
  -r --rev      revision
  -I --include  include names matching the given patterns
  -X --exclude  exclude names matching the given patterns
+
+use "hg -v help falabala" to show global options
 making snapshot of 1 files from rev e27a2475d60a
 making snapshot of 1 files from rev 5e49ec8d3f05
 diffing a.e27a2475d60a a.5e49ec8d3f05
--- a/tests/test-globalopts.out
+++ b/tests/test-globalopts.out
@@ -117,7 +117,7 @@ Mercurial Distributed SCM (version xxx)
 %% -h/--help
 Mercurial Distributed SCM
 
-list of commands (use "hg help -v" to show aliases and global options):
+list of commands:
 
  add          add the specified files on the next commit
  addremove    add all new files, delete all missing files
@@ -165,9 +165,11 @@ list of commands (use "hg help -v" to sh
  update       update working directory
  verify       verify the integrity of the repository
  version      output version and copyright information
+
+use "hg -v help" to show aliases and global options
 Mercurial Distributed SCM
 
-list of commands (use "hg help -v" to show aliases and global options):
+list of commands:
 
  add          add the specified files on the next commit
  addremove    add all new files, delete all missing files
@@ -215,4 +217,6 @@ list of commands (use "hg help -v" to sh
  update       update working directory
  verify       verify the integrity of the repository
  version      output version and copyright information
+
+use "hg -v help" to show aliases and global options
 %% not tested: --debugger
--- a/tests/test-help.out
+++ b/tests/test-help.out
@@ -1,6 +1,6 @@
 Mercurial Distributed SCM
 
-basic commands (use "hg help" for the full list or option "-v" for details):
+basic commands:
 
  add        add the specified files on the next commit
  annotate   show changeset information per file line
@@ -19,6 +19,8 @@ basic commands (use "hg help" for the fu
  serve      export the repository via HTTP
  status     show changed files in the working directory
  update     update working directory
+
+use "hg help" for the full list of commands or "hg -v" for details
  add        add the specified files on the next commit
  annotate   show changeset information per file line
  clone      make a copy of an existing repository
@@ -38,7 +40,7 @@ basic commands (use "hg help" for the fu
  update     update working directory
 Mercurial Distributed SCM
 
-list of commands (use "hg help -v" to show aliases and global options):
+list of commands:
 
  add          add the specified files on the next commit
  addremove    add all new files, delete all missing files
@@ -86,6 +88,8 @@ list of commands (use "hg help -v" to sh
  update       update working directory
  verify       verify the integrity of the repository
  version      output version and copyright information
+
+use "hg -v help" to show aliases and global options
  add          add the specified files on the next commit
  addremove    add all new files, delete all missing files
  annotate     show changeset information per file line
@@ -148,6 +152,8 @@ options:
  -I --include  include names matching the given patterns
  -X --exclude  exclude names matching the given patterns
  -n --dry-run  do not perform actions, just print output
+
+use "hg -v help add" to show global options
 hg add: option --skjdfks not recognized
 hg add [OPTION]... [FILE]...
 
@@ -165,6 +171,8 @@ options:
  -I --include  include names matching the given patterns
  -X --exclude  exclude names matching the given patterns
  -n --dry-run  do not perform actions, just print output
+
+use "hg -v help add" to show global options
 hg diff [OPTION]... [-r REV1 [-r REV2]] [FILE]...
 
 diff repository (or selected files)
@@ -199,6 +207,8 @@ options:
  -B --ignore-blank-lines   ignore changes whose lines are all blank
  -I --include              include names matching the given patterns
  -X --exclude              exclude names matching the given patterns
+
+use "hg -v help diff" to show global options
 hg status [OPTION]... [FILE]...
 
 show changed files in the working directory
@@ -243,13 +253,15 @@ options:
     --rev        show difference from revision
  -I --include    include names matching the given patterns
  -X --exclude    exclude names matching the given patterns
+
+use "hg -v help status" to show global options
 hg status [OPTION]... [FILE]...
 
 show changed files in the working directory
 hg: unknown command 'foo'
 Mercurial Distributed SCM
 
-basic commands (use "hg help" for the full list or option "-v" for details):
+basic commands:
 
  add        add the specified files on the next commit
  annotate   show changeset information per file line
@@ -268,10 +280,12 @@ basic commands (use "hg help" for the fu
  serve      export the repository via HTTP
  status     show changed files in the working directory
  update     update working directory
+
+use "hg help" for the full list of commands or "hg -v" for details
 hg: unknown command 'skjdfks'
 Mercurial Distributed SCM
 
-basic commands (use "hg help" for the full list or option "-v" for details):
+basic commands:
 
  add        add the specified files on the next commit
  annotate   show changeset information per file line
@@ -290,3 +304,5 @@ basic commands (use "hg help" for the fu
  serve      export the repository via HTTP
  status     show changed files in the working directory
  update     update working directory
+
+use "hg help" for the full list of commands or "hg -v" for details
--- a/tests/test-mq.out
+++ b/tests/test-mq.out
@@ -22,7 +22,7 @@ add known patch to applied stack        
 remove patch from applied stack           qpop
 refresh contents of top applied patch     qrefresh
 
-list of commands (use "hg help -v mq" to show aliases and global options):
+list of commands:
 
  qapplied     print the patches already applied
  qclone       clone main and patch repository at same time
@@ -48,6 +48,8 @@ list of commands (use "hg help -v mq" to
  qtop         print the name of the current patch
  qunapplied   print the patches not yet applied
  strip        strip a revision and all later revs on the same branch
+
+use "hg -v help mq" to show aliases and global options
 adding a
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 adding b/z
--- a/tests/test-strict.out
+++ b/tests/test-strict.out
@@ -3,7 +3,7 @@ 0: a
 hg: unknown command 'an'
 Mercurial Distributed SCM
 
-basic commands (use "hg help" for the full list or option "-v" for details):
+basic commands:
 
  add        add the specified files on the next commit
  annotate   show changeset information per file line
@@ -22,6 +22,8 @@ basic commands (use "hg help" for the fu
  serve      export the repository via HTTP
  status     show changed files in the working directory
  update     update working directory
+
+use "hg help" for the full list of commands or "hg -v" for details
 0: a
 % should succeed - up is an alias, not an abbreviation
 0 files updated, 0 files merged, 0 files removed, 0 files unresolved