Patchwork D1880: blackbox: if --debug is used, also trace ui.debug() calls

login
register
mail settings
Submitter phabricator
Date Jan. 18, 2018, 11:56 a.m.
Message ID <differential-rev-PHID-DREV-wefw7jxgnml43t37qrw6-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26858/
State Superseded
Headers show

Comments

phabricator - Jan. 18, 2018, 11:56 a.m.
joerg.sonnenberger created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1880

AFFECTED FILES
  hgext/blackbox.py
  tests/blackbox-readonly-dispatch.py
  tests/test-blackbox.t

CHANGE DETAILS




To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-devel
phabricator - Jan. 18, 2018, 12:56 p.m.
yuja requested changes to this revision.
yuja added a comment.
This revision now requires changes to proceed.


  I'm 0 on this, but I have no reason against it.

INLINE COMMENTS

> blackbox.py:136
> +            if self.debugflag:
> +                self.log('debug', *msg, **opts)
> +

These arguments can't be passed directly to `.log()`.
`.log()` takes a format string and its parameters, whereas `.debug()`
takes a list of arbitrary strings to print.

Perhaps `**opts` should be dropped.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1880

To: joerg.sonnenberger, #hg-reviewers, yuja
Cc: yuja, mercurial-devel
phabricator - Jan. 18, 2018, 6:35 p.m.
joerg.sonnenberger marked an inline comment as done.
joerg.sonnenberger added inline comments.

INLINE COMMENTS

> yuja wrote in blackbox.py:136
> These arguments can't be passed directly to `.log()`.
> `.log()` takes a format string and its parameters, whereas `.debug()`
> takes a list of arbitrary strings to print.
> 
> Perhaps `**opts` should be dropped.

Fixed, thanks.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1880

To: joerg.sonnenberger, #hg-reviewers, yuja
Cc: yuja, mercurial-devel

Patch

diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t
--- a/tests/test-blackbox.t
+++ b/tests/test-blackbox.t
@@ -193,37 +193,68 @@ 
   > os.rename(".hg/blackbox.log-", ".hg/blackbox.log")\
   > \1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py
   $ $PYTHON $TESTDIR/blackbox-readonly-dispatch.py
-  running: add foo
+  running: --debug add foo
+  warning: cannot write to blackbox.log: Is a directory
+  adding foo
   result: 0
-  running: commit -m commit1 -d 2000-01-01 foo
+  running: --debug commit -m commit1 -d 2000-01-01 foo
+  warning: cannot write to blackbox.log: Is a directory
+  committing files:
+  foo
+  committing manifest
+  committing changelog
+  updating the branch cache
+  committed changeset 0:0e46349438790c460c5c9f7546bfcd39b267bbd2
   result: None
-  running: commit -m commit2 -d 2000-01-02 foo
+  running: --debug commit -m commit2 -d 2000-01-02 foo
+  committing files:
+  foo
+  committing manifest
+  committing changelog
+  updating the branch cache
+  committed changeset 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7
   result: None
-  running: log -r 0
-  changeset:   0:0e4634943879
+  running: --debug log -r 0
+  changeset:   0:0e46349438790c460c5c9f7546bfcd39b267bbd2
+  phase:       draft
+  parent:      -1:0000000000000000000000000000000000000000
+  parent:      -1:0000000000000000000000000000000000000000
+  manifest:    0:9091aa5df980aea60860a2e39c95182e68d1ddec
   user:        test
   date:        Sat Jan 01 00:00:00 2000 +0000
-  summary:     commit1
+  files+:      foo
+  extra:       branch=default
+  description:
+  commit1
+  
   
   result: None
-  running: log -r tip
-  changeset:   1:45589e459b2e
+  running: --debug log -r tip
+  changeset:   1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7
   tag:         tip
+  phase:       draft
+  parent:      0:0e46349438790c460c5c9f7546bfcd39b267bbd2
+  parent:      -1:0000000000000000000000000000000000000000
+  manifest:    1:895aa9b7886f89dd017a6d62524e1f9180b04df9
   user:        test
   date:        Sun Jan 02 00:00:00 2000 +0000
-  summary:     commit2
+  files:       foo
+  extra:       branch=default
+  description:
+  commit2
+  
   
   result: None
   $ hg blackbox
-  1970/01/01 00:00:00 bob @0e46349438790c460c5c9f7546bfcd39b267bbd2 (5000)> commit -m commit2 -d 2000-01-02 foo
+  1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updating the branch cache
   1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updated served branch cache in * seconds (glob)
   1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> wrote served branch cache with 1 labels and 1 nodes
-  1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> commit -m commit2 -d 2000-01-02 foo exited 0 after * seconds (glob)
-  1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r 0
+  1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug commit -m commit2 -d 2000-01-02 foo exited 0 after *.?? seconds (glob)
+  1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r 0
   1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> writing .hg/cache/tags2-visible with 0 tags
-  1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r 0 exited 0 after * seconds (glob)
-  1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip
-  1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip exited 0 after * seconds (glob)
+  1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r 0 exited 0 after *.?? seconds (glob)
+  1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r tip
+  1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r tip exited 0 after *.?? seconds (glob)
   1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox
 
 Test log recursion from dirty status check
diff --git a/tests/blackbox-readonly-dispatch.py b/tests/blackbox-readonly-dispatch.py
--- a/tests/blackbox-readonly-dispatch.py
+++ b/tests/blackbox-readonly-dispatch.py
@@ -18,8 +18,8 @@ 
 f = open('foo', 'wb')
 f.write('foo\n')
 f.close()
-testdispatch("add foo")
-testdispatch("commit -m commit1 -d 2000-01-01 foo")
+testdispatch("--debug add foo")
+testdispatch("--debug commit -m commit1 -d 2000-01-01 foo")
 
 # append to file 'foo' and commit
 f = open('foo', 'ab')
@@ -29,8 +29,8 @@ 
 os.rmdir(".hg/blackbox.log")
 # replace it with the real blackbox.log file
 os.rename(".hg/blackbox.log-", ".hg/blackbox.log")
-testdispatch("commit -m commit2 -d 2000-01-02 foo")
+testdispatch("--debug commit -m commit2 -d 2000-01-02 foo")
 
 # check 88803a69b24 (fancyopts modified command table)
-testdispatch("log -r 0")
-testdispatch("log -r tip")
+testdispatch("--debug log -r 0")
+testdispatch("--debug log -r tip")
diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -130,6 +130,11 @@ 
         def track(self):
             return self.configlist('blackbox', 'track')
 
+        def debug(self, *msg, **opts):
+            super(blackboxui, self).debug(*msg, **opts)
+            if self.debugflag:
+                self.log('debug', *msg, **opts)
+
         def log(self, event, *msg, **opts):
             global lastui
             super(blackboxui, self).log(event, *msg, **opts)