Patchwork [1,of,2] context: add instabilities() method to basefilectx

login
register
mail settings
Submitter Anton Shestakov
Date Nov. 19, 2017, 9:06 a.m.
Message ID <95bfd552561c2bc88284.1511082393@neuro>
Download mbox | patch
Permalink /patch/25644/
State Accepted
Headers show

Comments

Anton Shestakov - Nov. 19, 2017, 9:06 a.m.
# HG changeset patch
# User Anton Shestakov <av6@dwimlabs.net>
# Date 1511068734 -28800
#      Sun Nov 19 13:18:54 2017 +0800
# Node ID 95bfd552561c2bc88284903c2d001df7e2080bfb
# Parent  7dee8249ba0efc42a60c4523fd9593853ec2eb79
# EXP-Topic hgweb-more-info
context: add instabilities() method to basefilectx

This method is now used in webutils.commonentry(), which adds common data items
(commit hash, author, date, etc) for rendering changesets in hgweb. Usually,
commonentry() is given a changectx as ctx; but in views related to files (e.g.
file view, diff, annotate) it's replaced by a filectx, so the latter also needs
to have instabilities() method.
Augie Fackler - Nov. 20, 2017, 10:01 p.m.
On Sun, Nov 19, 2017 at 05:06:33PM +0800, Anton Shestakov wrote:
> # HG changeset patch
> # User Anton Shestakov <av6@dwimlabs.net>
> # Date 1511068734 -28800
> #      Sun Nov 19 13:18:54 2017 +0800
> # Node ID 95bfd552561c2bc88284903c2d001df7e2080bfb
> # Parent  7dee8249ba0efc42a60c4523fd9593853ec2eb79
> # EXP-Topic hgweb-more-info
> context: add instabilities() method to basefilectx

queued, thanks
Yuya Nishihara - Nov. 26, 2017, 2:28 a.m.
On Sun, 19 Nov 2017 17:06:33 +0800, Anton Shestakov wrote:
> # HG changeset patch
> # User Anton Shestakov <av6@dwimlabs.net>
> # Date 1511068734 -28800
> #      Sun Nov 19 13:18:54 2017 +0800
> # Node ID 95bfd552561c2bc88284903c2d001df7e2080bfb
> # Parent  7dee8249ba0efc42a60c4523fd9593853ec2eb79
> # EXP-Topic hgweb-more-info
> context: add instabilities() method to basefilectx

> diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
> --- a/mercurial/hgweb/webutil.py
> +++ b/mercurial/hgweb/webutil.py
> @@ -362,6 +362,7 @@ def commonentry(repo, ctx):
>          'extra': ctx.extra(),
>          'phase': ctx.phasestr(),
>          'obsolete': ctx.obsolete(),
> +        'instabilities': [{"name": i} for i in ctx.instabilities()],
                              ^^^^^^

It's better to call each item an 'instability' for compatibility with the
log template. Can you send a followup?

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -821,6 +821,8 @@  class basefilectx(object):
         return self._changectx.phasestr()
     def obsolete(self):
         return self._changectx.obsolete()
+    def instabilities(self):
+        return self._changectx.instabilities()
     def manifest(self):
         return self._changectx.manifest()
     def changectx(self):
diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -362,6 +362,7 @@  def commonentry(repo, ctx):
         'extra': ctx.extra(),
         'phase': ctx.phasestr(),
         'obsolete': ctx.obsolete(),
+        'instabilities': [{"name": i} for i in ctx.instabilities()],
         'branch': nodebranchnodefault(ctx),
         'inbranch': nodeinbranch(repo, ctx),
         'branches': nodebranchdict(repo, ctx),