Fix time sort mode

Fix topological/time sort mode
Save miss commits on same second until its parents are painted
This commit is contained in:
Alberto Fanjul 2019-05-05 12:11:50 +02:00
parent f689d8b32d
commit 1be2990fea
3 changed files with 58 additions and 7 deletions

View File

@ -231,11 +231,11 @@ namespace GitgHistory
{
if (d_settings.get_boolean("topological-order"))
{
d_commit_list_model.sort_mode |= Ggit.SortMode.TOPOLOGICAL;
d_commit_list_model.sort_mode = Ggit.SortMode.TOPOLOGICAL;
}
else
{
d_commit_list_model.sort_mode &= ~Ggit.SortMode.TOPOLOGICAL;
d_commit_list_model.sort_mode = Ggit.SortMode.TIME | Ggit.SortMode.TOPOLOGICAL;
}
}

View File

@ -138,7 +138,7 @@ namespace Gitg
construct
{
d_lanes = new Lanes();
d_sortmode = Ggit.SortMode.TIME | Ggit.SortMode.TOPOLOGICAL;
d_sortmode = Ggit.SortMode.TOPOLOGICAL | Ggit.SortMode.TIME;
}
public override void dispose()
@ -418,8 +418,10 @@ namespace Gitg
int mylane;
SList<Lane> lanes;
if (d_lanes.next(commit, out lanes, out mylane))
bool finded = d_lanes.next(commit, out lanes, out mylane, true);
if (finded)
{
debug ("finded parent for %s %s\n", commit.get_subject(), commit.get_id().to_string());
commit.update_lanes((owned)lanes, mylane);
lock(d_id_hash)
@ -440,7 +442,48 @@ namespace Gitg
d_ids[d_ids.length++] = commit;
}
else
while (d_lanes.miss_commits.size > 0)
{
finded = false;
var iter = d_lanes.miss_commits.iterator();
while (iter.next())
{
var miss_commit = iter.get();
debug ("trying again %s %s", miss_commit.get_subject(), miss_commit.get_id().to_string());
bool tmp_finded = d_lanes.next(miss_commit, out lanes, out mylane);
if (tmp_finded)
{
finded = true;
debug ("finded parent for miss %s %s\n", miss_commit.get_subject(), miss_commit.get_id().to_string());
iter.remove();
commit = miss_commit;
commit.update_lanes((owned)lanes, mylane);
lock(d_id_hash)
{
d_id_hash.set(id, d_ids.length);
}
if (needs_resize(d_ids, ref size))
{
var l = d_ids.length;
lock(d_ids)
{
d_ids.resize((int)size);
d_ids.length = l;
}
}
d_ids[d_ids.length++] = commit;
}
}
if (!finded)
break;
}
if (!finded)
{
if (needs_resize(d_hidden_ids, ref hidden_size))
{

View File

@ -26,6 +26,7 @@ public class Lanes : Object
public int inactive_collapse { get; set; default = 10; }
public int inactive_gap { get; set; default = 10; }
public bool inactive_enabled { get; set; default = true; }
public Gee.LinkedList<Commit> miss_commits {get; set; }
private SList<weak Commit> d_previous;
private Gee.LinkedList<LaneContainer> d_lanes;
@ -133,6 +134,7 @@ public class Lanes : Object
Gee.HashSet<Ggit.OId>? roots = null)
{
d_lanes = new Gee.LinkedList<LaneContainer>();
miss_commits = new Gee.LinkedList<Commit>();
d_roots = roots;
Color.reset();
@ -155,7 +157,8 @@ public class Lanes : Object
public bool next(Commit next,
out SList<Lane> lanes,
out int nextpos)
out int nextpos,
bool save_miss = false)
{
var myoid = next.get_id();
@ -165,11 +168,16 @@ public class Lanes : Object
expand_lanes(next);
}
debug("commit: %s %s", next.get_subject(), next.get_id().to_string());
LaneContainer? mylane = find_lane_by_oid(myoid, out nextpos);
if (mylane == null && d_roots != null && !d_roots.contains(myoid))
{
lanes = null;
if (save_miss) {
debug ("saving miss %s %s", next.get_id().to_string(), next.get_id().to_string());
miss_commits.add(next);
}
return false;
}