diff --git a/debian/changelog b/debian/changelog index effd8b5..e2463a3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,9 @@ patroni (2.0.0-1) UNRELEASED; urgency=medium [ Michael Banck ] * debian/README.Debian: Add note about rewind user. * debian/patches/requirements_setuptools.patch: Refreshed. + * debian/patches/allow_custom_pager_support_in_patronictl_edit-config.patch: + New patch, adds custom pager support for patronictl, taken from upstream + commit e27ff480. -- Debian PostgreSQL Maintainers Wed, 26 Aug 2020 15:34:34 +0200 diff --git a/debian/patches/allow_custom_pager_support_in_patronictl_edit-config.patch b/debian/patches/allow_custom_pager_support_in_patronictl_edit-config.patch new file mode 100644 index 0000000..1c99e21 --- /dev/null +++ b/debian/patches/allow_custom_pager_support_in_patronictl_edit-config.patch @@ -0,0 +1,85 @@ +From e27ff480d0ea827a1b84d995c90ca78690a26d20 Mon Sep 17 00:00:00 2001 +From: Pavlo Golub +Date: Wed, 16 Sep 2020 15:21:52 +0200 +Subject: [PATCH] Allow custom pager support in patronictl edit-config (#1696) + +Fixes #1695 +--- + patroni/ctl.py | 14 ++++++++++++-- + requirements.txt | 2 +- + tests/test_ctl.py | 5 ++++- + 3 files changed, 17 insertions(+), 4 deletions(-) + +diff --git a/patroni/ctl.py b/patroni/ctl.py +index 3d900dfd..30070545 100644 +--- a/patroni/ctl.py ++++ b/patroni/ctl.py +@@ -7,7 +7,6 @@ + import datetime + import dateutil.parser + import dateutil.tz +-import cdiff + import copy + import difflib + import io +@@ -34,6 +33,10 @@ + from patroni.version import __version__ + from prettytable import ALL, FRAME, PrettyTable + from six.moves.urllib_parse import urlparse ++try: ++ from ydiff import markup_to_pager, PatchStream ++except ImportError: # pragma: no cover ++ from cdiff import markup_to_pager, PatchStream + + CONFIG_DIR_PATH = click.get_app_dir('patroni') + CONFIG_FILE_PATH = os.path.join(CONFIG_DIR_PATH, 'patronictl.yaml') +@@ -1086,7 +1089,14 @@ class opts: + side_by_side = False + width = 80 + tab_width = 8 +- cdiff.markup_to_pager(cdiff.PatchStream(buf), opts) ++ wrap = True ++ if find_executable('less'): ++ pager = None ++ else: ++ pager = 'more.com' if sys.platform == 'win32' else 'more' ++ pager_options = None ++ ++ markup_to_pager(PatchStream(buf), opts) + else: + for line in unified_diff: + click.echo(line.rstrip('\n')) +diff --git a/requirements.txt b/requirements.txt +index 5c30d3a0..8e568c9f 100644 +--- a/requirements.txt ++++ b/requirements.txt +@@ -10,5 +10,5 @@ prettytable>=0.7 + python-dateutil + pysyncobj>=0.3.5 + psutil>=2.0.0 +-cdiff ++ydiff>=1.2.0 + setuptools +diff --git a/tests/test_ctl.py b/tests/test_ctl.py +index e63da17d..d93c5d1f 100644 +--- a/tests/test_ctl.py ++++ b/tests/test_ctl.py +@@ -561,7 +561,7 @@ def test_apply_config_changes(self): + self.assertRaises(PatroniCtlException, apply_config_changes, before_editing, config, ['a']) + + @patch('sys.stdout.isatty', return_value=False) +- @patch('cdiff.markup_to_pager') ++ @patch('patroni.ctl.markup_to_pager') + def test_show_diff(self, mock_markup_to_pager, mock_isatty): + show_diff("foo:\n bar: 1\n", "foo:\n bar: 2\n") + mock_markup_to_pager.assert_not_called() +@@ -570,6 +570,9 @@ def test_show_diff(self, mock_markup_to_pager, mock_isatty): + show_diff("foo:\n bar: 1\n", "foo:\n bar: 2\n") + mock_markup_to_pager.assert_called_once() + ++ with patch('patroni.ctl.find_executable', Mock(return_value=None)): ++ show_diff("foo:\n bar: 1\n", "foo:\n bar: 2\n") ++ + # Test that unicode handling doesn't fail with an exception + show_diff(b"foo:\n bar: \xc3\xb6\xc3\xb6\n".decode('utf-8'), + b"foo:\n bar: \xc3\xbc\xc3\xbc\n".decode('utf-8')) diff --git a/debian/patches/series b/debian/patches/series index cbf14f8..c00c257 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -2,3 +2,4 @@ startup_scripts.patch acceptance_tests_system_patroni.patch requirements_setuptools.patch offline_intersphinx.patch +allow_custom_pager_support_in_patronictl_edit-config.patch