[PATCH 1 of 7] blackbox: log working directory version

Yuya Nishihara yuya at tcha.org
Wed Feb 3 10:02:49 EST 2016


On Mon, 01 Feb 2016 22:14:10 -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless at mozdev.org>
> # Date 1454011674 0
> #      Thu Jan 28 20:07:54 2016 +0000
> # Node ID 13667e60c651f6db247234ec46fd040e002420fc
> # Parent  8e79ad2da8a69735488402fd018dd82bc1eb9309
> blackbox: log working directory version
> 
> This includes a `+` for dirty repositories.
> 
> diff --git a/hgext/blackbox.py b/hgext/blackbox.py
> --- a/hgext/blackbox.py
> +++ b/hgext/blackbox.py
> @@ -42,6 +42,13 @@
>  testedwith = 'internal'
>  lastblackbox = None
>  
> +def hexfn(ui, node):
> +    fm = ui.formatter('blackbox', {})
> +    if node is None:
> +        return None
> +    else:
> +        return fm.hexfunc(node)

It seems awkward to create a formatter just to select hex/short func.

>  def wrapui(ui):
>      class blackboxui(ui.__class__):
>          @util.propertycache
> @@ -109,16 +116,26 @@
>                  user = util.getuser()
>                  pid = str(os.getpid())
>                  formattedmsg = msg[0] % msg[1:]
> +                rev = '(unknown)'
> +                changed = ''
> +                if util.safehasattr(self, '_bbopenerrepo'):
> +                    ctx = self._bbopenerrepo['.']

Is it legit to do repository operation in blackboxui.log() ?
I think log() function shouldn't change internal state (e.g. caches attached
to repo object).

> +                    rev = hexfn(self, ctx.node())
> +                    if (any(self._bbopenerrepo.status())
> +                        or any(ctx.sub(s).dirty() for s in ctx.substate)):
> +                        changed = '+'

Because 'ctx' isn't a workingctx, ctx.sub(s).dirty() won't do the right thing.

> -                lastblackbox = blackbox
> +                if not lastblackbox or util.safehasattr(self, '_bbopenerrepo'):
> +                    lastblackbox = blackbox

Not sure why you've changed it.


More information about the Mercurial-devel mailing list