Merged with crew.
authorThomas Arendsen Hein <thomas@intevation.de>
Sun, 02 Apr 2006 08:19:41 +0200
changeset 2037 f90513a3dbcd
parent 2036 c9226bcc288d (current diff)
parent 2035 107dc72880f8 (diff)
child 2038 5c4496ed152d
Merged with crew.
mercurial/commands.py
--- a/README	Sat Apr 01 11:58:50 2006 +0200
+++ b/README	Sun Apr 02 08:19:41 2006 +0200
@@ -97,4 +97,3 @@
 
  Documentation in doc/
  Mercurial website at http://selenic.com/mercurial
- Mercurial wiki at http://selenic.com/mercurial/wiki
--- a/contrib/bash_completion	Sat Apr 01 11:58:50 2006 +0200
+++ b/contrib/bash_completion	Sun Apr 02 08:19:41 2006 +0200
@@ -1,18 +1,5 @@
 shopt -s extglob
 
-_hg_option_list()
-{
-    "$hg" -v help $1 2>/dev/null | \
-	awk '/^ *-/ {
-		for (i = 1; i <= NF; i ++) {
-		    if (index($i, "-") != 1)
-			break;
-		    print $i;
-		}
-	    }'
-}
-
-
 _hg_commands()
 {
     local commands
@@ -42,8 +29,8 @@
 
 _hg_tags()
 {
-    local tags="$("$hg" tags 2>/dev/null |
-	sed -e 's/[0-9]*:[a-f0-9]\{40\}$//; s/ *$//')"
+    local tags="$("$hg" tags -q 2>/dev/null)"
+    local IFS=$'\n'
     COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$tags' -- "$cur"))
 }
 
@@ -89,7 +76,7 @@
     done
 
     if [[ "$cur" == -* ]]; then
-	opts=$(_hg_option_list $cmd)
+	opts=$("$hg" debugcomplete --options "$cmd" 2>/dev/null)
 
 	COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur"))
 	return
--- a/doc/hg.1.txt	Sat Apr 01 11:58:50 2006 +0200
+++ b/doc/hg.1.txt	Sun Apr 02 08:19:41 2006 +0200
@@ -210,8 +210,6 @@
 ---------
 http://selenic.com/mercurial[Main Web Site]
 
-http://www.serpentine.com/mercurial[Wiki site]
-
 http://selenic.com/hg[Source code repository]
 
 http://selenic.com/mailman/listinfo/mercurial[Mailing list]
--- a/mercurial/commands.py	Sat Apr 01 11:58:50 2006 +0200
+++ b/mercurial/commands.py	Sun Apr 02 08:19:41 2006 +0200
@@ -407,15 +407,20 @@
         '''set template string to use'''
         self.t.cache['changeset'] = t
 
-    def write(self, thing):
+    def write(self, thing, header=False):
         '''write expanded template.
         uses in-order recursive traverse of iterators.'''
         for t in thing:
             if hasattr(t, '__iter__'):
-                self.write(t)
+                self.write(t, header=header)
+            elif header:
+                self.ui.write_header(t)
             else:
                 self.ui.write(t)
 
+    def write_header(self, thing):
+        self.write(thing, header=True)
+
     def show(self, rev=0, changenode=None, brinfo=None):
         '''show a single changeset or file revision'''
         log = self.repo.changelog
@@ -549,6 +554,18 @@
             }
 
         try:
+            if self.ui.debugflag and 'header_debug' in self.t:
+                key = 'header_debug'
+            elif self.ui.quiet and 'header_quiet' in self.t:
+                key = 'header_quiet'
+            elif self.ui.verbose and 'header_verbose' in self.t:
+                key = 'header_verbose'
+            elif 'header' in self.t:
+                key = 'header'
+            else:
+                key = ''
+            if key:
+                self.write_header(self.t(key, **props))
             if self.ui.debugflag and 'changeset_debug' in self.t:
                 key = 'changeset_debug'
             elif self.ui.quiet and 'changeset_quiet' in self.t:
@@ -1255,11 +1272,26 @@
     a = r.ancestor(r.lookup(rev1), r.lookup(rev2))
     ui.write("%d:%s\n" % (r.rev(a), hex(a)))
 
-def debugcomplete(ui, cmd):
+def debugcomplete(ui, cmd='', **opts):
     """returns the completion list associated with the given command"""
+
+    if opts['options']:
+        options = []
+        otables = [globalopts]
+        if cmd:
+            aliases, entry = find(cmd)
+            otables.append(entry[1])
+        for t in otables:
+            for o in t:
+                if o[0]:
+                    options.append('-%s' % o[0])
+                options.append('--%s' % o[1])
+        ui.write("%s\n" % "\n".join(options))
+        return
+
     clist = findpossible(cmd).keys()
     clist.sort()
-    ui.write("%s\n" % " ".join(clist))
+    ui.write("%s\n" % "\n".join(clist))
 
 def debugrebuildstate(ui, repo, rev=None):
     """rebuild the dirstate as it would look like for the given revision"""
