[PATCH] cmdutil: minor refactoring of changeset_printer._show

Adrian Buehlmann adrian at cadifra.com
Sat Oct 24 12:07:06 CDT 2009


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1256403700 -7200
# Node ID 8a708cbba6369b5df01d8790b7ff4230af630ff4
# Parent  16698d87ad20bba4118d45561800633d3451962b
cmdutil: minor refactoring of changeset_printer._show

- use ctx.branch() instead of directly accessing the extra field "branch"
- move definitions of locals ('extra' and 'branch') down to where they
  are used

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -653,8 +653,6 @@ class changeset_printer(object):
 
         log = self.repo.changelog
         date = util.datestr(ctx.date())
-        extra = ctx.extra()
-        branch = extra.get("branch")
 
         hexfunc = self.ui.debugflag and hex or short
 
@@ -663,6 +661,7 @@ class changeset_printer(object):
 
         self.ui.write(_("changeset:   %d:%s\n") % (rev, hexfunc(changenode)))
 
+        branch = ctx.branch()
         # don't show the default branch name
         if branch != 'default':
             branch = encoding.tolocal(branch)
@@ -691,6 +690,7 @@ class changeset_printer(object):
             copies = ['%s (%s)' % c for c in copies]
             self.ui.write(_("copies:      %s\n") % ' '.join(copies))
 
+        extra = ctx.extra()
         if extra and self.ui.debugflag:
             for key, value in sorted(extra.items()):
                 self.ui.write(_("extra:       %s=%s\n")


More information about the Mercurial-devel mailing list