From 9afda4c82fae75a3ce1658d14845e307971e1407 Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Mon, 11 Nov 2024 11:24:27 +1300 Subject: [PATCH] Fix WC session aliasing issue session & state_session are no longer the same function; one calls the other --- kart/working_copy.py | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/kart/working_copy.py b/kart/working_copy.py index 41fd7f9c..9ea2cefe 100644 --- a/kart/working_copy.py +++ b/kart/working_copy.py @@ -668,14 +668,7 @@ def reset( repo_key_filter, ) - # Start a DB session that surrounds both the working copy modifications and the state table modifications - - # if the same DB session can be used for both, otherwise, let _do_reset_datasets handle it. - session_context = ( - self.session - if hasattr(self, "session") and self.session == self.state_session - else contextlib.nullcontext - ) - with session_context(): + with self.state_session() as sess: if ds_inserts or ds_updates or ds_deletes: self._do_reset_datasets( base_datasets=base_datasets, @@ -691,15 +684,12 @@ def reset( quiet=quiet, ) - with self.state_session() as sess: - if not track_changes_as_dirty: - self._update_state_table_tree(sess, target_tree_id) - self._update_state_table_spatial_filter_hash( - sess, self.repo.spatial_filter.hexhash - ) - self._update_state_table_non_checkout_datasets( - sess, non_checkout_datasets - ) + if not track_changes_as_dirty: + self._update_state_table_tree(sess, target_tree_id) + self._update_state_table_spatial_filter_hash( + sess, self.repo.spatial_filter.hexhash + ) + self._update_state_table_non_checkout_datasets(sess, non_checkout_datasets) def _do_reset_datasets( self,