[meld] dirdiff: Reduce useless display of newer emblem and fix multiple newest
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] dirdiff: Reduce useless display of newer emblem and fix multiple newest
- Date: Fri, 23 Dec 2016 21:33:01 +0000 (UTC)
commit bb4fdc0a333b9130eedb8a272984d735090de914
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Dec 24 07:27:27 2016 +1000
dirdiff: Reduce useless display of newer emblem and fix multiple newest
Prior to this commit, we would always display a small star to indicate
when the file/folder in a column was the newest in the comparison. This
mostly makes sense for e.g., modified files, but makes no sense in a
couple of scenarios:
* We'd show this when there was only one file in the comparison, for
example when we were in a two-way comparison and the file was
missing on the other side. Clearly this is pointless, since that was
already marked as new, so there's no additional information.
* We'd show the star on the first column whenever both columns had the
same mtime, which is very misleading.
This handles both of these cases, and also handles three-way
comparisons correctly, so that if two of the three columns have the
same mtime, we'll actually show that *both* of those are newer than the
other.
meld/dirdiff.py | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index db53951..12730a5 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -1300,11 +1300,17 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
sizes = [s.st_size if s else 0 for s in stats]
perms = [s.st_mode if s else 0 for s in stats]
- # find the newest file, checking also that they differ
mod_times = [s.st_mtime if s else 0 for s in stats]
- newest_index = mod_times.index( max(mod_times) )
- if mod_times.count( max(mod_times) ) == len(mod_times):
- newest_index = -1 # all same
+ existing_times = [s.st_mtime for s in stats if s]
+ newest_time = max(existing_times)
+ if existing_times.count(newest_time) == len(existing_times):
+ # If all actually-present files have the same mtime, don't
+ # pretend that any are "newer", and do the same if e.g.,
+ # there's only one file.
+ newest = set()
+ else:
+ newest = {i for i, t in enumerate(mod_times) if t == newest_time}
+
all_present = 0 not in mod_times
if all_present:
all_same = self.file_compare(files, regexes)
@@ -1336,9 +1342,9 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
# Different and DodgyDifferent
else:
self.model.set_path_state(it, j, tree.STATE_MODIFIED, isdir)
- self.model.set_value(it,
- self.model.column_index(COL_EMBLEM, j),
- j == newest_index and "emblem-meld-newer-file" or None)
+ emblem = "emblem-meld-newer-file" if j in newest else None
+ self.model.set_value(
+ it, self.model.column_index(COL_EMBLEM, j), emblem)
one_isdir[j] = isdir
# A DateCellRenderer would be nicer, but potentially very slow
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]