Patchwork [4,of,6,V2] blackbox: log incoming changes via ui.log()

login
register
mail settings
Submitter Durham Goode
Date Feb. 12, 2013, 11:12 p.m.
Message ID <73e79367c0519b8552b5.1360710776@dev350.prn1.facebook.com>
Download mbox | patch
Permalink /patch/974/
State Accepted
Commit b2b4ddc55caad31898a328ba1c26d10b84f5d73e
Headers show

Comments

Durham Goode - Feb. 12, 2013, 11:12 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1360429488 28800
#      Sat Feb 09 09:04:48 2013 -0800
# Node ID 73e79367c0519b8552b5a4d6ccfdccf9a4db926a
# Parent  0ad8fad9d10c58548d6472a0787dd53a5a681383
blackbox: log incoming changes via ui.log()

Logs incoming changes to a repo to ui.log(). Includes the number of changes
and the hashes of the heads after the new changes.

Example log line:
2013/02/09 08:35:19 durham> 1 incoming changes - new heads: cb9a9f314b8b

Currently the blackbox logs the unix user that is performing the push/pull.
It would be nice to log the http authorized user as well so it works with
hgweb, but that's outside the scope of this commit.
Bryan O'Sullivan - Feb. 12, 2013, 11:39 p.m.
On Tue, Feb 12, 2013 at 3:12 PM, Durham Goode <durham@fb.com> wrote:

> Logs incoming changes to a repo to ui.log(). Includes the number of changes
> and the hashes of the heads after the new changes.
>

I'm applying this, but the log message is a bit misleading. It says "new
heads", when in fact it prints all the heads, new or not.

If you could filter the list of heads so that it does not include heads
that were already present, that would be a good followup patch.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2399,6 +2399,10 @@ 
                     for n in added:
                         self.hook("incoming", node=hex(n), source=srctype,
                                   url=url)
+
+                    heads = self.heads()
+                    self.ui.log("incoming", _("%s incoming changes - new heads: %s\n"),
+                        len(added), ', '.join([hex(c[:6]) for c in heads]))
                 self._afterlock(runhooks)
 
         finally: