# # patch "roster4.cc" # from [01795c08a0b1ba5a1d3742b44dbb06e5455ffabb] # to [a75fc4f5b6bd0119946f3605d4588aa37d4be915] # # patch "roster4.hh" # from [e7e9d52f55747bdcd7dc9fa745e7c02808fc3712] # to [59f97e54978e976ba93b9afb23f06ab1108d1bab] # ======================================================================== --- roster4.cc 01795c08a0b1ba5a1d3742b44dbb06e5455ffabb +++ roster4.cc a75fc4f5b6bd0119946f3605d4588aa37d4be915 @@ -9,6 +9,7 @@ #include #include #include +#include #include "app_state.hh" #include "basic_io.hh" @@ -34,8 +35,17 @@ /////////////////////////////////////////////////////////////////// +void +dump(full_attr_map_t const & val, std::string & out) +{ + std::ostringstream oss; + for (full_attr_map_t::const_iterator i = val.begin(); i != val.end(); ++i) + oss << "attr key: '" << i->first << "'\n" + << " status: " << (i->second.first ? "live" : "dead") << "\n" + << " value: '" << i->second.second << "'\n"; + out = oss.str(); +} -/////////////////////////////////////////////////////////////////// namespace { @@ -173,7 +183,33 @@ return f; } +void +dump(node_t const & n, std::string & out) +{ + std::ostringstream oss; + oss << "address: " << n << " (uses: " << n.use_count() << ")\n" + << "self: " << n->self << "\n" + << "parent: " << n->parent << "\n" + << "name: " << n->name << "\n"; + std::string attr_map_s; + dump(n->attrs, attr_map_s); + oss << "attrs:\n" << attr_map_s; + oss << "type: "; + if (is_file_t(n)) + oss << "file\n" + << "content: " << downcast_to_file_t(n)->content << "\n"; + else + { + oss << "dir\n"; + dir_map const & c = downcast_to_dir_t(n)->children; + oss << "children: " << c.size() << "\n"; + for (dir_map::const_iterator i = c.begin(); i != c.end(); ++i) + oss << " " << i->first << " -> " << i->second << "\n"; + } + out = oss.str(); +} + static inline void dirname_basename(split_path const & sp, split_path & dirname, path_component & basename) @@ -581,6 +617,22 @@ i->second = val; } +void +dump(roster_t const & val, std::string & out) +{ + std::ostringstream oss; + oss << "Root node: " << val.root_dir->self << "\n" + << " at " << val.root_dir << ", uses: " << val.root_dir.use_count() << "\n"; + for (node_map::const_iterator i = val.nodes.begin(); i != val.nodes.end(); ++i) + { + oss << "Node " << i->first << "\n"; + std::string node_s; + dump(i->second, node_s); + oss << "\n" + << node_s; + } + out = oss.str(); +} marking_t::marking_t() { @@ -2091,7 +2143,9 @@ } // now do it MM(c); + MM(r); roster_t before = r; + MM(before); editable_roster_base e = editable_roster_base(r, nis); c.apply_to(e); cset derived; ======================================================================== --- roster4.hh e7e9d52f55747bdcd7dc9fa745e7c02808fc3712 +++ roster4.hh 59f97e54978e976ba93b9afb23f06ab1108d1bab @@ -39,7 +39,9 @@ typedef std::map dir_map; typedef std::map node_map; +void dump(full_attr_map_t const & val, std::string & out); + struct node { node(); @@ -90,7 +92,6 @@ return static_cast(d); } - inline bool is_file_t(node_t n) { @@ -116,7 +117,9 @@ return f; } +void dump(node_t const & n, std::string & out); + struct marking_t { revision_id birth_revision; @@ -177,8 +180,8 @@ void check_sane(marking_map const & marks) const; void print_to(basic_io::printer & pr, - marking_map const & mm, - bool print_local_parts) const; + marking_map const & mm, + bool print_local_parts) const; void parse_from(basic_io::parser & pa, marking_map & mm); @@ -187,8 +190,10 @@ void check_finite_depth() const; dir_t root_dir; node_map nodes; + friend void dump(roster_t const & val, std::string & out); }; +void dump(roster_t const & val, std::string & out); struct app_state; struct revision_set;