@@ -1897,9 +1929,11 @@
         def __init__(self, ui):
             self.ui = ui
             self.hunk = {}
+            self.header = {}
         def bump(self, rev):
             self.rev = rev
             self.hunk[rev] = []
+            self.header[rev] = []
         def note(self, *args):
             if self.verbose:
                 self.write(*args)
@@ -1908,6 +1942,8 @@
                 self.write(*args)
         def write(self, *args):
             self.hunk[self.rev].append(args)
+        def write_header(self, *args):
+            self.header[self.rev].append(args)
         def debug(self, *args):
             if self.debugflag:
                 self.write(*args)
@@ -1964,6 +2000,9 @@
                 du.write("\n\n")
         elif st == 'iter':
             if count == limit: break
+            if du.header[rev]:
+                for args in du.header[rev]:
+                    ui.write_header(*args)
             if du.hunk[rev]:
                 count += 1
                 for args in du.hunk[rev]:
@@ -2637,7 +2676,10 @@
             r = "%5d:%s" % (repo.changelog.rev(n), hex(n))
         except KeyError:
             r = "    ?:?"
-        ui.write("%-30s %s\n" % (t, r))
+        if ui.quiet:
+            ui.write("%s\n" % t)
+        else:
+            ui.write("%-30s %s\n" % (t, r))
 
 def tip(ui, repo, **opts):
     """show the tip revision
@@ -2814,7 +2856,10 @@
           ('X', 'exclude', [], _('exclude names matching the given patterns'))],
          _('hg copy [OPTION]... [SOURCE]... DEST')),
     "debugancestor": (debugancestor, [], _('debugancestor INDEX REV1 REV2')),
-    "debugcomplete": (debugcomplete, [], _('debugcomplete CMD')),
+    "debugcomplete":
+        (debugcomplete,
+         [('o', 'options', None, _('show the command options'))],
+         _('debugcomplete [-o] CMD')),
     "debugrebuildstate":
         (debugrebuildstate,
          [('r', 'rev', '', _('revision to rebuild to'))],
--- a/mercurial/ui.py	Sat Apr 01 11:58:50 2006 +0200
+++ b/mercurial/ui.py	Sun Apr 02 08:19:41 2006 +0200
@@ -27,6 +27,8 @@
 
             self.updateopts(verbose, debug, quiet, interactive)
             self.diffcache = None
+            self.header = []
+            self.prev_header = []
         else:
             # parentui may point to an ui object which is already a child
             self.parentui = parentui.parentui or parentui
@@ -184,9 +186,18 @@
         return self.config("paths", loc, loc)
 
     def write(self, *args):
+        if self.header:
+            if self.header != self.prev_header:
+                self.prev_header = self.header
+                self.write(*self.header)
+            self.header = []
         for a in args:
             sys.stdout.write(str(a))
 
+    def write_header(self, *args):
+        for a in args:
+            self.header.append(str(a))
+
     def write_err(self, *args):
         try:
             if not sys.stdout.closed: sys.stdout.flush()
--- a/templates/map-cmdline.changelog	Sat Apr 01 11:58:50 2006 +0200
+++ b/templates/map-cmdline.changelog	Sun Apr 02 08:19:41 2006 +0200
@@ -1,15 +1,14 @@
-changeset = '{date|shortdate}  {author|person}  <{author|email}>  ({node|short}{tags})\n\n\t* {files|stringify|fill68|tabindent}{desc|fill68|tabindent|strip}\n\n'
-changeset_quiet = '{date|shortdate}  {author|person}  <{author|email}>\n\n\t* {desc|firstline|fill68|tabindent|strip}\n\n'
+header = '{date|shortdate}  {author|person}  <{author|email}>\n\n'
+header_verbose = ''
+changeset = '\t* {files|stringify|fill68|tabindent}{desc|fill68|tabindent|strip}\n\t[{node|short}]{tags}\n\n'
+changeset_quiet = '\t* {desc|firstline|fill68|tabindent|strip}\n\n'
 changeset_verbose = '{date|isodate}  {author|person}  <{author|email}>  ({node|short}{tags})\n\n\t* {file_adds|stringify|fill68|tabindent}{file_dels|stringify|fill68|tabindent}{files|stringify|fill68|tabindent}{desc|fill68|tabindent|strip}\n\n'
 start_tags = ' ['
 tag = '{tag}, '
 last_tag = '{tag}]'
-start_files = '('
 file = '{file}, '
-last_file = '{file}):\n\t'
-start_file_adds = '('
+last_file = '{file}:\n\t'
 file_add = '{file_add}, '
-last_file_add = '{file_add}): new file.\n* '
-start_file_dels = '('
+last_file_add = '{file_add}: new file.\n* '
 file_del = '{file_del}, '
-last_file_del = '{file_del}): deleted file.\n* '
+last_file_del = '{file_del}: deleted file.\n* '