# HG changeset patch # User Thomas Arendsen Hein # Date 2006-04-01 19:37:08 # Node ID e3280d35079233583bfe2ad9ae63fc69053c5a52 # Parent cd6bdbc508ddc744fe51b39bfdbbdfaf0e9d3eef 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. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -407,15 +407,20 @@ class changeset_templater(object): '''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 @@ class changeset_templater(object): } 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 log(ui, repo, *pats, **opts): 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 @@ def log(ui, repo, *pats, **opts): 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 @@ def log(ui, repo, *pats, **opts): 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]: diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -27,6 +27,8 @@ class ui(object): 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 @@ class ui(object): 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() diff --git a/templates/map-cmdline.changelog b/templates/map-cmdline.changelog --- a/templates/map-cmdline.changelog +++ b/templates/map-cmdline.changelog @@ -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}, '