changeset 2033:e3280d350792

Group changes done by the same developer on the same with --style=changelog Changeset and tags are appended to the change message for non-quiet and non-verbose output, so grouping works. Fixes last bit of issue110.
author Thomas Arendsen Hein <thomas@intevation.de>
date Sat, 01 Apr 2006 21:37:08 +0200
parents cd6bdbc508dd
children 5e7aff1b6ae1
files mercurial/commands.py mercurial/ui.py templates/map-cmdline.changelog
diffstat 3 files changed, 41 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sat Apr 01 20:56:55 2006 +0200
+++ b/mercurial/commands.py	Sat Apr 01 21:37:08 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:
@@ -1897,9 +1914,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 +1927,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 +1985,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]:
--- a/mercurial/ui.py	Sat Apr 01 20:56:55 2006 +0200
+++ b/mercurial/ui.py	Sat Apr 01 21:37:08 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 20:56:55 2006 +0200
+++ b/templates/map-cmdline.changelog	Sat Apr 01 21:37:08 2006 +0200
@@ -1,5 +1,7 @@
-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}, '