# HG changeset patch # User Greg Ward # Date 2009-10-05 22:17:13 # Node ID f57640bf10d407efaa025072d2c41c407e95c3ad # Parent 4333b97444193012ed5eaea1a6c69b4209b5f248 cmdutil: changeset_printer: use methods of filectx/changectx. This allows extensions that modify changeset metadata (e.g. description) by overriding methods of changectx to get consistent behavior from all log-like commands, regardless of whether templates or styles are used. Without this, overriding changectx methods works if you use styles or templates, but not with default log format. This meant adding filectx.extra() for consistency with changectx. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -652,9 +652,8 @@ class changeset_printer(object): return log = self.repo.changelog - changes = log.read(changenode) - date = util.datestr(changes[2]) - extra = changes[5] + date = util.datestr(ctx.date()) + extra = ctx.extra() branch = extra.get("branch") hexfunc = self.ui.debugflag and hex or short @@ -674,9 +673,10 @@ class changeset_printer(object): self.ui.write(_("parent: %d:%s\n") % parent) if self.ui.debugflag: + mnode = ctx.manifestnode() self.ui.write(_("manifest: %d:%s\n") % - (self.repo.manifest.rev(changes[0]), hex(changes[0]))) - self.ui.write(_("user: %s\n") % changes[1]) + (self.repo.manifest.rev(mnode), hex(mnode))) + self.ui.write(_("user: %s\n") % ctx.user()) self.ui.write(_("date: %s\n") % date) if self.ui.debugflag: @@ -685,8 +685,8 @@ class changeset_printer(object): files): if value: self.ui.write("%-12s %s\n" % (key, " ".join(value))) - elif changes[3] and self.ui.verbose: - self.ui.write(_("files: %s\n") % " ".join(changes[3])) + elif ctx.files() and self.ui.verbose: + self.ui.write(_("files: %s\n") % " ".join(ctx.files())) if copies and self.ui.verbose: copies = ['%s (%s)' % c for c in copies] self.ui.write(_("copies: %s\n") % ' '.join(copies)) @@ -696,7 +696,7 @@ class changeset_printer(object): self.ui.write(_("extra: %s=%s\n") % (key, value.encode('string_escape'))) - description = changes[4].strip() + description = ctx.description().strip() if description: if self.ui.verbose: self.ui.write(_("description:\n")) diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -299,6 +299,7 @@ class filectx(object): def files(self): return self._changectx.files() def description(self): return self._changectx.description() def branch(self): return self._changectx.branch() + def extra(self): return self._changectx.extra() def manifest(self): return self._changectx.manifest() def changectx(self): return self._changectx