[PATCH] blackbox: only show new heads on incoming

Durham Goode durham at fb.com
Wed Feb 13 13:23:20 CST 2013


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1360782421 28800
#      Wed Feb 13 11:07:01 2013 -0800
# Node ID 20a00d8c36a1e4209454b42468205df439b1ea8c
# Parent  111fef1dae2c3f5feecb3fd3fe075c093f4f993a
blackbox: only show new heads on incoming

The blackbox was logging every head after every incoming group.
Now we only log the heads that have changed.

Added a test.  Moved the hooks test to the bottom of the file since
the hooks interfer with the tests after it.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2400,11 +2400,11 @@
                         self.hook("incoming", node=hex(n), source=srctype,
                                   url=url)
 
-                    heads = self.heads()
+                    newheads = [h for h in self.heads() if h not in oldheads]
                     self.ui.log("incoming",
                                 _("%s incoming changes - new heads: %s\n"),
                                 len(added),
-                                ', '.join([hex(c[:6]) for c in heads]))
+                                ', '.join([hex(c[:6]) for c in newheads]))
                 self._afterlock(runhooks)
 
         finally:
diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t
--- a/tests/test-blackbox.t
+++ b/tests/test-blackbox.t
@@ -28,6 +28,38 @@
   1970/01/01 00:00:00 bob> add a
   1970/01/01 00:00:00 bob> add exited 0 after * seconds (glob)
 
+incoming change tracking
+
+create two heads to verify that we only see one change in the log later
+  $ hg commit -ma
+  $ hg up null
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo b > b
+  $ hg commit -Amb
+  adding b
+  created new head
+
+clone, commit, pull
+  $ hg clone . ../blackboxtest2
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo c > c
+  $ hg commit -Amc
+  adding c
+  $ cd ../blackboxtest2
+  $ hg pull
+  pulling from $TESTTMP/blackboxtest
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  (run 'hg update' to get a working copy)
+  $ hg blackbox -l 3
+  1970/01/01 00:00:00 bob> pull
+  1970/01/01 00:00:00 bob> 1 incoming changes - new heads: d02f48003e62 (glob)
+  1970/01/01 00:00:00 bob> pull exited None after * seconds (glob)
+
 extension and python hooks - use the eol extension for a pythonhook
 
   $ echo '[extensions]' >> .hg/hgrc
@@ -36,32 +68,12 @@
   $ echo 'update = echo hooked' >> .hg/hgrc
   $ hg update
   hooked
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg blackbox -l 4
   1970/01/01 00:00:00 bob> update
   1970/01/01 00:00:00 bob> pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob)
   1970/01/01 00:00:00 bob> exthook-update: echo hooked finished in * seconds (glob)
   1970/01/01 00:00:00 bob> update exited False after * seconds (glob)
 
-incoming change tracking
-
-  $ hg clone . ../blackboxtest2
-  updating to branch default
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg commit -ma
-  $ cd ../blackboxtest2
-  $ hg pull
-  pulling from $TESTTMP/blackboxtest
-  requesting all changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 1 changes to 1 files
-  (run 'hg update' to get a working copy)
-  $ hg blackbox -l 3
-  1970/01/01 00:00:00 bob> pull
-  1970/01/01 00:00:00 bob> 1 incoming changes - new heads: cb9a9f314b8b (glob)
-  1970/01/01 00:00:00 bob> pull exited None after * seconds (glob)
-
 cleanup
   $ cd ..


More information about the Mercurial-devel mailing list