From ddd05cb9c99ffb4d2376730e3a9b637ea6dda09e Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Fri, 12 Jun 2026 08:50:28 +0200 Subject: [PATCH 1/6] add function --- mergin/merginproject.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mergin/merginproject.py b/mergin/merginproject.py index 87f3c5f..3788da3 100644 --- a/mergin/merginproject.py +++ b/mergin/merginproject.py @@ -1084,6 +1084,20 @@ def set_tables_to_skip(self, tables): """ self.geodiff.set_tables_to_skip(tables) + def set_tables_to_include(self, tables: List[str]): + """ + Set list of tables to include in geodiff operations. Once defined, only these + tables will be included in the following operations: create changeset, apply + changeset, rebase, get database schema, dump database contents, copy database + between different drivers. + + If empty list is passed, list will be reset. + + :param tables: list of table names to include + :type tables: list[str] + """ + self.geodiff.set_tables_to_include(tables) + def get_geodiff_changes_count(self, diff_rel_path: str): """ Best-effort: return number of changes in the .gpkg diff (int) or None. From 990e5d572212a9b5010830415e4d7de9e9300571 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Fri, 26 Jun 2026 13:43:52 +0200 Subject: [PATCH 2/6] add docstring --- mergin/merginproject.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mergin/merginproject.py b/mergin/merginproject.py index 3788da3..12d798f 100644 --- a/mergin/merginproject.py +++ b/mergin/merginproject.py @@ -1079,6 +1079,9 @@ def set_tables_to_skip(self, tables): If empty list is passed, list will be reset. + This method is mutually exclusive with set_tables_to_include() and error + GeoDiffLibError will be raised if both are set. + :param tables: list of table names to ignore :type tables: list[str] """ @@ -1093,6 +1096,9 @@ def set_tables_to_include(self, tables: List[str]): If empty list is passed, list will be reset. + This method is mutually exclusive with set_tables_to_skip() and error + GeoDiffLibError will be raised if both are set. + :param tables: list of table names to include :type tables: list[str] """ From 5086e4f3443eaff95ce9aad1f4563551316bfa8c Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Fri, 26 Jun 2026 13:44:15 +0200 Subject: [PATCH 3/6] bum required version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9e3ead7..e0ba1c7 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ platforms="any", install_requires=[ "python-dateutil==2.8.2", - "pygeodiff==2.2.0", + "pygeodiff==2.3.0", "pytz==2022.1", "click==8.1.3", ], From fe1193e8f9b4766535a36c68146d58dd25afcb00 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Fri, 26 Jun 2026 13:44:25 +0200 Subject: [PATCH 4/6] bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e0ba1c7..24ee9ad 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name="mergin-client", - version="0.13.1", + version="0.14.0", url="https://github.com/MerginMaps/python-api-client", license="MIT", author="Lutra Consulting Ltd.", From eca7ba49169ea538acd29367e781b8f9b3da73b9 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Fri, 26 Jun 2026 13:44:52 +0200 Subject: [PATCH 5/6] add tests --- mergin/test/test_mergin_project.py | 54 ++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/mergin/test/test_mergin_project.py b/mergin/test/test_mergin_project.py index 6da69e7..a2642e0 100644 --- a/mergin/test/test_mergin_project.py +++ b/mergin/test/test_mergin_project.py @@ -4,6 +4,7 @@ import tempfile import pytest from mergin.merginproject import MerginProject +from pygeodiff import GeoDiffLibError from mergin.common import DeltaChangeType, PullActionType, ClientError from mergin.models import ProjectDeltaChange, ProjectDeltaItemDiff from mergin.client_pull import PullAction @@ -418,3 +419,56 @@ def username(self): assert not mp.geodiff.has_changes(os.path.join(tmp_dir, "live-server.diff")) assert not mp.geodiff.has_changes(os.path.join(tmp_dir, "live-base.diff")) assert mp.geodiff.has_changes(os.path.join(tmp_dir, "live-conflict.diff")) + + +def test_set_tables_to_skip(): + """Tables in set_tables_to_skip are excluded from changeset creation.""" + base = os.path.join(TEST_DATA_DIR, "two_tables.gpkg") + modified = os.path.join(TEST_DATA_DIR, "two_tables_1_A.gpkg") + + with tempfile.TemporaryDirectory() as tmp_dir: + mp = MerginProject(tmp_dir) + diff = os.path.join(tmp_dir, "diff.diff") + + mp.geodiff.create_changeset(base, modified, diff) + assert mp.geodiff.has_changes(diff) + + mp.set_tables_to_skip(["survey"]) + mp.geodiff.create_changeset(base, modified, diff) + assert not mp.geodiff.has_changes(diff) + + mp.set_tables_to_skip([]) + mp.geodiff.create_changeset(base, modified, diff) + assert mp.geodiff.has_changes(diff) + + +def test_set_tables_to_include(): + """Only tables in set_tables_to_include appear in the changeset.""" + # two_tables.gpkg -> two_tables_1_A.gpkg: only survey changes, simple is unchanged + base = os.path.join(TEST_DATA_DIR, "two_tables.gpkg") + modified = os.path.join(TEST_DATA_DIR, "two_tables_1_A.gpkg") + + with tempfile.TemporaryDirectory() as tmp_dir: + mp = MerginProject(tmp_dir) + diff = os.path.join(tmp_dir, "diff.diff") + + mp.set_tables_to_include(["simple"]) + mp.geodiff.create_changeset(base, modified, diff) + assert not mp.geodiff.has_changes(diff) + + mp.set_tables_to_include(["survey"]) + mp.geodiff.create_changeset(base, modified, diff) + assert mp.geodiff.has_changes(diff) + + mp.set_tables_to_include([]) + mp.geodiff.create_changeset(base, modified, diff) + assert mp.geodiff.has_changes(diff) + + +def test_tables_to_skip_and_include_mutually_exclusive(): + """Setting both skip and include lists should raise an error.""" + with tempfile.TemporaryDirectory() as tmp_dir: + mp = MerginProject(tmp_dir) + mp.set_tables_to_skip(["table_a"]) + with pytest.raises(GeoDiffLibError): + mp.set_tables_to_include(["table_b"]) From ef9838efef791e053aee5f1fc889ea5d37f3e25e Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Fri, 26 Jun 2026 13:45:14 +0200 Subject: [PATCH 6/6] remove --- mergin/test/test_mergin_project.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mergin/test/test_mergin_project.py b/mergin/test/test_mergin_project.py index a2642e0..97fe554 100644 --- a/mergin/test/test_mergin_project.py +++ b/mergin/test/test_mergin_project.py @@ -444,7 +444,6 @@ def test_set_tables_to_skip(): def test_set_tables_to_include(): """Only tables in set_tables_to_include appear in the changeset.""" - # two_tables.gpkg -> two_tables_1_A.gpkg: only survey changes, simple is unchanged base = os.path.join(TEST_DATA_DIR, "two_tables.gpkg") modified = os.path.join(TEST_DATA_DIR, "two_tables_1_A.gpkg")