[PATCH STABLE] mq: copy pager attributes back to qrepo.ui

Yuya Nishihara yuya at tcha.org
Sat Oct 21 05:16:50 UTC 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1508560963 -32400
#      Sat Oct 21 13:42:43 2017 +0900
# Branch stable
# Node ID aff8579c731276bed3d2afe416dc4988042e89c9
# Parent  dc05c59e3f1714c4faceb4c1eed66a5afe0ec000
mq: copy pager attributes back to qrepo.ui

If the legacy pager extension is enabled, a pager is started through repo.ui
at dispatch._runcommand(). After that, mqcommand() creates a qrepo with a
fresh repo.baseui, at which point pager information was lost and another pager
would be spawned by the modern pager interface.

This is a minimal workaround for the problem.

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1963,6 +1963,14 @@ class queue(object):
 
     def qrepo(self, create=False):
         ui = self.baseui.copy()
+        # copy back attributes set by ui.pager()
+        if self.ui.pageractive and not ui.pageractive:
+            ui.pageractive = self.ui.pageractive
+            # internal config: ui.formatted
+            ui.setconfig('ui', 'formatted',
+                         self.ui.config('ui', 'formatted'), 'mqpager')
+            ui.setconfig('ui', 'interactive',
+                         self.ui.config('ui', 'interactive'), 'mqpager')
         if create or os.path.isdir(self.join(".hg")):
             return hg.repository(ui, path=self.path, create=create)
 
diff --git a/tests/test-pager-legacy.t b/tests/test-pager-legacy.t
--- a/tests/test-pager-legacy.t
+++ b/tests/test-pager-legacy.t
@@ -194,6 +194,36 @@ Pager works with shell aliases.
   $ hg --config pager.attend-echoa=yes echoa
   paged! 'a\n'
 
+Pager attributes should be copied to mq repo. Otherwise pager would be started
+twice and color mode would be lost.
+
+  $ cat >> $HGRCPATH <<EOF
+  > [extensions]
+  > mq =
+  > EOF
+  $ hg init --mq
+  $ hg qnew foo.patch
+  $ hg qpop
+  popping foo.patch
+  patch queue now empty
+  $ hg ci --mq -m 'commit patches'
+  $ hg log --mq --debug
+  starting pager for command 'extension-via-attend-log'
+  paged! '\x1b[0;33mchangeset:   0:6cc2ded15503e368aaf76b6cc3d12f320c9e3b87\x1b[0m\n'
+  paged! 'tag:         tip\n'
+  paged! 'phase:       draft\n'
+  paged! 'parent:      -1:0000000000000000000000000000000000000000\n'
+  paged! 'parent:      -1:0000000000000000000000000000000000000000\n'
+  paged! 'manifest:    0:4980de1ae1b612014d5bcfa9507da84ce8891daa\n'
+  paged! 'user:        test\n'
+  paged! 'date:        Thu Jan 01 00:00:00 1970 +0000\n'
+  paged! 'files+:      .hgignore foo.patch series\n'
+  paged! 'extra:       branch=default\n'
+  paged! 'description:\n'
+  paged! 'commit patches\n'
+  paged! '\n'
+  paged! '\n'
+
 Pager works with hg aliases including environment variables.
 
   $ cat >> $HGRCPATH <<'EOF'


More information about the Mercurial-devel mailing list