private Tuple<Dictionary<string, line>, List<note_item>> adjust_guids_before_merge(Tuple<Dictionary<string, line>, List<note_item>> merge_from) {
// problem : two different people can enter a note on the same line
// in this case, each will get its own GUID for the line they added teh note on
// we need to merge the two GUIDs, since they literally point to the same line
Dictionary<string,string> merge_to_local_line_id = new Dictionary<string, string>();
foreach (var l in merge_from.Item1) {
var local = lines_.FirstOrDefault(x => x.Value.idx == l.Value.idx);
if ( local.Value != null)
merge_to_local_line_id.Add( l.Key, local.Key);
else
merge_to_local_line_id.Add( l.Key, l.Key);
}
Dictionary<string, line> updated_lines = merge_from.Item1.ToDictionary(x => merge_to_local_line_id[x.Key], x => x.Value);
foreach (var n in merge_from.Item2)
n.line_id = merge_to_local_line_id[n.line_id];
return new Tuple<Dictionary<string, line>, List<note_item>>(updated_lines, merge_from.Item2);
}