Skip to content

refactor: remove dead code and pass-through overrides in archive tree dialogs - #2632

Merged
m3nu merged 1 commit into
masterfrom
refactor/2609-archive-tree-dead-code
Nov 15, 2026
Merged

m3nu merged 1 commit into
masterfrom
refactor/2609-archive-tree-dead-code

Conversation

@m3nu

@m3nu m3nu commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Description

Removes dead code and pass-through overrides from the diff and extract tree models. Behaviour is meant to be unchanged.

  • FileTreeModel.data, flags and headerData only called super(). Removed.
  • DiffTree and ExtractTree overrode _make_filesystemitem and _merge_data only to call super() and log a misleading "Overriding" message. Removed, together with the then-unused logger in both dialog modules and the same two pass-throughs in the test's TreeModelImp.
  • FileTreeSortProxyModel.sorted was never emitted. Removed the signal, both sorted.connect(...) lines and both slot_sorted methods.
  • ChangeType.__ge__, __gt__ and __le__ were unused, and __ge__ recursed infinitely. Removed; sorting only uses __lt__.
  • FileSystemItem.addChildren had no callers. Removed.
  • ExtractTree._flat_filter now returns False. The extract dialog has no flat mode, but every item was still bisected into the flat list while the archive listing was loaded.
  • The first-column name logic was identical in DiffTree.data and ExtractTree.data. It moves to FileTreeModel.display_name(). FileTreeSortProxyModel.extract_path is left alone: it sorts by the first path segment in simplified mode on purpose.

The only behaviour difference: an ExtractTree put into flat mode by code would now show no rows. Nothing does that, and ExtractDialog.change_display_mode raises for anything but the two tree modes.

Related Issue

Closes #2609

The issue suggests holding the extract.py part back until #2598 is resolved. This PR does all of it in one go, because the sorted signal cannot be removed without also removing the connect in ExtractDialog.__init__. #2598 and #2593 touch nearby lines in extract.py and will need a small rebase after this.

Motivation and Context

See the issue. Left out, as the issue asks: addItem / removeItem / indexPath (used by tests), a shared dialog base class, and sharing _process_child or ParseThread.

How Has This Been Tested?

On macOS with Borg 1.4.3 (nox default).

  • New tests/unit/test_diff.py::test_diff_tree_display_name checks the first-column names of a DiffTree in tree, simplified and flat mode. Breaking any of the four branches of display_name makes it fail.
  • tests/unit/test_treemodel.py, test_diff.py, test_extract.py, test_borg_argv.py and test_archives.py pass.
  • Full unit suite: 686 passed, 8 skipped, 1 deselected (test_keyring_darwin.py::test_keyring_non_ascii_repo, which writes to the real login keychain).
  • Before/after comparison of data (12 roles), flags and headerData for every cell of the diff and extract models and their sort proxies, in every display mode, column, sort order and folders-on-top setting: identical apart from the flat-mode ExtractTree case above.
  • Both dialogs were built with fixture data on base and on this branch and driven from a script: switching display modes, sorting every column both ways with a row selected, folders-on-top, expand/collapse, context menu, copy. No exceptions, and selection, menu entries and clipboard text matched.

Not tested: real mouse and keyboard use of the dialogs, Linux, and other Borg versions. Integration tests were not run locally.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Refactoring only.

Checklist:

  • I have read the CONTRIBUTING guide.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.

… dialogs

Closes #2609. Behaviour-preserving cleanup of the diff and extract tree models:

- FileTreeModel.data, flags and headerData, which only called super()
- the _make_filesystemitem/_merge_data pass-throughs in DiffTree, ExtractTree
  and the test TreeModelImp, plus the now-unused logger in both dialogs
- the never-emitted FileTreeSortProxyModel.sorted signal, both connects and
  both slot_sorted methods
- ChangeType.__ge__ (infinitely recursive), __gt__ and __le__; only __lt__ is used
- the unused FileSystemItem.addChildren
- ExtractTree._flat_filter now returns False: the extract dialog has no flat
  mode, so nothing needs to go into _flattened
- the duplicated first-column name logic moves to FileTreeModel.display_name

Adds a test for the DiffTree first-column name in each display mode.
@m3nu
m3nu merged commit 7c42d9c into master Nov 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove dead code and pass-through overrides in archive tree dialogs

1 participant