# # patch "cset.cc" # from [49d2b2d080bd074f229d4c15e34ffa86303b0234] # to [bdaafbc498145dd7d5a8a4855effe171c90a4904] # # patch "cset.hh" # from [6a2ab00c024533f530ae9aa3106fc84a47fb06e0] # to [b4dfecf288821a2e5b7ccae2b97328af59b17da9] # # patch "roster2.cc" # from [ecee7d65972ac00a227890f8c2bfa90f6bc19eed] # to [fb9af375574aab7c53b7681ece5a931bba286257] # ======================================================================== --- cset.cc 49d2b2d080bd074f229d4c15e34ffa86303b0234 +++ cset.cc bdaafbc498145dd7d5a8a4855effe171c90a4904 @@ -20,7 +20,7 @@ {} detach(split_path const & src, - split_path const & dst) + split_path const & dst) : src_path(src), reattach(true), dst_path(dst) @@ -41,7 +41,7 @@ attach { attach(node_id n, - split_path const & p) + split_path const & p) : node(n), path(p) {} @@ -51,19 +51,15 @@ bool operator<(struct attach const & other) const { // We sort attach operations top-down by path + // SPEEDUP?: simply sort by path.size() rather than full lexicographical + // comparison? return path < other.path; } }; - -void -cset::apply_to(editable_tree & t) +static void +check_normalized(cset const & cs) { - set detaches; - set attaches; - set drops; - - // FIXME -- normalize: // // add_file address@hidden + apply_delta id1->id2 @@ -71,7 +67,50 @@ // // possibly more? + // no file appears in both the "added" list and the "patched" list + { + set::const_iterator a = cs.files_added.begin(); + map >::const_iterator + d = cs.deltas_applied.begin(); + while (a != cs.files_added.end() && d != cs.deltas_applied.end()) + { + if (a->first < d->first) + ++a; + else if (d->first < a->first) + ++d; + else + I(false); + } + } + + // no file+attr pair appears in both the "set" list and the "cleared" list + { + set >::const_iterator c = cs.attrs_cleared.begin(); + map, attr_value>::const_iterator + s = cs.attrs_set.begin(); + while (c != cs.attrs_cleared.end() && s != cs.attrs_set.end()) + { + if (*c < s->first) + ++c; + else if (s->first < *c) + ++s; + else + I(false); + } + } +} +void +cset::apply_to(editable_tree & t) +{ + // SPEEDUP?: use vectors and sort them once, instead of maintaining sorted + // sets? + set detaches; + set attaches; + set drops; + + check_normalized(*this); + // Decompose all additions into a set of pending attachments to be // executed top-down. We might as well do this first, to be sure we // can form the new nodes -- such as in a filesystem -- before we do @@ -108,9 +147,9 @@ { node_id n = t.detach_node(i->src_path); if (i->reattach) - attaches.insert(attach(n, i->dst_path)); + attaches.insert(attach(n, i->dst_path)); else - drops.insert(n); + drops.insert(n); } @@ -131,7 +170,7 @@ i != deltas_applied.end(); ++i) t.apply_delta(i->first, i->second.first, i->second.second); - for (map::const_iterator i = attrs_cleared.begin(); + for (set >::const_iterator i = attrs_cleared.begin(); i != attrs_cleared.end(); ++i) t.clear_attr(i->first, i->second); ======================================================================== --- cset.hh 6a2ab00c024533f530ae9aa3106fc84a47fb06e0 +++ cset.hh b4dfecf288821a2e5b7ccae2b97328af59b17da9 @@ -41,13 +41,13 @@ // Modifying elements in-place virtual void apply_delta(split_path const & pth, - file_id const & old_id, - file_id const & new_new) = 0; + file_id const & old_id, + file_id const & new_new) = 0; virtual void clear_attr(split_path const & pth, - attr_name const & name) = 0; + attr_name const & name) = 0; virtual void set_attr(split_path const & pth, - attr_name const & name, - attr_val const & val) = 0; + attr_name const & name, + attr_val const & val) = 0; virtual ~editable_tree() {} }; @@ -71,7 +71,7 @@ std::map > deltas_applied; // Attribute changes. - std::map attrs_cleared; + std::set > attrs_cleared; std::map, attr_val> attrs_set; void apply_to(editable_tree & t); ======================================================================== --- roster2.cc ecee7d65972ac00a227890f8c2bfa90f6bc19eed +++ roster2.cc fb9af375574aab7c53b7681ece5a931bba286257 @@ -472,5 +472,8 @@ // get uncommon ancestors // scan over new and touched pieces of new roster to generate markings + // NB: merge parents cannot have null ids + // note: remove old_manifest lines, pure redundancy + // otherwise: I(false) }