# # # patch "ChangeLog" # from [81e3045140bcbf832f6fe43481c287b7343f50a8] # to [effebb6d6ea8613ca6a0306794ceaf91df89128a] # # patch "annotate.cc" # from [5f284a607f1ef3dd5a7e192a58c396ce135ae9ff] # to [f77b679344341a4af199df9b59efd49b4676a6af] # # patch "app_state.cc" # from [6a8be1d3051e8e84464730d9d4f60cc9abca098d] # to [55a92b8e0df6ce29b219a3efef760983fa57c9ae] # # patch "automate.cc" # from [8aa16555b3ed2bbd87bbdb395a2d23a790803f19] # to [7d53f42255a88e41a2b1bd27c85aff62ecad823d] # # patch "basic_io.cc" # from [5c8f164d4a3f4829497c834164cb09ac6341467c] # to [0cd7c3eb2d37b603a49cab9959f582bcc4fb661f] # # patch "cert.cc" # from [90434ca979245b8d440c3daead3d8ad5120e27ee] # to [d568dcf9cbf42901fbc3aec941fb6111004a74e4] # # patch "charset.cc" # from [e954d3206a9df54b32bea7aba29d723fbad74f14] # to [c958f957b5deca18a5803c512ae5cf58d08b5fb1] # # patch "cmd_automate.cc" # from [d973f6704cc5cf5a777b8e4f5bdd60ee10048b7c] # to [9888db8b3c4b072092f933a65973fa42e94f7980] # # patch "cmd_db.cc" # from [cef42bd1ec6ec18b7e37bfbd70d1d9decee2d679] # to [7403b1a1bb54a12e01dee5fcbbc3db7aaf8ba557] # # patch "cmd_diff_log.cc" # from [31fe8c5d41bd88bd58dae13ad2b21a8839b5a415] # to [6b49be84ff5e47f22c1942927ea41ab7c24da386] # # patch "cmd_list.cc" # from [5fcd71a963f52bf864f3a8f392c8d9ae328ac953] # to [7647566d20b4a6c7c435b01f92ea90838c12646c] # # patch "cmd_merging.cc" # from [8cb9a727c46da071534f510458de386f45b2c092] # to [14dbf8776d68cf092e76c4d7479afaafd24e4705] # # patch "cmd_netsync.cc" # from [431b5bb6daff4f8d8992eee7ff14a21512895b81] # to [1085c92a4b4e60e11c02378427e0cd2c4e844acd] # # patch "cmd_packet.cc" # from [26b3d187c3a139599b7c50ba80c29f81c382dfdd] # to [0d127531d08a403249ba6fea64f09ee1fd0546e3] # # patch "cmd_ws_commit.cc" # from [130ebf460f4770ca6b39dd7c5d2b8dbf39405656] # to [159a7abbffa9e3992f5a3dba2af148de388e1f53] # # patch "commands.cc" # from [a02d61685a3807368a2e1ec1fed79ea5f342ea79] # to [9eb8b9fe197b66baa555579ff90b5e1ed9f9c8dd] # # patch "constants.cc" # from [45406dd40ffed1993ee987120843b62ef9d3b8ec] # to [b175c8ae9c808089d3e9f7216896be26714703db] # # patch "crypto_tests.cc" # from [6e7f56e97edd513e405a24beb2df684d0bfab1b4] # to [5f2ad6110bb7f9a10978ede2c860ad44b24ffed0] # # patch "cset.cc" # from [17cc4461f4e98e06986d4543b0952be1272ef3e9] # to [bf3abceb49091cfed0d14d02c1188d14378b8f6e] # # patch "database.cc" # from [e185a4b7db7def9d9c5ddb0b1bc9f883d623220b] # to [0d25c2fa019f20eb0b7299f2b569a4091571aed1] # # patch "database_check.cc" # from [91784581512b6a22dba4959fd46076f8ac2d18b6] # to [1354e4948560a3e9197df485a0d6d4208c7d442c] # # patch "diff_patch.cc" # from [c538374230aa5c4eb9c455418cfa55e443af7244] # to [830fa80815a651ce2a0d371aa7ee82ab78410845] # # patch "enumerator.cc" # from [43edc729be97fabc35880f79fbea7640d109bea0] # to [e2ebd144f9f66f1dab7a5324c62e2f7d73eb4646] # # patch "epoch.cc" # from [54bd9b44a5daae23e9b188fec591acf6c79bcf90] # to [b150f9d678d4fba5c2b35c4932a1a04a7c4564c0] # # patch "file_io.cc" # from [7fc3a9cac7cb770a2a4fa826d3a23797cda1242e] # to [758cd915fad8ada25a51dbce3d0565ed68de0895] # # patch "globish.cc" # from [93e5d9dfe7630bf765164f90363c7d30cc9e4e01] # to [409df5d1f8ff0ad46a144ed6f1344418185d54dc] # # patch "hmac.cc" # from [01430adfa6339a539db4327741755a05191bab7b] # to [3884bf3dd20a12ec2023bc4f5fb6b60eaca69fd6] # # patch "inodeprint.cc" # from [49cfddcee6a39755d3d2f8d6c2bc7fb49c5a556d] # to [62b091111b84a22f6de804b3c9d37716e7a06169] # # patch "key_store.cc" # from [7a33f02a482db43ad119b210848f3fdb9a306ba0] # to [dcdebf60e129b121b78cc0f2c53e3c7a19cf69a9] # # patch "keys.cc" # from [ab0e49cae3664e3aa8f52c652e0825dea72de281] # to [bfdcb803f58119ab0c399b553bd69e35fc6e47ce] # # patch "lcs.cc" # from [fd29f8174a6718842724caece25b5ea753da1a04] # to [6c1c76404a788927308bff3b8f52d52f8ae1c12a] # # patch "legacy.cc" # from [56eba9490503059bb62f34ca4d04007d3b56bbd5] # to [cb7eb7d67ccf5f3b3d762c3889a90f1e17509222] # # patch "lua.cc" # from [8412d7a38d765381e449c100f085a2dbdca3ae63] # to [06e4a9aeca73e87a2617ff8df2d674646bf2cb8e] # # patch "lua_hooks.cc" # from [2c8a4626208b7b0128a96da8ea532f7d3fce0e85] # to [348229d0b87e5aad59d452c8dea3f26ca9481031] # # patch "main.cc" # from [0981328eff2cd408bb7d9b13208b16243feec637] # to [1b50bf9eefcb967254582b38a5a886f8ad09eea6] # # patch "merge.cc" # from [f129963451cc6c8f1562d84852c6d4e31a211eec] # to [cc6860bdc2e1ba18713800ef24ceb08c605abab0] # # patch "merkle_tree.cc" # from [0be64fcc156d10e75e0f235856e9c4c428f1915c] # to [7011e2dbceb1d2e78db31c8c4570d443b383c639] # # patch "mkstemp.cc" # from [a58750be73db167658f8b3df2993d0dec8648a5c] # to [97f331512edf52eaa5940a6f891167e4f990c1fc] # # patch "monotone.cc" # from [7ce7990a7e4ebb99f1980ccdeca7a6e1b297ea7b] # to [e346183d0490498d8bc028de420c85e7ebc55cac] # # patch "mt_version.cc" # from [45d1e20bb6dc2d490854f8647d9788bc3ae04654] # to [244fa7c8fa1c1d2f65c9ee9c2542e95f8e284655] # # patch "netcmd.cc" # from [da3773c93069c0834ce0b3caf34020305dd7d8b2] # to [fd1bcbe65cd56e1a9379aa56c6039df9eac81b48] # # patch "netsync.cc" # from [e56f12d1ea09ad60c675560199cb7819d258c025] # to [cfd4bd5fa05d58c54c8ddf1cfe706120f6212e87] # # patch "packet.cc" # from [130498edfbbd9c527c89e6e6c5c2d8d6193d3590] # to [dfdefb2d2808183cd0312752b2ee1f840bace11c] # # patch "paths.cc" # from [5680d2c2726d5894fe21cc4c7dd9f149ba1efb32] # to [e780082307c87355306be40b824b8827f1db7d43] # # patch "rcs_file.cc" # from [f5dde1d6e49f0472b11704c24d36a0bcb161f257] # to [e6ecf0169b282a6f96e278227893eef9ca10680e] # # patch "rcs_import.cc" # from [36d442b3ce162881956dffeb17d9ff88d70ea794] # to [cc36f7773a0101a51850cc9f218b6f5dd6272a24] # # patch "refiner.cc" # from [baa7581b2a14e8f76c65e90aa682bd54a44cb292] # to [f2f64fe6722f3501ce1fea2d85516818070151e2] # # patch "revision.cc" # from [e41a1f765fa1a8d68288a62f74da3215864ada44] # to [ef6feacfdac32584040843bcd70f3bb66df67ad7] # # patch "roster.cc" # from [5955f1339c8276c1ad2964abf5051b7d9cb13890] # to [fde433622561c188f726b4b591388c070cc1e391] # # patch "roster_merge.cc" # from [282aa6d4625b5276c3997aa6aca10faf15f69eea] # to [ff845578375e028041eb8731d2f870ebfcad9eeb] # # patch "sanity.cc" # from [d10487eb6479f58640483c72bb8c207903b0ade1] # to [eb02236fb3eb72ac83d3b4a30cadad147aec9895] # # patch "schema_migration.cc" # from [f820f10c5c4992df47354a9653d89a6de21c3a87] # to [e26608a79f5d7cef3cc41da156dfc6d5f5f840db] # # patch "selectors.cc" # from [a179c48e93ea4c6e98558ce1f4b76da04ae88e61] # to [6e4fa17b861b28cc469b4adcdcdc58206ab2d654] # # patch "simplestring_xform.cc" # from [b6d21fa059da420562b8dfea0e833b1806d7766d] # to [dcf9e39b1a9c1bb565447a90f6068bdf82a7ee68] # # patch "ui.cc" # from [180abc6a7a5e1e7c552abc05d8d1806aebcae786] # to [cd43c58d97f3b15c45109e37c1fdad43ba84284a] # # patch "unit_tests.cc" # from [9b3d3fd11212c735e093314f79e5fbd76977ebab] # to [56038ad7f4260307ce03f9e4313720c59466f564] # # patch "vocab.cc" # from [734ef82435e130f3ba3674573a142a8a980de91c] # to [cd9e884668636ad1bb7cd1607d5d2fd0015fd307] # # patch "vocab_macros.hh" # from [5f7434315d7ad936ca9bf09abe40899eb7e44d49] # to [c82a27c1bc1c60037141f7e4bc26c00edc7d61a4] # # patch "work.cc" # from [0d47dba0c23494d21067c094cca9cba8acd71f3b] # to [afe3d7f65d252d2874181c2c43d50f95d51c8d61] # # patch "xdelta.cc" # from [0dba3763bd06fe89479c0c91d649eaba2b9e37ba] # to [0d2c397234e43b065c82f446ac4192803dec1146] # ============================================================ --- ChangeLog 81e3045140bcbf832f6fe43481c287b7343f50a8 +++ ChangeLog effebb6d6ea8613ca6a0306794ceaf91df89128a @@ -1,3 +1,66 @@ +2006-05-27 Derek Scherger + + * annotate.cc: + * app_state.cc: + * automate.cc: + * basic_io.cc: + * cert.cc: + * charset.cc: + * cmd_automate.cc: + * cmd_db.cc: + * cmd_diff_log.cc: + * cmd_list.cc: + * cmd_merging.cc: + * cmd_netsync.cc: + * cmd_packet.cc: + * cmd_ws_commit.cc: + * commands.cc: + * constants.cc: + * crypto_tests.cc: + * cset.cc: + * database.cc: + * database_check.cc: + * diff_patch.cc: + * enumerator.cc: + * epoch.cc: + * file_io.cc: + * globish.cc: + * hmac.cc: + * inodeprint.cc: + * key_store.cc: + * keys.cc: + * lcs.cc: + * legacy.cc: + * lua.cc: + * lua_hooks.cc: + * main.cc: + * merge.cc: + * merkle_tree.cc: + * mkstemp.cc: + * monotone.cc: + * mt_version.cc: + * netcmd.cc: + * netsync.cc: + * packet.cc: + * paths.cc: + * rcs_file.cc: + * rcs_import.cc: + * refiner.cc: + * revision.cc: + * roster.cc: + * roster_merge.cc: + * sanity.cc: + * schema_migration.cc: + * selectors.cc: + * simplestring_xform.cc: + * ui.cc: + * unit_tests.cc: + * vocab.cc: + * vocab_macros.hh: + * work.cc: + * xdelta.cc: + namespace fixups as described in the ROADMAP + 2006-05-26 Derek Scherger * automate.cc (automate_get_manifest_of, automate_get_file): ============================================================ --- annotate.cc 5f284a607f1ef3dd5a7e192a58c396ce135ae9ff +++ annotate.cc f77b679344341a4af199df9b59efd49b4676a6af @@ -26,7 +26,21 @@ #include "cert.hh" #include "ui.hh" +using std::auto_ptr; +using std::back_insert_iterator; +using std::back_inserter; +using std::cout; +using std::deque; +using std::endl; +using std::make_pair; +using std::map; +using std::min; +using std::set; +using std::string; +using std::vector; +using boost::shared_ptr; + class annotate_lineage_mapping; @@ -34,7 +48,7 @@ public: annotate_context(file_id fid, app_state &app); - boost::shared_ptr initial_lineage() const; + shared_ptr initial_lineage() const; /// credit any uncopied lines (as recorded in copied_lines) to /// rev, and reset copied_lines. @@ -51,27 +65,27 @@ void dump(app_state & app) const; - std::string get_line(int line_index) const { return file_lines[line_index]; } + string get_line(int line_index) const { return file_lines[line_index]; } private: - void build_revisions_to_annotations(app_state & app, std::map & revs_to_notations) const; + void build_revisions_to_annotations(app_state & app, map & revs_to_notations) const; - std::vector file_lines; - std::vector annotations; + vector file_lines; + vector annotations; /// equivalent_lines[n] = m means that line n should be blamed to the same /// revision as line m - std::map equivalent_lines; + map equivalent_lines; /// keep a count so we can tell quickly whether we can terminate size_t annotated_lines_completed; // elements of the set are indexes into the array of lines in the UDOI // lineages add entries here when they notice that they copied a line from the UDOI - std::set copied_lines; + set copied_lines; // similarly, lineages add entries here for all the lines from the UDOI they know about that they didn't copy - std::set touched_lines; + set touched_lines; }; @@ -84,31 +98,31 @@ class annotate_lineage_mapping { public: annotate_lineage_mapping(const file_data &data); - annotate_lineage_mapping(const std::vector &lines); + annotate_lineage_mapping(const vector &lines); // debugging //bool equal_interned (const annotate_lineage_mapping &rhs) const; /// need a better name. does the work of setting copied bits in the context object. - boost::shared_ptr - build_parent_lineage(boost::shared_ptr acp, revision_id parent_rev, const file_data &parent_data) const; + shared_ptr + build_parent_lineage(shared_ptr acp, revision_id parent_rev, const file_data &parent_data) const; - void merge(const annotate_lineage_mapping &other, const boost::shared_ptr &acp); + void merge(const annotate_lineage_mapping &other, const shared_ptr &acp); - void credit_mapped_lines (boost::shared_ptr acp) const; - void set_copied_all_mapped (boost::shared_ptr acp) const; + void credit_mapped_lines(shared_ptr acp) const; + void set_copied_all_mapped(shared_ptr acp) const; private: - void init_with_lines(const std::vector &lines); + void init_with_lines(const vector &lines); static interner in; // FIX, testing hack - std::vector file_interned; + vector file_interned; // maps an index into the vector of lines for our current version of the file // into an index into the vector of lines of the UDOI: // eg. if the line file_interned[i] will turn into line 4 in the UDOI, mapping[i] = 4 - std::vector mapping; + vector mapping; }; @@ -121,23 +135,23 @@ childrev -> parentrevN edges. */ struct annotate_node_work { - annotate_node_work (boost::shared_ptr annotations_, - boost::shared_ptr lineage_, - revision_id revision_, node_id fid_)//, file_path node_fpath_) + annotate_node_work(shared_ptr annotations_, + shared_ptr lineage_, + revision_id revision_, node_id fid_)//, file_path node_fpath_) : annotations(annotations_), lineage(lineage_), revision(revision_), fid(fid_)//, node_fpath(node_fpath_) {} - annotate_node_work (const annotate_node_work &w) + annotate_node_work(const annotate_node_work &w) : annotations(w.annotations), lineage(w.lineage), revision(w.revision), fid(w.fid) //, node_fpath(w.node_fpath) {} - boost::shared_ptr annotations; - boost::shared_ptr lineage; + shared_ptr annotations; + shared_ptr lineage; revision_id revision; //file_id node_fid; node_id fid; @@ -147,7 +161,7 @@ class lineage_merge_node { public: - typedef boost::shared_ptr splm; + typedef shared_ptr splm; lineage_merge_node(const lineage_merge_node &m) : work(m.work), incoming_edges(m.incoming_edges), completed_edges(m.completed_edges) @@ -157,7 +171,7 @@ : work(wu), incoming_edges(incoming), completed_edges(1) {} - void merge(splm incoming, const boost::shared_ptr &acp) + void merge(splm incoming, const shared_ptr &acp) { work.lineage->merge(*incoming, acp); completed_edges++; } @@ -182,7 +196,7 @@ // initialize file_lines file_data fpacked; app.db.get_file_version(fid, fpacked); - std::string encoding = constants::default_encoding; // FIXME + string encoding = constants::default_encoding; // FIXME split_into_lines(fpacked.inner()(), encoding, file_lines); L(FL("annotate_context::annotate_context initialized with %d file lines\n") % file_lines.size()); @@ -199,10 +213,10 @@ } -boost::shared_ptr +shared_ptr annotate_context::initial_lineage() const { - boost::shared_ptr res(new annotate_lineage_mapping(file_lines)); + shared_ptr res(new annotate_lineage_mapping(file_lines)); return res; } @@ -215,12 +229,12 @@ I(touched_lines.size() <= annotations.size()); // Find the lines that we touched but that no other parent copied. - std::set credit_lines; - std::set_difference(touched_lines.begin(), touched_lines.end(), - copied_lines.begin(), copied_lines.end(), - inserter(credit_lines, credit_lines.begin())); + set credit_lines; + set_difference(touched_lines.begin(), touched_lines.end(), + copied_lines.begin(), copied_lines.end(), + inserter(credit_lines, credit_lines.begin())); - std::set::const_iterator i; + set::const_iterator i; for (i = credit_lines.begin(); i != credit_lines.end(); i++) { I(*i < annotations.size()); if (annotations[*i] == nullid) { @@ -273,7 +287,7 @@ for (size_t i=0; i::const_iterator j = equivalent_lines.find(i); + map::const_iterator j = equivalent_lines.find(i); if (j == equivalent_lines.end()) { L(FL("annotate_equivalent_lines unable to find equivalent for line %d\n") % i); } @@ -295,26 +309,26 @@ } -std::string cert_string_value (std::vector< revision > const & certs, - const std::string & name, - bool from_start, bool from_end, - const std::string & sep) +string cert_string_value(vector< revision > const & certs, + const string & name, + bool from_start, bool from_end, + const string & sep) { - for (std::vector < revision < cert > >::const_iterator i = certs.begin (); + for (vector < revision < cert > >::const_iterator i = certs.begin (); i != certs.end (); ++i) { if (i->inner ().name () == name) { cert_value tv; decode_base64 (i->inner ().value, tv); - std::string::size_type f = 0; - std::string::size_type l = std::string::npos; + string::size_type f = 0; + string::size_type l = string::npos; if (from_start) l = tv ().find_first_of (sep); if (from_end) { f = tv ().find_last_of (sep); - if (f == std::string::npos) + if (f == string::npos) f = 0; } return tv ().substr (f, l); @@ -327,13 +341,13 @@ void annotate_context::build_revisions_to_annotations(app_state &app, - std::map &revs_to_notations) const + map &revs_to_notations) const { I(annotations.size() == file_lines.size()); // build set of unique revisions present in annotations - std::set seen; - for (std::vector::const_iterator i = annotations.begin(); i != annotations.end(); i++) + set seen; + for (vector::const_iterator i = annotations.begin(); i != annotations.end(); i++) { seen.insert(*i); } @@ -341,16 +355,16 @@ size_t max_note_length = 0; // build revision -> annotation string mapping - for (std::set::const_iterator i = seen.begin(); i != seen.end(); i++) + for (set::const_iterator i = seen.begin(); i != seen.end(); i++) { - std::vector< revision > certs; + vector< revision > certs; app.db.get_revision_certs(*i, certs); erase_bogus_certs(certs, app); - std::string author(cert_string_value(certs, author_cert_name, true, false, "@< ")); - std::string date(cert_string_value(certs, date_cert_name, true, false, "T")); + string author(cert_string_value(certs, author_cert_name, true, false, "@< ")); + string date(cert_string_value(certs, date_cert_name, true, false, "T")); - std::string result; + string result; result.append((*i).inner ()().substr(0, 8)); result.append(".. by "); result.append(author); @@ -363,10 +377,10 @@ } // justify annotation strings - for (std::map::iterator i = revs_to_notations.begin(); i != revs_to_notations.end(); i++) + for (map::iterator i = revs_to_notations.begin(); i != revs_to_notations.end(); i++) { size_t l = i->second.size(); - i->second.insert(std::string::size_type(0), max_note_length - l, ' '); + i->second.insert(string::size_type(0), max_note_length - l, ' '); } } @@ -377,13 +391,13 @@ revision_id nullid; I(annotations.size() == file_lines.size()); - std::map revs_to_notations; - std::string empty_note; + map revs_to_notations; + string empty_note; if (global_sanity.brief) { build_revisions_to_annotations(app, revs_to_notations); size_t max_note_length = revs_to_notations.begin()->second.size(); - empty_note.insert(std::string::size_type(0), max_note_length - 2, ' '); + empty_note.insert(string::size_type(0), max_note_length - 2, ' '); } revision_id lastid = nullid; @@ -393,13 +407,13 @@ if (global_sanity.brief) { if (lastid == annotations[i]) - std::cout << empty_note << ": " << file_lines[i] << std::endl; + cout << empty_note << ": " << file_lines[i] << endl; else - std::cout << revs_to_notations[annotations[i]] << file_lines[i] << std::endl; + cout << revs_to_notations[annotations[i]] << file_lines[i] << endl; lastid = annotations[i]; } else - std::cout << annotations[i] << ": " << file_lines[i] << std::endl; + cout << annotations[i] << ": " << file_lines[i] << endl; } } @@ -407,14 +421,14 @@ annotate_lineage_mapping::annotate_lineage_mapping(const file_data &data) { // split into lines - std::vector lines; - std::string encoding = constants::default_encoding; // FIXME + vector lines; + string encoding = constants::default_encoding; // FIXME split_into_lines (data.inner()().data(), encoding, lines); init_with_lines(lines); } -annotate_lineage_mapping::annotate_lineage_mapping(const std::vector &lines) +annotate_lineage_mapping::annotate_lineage_mapping(const vector &lines) { init_with_lines(lines); } @@ -431,7 +445,7 @@ result = false; } - size_t limit = std::min(file_interned.size(), rhs.file_interned.size()); + size_t limit = min(file_interned.size(), rhs.file_interned.size()); for (size_t i=0; i &lines) +annotate_lineage_mapping::init_with_lines(const vector &lines) { file_interned.clear(); file_interned.reserve(lines.size()); @@ -453,7 +467,7 @@ mapping.reserve(lines.size()); int count; - std::vector::const_iterator i; + vector::const_iterator i; for (count=0, i = lines.begin(); i != lines.end(); i++, count++) { file_interned.push_back(in.intern(*i)); mapping.push_back(count); @@ -462,29 +476,29 @@ } -boost::shared_ptr -annotate_lineage_mapping::build_parent_lineage (boost::shared_ptr acp, - revision_id parent_rev, - const file_data &parent_data) const +shared_ptr +annotate_lineage_mapping::build_parent_lineage(shared_ptr acp, + revision_id parent_rev, + const file_data &parent_data) const { bool verbose = false; - boost::shared_ptr parent_lineage(new annotate_lineage_mapping(parent_data)); + shared_ptr parent_lineage(new annotate_lineage_mapping(parent_data)); - std::vector lcs; - std::back_insert_iterator< std::vector > bii(lcs); + vector lcs; + back_insert_iterator< vector > bii(lcs); longest_common_subsequence(file_interned.begin(), file_interned.end(), parent_lineage->file_interned.begin(), parent_lineage->file_interned.end(), - std::min(file_interned.size(), parent_lineage->file_interned.size()), - std::back_inserter(lcs)); + min(file_interned.size(), parent_lineage->file_interned.size()), + back_inserter(lcs)); if (verbose) L(FL("build_parent_lineage: file_lines.size() == %d, parent.file_lines.size() == %d, lcs.size() == %d\n") % file_interned.size() % parent_lineage->file_interned.size() % lcs.size()); // do the copied lines thing for our annotate_context - std::vector lcs_src_lines; + vector lcs_src_lines; lcs_src_lines.resize(lcs.size()); size_t i, j; i = j = 0; @@ -544,8 +558,8 @@ void -annotate_lineage_mapping::merge (const annotate_lineage_mapping &other, - const boost::shared_ptr &acp) +annotate_lineage_mapping::merge(const annotate_lineage_mapping &other, + const shared_ptr &acp) { I(file_interned.size() == other.file_interned.size()); I(mapping.size() == other.mapping.size()); @@ -569,9 +583,9 @@ } void -annotate_lineage_mapping::credit_mapped_lines (boost::shared_ptr acp) const +annotate_lineage_mapping::credit_mapped_lines (shared_ptr acp) const { - std::vector::const_iterator i; + vector::const_iterator i; for (i=mapping.begin(); i != mapping.end(); i++) { acp->set_touched(*i); } @@ -579,9 +593,9 @@ void -annotate_lineage_mapping::set_copied_all_mapped (boost::shared_ptr acp) const +annotate_lineage_mapping::set_copied_all_mapped (shared_ptr acp) const { - std::vector::const_iterator i; + vector::const_iterator i; for (i=mapping.begin(); i != mapping.end(); i++) { acp->set_copied(*i); } @@ -591,20 +605,20 @@ static void do_annotate_node (const annotate_node_work &work_unit, app_state &app, - std::deque &nodes_to_process, - std::set &nodes_complete, - const std::map &paths_to_nodes, - std::map &pending_merge_nodes) + deque &nodes_to_process, + set &nodes_complete, + const map &paths_to_nodes, + map &pending_merge_nodes) { L(FL("do_annotate_node for node %s\n") % work_unit.revision); I(nodes_complete.find(work_unit.revision) == nodes_complete.end()); - // nodes_seen.insert(std::make_pair(work_unit.revision, work_unit.lineage)); + // nodes_seen.insert(make_pair(work_unit.revision, work_unit.lineage)); roster_t roster; marking_map markmap; app.db.get_roster(work_unit.revision, roster, markmap); marking_t marks; - std::map::const_iterator mmi = markmap.find(work_unit.fid); + map::const_iterator mmi = markmap.find(work_unit.fid); I(mmi != markmap.end()); marks = mmi->second; @@ -617,7 +631,7 @@ return; } - std::set parents; + set parents; // If we have content-marks which are *not* equal to the current rev, // we can jump back to them directly. If we have only a content-mark @@ -637,7 +651,7 @@ size_t added_in_parent_count = 0; - for (std::set::const_iterator i = parents.begin(); + for (set::const_iterator i = parents.begin(); i != parents.end(); i++) { revision_id parent_revision = *i; @@ -661,7 +675,7 @@ file_t file_in_child = downcast_to_file_t(roster.get_node(work_unit.fid)); file_t file_in_parent = downcast_to_file_t(parent_roster.get_node(work_unit.fid)); - boost::shared_ptr parent_lineage; + shared_ptr parent_lineage; if (file_in_parent->content == file_in_child->content) { @@ -681,7 +695,7 @@ // If this parent has not yet been queued for processing, create the // work unit for it. - std::map::iterator lmn + map::iterator lmn = pending_merge_nodes.find(parent_revision); if (lmn == pending_merge_nodes.end()) @@ -693,13 +707,13 @@ parent_revision, work_unit.fid); - std::map::const_iterator ptn + map::const_iterator ptn = paths_to_nodes.find(parent_revision); if (ptn->second > 1) { lineage_merge_node nmn(newunit, ptn->second); - pending_merge_nodes.insert(std::make_pair(parent_revision, nmn)); + pending_merge_nodes.insert(make_pair(parent_revision, nmn)); L(FL("put new merge node on pending_merge_nodes for parent %s\n") % parent_revision); // just checking... @@ -741,9 +755,9 @@ void -find_ancestors(app_state &app, revision_id rid, std::map &paths_to_nodes) +find_ancestors(app_state &app, revision_id rid, map &paths_to_nodes) { - std::vector frontier; + vector frontier; frontier.push_back(rid); while (!frontier.empty()) @@ -751,16 +765,16 @@ revision_id rid = frontier.back(); frontier.pop_back(); if(!null_id(rid)) { - std::set parents; + set parents; app.db.get_revision_parents(rid, parents); - for (std::set::const_iterator i = parents.begin(); + for (set::const_iterator i = parents.begin(); i != parents.end(); ++i) { - std::map::iterator found = paths_to_nodes.find(*i); + map::iterator found = paths_to_nodes.find(*i); if (found == paths_to_nodes.end()) { frontier.push_back(*i); - paths_to_nodes.insert(std::make_pair(*i, 1)); + paths_to_nodes.insert(make_pair(*i, 1)); } else { @@ -776,20 +790,20 @@ { L(FL("annotating file %s with content %s in revision %s\n") % file_node->self % file_node->content % rid); - boost::shared_ptr acp(new annotate_context(file_node->content, app)); - boost::shared_ptr lineage = acp->initial_lineage(); + shared_ptr acp(new annotate_context(file_node->content, app)); + shared_ptr lineage = acp->initial_lineage(); - std::set nodes_complete; - std::map paths_to_nodes; - std::map pending_merge_nodes; + set nodes_complete; + map paths_to_nodes; + map pending_merge_nodes; find_ancestors(app, rid, paths_to_nodes); // build node work unit - std::deque nodes_to_process; + deque nodes_to_process; annotate_node_work workunit(acp, lineage, rid, file_node->self); //, fpath); nodes_to_process.push_back(workunit); - std::auto_ptr revs_ticker(new ticker(N_("revs done"), "r", 1)); + auto_ptr revs_ticker(new ticker(N_("revs done"), "r", 1)); revs_ticker->set_total(paths_to_nodes.size() + 1); while (nodes_to_process.size() && !acp->is_complete()) { ============================================================ --- app_state.cc 6a8be1d3051e8e84464730d9d4f60cc9abca098d +++ app_state.cc 55a92b8e0df6ce29b219a3efef760983fa57c9ae @@ -17,6 +17,10 @@ #include "work.hh" #include "platform.hh" +using std::exception; +using std::map; +using std::string; + // copyright (C) 2002, 2003 graydon hoare // all rights reserved. // licensed to the public under the terms of the GNU GPL (>= 2) @@ -42,7 +46,7 @@ db.set_app(this); lua.set_app(this); keys.set_key_dir(confdir / "keys"); - set_prog_name(utf8(std::string("mtn"))); + set_prog_name(utf8(string("mtn"))); } app_state::~app_state() @@ -58,7 +62,7 @@ bool app_state::is_explicit_option(int option_id) const { - std::map::const_iterator i = explicit_option_map.find(option_id); + map::const_iterator i = explicit_option_map.find(option_id); if (i == explicit_option_map.end()) return false; return i->second; } @@ -113,7 +117,7 @@ } void -app_state::require_workspace(std::string const & explanation) +app_state::require_workspace(string const & explanation) { N(found_workspace, F("workspace required but not found%s%s") @@ -239,14 +243,14 @@ // form 20000101T120000, but not "extended" ISO times, of the form // 2000-01-01T12:00:00. So do something stupid to convert one to the // other. - std::string tmp = d(); - std::string::size_type pos = 0; + string tmp = d(); + string::size_type pos = 0; while ((pos = tmp.find_first_of("-:")) != string::npos) tmp.erase(pos, 1); date = boost::posix_time::from_iso_string(tmp); date_set = true; } - catch (std::exception &e) + catch (exception &e) { N(false, F("failed to parse date string '%s': %s") % d % e.what()); } @@ -412,7 +416,7 @@ read_options_map(dat, options); } } - catch(std::exception & e) + catch(exception & e) { W(F("Failed to read options file %s") % o_path); } @@ -429,7 +433,7 @@ write_options_map(dat, options); write_data(o_path, dat); } - catch(std::exception & e) + catch(exception & e) { W(F("Failed to write options file %s") % o_path); } ============================================================ --- automate.cc 8aa16555b3ed2bbd87bbdb395a2d23a790803f19 +++ automate.cc 7d53f42255a88e41a2b1bd27c85aff62ecad823d @@ -28,8 +28,26 @@ #include "packet.hh" #include "cert.hh" -static std::string const interface_version = "2.1"; +using std::allocator; +using std::basic_stringbuf; +using std::basic_ios; +using std::char_traits; +using std::endl; +using std::inserter; +using std::make_pair; +using std::map; +using std::multimap; +using std::ostream; +using std::ostringstream; +using std::pair; +using std::set; +using std::sort; +using std::streamsize; +using std::string; +using std::vector; +static string const interface_version = "2.1"; + // Name: interface_version // Arguments: none // Added in: 0.0 @@ -40,15 +58,15 @@ // "[0-9]+\.[0-9]+\n". // Error conditions: None. static void -automate_interface_version(std::vector args, - std::string const & help_name, +automate_interface_version(vector args, + string const & help_name, app_state & app, - std::ostream & output) + ostream & output) { if (args.size() != 0) throw usage(help_name); - output << interface_version << std::endl; + output << interface_version << endl; } // Name: heads @@ -61,10 +79,10 @@ // Error conditions: If the branch does not exist, prints nothing. (There are // no heads.) static void -automate_heads(std::vector args, - std::string const & help_name, +automate_heads(vector args, + string const & help_name, app_state & app, - std::ostream & output) + ostream & output) { if (args.size() > 1) throw usage(help_name); @@ -73,10 +91,10 @@ // branchname was explicitly given, use that app.set_branch(idx(args, 0)); } - std::set heads; + set heads; get_branch_heads(app.branch_name(), app, heads); - for (std::set::const_iterator i = heads.begin(); i != heads.end(); ++i) - output << (*i).inner()() << std::endl; + for (set::const_iterator i = heads.begin(); i != heads.end(); ++i) + output << (*i).inner()() << endl; } // Name: ancestors @@ -89,17 +107,17 @@ // Error conditions: If any of the revisions do not exist, prints nothing to // stdout, prints an error message to stderr, and exits with status 1. static void -automate_ancestors(std::vector args, - std::string const & help_name, - app_state & app, - std::ostream & output) +automate_ancestors(vector args, + string const & help_name, + app_state & app, + ostream & output) { if (args.size() == 0) throw usage(help_name); - std::set ancestors; - std::vector frontier; - for (std::vector::const_iterator i = args.begin(); i != args.end(); ++i) + set ancestors; + vector frontier; + for (vector::const_iterator i = args.begin(); i != args.end(); ++i) { revision_id rid((*i)()); N(app.db.revision_exists(rid), F("No such revision %s") % rid); @@ -110,9 +128,9 @@ revision_id rid = frontier.back(); frontier.pop_back(); if(!null_id(rid)) { - std::set parents; + set parents; app.db.get_revision_parents(rid, parents); - for (std::set::const_iterator i = parents.begin(); + for (set::const_iterator i = parents.begin(); i != parents.end(); ++i) { if (ancestors.find(*i) == ancestors.end()) @@ -123,10 +141,10 @@ } } } - for (std::set::const_iterator i = ancestors.begin(); + for (set::const_iterator i = ancestors.begin(); i != ancestors.end(); ++i) if (!null_id(*i)) - output << (*i).inner()() << std::endl; + output << (*i).inner()() << endl; } @@ -140,17 +158,17 @@ // Error conditions: If any of the revisions do not exist, prints nothing to // stdout, prints an error message to stderr, and exits with status 1. static void -automate_descendents(std::vector args, - std::string const & help_name, +automate_descendents(vector args, + string const & help_name, app_state & app, - std::ostream & output) + ostream & output) { if (args.size() == 0) throw usage(help_name); - std::set descendents; - std::vector frontier; - for (std::vector::const_iterator i = args.begin(); i != args.end(); ++i) + set descendents; + vector frontier; + for (vector::const_iterator i = args.begin(); i != args.end(); ++i) { revision_id rid((*i)()); N(app.db.revision_exists(rid), F("No such revision %s") % rid); @@ -160,9 +178,9 @@ { revision_id rid = frontier.back(); frontier.pop_back(); - std::set children; + set children; app.db.get_revision_children(rid, children); - for (std::set::const_iterator i = children.begin(); + for (set::const_iterator i = children.begin(); i != children.end(); ++i) { if (descendents.find(*i) == descendents.end()) @@ -172,9 +190,9 @@ } } } - for (std::set::const_iterator i = descendents.begin(); + for (set::const_iterator i = descendents.begin(); i != descendents.end(); ++i) - output << (*i).inner()() << std::endl; + output << (*i).inner()() << endl; } @@ -192,21 +210,21 @@ // Error conditions: If any of the revisions do not exist, prints nothing to // stdout, prints an error message to stderr, and exits with status 1. static void -automate_erase_ancestors(std::vector args, - std::string const & help_name, +automate_erase_ancestors(vector args, + string const & help_name, app_state & app, - std::ostream & output) + ostream & output) { - std::set revs; - for (std::vector::const_iterator i = args.begin(); i != args.end(); ++i) + set revs; + for (vector::const_iterator i = args.begin(); i != args.end(); ++i) { revision_id rid((*i)()); N(app.db.revision_exists(rid), F("No such revision %s") % rid); revs.insert(rid); } erase_ancestors(revs, app); - for (std::set::const_iterator i = revs.begin(); i != revs.end(); ++i) - output << (*i).inner()() << std::endl; + for (set::const_iterator i = revs.begin(); i != revs.end(); ++i) + output << (*i).inner()() << endl; } // Name: attributes @@ -219,10 +237,10 @@ // or a list of attributes if a file name provided. // Error conditions: If the file name has no attributes, prints nothing. static void -automate_attributes(std::vector args, - std::string const & help_name, +automate_attributes(vector args, + string const & help_name, app_state & app, - std::ostream & output) + ostream & output) { if (args.size() > 1) throw usage(help_name); @@ -244,7 +262,7 @@ for (full_attr_map_t::const_iterator i = n->attrs.begin(); i != n->attrs.end(); ++i) if (i->second.first) - output << i->first << std::endl; + output << i->first << endl; } } else @@ -256,7 +274,7 @@ { split_path path; current.get_name(i->first, path); - output << file_path(path) << std::endl; + output << file_path(path) << endl; } } } @@ -273,23 +291,23 @@ // Error conditions: If any of the revisions do not exist, prints nothing to // stdout, prints an error message to stderr, and exits with status 1. static void -automate_toposort(std::vector args, - std::string const & help_name, +automate_toposort(vector args, + string const & help_name, app_state & app, - std::ostream & output) + ostream & output) { - std::set revs; - for (std::vector::const_iterator i = args.begin(); i != args.end(); ++i) + set revs; + for (vector::const_iterator i = args.begin(); i != args.end(); ++i) { revision_id rid((*i)()); N(app.db.revision_exists(rid), F("No such revision %s") % rid); revs.insert(rid); } - std::vector sorted; + vector sorted; toposort(revs, sorted, app); - for (std::vector::const_iterator i = sorted.begin(); + for (vector::const_iterator i = sorted.begin(); i != sorted.end(); ++i) - output << (*i).inner()() << std::endl; + output << (*i).inner()() << endl; } // Name: ancestry_difference @@ -309,17 +327,17 @@ // Error conditions: If any of the revisions do not exist, prints nothing to // stdout, prints an error message to stderr, and exits with status 1. static void -automate_ancestry_difference(std::vector args, - std::string const & help_name, +automate_ancestry_difference(vector args, + string const & help_name, app_state & app, - std::ostream & output) + ostream & output) { if (args.size() == 0) throw usage(help_name); revision_id a; - std::set bs; - std::vector::const_iterator i = args.begin(); + set bs; + vector::const_iterator i = args.begin(); a = revision_id((*i)()); N(app.db.revision_exists(a), F("No such revision %s") % a); for (++i; i != args.end(); ++i) @@ -328,14 +346,14 @@ N(app.db.revision_exists(b), F("No such revision %s") % b); bs.insert(b); } - std::set ancestors; + set ancestors; ancestry_difference(a, bs, ancestors, app); - std::vector sorted; + vector sorted; toposort(ancestors, sorted, app); - for (std::vector::const_iterator i = sorted.begin(); + for (vector::const_iterator i = sorted.begin(); i != sorted.end(); ++i) - output << (*i).inner()() << std::endl; + output << (*i).inner()() << endl; } // Name: leaves @@ -352,24 +370,24 @@ // newline. Revision ids are printed in alphabetically sorted order. // Error conditions: None. static void -automate_leaves(std::vector args, - std::string const & help_name, - app_state & app, - std::ostream & output) +automate_leaves(vector args, + string const & help_name, + app_state & app, + ostream & output) { if (args.size() != 0) throw usage(help_name); // this might be more efficient in SQL, but for now who cares. - std::set leaves; + set leaves; app.db.get_revision_ids(leaves); - std::multimap graph; + multimap graph; app.db.get_revision_ancestry(graph); - for (std::multimap::const_iterator i = graph.begin(); + for (multimap::const_iterator i = graph.begin(); i != graph.end(); ++i) leaves.erase(i->first); - for (std::set::const_iterator i = leaves.begin(); i != leaves.end(); ++i) - output << (*i).inner()() << std::endl; + for (set::const_iterator i = leaves.begin(); i != leaves.end(); ++i) + output << (*i).inner()() << endl; } // Name: parents @@ -383,21 +401,21 @@ // Error conditions: If the revision does not exist, prints nothing to stdout, // prints an error message to stderr, and exits with status 1. static void -automate_parents(std::vector args, - std::string const & help_name, +automate_parents(vector args, + string const & help_name, app_state & app, - std::ostream & output) + ostream & output) { if (args.size() != 1) throw usage(help_name); revision_id rid(idx(args, 0)()); N(app.db.revision_exists(rid), F("No such revision %s") % rid); - std::set parents; + set parents; app.db.get_revision_parents(rid, parents); - for (std::set::const_iterator i = parents.begin(); + for (set::const_iterator i = parents.begin(); i != parents.end(); ++i) if (!null_id(*i)) - output << (*i).inner()() << std::endl; + output << (*i).inner()() << endl; } // Name: children @@ -411,21 +429,21 @@ // Error conditions: If the revision does not exist, prints nothing to stdout, // prints an error message to stderr, and exits with status 1. static void -automate_children(std::vector args, - std::string const & help_name, +automate_children(vector args, + string const & help_name, app_state & app, - std::ostream & output) + ostream & output) { if (args.size() != 1) throw usage(help_name); revision_id rid(idx(args, 0)()); N(app.db.revision_exists(rid), F("No such revision %s") % rid); - std::set children; + set children; app.db.get_revision_children(rid, children); - for (std::set::const_iterator i = children.begin(); + for (set::const_iterator i = children.begin(); i != children.end(); ++i) if (!null_id(*i)) - output << (*i).inner()() << std::endl; + output << (*i).inner()() << endl; } // Name: graph @@ -449,40 +467,40 @@ // within each line are alphabetically sorted. // Error conditions: None. static void -automate_graph(std::vector args, - std::string const & help_name, +automate_graph(vector args, + string const & help_name, app_state & app, - std::ostream & output) + ostream & output) { if (args.size() != 0) throw usage(help_name); - std::multimap edges_mmap; - std::map > child_to_parents; + multimap edges_mmap; + map > child_to_parents; app.db.get_revision_ancestry(edges_mmap); - for (std::multimap::const_iterator i = edges_mmap.begin(); + for (multimap::const_iterator i = edges_mmap.begin(); i != edges_mmap.end(); ++i) { if (child_to_parents.find(i->second) == child_to_parents.end()) - child_to_parents.insert(std::make_pair(i->second, std::set())); + child_to_parents.insert(make_pair(i->second, set())); if (null_id(i->first)) continue; - std::map >::iterator + map >::iterator j = child_to_parents.find(i->second); I(j->first == i->second); j->second.insert(i->first); } - for (std::map >::const_iterator i = child_to_parents.begin(); + for (map >::const_iterator i = child_to_parents.begin(); i != child_to_parents.end(); ++i) { output << (i->first).inner()(); - for (std::set::const_iterator j = i->second.begin(); + for (set::const_iterator j = i->second.begin(); j != i->second.end(); ++j) output << " " << (*j).inner()(); - output << std::endl; + output << endl; } } @@ -495,25 +513,25 @@ // newline. Revision ids are printed in alphabetically sorted order. // Error conditions: None. static void -automate_select(std::vector args, - std::string const & help_name, - app_state & app, - std::ostream & output) +automate_select(vector args, + string const & help_name, + app_state & app, + ostream & output) { if (args.size() != 1) throw usage(help_name); - std::vector > + vector > sels(selectors::parse_selector(args[0](), app)); // we jam through an "empty" selection on sel_ident type - std::set completions; + set completions; selectors::selector_type ty = selectors::sel_ident; selectors::complete_selector("", sels, ty, completions, app); - for (std::set::const_iterator i = completions.begin(); + for (set::const_iterator i = completions.begin(); i != completions.end(); ++i) - output << *i << std::endl; + output << *i << endl; } // consider a changeset with the following @@ -548,9 +566,9 @@ pre_id(0), post_id(0) {} }; -typedef std::map inventory_map; -typedef std::map rename_map; // this might be good in cset.hh -typedef std::map addition_map; // ditto +typedef map inventory_map; +typedef map rename_map; // this might be good in cset.hh +typedef map addition_map; // ditto static void inventory_pre_state(inventory_map & inventory, @@ -672,10 +690,10 @@ // prints an error message to stderr, and exits with status 1. static void -automate_inventory(std::vector args, - std::string const & help_name, +automate_inventory(vector args, + string const & help_name, app_state & app, - std::ostream & output) + ostream & output) { if (args.size() != 0) throw usage(help_name); @@ -725,7 +743,7 @@ for (inventory_map::const_iterator i = inventory.begin(); i != inventory.end(); ++i) { - std::string path_suffix; + string path_suffix; if (curr.has_node(i->first)) { @@ -776,7 +794,7 @@ output << path_suffix; - output << std::endl; + output << endl; } } @@ -825,15 +843,15 @@ // warning message is printed to stderr. If the revision specified is unknown // or invalid prints an error message to stderr and exits with status 1. static void -automate_certs(std::vector args, - std::string const & help_name, - app_state & app, - std::ostream & output) +automate_certs(vector args, + string const & help_name, + app_state & app, + ostream & output) { if (args.size() != 1) throw usage(help_name); - std::vector certs; + vector certs; transaction_guard guard(app.db, false); @@ -841,13 +859,13 @@ N(app.db.revision_exists(rid), F("No such revision %s") % rid); hexenc ident(rid.inner()); - std::vector< revision > ts; + vector< revision > ts; app.db.get_revision_certs(rid, ts); for (size_t i = 0; i < ts.size(); ++i) certs.push_back(idx(ts, i).inner()); { - std::set checked; + set checked; for (size_t i = 0; i < certs.size(); ++i) { if (checked.find(idx(certs, i).key) == checked.end() && @@ -860,7 +878,7 @@ // Make the output deterministic; this is useful for the test suite, in // particular. - std::sort(certs.begin(), certs.end()); + sort(certs.begin(), certs.end()); basic_io::printer pr; @@ -870,7 +888,7 @@ cert_status status = check_cert(app, idx(certs, i)); cert_value tv; cert_name name = idx(certs, i).name(); - std::set signers; + set signers; decode_base64(idx(certs, i).value, tv); @@ -882,7 +900,7 @@ st.push_str_pair(syms::key, keyid()); - std::string stat; + string stat; switch (status) { case cert_ok: @@ -970,10 +988,10 @@ // Error conditions: If the revision specified is unknown or invalid prints an // error message to stderr and exits with status 1. static void -automate_get_revision(std::vector args, - std::string const & help_name, - app_state & app, - std::ostream & output) +automate_get_revision(vector args, + string const & help_name, + app_state & app, + ostream & output) { if (args.size() > 1) throw usage(help_name); @@ -1018,10 +1036,10 @@ // Error conditions: If no workspace book keeping _MTN directory is found, // prints an error message to stderr, and exits with status 1. static void -automate_get_base_revision_id(std::vector args, - std::string const & help_name, +automate_get_base_revision_id(vector args, + string const & help_name, app_state & app, - std::ostream & output) + ostream & output) { if (args.size() > 0) throw usage(help_name); @@ -1030,7 +1048,7 @@ revision_id rid; get_revision_id(rid); - output << rid << std::endl; + output << rid << endl; } // Name: get_current_revision_id @@ -1042,10 +1060,10 @@ // Error conditions: If no workspace book keeping _MTN directory is found, // prints an error message to stderr, and exits with status 1. static void -automate_get_current_revision_id(std::vector args, - std::string const & help_name, +automate_get_current_revision_id(vector args, + string const & help_name, app_state & app, - std::ostream & output) + ostream & output) { if (args.size() > 0) throw usage(help_name); @@ -1066,7 +1084,7 @@ calculate_ident(rev, new_revision_id); - output << new_revision_id << std::endl; + output << new_revision_id << endl; } // Name: get_manifest_of @@ -1110,10 +1128,10 @@ // Error conditions: If the revision ID specified is unknown or invalid prints an // error message to stderr and exits with status 1. static void -automate_get_manifest_of(std::vector args, - std::string const & help_name, +automate_get_manifest_of(vector args, + string const & help_name, app_state & app, - std::ostream & output) + ostream & output) { if (args.size() > 1) throw usage(help_name); @@ -1157,10 +1175,10 @@ // Error conditions: If the file id specified is unknown or invalid prints // an error message to stderr and exits with status 1. static void -automate_get_file(std::vector args, - std::string const & help_name, - app_state & app, - std::ostream & output) +automate_get_file(vector args, + string const & help_name, + app_state & app, + ostream & output) { if (args.size() != 1) throw usage(help_name); @@ -1186,10 +1204,10 @@ // Error conditions: If the revision id specified is unknown or invalid prints // an error message to stderr and exits with status 1. static void -automate_packet_for_rdata(std::vector args, - std::string const & help_name, - app_state & app, - std::ostream & output) +automate_packet_for_rdata(vector args, + string const & help_name, + app_state & app, + ostream & output) { if (args.size() != 1) throw usage(help_name); @@ -1216,10 +1234,10 @@ // Error conditions: If the revision id specified is unknown or invalid prints // an error message to stderr and exits with status 1. static void -automate_packets_for_certs(std::vector args, - std::string const & help_name, - app_state & app, - std::ostream & output) +automate_packets_for_certs(vector args, + string const & help_name, + app_state & app, + ostream & output) { if (args.size() != 1) throw usage(help_name); @@ -1227,7 +1245,7 @@ packet_writer pw(output); revision_id r_id(idx(args, 0)()); - std::vector< revision > certs; + vector< revision > certs; N(app.db.revision_exists(r_id), F("no such revision '%s'") % r_id); @@ -1247,10 +1265,10 @@ // Error conditions: If the file id specified is unknown or invalid prints // an error message to stderr and exits with status 1. static void -automate_packet_for_fdata(std::vector args, - std::string const & help_name, - app_state & app, - std::ostream & output) +automate_packet_for_fdata(vector args, + string const & help_name, + app_state & app, + ostream & output) { if (args.size() != 1) throw usage(help_name); @@ -1278,10 +1296,10 @@ // Error conditions: If any of the file ids specified are unknown or // invalid prints an error message to stderr and exits with status 1. static void -automate_packet_for_fdelta(std::vector args, - std::string const & help_name, - app_state & app, - std::ostream & output) +automate_packet_for_fdelta(vector args, + string const & help_name, + app_state & app, + ostream & output) { if (args.size() != 2) throw usage(help_name); @@ -1304,10 +1322,10 @@ } void -automate_command(utf8 cmd, std::vector args, - std::string const & root_cmd_name, +automate_command(utf8 cmd, vector args, + string const & root_cmd_name, app_state & app, - std::ostream & output); + ostream & output); // Name: stdio // Arguments: none @@ -1349,16 +1367,16 @@ //We use our own stringbuf class so we can put in a callback on write. //This lets us dump output at a set length, rather than waiting until //we have all of the output. -typedef std::basic_stringbuf, - std::allocator > char_stringbuf; +typedef basic_stringbuf, + allocator > char_stringbuf; struct my_stringbuf : public char_stringbuf { private: - std::streamsize written; + streamsize written; boost::function1 on_write; - std::streamsize last_call; - std::streamsize call_every; + streamsize last_call; + streamsize call_every; bool clear; public: my_stringbuf() : char_stringbuf(), @@ -1366,10 +1384,10 @@ last_call(0), call_every(constants::automate_stdio_size) {} - virtual std::streamsize - xsputn(const char_stringbuf::char_type* __s, std::streamsize __n) + virtual streamsize + xsputn(const char_stringbuf::char_type* __s, streamsize __n) { - std::streamsize ret=char_stringbuf::xsputn(__s, __n); + streamsize ret=char_stringbuf::xsputn(__s, __n); written+=__n; while(written>=last_call+call_every) { @@ -1396,8 +1414,8 @@ void print_some_output(int cmdnum, int err, bool last, - std::string const & text, - std::ostream & s, + string const & text, + ostream & s, int & pos, int size) { @@ -1437,10 +1455,10 @@ } static void -automate_stdio(std::vector args, - std::string const & help_name, - app_state & app, - std::ostream & output) +automate_stdio(vector args, + string const & help_name, + app_state & app, + ostream & output) { if (args.size() != 0) throw usage(help_name); @@ -1449,7 +1467,7 @@ ssize_t n=1; while(n)//while(!EOF) { - std::string x; + string x; utf8 cmd; args.clear(); bool first=true; @@ -1470,9 +1488,9 @@ while(count >::rdbuf(&sb); + s.basic_ios >::rdbuf(&sb); try { err=0; @@ -1562,17 +1580,17 @@ // // Error conditions: None. static void -automate_keys(std::vector args, std::string const & help_name, - app_state & app, std::ostream & output) +automate_keys(vector args, string const & help_name, + app_state & app, ostream & output) { if (args.size() != 0) throw usage(help_name); - std::vector dbkeys; - std::vector kskeys; + vector dbkeys; + vector kskeys; // public_hash, private_hash, public_location, private_location - std::map, hexenc, - std::vector, - std::vector > > items; + map, hexenc, + vector, + vector > > items; if (app.db.database_specified()) { transaction_guard guard(app.db, false); @@ -1581,7 +1599,7 @@ } app.keys.get_key_ids("", kskeys); - for (std::vector::iterator i = dbkeys.begin(); + for (vector::iterator i = dbkeys.begin(); i != dbkeys.end(); i++) { base64 pub_encoded; @@ -1593,7 +1611,7 @@ items[(*i)()].get<2>().push_back("database"); } - for (std::vector::iterator i = kskeys.begin(); + for (vector::iterator i = kskeys.begin(); i != kskeys.end(); i++) { keypair kp; @@ -1607,9 +1625,9 @@ items[(*i)()].get<3>().push_back("keystore"); } basic_io::printer prt; - for (std::map, hexenc, - std::vector, - std::vector > >::iterator + for (map, hexenc, + vector, + vector > >::iterator i = items.begin(); i != items.end(); ++i) { basic_io::stanza stz; @@ -1636,15 +1654,15 @@ // Error conditions: If any of the revisions do not exist, prints nothing to // stdout, prints an error message to stderr, and exits with status 1. static void -automate_common_ancestors(std::vector args, std::string const & help_name, - app_state & app, std::ostream & output) +automate_common_ancestors(vector args, string const & help_name, + app_state & app, ostream & output) { if (args.size() == 0) throw usage(help_name); - std::set ancestors, common_ancestors; - std::vector frontier; - for (std::vector::const_iterator i = args.begin(); i != args.end(); ++i) + set ancestors, common_ancestors; + vector frontier; + for (vector::const_iterator i = args.begin(); i != args.end(); ++i) { revision_id rid((*i)()); N(app.db.revision_exists(rid), F("No such revision %s") % rid); @@ -1657,9 +1675,9 @@ frontier.pop_back(); if(!null_id(rid)) { - std::set parents; + set parents; app.db.get_revision_parents(rid, parents); - for (std::set::const_iterator i = parents.begin(); + for (set::const_iterator i = parents.begin(); i != parents.end(); ++i) { if (ancestors.find(*i) == ancestors.end()) @@ -1674,26 +1692,26 @@ common_ancestors = ancestors; else { - std::set common; - std::set_intersection(ancestors.begin(), ancestors.end(), + set common; + set_intersection(ancestors.begin(), ancestors.end(), common_ancestors.begin(), common_ancestors.end(), - std::inserter(common, common.begin())); + inserter(common, common.begin())); common_ancestors = common; } } - for (std::set::const_iterator i = common_ancestors.begin(); + for (set::const_iterator i = common_ancestors.begin(); i != common_ancestors.end(); ++i) if (!null_id(*i)) - output << (*i).inner()() << std::endl; + output << (*i).inner()() << endl; } void -automate_command(utf8 cmd, std::vector args, - std::string const & root_cmd_name, +automate_command(utf8 cmd, vector args, + string const & root_cmd_name, app_state & app, - std::ostream & output) + ostream & output) { if (cmd() == "interface_version") automate_interface_version(args, root_cmd_name, app, output); ============================================================ --- basic_io.cc 5c8f164d4a3f4829497c834164cb09ac6341467c +++ basic_io.cc 0cd7c3eb2d37b603a49cab9959f582bcc4fb661f @@ -10,6 +10,12 @@ #include "sanity.hh" #include "vocab.hh" +using std::logic_error; +using std::make_pair; +using std::pair; +using std::string; +using std::vector; + // copyright (C) 2004 graydon hoare // all rights reserved. // licensed to the public under the terms of the GNU GPL (>= 2) @@ -21,28 +27,28 @@ // their i/o routines are somewhat related. -void basic_io::input_source::err(std::string const & s) +void basic_io::input_source::err(string const & s) { L(FL("error in %s:%d:%d:E: %s") % name % line % col % s); - throw std::logic_error((F("error in %s:%d:%d:E: %s") - % name % line % col % s).str()); + throw logic_error((F("error in %s:%d:%d:E: %s") + % name % line % col % s).str()); } -void basic_io::tokenizer::err(std::string const & s) +void basic_io::tokenizer::err(string const & s) { in.err(s); } -std::string -basic_io::escape(std::string const & s) +string +basic_io::escape(string const & s) { - std::string escaped; + string escaped; escaped.reserve(s.size() + 8); escaped += "\""; - for (std::string::const_iterator i = s.begin(); i != s.end(); ++i) + for (string::const_iterator i = s.begin(); i != s.end(); ++i) { switch (*i) { @@ -64,23 +70,23 @@ void basic_io::stanza::push_hex_pair(symbol const & k, hexenc const & v) { - entries.push_back(std::make_pair(k, "[" + v() + "]")); + entries.push_back(make_pair(k, "[" + v() + "]")); if (k().size() > indent) indent = k().size(); } void basic_io::stanza::push_hex_triple(symbol const & k, - std::string const & n, + string const & n, hexenc const & v) { - entries.push_back(std::make_pair(k, escape(n) + " " + "[" + v() + "]")); + entries.push_back(make_pair(k, escape(n) + " " + "[" + v() + "]")); if (k().size() > indent) indent = k().size(); } -void basic_io::stanza::push_str_pair(symbol const & k, std::string const & v) +void basic_io::stanza::push_str_pair(symbol const & k, string const & v) { - entries.push_back(std::make_pair(k, escape(v))); + entries.push_back(make_pair(k, escape(v))); if (k().size() > indent) indent = k().size(); } @@ -91,11 +97,11 @@ } void basic_io::stanza::push_str_multi(symbol const & k, - std::vector const & v) + vector const & v) { - std::string val; + string val; bool first = true; - for (std::vector::const_iterator i = v.begin(); + for (vector::const_iterator i = v.begin(); i != v.end(); ++i) { if (!first) @@ -103,22 +109,22 @@ val += escape(*i); first = false; } - entries.push_back(std::make_pair(k, val)); + entries.push_back(make_pair(k, val)); if (k().size() > indent) indent = k().size(); } void basic_io::stanza::push_str_triple(symbol const & k, - std::string const & n, - std::string const & v) + string const & n, + string const & v) { - entries.push_back(std::make_pair(k, escape(n) + " " + escape(v))); + entries.push_back(make_pair(k, escape(n) + " " + escape(v))); if (k().size() > indent) indent = k().size(); } -std::string basic_io::printer::buf; +string basic_io::printer::buf; basic_io::printer::printer() { @@ -130,7 +136,7 @@ if (LIKELY(!buf.empty())) buf += '\n'; - for (std::vector >::const_iterator i = st.entries.begin(); + for (vector >::const_iterator i = st.entries.begin(); i != st.entries.end(); ++i) { for (size_t k = i->first().size(); k < st.indent; ++k) @@ -142,12 +148,12 @@ } } -void basic_io::parser::err(std::string const & s) +void basic_io::parser::err(string const & s) { tok.err(s); } -std::string basic_io::parser::tt2str(token_type tt) +string basic_io::parser::tt2str(token_type tt) { switch (tt) { ============================================================ --- cert.cc 90434ca979245b8d440c3daead3d8ad5120e27ee +++ cert.cc d568dcf9cbf42901fbc3aec941fb6111004a74e4 @@ -30,7 +30,13 @@ #include #include -using namespace std; +using std::make_pair; +using std::map; +using std::pair; +using std::set; +using std::string; +using std::vector; + using boost::shared_ptr; using boost::get; using boost::tuple; @@ -104,7 +110,7 @@ vector< manifest > tmp_certs; // sorry, this is a crazy data structure - typedef boost::tuple< hexenc, cert_name, base64 > trust_key; + typedef tuple< hexenc, cert_name, base64 > trust_key; typedef map< trust_key, pair< shared_ptr< set >, it > > trust_map; trust_map trust; @@ -346,7 +352,7 @@ keypair & kp) { - static std::map keys; + static map keys; bool persist_ok = (!keys.empty()) || app.lua.hook_persist_phrase_ok(); @@ -385,7 +391,7 @@ base64< rsa_pub_key > pub; - static std::map > pubkeys; + static map > pubkeys; bool persist_ok = (!pubkeys.empty()) || app.lua.hook_persist_phrase_ok(); if (persist_ok ============================================================ --- charset.cc e954d3206a9df54b32bea7aba29d723fbad74f14 +++ charset.cc c958f957b5deca18a5803c512ae5cf58d08b5fb1 @@ -59,9 +59,9 @@ size_t display_width(utf8 const & utf) { - std::string const & u = utf(); + string const & u = utf(); size_t sz = 0; - std::string::const_iterator i = u.begin(); + string::const_iterator i = u.begin(); while (i != u.end()) { if (UNLIKELY(static_cast(*i) & static_cast(0x80))) @@ -91,7 +91,7 @@ static inline bool system_charset_is_utf8_impl() { - std::string lc_encoding = lowercase(system_charset()); + string lc_encoding = lowercase(system_charset()); return (lc_encoding == "utf-8" || lc_encoding == "utf_8" || lc_encoding == "utf8"); @@ -109,17 +109,17 @@ { if (system_charset_is_utf8()) return true; - std::string lc_encoding = lowercase(system_charset()); + string lc_encoding = lowercase(system_charset()); // if your character set is identical to ascii in the lower 7 bits, then add // it here for a speed boost. - return (lc_encoding.find("ascii") != std::string::npos - || lc_encoding.find("8859") != std::string::npos - || lc_encoding.find("ansi_x3.4") != std::string::npos + return (lc_encoding.find("ascii") != string::npos + || lc_encoding.find("8859") != string::npos + || lc_encoding.find("ansi_x3.4") != string::npos // http://www.cs.mcgill.ca/~aelias4/encodings.html -- "EUC (Extended // Unix Code) is a simple and clean encoding, standard on Unix // systems.... It is backwards-compatible with ASCII (i.e. valid // ASCII implies valid EUC)." - || lc_encoding.find("euc") != std::string::npos); + || lc_encoding.find("euc") != string::npos); } static inline bool @@ -134,7 +134,7 @@ { // could speed this up by vectorization -- mask against 0x80808080, // process a whole word at at time... - for (std::string::const_iterator i = utf.begin(); i != utf.end(); ++i) + for (string::const_iterator i = utf.begin(); i != utf.end(); ++i) if (0x80 & *i) return false; return true; @@ -142,7 +142,7 @@ // this function must be fast. do not make it slow. void -utf8_to_system(utf8 const & utf, std::string & ext) +utf8_to_system(utf8 const & utf, string & ext) { if (system_charset_is_utf8()) ext = utf(); @@ -187,10 +187,10 @@ bool utf8_validate(utf8 const & utf) { - std::string::size_type left = utf().size(); + string::size_type left = utf().size(); u32 min, val; - for (std::string::const_iterator i = utf().begin(); + for (string::const_iterator i = utf().begin(); i != utf().end(); ++i, --left) { u8 c = *i; ============================================================ --- cmd_automate.cc d973f6704cc5cf5a777b8e4f5bdd60ee10048b7c +++ cmd_automate.cc 9888db8b3c4b072092f933a65973fa42e94f7980 @@ -1,9 +1,11 @@ #include "cmd.hh" #include "automate.hh" #include +using std::cout; + CMD(automate, N_("automation"), N_("interface_version\n" "heads [BRANCH]\n" @@ -45,5 +47,5 @@ make_io_binary(); - automate_command(cmd, cmd_args, name, app, std::cout); + automate_command(cmd, cmd_args, name, app, cout); } ============================================================ --- cmd_db.cc cef42bd1ec6ec18b7e37bfbd70d1d9decee2d679 +++ cmd_db.cc 7403b1a1bb54a12e01dee5fcbbc3db7aaf8ba557 @@ -1,20 +1,22 @@ #include "cmd.hh" #include "revision.hh" #include "database_check.hh" #include "charset.hh" #include +#include + using std::cin; using std::cout; -#include +using std::make_pair; using std::pair; - using std::set; +using std::string; // Deletes a revision from the local database. This can be used to 'undo' a // changed revision from a local database without leaving (much of) a trace. static void -kill_rev_locally(app_state& app, std::string const& id) +kill_rev_locally(app_state& app, string const& id) { revision_id ident; complete(app, id, ident); @@ -115,7 +117,7 @@ internalize_var_domain(idx(args, 0), d); n = var_name(idx(args, 1)()); v = var_value(idx(args, 2)()); - app.db.set_var(std::make_pair(d, n), v); + app.db.set_var(make_pair(d, n), v); } CMD(unset, N_("vars"), N_("DOMAIN NAME"), ============================================================ --- cmd_diff_log.cc 31fe8c5d41bd88bd58dae13ad2b21a8839b5a415 +++ cmd_diff_log.cc 6b49be84ff5e47f22c1942927ea41ab7c24da386 @@ -6,16 +6,24 @@ #include "restrictions.hh" #include "localized_file_io.hh" -using std::set; #include -using std::map; #include -using std::cout; #include -using std::ostringstream; #include + +using std::cout; using std::deque; +using std::make_pair; +using std::map; +using std::ostream; +using std::ostringstream; +using std::pair; +using std::set; +using std::string; +using std::vector; +using boost::lexical_cast; + // The changes_summary structure holds a list all of files and directories // affected in a revision, and is useful in the 'log' command to print this // information easily. It has to be constructed from all cset objects @@ -27,7 +35,7 @@ cset cs; changes_summary(void); void add_change_set(cset const & cs); - void print(std::ostream & os, size_t max_cols) const; + void print(ostream & os, size_t max_cols) const; }; changes_summary::changes_summary(void) @@ -68,7 +76,7 @@ } static void -print_indented_set(std::ostream & os, +print_indented_set(ostream & os, path_set const & s, size_t max_cols) { @@ -77,7 +85,7 @@ for (path_set::const_iterator i = s.begin(); i != s.end(); i++) { - const std::string str = boost::lexical_cast(file_path(*i)); + const string str = lexical_cast(file_path(*i)); if (cols > 8 && cols + str.size() + 1 >= max_cols) { cols = 8; @@ -90,7 +98,7 @@ } void -changes_summary::print(std::ostream & os, size_t max_cols) const +changes_summary::print(ostream & os, size_t max_cols) const { if (! cs.nodes_deleted.empty()) @@ -102,7 +110,7 @@ if (! cs.nodes_renamed.empty()) { os << "Renamed entries:" << "\n"; - for (std::map::const_iterator + for (map::const_iterator i = cs.nodes_renamed.begin(); i != cs.nodes_renamed.end(); i++) os << " " << file_path(i->first) << " to " << file_path(i->second) << "\n"; @@ -111,7 +119,7 @@ if (! cs.files_added.empty()) { path_set tmp; - for (std::map::const_iterator i = cs.files_added.begin(); + for (map::const_iterator i = cs.files_added.begin(); i != cs.files_added.end(); ++i) tmp.insert(i->first); os << "Added files:" << "\n"; @@ -127,7 +135,7 @@ if (! cs.deltas_applied.empty()) { path_set tmp; - for (std::map >::const_iterator i = cs.deltas_applied.begin(); + for (map >::const_iterator i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) tmp.insert(i->first); os << "Modified files:" << "\n"; @@ -137,11 +145,11 @@ if (! cs.attrs_set.empty() || ! cs.attrs_cleared.empty()) { path_set tmp; - for (std::set >::const_iterator i = cs.attrs_cleared.begin(); + for (set >::const_iterator i = cs.attrs_cleared.begin(); i != cs.attrs_cleared.end(); ++i) tmp.insert(i->first); - for (std::map, attr_value>::const_iterator i = cs.attrs_set.begin(); + for (map, attr_value>::const_iterator i = cs.attrs_set.begin(); i != cs.attrs_set.end(); ++i) tmp.insert(i->first.first); @@ -155,7 +163,7 @@ app_state & app, bool new_is_archived) { - for (std::map >::const_iterator + for (map >::const_iterator i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) { @@ -203,9 +211,9 @@ bool limit_paths = false) { // 60 is somewhat arbitrary, but less than 80 - std::string patch_sep = std::string(60, '='); + string patch_sep = string(60, '='); - for (std::map::const_iterator + for (map::const_iterator i = cs.files_added.begin(); i != cs.files_added.end(); ++i) { @@ -247,16 +255,16 @@ } } - std::map reverse_rename_map; + map reverse_rename_map; - for (std::map::const_iterator + for (map::const_iterator i = cs.nodes_renamed.begin(); i != cs.nodes_renamed.end(); ++i) { - reverse_rename_map.insert(std::make_pair(i->second, i->first)); + reverse_rename_map.insert(make_pair(i->second, i->first)); } - for (std::map >::const_iterator + for (map >::const_iterator i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) { @@ -295,7 +303,7 @@ split_path dst_path = delta_entry_path(i); split_path src_path = dst_path; - std::map::const_iterator re; + map::const_iterator re; re = reverse_rename_map.find(dst_path); if (re != reverse_rename_map.end()) @@ -539,7 +547,7 @@ } else { - for (std::vector::const_iterator i = app.revision_selectors.begin(); + for (vector::const_iterator i = app.revision_selectors.begin(); i != app.revision_selectors.end(); i++) { set rids; ============================================================ --- cmd_list.cc 5fcd71a963f52bf864f3a8f392c8d9ae328ac953 +++ cmd_list.cc 7647566d20b4a6c7c435b01f92ea90838c12646c @@ -11,16 +11,19 @@ #include "keys.hh" #include "cert.hh" +#include #include -using std::cout; -using std::sort; +#include #include + +using std::cout; +using std::make_pair; +using std::map; +using std::ostream_iterator; using std::pair; using std::set; -#include -using std::map; -#include using std::sort; +using std::string; static void ls_certs(string const & name, app_state & app, vector const & args) @@ -103,7 +106,7 @@ split_into_lines(washed, lines); I(lines.size() > 0); - cout << std::string(guess_terminal_width(), '-') << '\n' + cout << string(guess_terminal_width(), '-') << '\n' << (i18n_format(str) % idx(certs, i).key() % stat @@ -125,7 +128,7 @@ { vector pubs; vector privkeys; - std::string pattern; + string pattern; if (args.size() == 1) pattern = idx(args, 0)(); else if (args.size() > 1) @@ -234,12 +237,12 @@ static void ls_epochs(string name, app_state & app, vector const & args) { - std::map epochs; + map epochs; app.db.get_epochs(epochs); if (args.size() == 0) { - for (std::map::const_iterator i = epochs.begin(); + for (map::const_iterator i = epochs.begin(); i != epochs.end(); ++i) { cout << i->second << " " << i->first << "\n"; @@ -250,7 +253,7 @@ for (vector::const_iterator i = args.begin(); i != args.end(); ++i) { - std::map::const_iterator j = epochs.find(cert_value((*i)())); + map::const_iterator j = epochs.find(cert_value((*i)())); N(j != epochs.end(), F("no epoch for branch %s\n") % *i); cout << j->second << " " << j->first << "\n"; } @@ -263,7 +266,7 @@ vector< revision > certs; app.db.get_revision_certs(tag_cert_name, certs); - std::set< pair > > sorted_vals; + set< pair > > sorted_vals; for (vector< revision >::const_iterator i = certs.begin(); i != certs.end(); ++i) @@ -271,9 +274,9 @@ cert_value name; cert c = i->inner(); decode_base64(c.value, name); - sorted_vals.insert(std::make_pair(name, std::make_pair(c.ident, c.key))); + sorted_vals.insert(make_pair(name, make_pair(c.ident, c.key))); } - for (std::set > >::const_iterator i = sorted_vals.begin(); i != sorted_vals.end(); ++i) { @@ -302,7 +305,7 @@ map vars; app.db.get_vars(vars); - for (std::map::const_iterator i = vars.begin(); + for (map::const_iterator i = vars.begin(); i != vars.end(); ++i) { if (filterp && !(i->first.first == filter)) @@ -372,7 +375,7 @@ { roster_t old_roster, new_roster; cset included, excluded; - std::set files; + set files; temp_node_id_source nis; app.require_workspace(); @@ -395,7 +398,7 @@ if (mask.includes(*i)) files.insert(file_path(*i)); } - for (std::map::const_iterator + for (map::const_iterator i = included.nodes_renamed.begin(); i != included.nodes_renamed.end(); ++i) { @@ -409,13 +412,13 @@ if (mask.includes(*i)) files.insert(file_path(*i)); } - for (std::map::const_iterator i = included.files_added.begin(); + for (map::const_iterator i = included.files_added.begin(); i != included.files_added.end(); ++i) { if (mask.includes(i->first)) files.insert(file_path(i->first)); } - for (std::map >::const_iterator + for (map >::const_iterator i = included.deltas_applied.begin(); i != included.deltas_applied.end(); ++i) { @@ -425,7 +428,7 @@ // FIXME: should attr changes count? copy(files.begin(), files.end(), - std::ostream_iterator(cout, "\n")); + ostream_iterator(cout, "\n")); } ============================================================ --- cmd_merging.cc 8cb9a727c46da071534f510458de386f45b2c092 +++ cmd_merging.cc 14dbf8776d68cf092e76c4d7479afaafd24e4705 @@ -11,21 +11,24 @@ #include "update.hh" #include + using std::cout; +using std::map; +using std::set; struct update_source : public file_content_source { - std::map & temporary_store; + map & temporary_store; app_state & app; - update_source (std::map & tmp, + update_source (map & tmp, app_state & app) : temporary_store(tmp), app(app) {} void get_file_content(file_id const & fid, file_data & dat) const { - std::map::const_iterator i = temporary_store.find(fid); + map::const_iterator i = temporary_store.find(fid); if (i != temporary_store.end()) dat = i->second; else @@ -171,7 +174,7 @@ app.db.get_roster(r_chosen_id, chosen_roster, chosen_mm); - std::set + set working_uncommon_ancestors, chosen_uncommon_ancestors; @@ -418,7 +421,7 @@ MM(left_roster); MM(right_roster); marking_map left_marking_map, right_marking_map; - std::set left_uncommon_ancestors, right_uncommon_ancestors; + set left_uncommon_ancestors, right_uncommon_ancestors; app.db.get_roster(left_rid, left_roster, left_marking_map); app.db.get_roster(right_rid, right_roster, right_marking_map); @@ -551,7 +554,7 @@ marking_map l_marking, r_marking; app.db.get_roster(l_id, l_roster, l_marking); app.db.get_roster(r_id, r_roster, r_marking); - std::set l_uncommon_ancestors, r_uncommon_ancestors; + set l_uncommon_ancestors, r_uncommon_ancestors; app.db.get_uncommon_ancestors(l_id, r_id, l_uncommon_ancestors, r_uncommon_ancestors); ============================================================ --- cmd_netsync.cc 431b5bb6daff4f8d8992eee7ff14a21512895b81 +++ cmd_netsync.cc 1085c92a4b4e60e11c02378427e0cd2c4e844acd @@ -6,9 +6,12 @@ #include "cert.hh" #include + using std::ifstream; +using std::ofstream; +using std::string; +using std::vector; - static const var_key default_server_key(var_domain("database"), var_name("default-server")); static const var_key default_include_pattern_key(var_domain("database"), @@ -17,8 +20,8 @@ var_name("default-exclude-pattern")); static void -process_netsync_args(std::string const & name, - std::vector const & args, +process_netsync_args(string const & name, + vector const & args, utf8 & addr, utf8 & include_pattern, utf8 & exclude_pattern, bool use_defaults, @@ -55,7 +58,7 @@ { E(serve_mode || args.size() >= 2, F("no branch pattern given")); int pattern_offset = (serve_mode ? 0 : 1); - std::vector patterns(args.begin() + pattern_offset, args.end()); + vector patterns(args.begin() + pattern_offset, args.end()); combine_and_check_globish(patterns, include_pattern); combine_and_check_globish(app.exclude_patterns, exclude_pattern); if (use_defaults && @@ -155,7 +158,7 @@ if (path.empty()) return; pid_t pid; - std::ifstream(path.as_external().c_str()) >> pid; + ifstream(path.as_external().c_str()) >> pid; if (pid == get_process_id()) { file.close(); delete_file(path); @@ -163,7 +166,7 @@ } private: - std::ofstream file; + ofstream file; system_path path; }; ============================================================ --- cmd_packet.cc 26b3d187c3a139599b7c50ba80c29f81c382dfdd +++ cmd_packet.cc 0d127531d08a403249ba6fea64f09ee1fd0546e3 @@ -1,12 +1,14 @@ #include "cmd.hh" #include "packet.hh" #include -using std::istringstream; #include + +using std::cin; using std::cout; -using std::cin; +using std::istringstream; +using std::vector; CMD(pubkey, N_("packet i/o"), N_("ID"), N_("write public key packet to stdout"), OPT_NONE) @@ -67,7 +69,7 @@ } else { - for (std::vector::const_iterator i = args.begin(); i != args.end(); ++i) + for (vector::const_iterator i = args.begin(); i != args.end(); ++i) { data dat; read_data(system_path(*i), dat); ============================================================ --- cmd_ws_commit.cc 130ebf460f4770ca6b39dd7c5d2b8dbf39405656 +++ cmd_ws_commit.cc 159a7abbffa9e3992f5a3dba2af148de388e1f53 @@ -9,10 +9,12 @@ #include "localized_file_io.hh" #include -using std::map; -using std::make_pair; #include + using std::cout; +using std::make_pair; +using std::pair; +using std::map; static void get_log_message_interactively(revision_set const & cs, @@ -324,7 +326,7 @@ i != cs.nodes_deleted.end(); ++i) cout << "dropped " << *i << "\n"; - for (std::map::const_iterator + for (map::const_iterator i = cs.nodes_renamed.begin(); i != cs.nodes_renamed.end(); ++i) cout << "renamed " << i->first << "\n" @@ -334,11 +336,11 @@ i != cs.dirs_added.end(); ++i) cout << "added " << *i << "\n"; - for (std::map::const_iterator i = cs.files_added.begin(); + for (map::const_iterator i = cs.files_added.begin(); i != cs.files_added.end(); ++i) cout << "added " << i->first << "\n"; - for (std::map >::const_iterator + for (map >::const_iterator i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) cout << "patched " << i->first << "\n"; } @@ -678,7 +680,7 @@ // process file deltas or new files cset const & cs = edge_changes(edge); - for (std::map >::const_iterator i = cs.deltas_applied.begin(); + for (map >::const_iterator i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) { file_path path(i->first); @@ -716,7 +718,7 @@ % old_content % path); } - for (std::map::const_iterator i = cs.files_added.begin(); + for (map::const_iterator i = cs.files_added.begin(); i != cs.files_added.end(); ++i) { file_path path(i->first); ============================================================ --- commands.cc a02d61685a3807368a2e1ec1fed79ea5f342ea79 +++ commands.cc 9eb8b9fe197b66baa555579ff90b5e1ed9f9c8dd @@ -15,6 +15,13 @@ #include "cert.hh" #include "cmd.hh" + +using std::cin; +using std::pair; +using std::set; +using std::string; + + // // this file defines the task-oriented "top level" commands which can be // issued as part of a monotone command line. the command line can only @@ -68,14 +75,16 @@ namespace commands { - using namespace std; + using std::endl; + using std::greater; + using std::ostream; bool operator<(command const & self, command const & other) { // *twitch* - return ((std::string(_(self.cmdgroup.c_str())) < std::string(_(other.cmdgroup.c_str()))) + return ((string(_(self.cmdgroup.c_str())) < string(_(other.cmdgroup.c_str()))) || ((self.cmdgroup == other.cmdgroup) - && (std::string(_(self.name.c_str())) < (std::string(_(other.name.c_str())))))); + && (string(_(self.name.c_str())) < (string(_(other.name.c_str())))))); } @@ -157,7 +166,7 @@ sorted.push_back(i->second); } - sort(sorted.begin(), sorted.end(), std::greater()); + sort(sorted.begin(), sorted.end(), greater()); string curr_group; size_t col = 0; @@ -241,10 +250,6 @@ throw usage(full_cmd); } -using std::set; -using std::pair; -using std::cin; - void maybe_update_inodeprints(app_state & app) { @@ -343,7 +348,7 @@ void complete(app_state & app, string const & str, - std::set & completion, + set & completion, bool must_exist) { // This copies the start of selectors::parse_selector().to avoid @@ -411,7 +416,7 @@ set heads; get_branch_heads(app.branch_name(), app, heads); if (heads.size() > 1) { - std::string prefixedline; + string prefixedline; prefix_lines_with(_("note: "), _("branch '%s' has multiple heads\n" "perhaps consider '%s merge'"), ============================================================ --- constants.cc 45406dd40ffed1993ee987120843b62ef9d3b8ec +++ constants.cc b175c8ae9c808089d3e9f7216896be26714703db @@ -12,6 +12,8 @@ #include +using std::string; + namespace constants { @@ -58,14 +60,14 @@ " \r\n\t" ; - std::string const regex_legal_packet_bytes("([a-zA-Z0-9+/=[:space:]]+)"); + string const regex_legal_packet_bytes("([a-zA-Z0-9+/=[:space:]]+)"); // all the ASCII characters (bytes) which are legal in a SHA1 hex id char const * const legal_id_bytes = "0123456789abcdef" ; - std::string const regex_legal_id_bytes("([[:xdigit:]]{40})"); + string const regex_legal_id_bytes("([[:xdigit:]]{40})"); // all the ASCII characters (bytes) which are legal in an ACE string char const * const legal_ace_bytes = @@ -87,7 +89,7 @@ "-" ; - std::string const regex_legal_cert_name_bytes("([-a-zA-Z0-9]+)"); + string const regex_legal_cert_name_bytes("([-a-zA-Z0-9]+)"); // all the ASCII characters (bytes) which can occur in key names char const * const legal_key_name_bytes = @@ -103,7 +105,7 @@ ".@" ; - std::string const regex_legal_key_name_bytes("(address@hidden)"); + string const regex_legal_key_name_bytes("(address@hidden)"); // all the ASCII characters (bytes) which are illegal in a (file|local)_path @@ -150,11 +152,11 @@ size_t const netsync_session_key_length_in_bytes = 20; // 160 bits size_t const netsync_hmac_value_length_in_bytes = 20; // 160 bits - std::string const & netsync_key_initializer = std::string(netsync_session_key_length_in_bytes, 0); + string const & netsync_key_initializer = string(netsync_session_key_length_in_bytes, 0); // attributes - std::string const encoding_attribute("mtn:encoding"); - std::string const manual_merge_attribute("mtn:manual_merge"); - std::string const binary_encoding("binary"); - std::string const default_encoding("default"); + string const encoding_attribute("mtn:encoding"); + string const manual_merge_attribute("mtn:manual_merge"); + string const binary_encoding("binary"); + string const default_encoding("default"); } ============================================================ --- crypto_tests.cc 6e7f56e97edd513e405a24beb2df684d0bfab1b4 +++ crypto_tests.cc 5f2ad6110bb7f9a10978ede2c860ad44b24ffed0 @@ -11,7 +11,9 @@ #include "transforms.hh" #include "sanity.hh" -static std::string expected_SHA_MCT[] = { +using std::string; + +static string expected_SHA_MCT[] = { "e216836819477c7f78e0d843fe4ff1b6d6c14cd4", "a2dbc7a5b1c6c0a8bcb7aaa41252a6a7d0690dbc", "db1f9050bb863dfef4ce37186044e2eeb17ee013", @@ -1052,7 +1054,7 @@ //SHA Short Message Test data input(decode_hexenc("5e")); - std::string ident("5e6f80a34a9798cafc6a5db96cc57ba4c4db59c2"); + string ident("5e6f80a34a9798cafc6a5db96cc57ba4c4db59c2"); calculate_ident(input, output); @@ -1082,9 +1084,9 @@ // //Seed = d0569cb3665a8a43eb6ea23d75a3c4d2054a0d7d - std::string Seed = ("d0569cb3665a8a43eb6ea23d75a3c4d2054a0d7d"); + string Seed = ("d0569cb3665a8a43eb6ea23d75a3c4d2054a0d7d"); - std::string MD[1003]; + string MD[1003]; for (int j = 0; j < 1000; j++) { @@ -1095,7 +1097,7 @@ for (int i = 3; i < 1003; i++) { - std::string messageString = MD[i - 3] + MD[i - 2] + MD[i - 1]; + string messageString = MD[i - 3] + MD[i - 2] + MD[i - 1]; // L(FL("messageString: %s\n") % messageString ); data messageData(decode_hexenc(messageString)); ============================================================ --- cset.cc 17cc4461f4e98e06986d4543b0952be1272ef3e9 +++ cset.cc bf3abceb49091cfed0d14d02c1188d14378b8f6e @@ -34,7 +34,7 @@ // no file appears in both the "added" list and the "patched" list { map::const_iterator a = cs.files_added.begin(); - map >::const_iterator + map >::const_iterator d = cs.deltas_applied.begin(); while (a != cs.files_added.end() && d != cs.deltas_applied.end()) { @@ -330,7 +330,7 @@ static inline void parse_path(basic_io::parser & parser, split_path & sp) { - std::string s; + string s; parser.str(s); file_path_internal(s).split(sp); } @@ -463,7 +463,7 @@ } template <> void -dump(cset const & cs, std::string & out) +dump(cset const & cs, string & out) { data dat; write_cset(cs, dat); @@ -475,6 +475,8 @@ #include "roster.hh" +using std::logic_error; + static void setup_roster(roster_t & r, file_id const & fid, node_id_source & nis) { @@ -520,14 +522,14 @@ "add_dir \"pling\"\n"); data d1(s); cset cs; - BOOST_CHECK_THROW(read_cset(d1, cs), std::logic_error); + BOOST_CHECK_THROW(read_cset(d1, cs), logic_error); // check that it still fails if there's extra stanzas past the // mis-ordered entries data d2(s + "\n" " set \"bar\"\n" " attr \"flavoursome\"\n" "value \"mostly\"\n"); - BOOST_CHECK_THROW(read_cset(d2, cs), std::logic_error); + BOOST_CHECK_THROW(read_cset(d2, cs), logic_error); } { @@ -537,7 +539,7 @@ "\n" "delete \"bar\"\n"); cset cs; - BOOST_CHECK_THROW(read_cset(dat, cs), std::logic_error); + BOOST_CHECK_THROW(read_cset(dat, cs), logic_error); } { @@ -549,7 +551,7 @@ "rename \"bar\"\n" " to \"barnew\"\n"); cset cs; - BOOST_CHECK_THROW(read_cset(dat, cs), std::logic_error); + BOOST_CHECK_THROW(read_cset(dat, cs), logic_error); } { @@ -559,7 +561,7 @@ "\n" "add_dir \"bar\"\n"); cset cs; - BOOST_CHECK_THROW(read_cset(dat, cs), std::logic_error); + BOOST_CHECK_THROW(read_cset(dat, cs), logic_error); } { @@ -571,7 +573,7 @@ "add_file \"bar\"\n" " content [0000000000000000000000000000000000000000]\n"); cset cs; - BOOST_CHECK_THROW(read_cset(dat, cs), std::logic_error); + BOOST_CHECK_THROW(read_cset(dat, cs), logic_error); } { @@ -583,7 +585,7 @@ "add_file \"bar\"\n" " content [0000000000000000000000000000000000000000]\n"); cset cs; - BOOST_CHECK_THROW(read_cset(dat, cs), std::logic_error); + BOOST_CHECK_THROW(read_cset(dat, cs), logic_error); } { @@ -597,7 +599,7 @@ " from [0000000000000000000000000000000000000000]\n" " to [1000000000000000000000000000000000000000]\n"); cset cs; - BOOST_CHECK_THROW(read_cset(dat, cs), std::logic_error); + BOOST_CHECK_THROW(read_cset(dat, cs), logic_error); } { @@ -609,7 +611,7 @@ "clear \"bar\"\n" " attr \"flavoursome\"\n"); cset cs; - BOOST_CHECK_THROW(read_cset(dat, cs), std::logic_error); + BOOST_CHECK_THROW(read_cset(dat, cs), logic_error); } { @@ -623,7 +625,7 @@ " attr \"flavoursome\"\n" "value \"yes\"\n"); cset cs; - BOOST_CHECK_THROW(read_cset(dat, cs), std::logic_error); + BOOST_CHECK_THROW(read_cset(dat, cs), logic_error); } { @@ -632,7 +634,7 @@ "\n" "delete \"foo\"\n"); cset cs; - BOOST_CHECK_THROW(read_cset(dat, cs), std::logic_error); + BOOST_CHECK_THROW(read_cset(dat, cs), logic_error); } { @@ -646,7 +648,7 @@ " attr \"smell\"\n" "value \"socks\"\n"); cset cs; - BOOST_CHECK_NOT_THROW(read_cset(dat, cs), std::logic_error); + BOOST_CHECK_NOT_THROW(read_cset(dat, cs), logic_error); } { @@ -658,7 +660,7 @@ "clear \"bar\"\n" " attr \"fooish\"\n"); cset cs; - BOOST_CHECK_THROW(read_cset(dat, cs), std::logic_error); + BOOST_CHECK_THROW(read_cset(dat, cs), logic_error); } { @@ -672,7 +674,7 @@ " attr \"fooish\"\n" "value \"seldom\"\n"); cset cs; - BOOST_CHECK_THROW(read_cset(dat, cs), std::logic_error); + BOOST_CHECK_THROW(read_cset(dat, cs), logic_error); } { @@ -686,16 +688,16 @@ " attr \"flavoursome\"\n" "value \"sometimes\"\n"); cset cs; - BOOST_CHECK_THROW(read_cset(dat, cs), std::logic_error); + BOOST_CHECK_THROW(read_cset(dat, cs), logic_error); } { L(FL("TEST: cset writing - normalisation")); cset cs; MM(cs); split_path foo, bar, quux, foo_quux, idle, fish, womble, policeman; - file_id f1(std::string("1234567800000000000000000000000000000000")); - file_id f2(std::string("9876543212394657263900000000000000000000")); - file_id f3(std::string("0000000000011111111000000000000000000000")); + file_id f1(string("1234567800000000000000000000000000000000")); + file_id f2(string("9876543212394657263900000000000000000000")); + file_id f3(string("0000000000011111111000000000000000000000")); file_path_internal("foo").split(foo); file_path_internal("foo/quux").split(foo_quux); file_path_internal("bar").split(bar); @@ -751,7 +753,7 @@ ); MM(expected); // I() so that it'll dump on failure - BOOST_CHECK_NOT_THROW(I(expected == dat), std::logic_error); + BOOST_CHECK_NOT_THROW(I(expected == dat), logic_error); } } @@ -765,8 +767,8 @@ editable_roster_base tree(r, nis); - file_id f1(std::string("0000000000000000000000000000000000000001")); - file_id f2(std::string("0000000000000000000000000000000000000002")); + file_id f1(string("0000000000000000000000000000000000000001")); + file_id f2(string("0000000000000000000000000000000000000002")); split_path root, foo, foo_bar, baz, quux; file_path().split(root); @@ -781,7 +783,7 @@ setup_roster(r, f1, nis); cset cs; MM(cs); cs.files_added.insert(make_pair(baz, f2)); - BOOST_CHECK_NOT_THROW(cs.apply_to(tree), std::logic_error); + BOOST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); BOOST_CHECK(is_file_t(r.get_node(baz))); BOOST_CHECK(downcast_to_file_t(r.get_node(baz))->content == f2); BOOST_CHECK(r.all_nodes().size() == 4); @@ -792,7 +794,7 @@ setup_roster(r, f1, nis); cset cs; MM(cs); cs.dirs_added.insert(quux); - BOOST_CHECK_NOT_THROW(cs.apply_to(tree), std::logic_error); + BOOST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); BOOST_CHECK(is_dir_t(r.get_node(quux))); BOOST_CHECK(r.all_nodes().size() == 4); } @@ -803,7 +805,7 @@ cset cs; MM(cs); cs.nodes_deleted.insert(foo_bar); cs.nodes_deleted.insert(foo); - BOOST_CHECK_NOT_THROW(cs.apply_to(tree), std::logic_error); + BOOST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); BOOST_CHECK(r.all_nodes().size() == 1); // only the root left } @@ -812,7 +814,7 @@ setup_roster(r, f1, nis); cset cs; MM(cs); cs.nodes_renamed.insert(make_pair(foo_bar, quux)); - BOOST_CHECK_NOT_THROW(cs.apply_to(tree), std::logic_error); + BOOST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); BOOST_CHECK(is_file_t(r.get_node(quux))); BOOST_CHECK(is_dir_t(r.get_node(foo))); BOOST_CHECK(!r.has_node(foo_bar)); @@ -826,7 +828,7 @@ setup_roster(r, f1, nis); cset cs; MM(cs); cs.nodes_renamed.insert(make_pair(foo, quux)); - BOOST_CHECK_NOT_THROW(cs.apply_to(tree), std::logic_error); + BOOST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); BOOST_CHECK(is_dir_t(r.get_node(quux))); BOOST_CHECK(is_file_t(r.get_node(quux_bar))); BOOST_CHECK(!r.has_node(foo)); @@ -838,7 +840,7 @@ setup_roster(r, f1, nis); cset cs; MM(cs); cs.deltas_applied.insert(make_pair(foo_bar, make_pair(f1, f2))); - BOOST_CHECK_NOT_THROW(cs.apply_to(tree), std::logic_error); + BOOST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); BOOST_CHECK(is_dir_t(r.get_node(foo))); BOOST_CHECK(is_file_t(r.get_node(foo_bar))); BOOST_CHECK(downcast_to_file_t(r.get_node(foo_bar))->content == f2); @@ -851,7 +853,7 @@ cset cs; MM(cs); cs.attrs_set.insert(make_pair(make_pair(foo_bar, attr_key("ping")), attr_value("klang"))); - BOOST_CHECK_NOT_THROW(cs.apply_to(tree), std::logic_error); + BOOST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); full_attr_map_t attrs = (r.get_node(foo_bar))->attrs; BOOST_CHECK(attrs[attr_key("ping")] == make_pair(true, attr_value("klang"))); @@ -869,7 +871,7 @@ cs.attrs_set.insert(make_pair(make_pair(foo_bar, attr_key("ping")), attr_value("klang"))); cs.attrs_cleared.insert(make_pair(foo_bar, attr_key("attr_file"))); - BOOST_CHECK_NOT_THROW(cs.apply_to(tree), std::logic_error); + BOOST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); BOOST_CHECK((r.get_node(foo_bar))->attrs[attr_key("attr_file")] == make_pair(false, attr_value(""))); BOOST_CHECK(r.all_nodes().size() == 3); @@ -899,7 +901,7 @@ cs.dirs_added.insert(foo_sub); cs.files_added.insert(make_pair(foo_sub_deep, f2)); cs.files_added.insert(make_pair(quux_sub_thing, f1)); - BOOST_CHECK_NOT_THROW(cs.apply_to(tree), std::logic_error); + BOOST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); BOOST_CHECK(r.all_nodes().size() == 8); } @@ -908,7 +910,7 @@ cs.nodes_renamed.insert(make_pair(foo, quux)); cs.nodes_renamed.insert(make_pair(quux, foo)); cs.nodes_renamed.insert(make_pair(foo_sub, foo_subsub)); - BOOST_CHECK_NOT_THROW(cs.apply_to(tree), std::logic_error); + BOOST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); } BOOST_CHECK(r.all_nodes().size() == 8); @@ -931,7 +933,7 @@ cset cs; MM(cs); cs.nodes_renamed.insert(make_pair(foo_bar, foo)); cs.nodes_deleted.insert(foo); - BOOST_CHECK_NOT_THROW(cs.apply_to(tree), std::logic_error); + BOOST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); BOOST_CHECK(r.all_nodes().size() == 2); BOOST_CHECK(is_file_t(r.get_node(foo))); } @@ -945,8 +947,8 @@ MM(r); editable_roster_base tree(r, nis); - file_id f1(std::string("0000000000000000000000000000000000000001")); - file_id f2(std::string("0000000000000000000000000000000000000002")); + file_id f1(string("0000000000000000000000000000000000000001")); + file_id f2(string("0000000000000000000000000000000000000002")); split_path root, foo, foo_bar, baz, quux; file_path().split(root); @@ -960,60 +962,60 @@ setup_roster(r, f1, nis); cset cs; MM(cs); cs.nodes_deleted.insert(foo_bar); - BOOST_CHECK_NOT_THROW(cs.apply_to(tree), std::logic_error); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + BOOST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } { L(FL("TEST: can't double-add file")); setup_roster(r, f1, nis); cset cs; MM(cs); - cs.files_added.insert(std::make_pair(baz, f2)); - BOOST_CHECK_NOT_THROW(cs.apply_to(tree), std::logic_error); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + cs.files_added.insert(make_pair(baz, f2)); + BOOST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } { L(FL("TEST: can't add file on top of dir")); setup_roster(r, f1, nis); cset cs; MM(cs); - cs.files_added.insert(std::make_pair(foo, f2)); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + cs.files_added.insert(make_pair(foo, f2)); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } { L(FL("TEST: can't delete+rename")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.nodes_deleted.insert(foo_bar); - cs.nodes_renamed.insert(std::make_pair(foo_bar, baz)); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + cs.nodes_renamed.insert(make_pair(foo_bar, baz)); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } { L(FL("TEST: can't add+rename")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.dirs_added.insert(baz); - cs.nodes_renamed.insert(std::make_pair(baz, quux)); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + cs.nodes_renamed.insert(make_pair(baz, quux)); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } { L(FL("TEST: can't add on top of root dir")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.dirs_added.insert(root); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } { L(FL("TEST: can't rename on top of root dir")); setup_roster(r, f1, nis); cset cs; MM(cs); - cs.nodes_renamed.insert(std::make_pair(foo, root)); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + cs.nodes_renamed.insert(make_pair(foo, root)); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } { L(FL("TEST: can't rename 'a' 'a'")); setup_roster(r, f1, nis); cset cs; MM(cs); - cs.nodes_renamed.insert(std::make_pair(foo_bar, foo_bar)); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + cs.nodes_renamed.insert(make_pair(foo_bar, foo_bar)); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } { L(FL("TEST: can't rename 'a' 'b'; rename 'a/foo' 'b/foo'")); @@ -1021,75 +1023,75 @@ cset cs; MM(cs); split_path baz_bar; file_path_internal("baz/bar").split(baz_bar); - cs.nodes_renamed.insert(std::make_pair(foo, baz)); - cs.nodes_renamed.insert(std::make_pair(foo_bar, baz_bar)); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + cs.nodes_renamed.insert(make_pair(foo, baz)); + cs.nodes_renamed.insert(make_pair(foo_bar, baz_bar)); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } { L(FL("TEST: can't attr_set + attr_cleared")); setup_roster(r, f1, nis); cset cs; MM(cs); - cs.attrs_set.insert(std::make_pair(std::make_pair(foo_bar, attr_key("blah")), + cs.attrs_set.insert(make_pair(make_pair(foo_bar, attr_key("blah")), attr_value("blahblah"))); - cs.attrs_cleared.insert(std::make_pair(foo_bar, attr_key("blah"))); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + cs.attrs_cleared.insert(make_pair(foo_bar, attr_key("blah"))); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } { L(FL("TEST: can't no-op attr_set")); setup_roster(r, f1, nis); cset cs; MM(cs); - cs.attrs_set.insert(std::make_pair(std::make_pair(foo_bar, attr_key("attr_file")), + cs.attrs_set.insert(make_pair(make_pair(foo_bar, attr_key("attr_file")), attr_value("value_file"))); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } { L(FL("TEST: can't clear non-existent attr")); setup_roster(r, f1, nis); cset cs; MM(cs); - cs.attrs_cleared.insert(std::make_pair(foo_bar, attr_key("blah"))); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + cs.attrs_cleared.insert(make_pair(foo_bar, attr_key("blah"))); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } { L(FL("TEST: can't clear non-existent attr that once existed")); setup_roster(r, f1, nis); cset cs; MM(cs); - cs.attrs_cleared.insert(std::make_pair(foo_bar, attr_key("attr_file"))); + cs.attrs_cleared.insert(make_pair(foo_bar, attr_key("attr_file"))); // exists now, so should be fine - BOOST_CHECK_NOT_THROW(cs.apply_to(tree), std::logic_error); + BOOST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); // but last time killed it, so can't be killed again - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } { L(FL("TEST: can't have no-op deltas")); setup_roster(r, f1, nis); cset cs; MM(cs); - cs.deltas_applied.insert(std::make_pair(foo_bar, - std::make_pair(f1, f1))); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + cs.deltas_applied.insert(make_pair(foo_bar, + make_pair(f1, f1))); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } { L(FL("TEST: can't have add+delta")); setup_roster(r, f1, nis); cset cs; MM(cs); - cs.files_added.insert(std::make_pair(baz, f1)); - cs.deltas_applied.insert(std::make_pair(baz, - std::make_pair(f1, f2))); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + cs.files_added.insert(make_pair(baz, f1)); + cs.deltas_applied.insert(make_pair(baz, + make_pair(f1, f2))); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } { L(FL("TEST: can't delta a directory")); setup_roster(r, f1, nis); cset cs; MM(cs); - cs.deltas_applied.insert(std::make_pair(foo, - std::make_pair(f1, f2))); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + cs.deltas_applied.insert(make_pair(foo, + make_pair(f1, f2))); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } { L(FL("TEST: can't delete non-empty directory")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.nodes_deleted.insert(foo); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } { L(FL("TEST: attach node with no root directory present")); @@ -1099,7 +1101,7 @@ split_path sp; file_path_internal("blah/blah/blah").split(sp); cs.dirs_added.insert(sp); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } { L(FL("TEST: can't move a directory underneath itself")); @@ -1107,8 +1109,8 @@ cset cs; MM(cs); split_path foo_blah; file_path_internal("foo/blah").split(foo_blah); - cs.nodes_renamed.insert(std::make_pair(foo, foo_blah)); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + cs.nodes_renamed.insert(make_pair(foo, foo_blah)); + BOOST_CHECK_THROW(cs.apply_to(tree), logic_error); } } @@ -1120,7 +1122,7 @@ MM(r); editable_roster_base tree(r, nis); - file_id f1(std::string("0000000000000000000000000000000000000001")); + file_id f1(string("0000000000000000000000000000000000000001")); split_path root, baz; file_path().split(root); @@ -1132,7 +1134,7 @@ cset cs; MM(cs); split_path sp1, sp2; cs.dirs_added.insert(root); - cs.nodes_renamed.insert(std::make_pair(root, baz)); + cs.nodes_renamed.insert(make_pair(root, baz)); cs.apply_to(tree); r.check_sane(true); } @@ -1144,7 +1146,7 @@ cset cs; MM(cs); cs.nodes_deleted.insert(root); cs.apply_to(tree); - BOOST_CHECK_THROW(r.check_sane(true), std::logic_error); + BOOST_CHECK_THROW(r.check_sane(true), logic_error); } { L(FL("TEST: can delete and replace root")); ============================================================ --- database.cc e185a4b7db7def9d9c5ddb0b1bc9f883d623220b +++ database.cc 0d25c2fa019f20eb0b7299f2b569a4091571aed1 @@ -54,9 +54,21 @@ // // see file schema.sql for the text of the schema. +using std::deque; +using std::endl; +using std::istream; +using std::ifstream; +using std::make_pair; +using std::map; +using std::multimap; +using std::ostream; +using std::pair; +using std::set; +using std::string; +using std::vector; + using boost::shared_ptr; using boost::lexical_cast; -using namespace std; int const one_row = 1; int const one_col = 1; @@ -69,11 +81,11 @@ { enum arg_type { text, blob }; arg_type type; - std::string data; + string data; }; query_param - text(std::string const & txt) + text(string const & txt) { query_param q = { query_param::text, @@ -83,7 +95,7 @@ } query_param - blob(std::string const & blb) + blob(string const & blb) { query_param q = { query_param::blob, @@ -98,7 +110,7 @@ struct query { - explicit query(std::string const & cmd) + explicit query(string const & cmd) : sql_cmd(cmd) {} @@ -111,8 +123,8 @@ return *this; } - std::vector args; - std::string sql_cmd; + vector args; + string sql_cmd; }; database::database(system_path const & fn) : @@ -214,7 +226,7 @@ data unpacked; const char *val = (const char*) sqlite3_value_blob(args[0]); int bytes = sqlite3_value_bytes(args[0]); - decode_gzip(gzip(std::string(val,val+bytes)), unpacked); + decode_gzip(gzip(string(val,val+bytes)), unpacked); sqlite3_result_blob(f, unpacked().c_str(), unpacked().size(), SQLITE_TRANSIENT); } @@ -229,12 +241,12 @@ { // sqlite 3 files begin with this constant string // (version 2 files begin with a different one) - std::string version_string("SQLite format 3"); + string version_string("SQLite format 3"); - std::ifstream file(filename.as_external().c_str()); + ifstream file(filename.as_external().c_str()); N(file, F("unable to probe database version in file %s") % filename); - for (std::string::const_iterator i = version_string.begin(); + for (string::const_iterator i = version_string.begin(); i != version_string.end(); ++i) { char c; @@ -265,7 +277,7 @@ } // note: if you update this, try to keep calculate_schema_id() in // schema_migration.cc consistent. - std::string auxiliary_message = ""; + string auxiliary_message = ""; if (errcode == SQLITE_ERROR) { auxiliary_message += _("make sure database and containing directory are writeable\n" @@ -344,7 +356,7 @@ }; static void -dump_row(std::ostream &out, sqlite3_stmt *stmt, std::string const& table_name) +dump_row(ostream &out, sqlite3_stmt *stmt, string const& table_name) { out << boost::format("INSERT INTO %s VALUES(") % table_name; unsigned n = sqlite3_data_count(stmt); @@ -358,7 +370,7 @@ out << "X'"; const char *val = (const char*) sqlite3_column_blob(stmt, i); int bytes = sqlite3_column_bytes(stmt, i); - out << encode_hexenc(std::string(val,val+bytes)); + out << encode_hexenc(string(val,val+bytes)); out << "'"; } else @@ -732,7 +744,7 @@ break; case query_param::blob: { - std::string const & data = idx(query.args, param - 1).data; + string const & data = idx(query.args, param - 1).data; sqlite3_bind_blob(i->second.stmt(), param, data.data(), data.size(), SQLITE_STATIC); @@ -757,7 +769,7 @@ const char * value = (const char*)sqlite3_column_blob(i->second.stmt(), col); int bytes = sqlite3_column_bytes(i->second.stmt(), col); E(value, F("null result in query: %s\n") % query.sql_cmd); - row.push_back(std::string(value, value + bytes)); + row.push_back(string(value, value + bytes)); //L(FL("row %d col %d value='%s'\n") % nrow % col % value); } res.push_back(row); @@ -1408,7 +1420,7 @@ } void -database::get_roster_links(std::map & links) +database::get_roster_links(map & links) { links.clear(); results res; @@ -1543,14 +1555,14 @@ void -database::get_revision_ancestry(std::multimap & graph) +database::get_revision_ancestry(multimap & graph) { results res; graph.clear(); fetch(res, 2, any_rows, query("SELECT parent,child FROM revision_ancestry")); for (size_t i = 0; i < res.size(); ++i) - graph.insert(std::make_pair(revision_id(res[i][0]), + graph.insert(make_pair(revision_id(res[i][0]), revision_id(res[i][1]))); } @@ -1637,7 +1649,7 @@ for (edge_map::const_iterator i = rev.edges.begin(); i != rev.edges.end(); ++i) { - for (std::map >::const_iterator + for (map >::const_iterator j = edge_changes(i).deltas_applied.begin(); j != edge_changes(i).deltas_applied.end(); ++j) { @@ -2140,8 +2152,8 @@ put_cert(cert.inner(), "revision_certs"); } -void database::get_revision_cert_nobranch_index(std::vector< std::pair, - std::pair > > & idx) +void database::get_revision_cert_nobranch_index(vector< pair, + pair > > & idx) { results res; fetch(res, 3, any_rows, @@ -2152,9 +2164,9 @@ idx.reserve(res.size()); for (results::const_iterator i = res.begin(); i != res.end(); ++i) { - idx.push_back(std::make_pair(hexenc((*i)[0]), - std::make_pair(revision_id((*i)[1]), - rsa_keypair_id((*i)[2])))); + idx.push_back(make_pair(hexenc((*i)[0]), + make_pair(revision_id((*i)[1]), + rsa_keypair_id((*i)[2])))); } } @@ -2591,7 +2603,7 @@ // epochs void -database::get_epochs(std::map & epochs) +database::get_epochs(map & epochs) { epochs.clear(); results res; @@ -2600,7 +2612,7 @@ { cert_value decoded(idx(*i, 0)); I(epochs.find(decoded) == epochs.end()); - epochs.insert(std::make_pair(decoded, epoch_data(idx(*i, 1)))); + epochs.insert(make_pair(decoded, epoch_data(idx(*i, 1)))); } } @@ -2663,7 +2675,7 @@ // vars void -database::get_vars(std::map & vars) +database::get_vars(map & vars) { vars.clear(); results res; @@ -2673,8 +2685,8 @@ var_domain domain(idx(*i, 0)); var_name name(idx(*i, 1)); var_value value(idx(*i, 2)); - I(vars.find(std::make_pair(domain, name)) == vars.end()); - vars.insert(std::make_pair(std::make_pair(domain, name), value)); + I(vars.find(make_pair(domain, name)) == vars.end()); + vars.insert(make_pair(make_pair(domain, name), value)); } } @@ -2682,9 +2694,9 @@ database::get_var(var_key const & key, var_value & value) { // FIXME: sillyly inefficient. Doesn't really matter, though. - std::map vars; + map vars; get_vars(vars); - std::map::const_iterator i = vars.find(key); + map::const_iterator i = vars.find(key); I(i != vars.end()); value = i->second; } @@ -2693,9 +2705,9 @@ database::var_exists(var_key const & key) { // FIXME: sillyly inefficient. Doesn't really matter, though. - std::map vars; + map vars; get_vars(vars); - std::map::const_iterator i = vars.find(key); + map::const_iterator i = vars.find(key); return i != vars.end(); } @@ -2837,12 +2849,12 @@ schedule_write(data_table, new_id.inner(), new_data.inner()); - std::set parents; + set parents; get_revision_parents(rev_id, parents); // Now do what deltify would do if we bothered (we have the // roster written now, so might as well do it here). - for (std::set::const_iterator i = parents.begin(); + for (set::const_iterator i = parents.begin(); i != parents.end(); ++i) { if (null_id(*i)) ============================================================ --- database_check.cc 91784581512b6a22dba4959fd46076f8ac2d18b6 +++ database_check.cc 1354e4948560a3e9197df485a0d6d4208c7d442c @@ -29,8 +29,11 @@ // files // -using std::set; +using std::logic_error; using std::map; +using std::multimap; +using std::set; +using std::string; using std::vector; struct checked_cert { @@ -101,10 +104,10 @@ bool parseable; // read_revision_set does not throw bool normalized; // write_revision_set( read_revision_set(dat) ) == dat - std::string history_error; + string history_error; - std::set parents; - std::vector checked_certs; + set parents; + vector checked_certs; checked_revision(): found(false), @@ -127,16 +130,16 @@ } static void -check_files(app_state & app, std::map & checked_files) +check_files(app_state & app, map & checked_files) { - std::set files; + set files; app.db.get_file_ids(files); L(FL("checking %d files\n") % files.size()); ticker ticks(_("files"), "f", files.size()/70+1); - for (std::set::const_iterator i = files.begin(); + for (set::const_iterator i = files.begin(); i != files.end(); ++i) { L(FL("checking file %s\n") % *i); @@ -153,10 +156,10 @@ // roster, and general parsability/normalisation static void check_rosters_manifest(app_state & app, - std::map & checked_rosters, - std::map & checked_revisions, - std::set & found_manifests, - std::map & checked_files) + map & checked_rosters, + map & checked_revisions, + set & found_manifests, + map & checked_files) { set rosters; @@ -180,7 +183,7 @@ { read_roster_and_marking(dat, ros, mm); } - catch (std::logic_error & e) + catch (logic_error & e) { L(FL("error parsing roster %s: %s") % *i % e.what()); checked_rosters[*i].parseable = false; @@ -225,14 +228,14 @@ // that the referenced revisions exist. static void check_rosters_marking(app_state & app, - std::map & checked_rosters, - std::map & checked_revisions) + map & checked_rosters, + map & checked_revisions) { L(FL("checking %d rosters, marking pass\n") % checked_rosters.size()); ticker ticks(_("markings"), "m", checked_rosters.size()/70+1); - for (std::map::const_iterator i + for (map::const_iterator i = checked_rosters.begin(); i != checked_rosters.end(); i++) { roster_id ros_id = i->first; @@ -288,28 +291,28 @@ static void check_roster_links(app_state & app, - std::map & checked_revisions, - std::map & checked_rosters, + map & checked_revisions, + map & checked_rosters, size_t & unreferenced_roster_links, size_t & missing_rosters) { unreferenced_roster_links = 0; - std::map links; + map links; app.db.get_roster_links(links); - for (std::map::const_iterator i = links.begin(); + for (map::const_iterator i = links.begin(); i != links.end(); ++i) { revision_id rev(i->first); roster_id ros(i->second); - std::map::const_iterator j + map::const_iterator j = checked_revisions.find(rev); if (j == checked_revisions.end() || (!j->second.found)) ++unreferenced_roster_links; - std::map::const_iterator k + map::const_iterator k = checked_rosters.find(ros); if (k == checked_rosters.end() || (!k->second.found)) ++missing_rosters; @@ -319,18 +322,18 @@ static void check_revisions(app_state & app, - std::map & checked_revisions, - std::map & checked_rosters, - std::set const & found_manifests) + map & checked_revisions, + map & checked_rosters, + set const & found_manifests) { - std::set revisions; + set revisions; app.db.get_revision_ids(revisions); L(FL("checking %d revisions\n") % revisions.size()); ticker ticks(_("revisions"), "r", revisions.size()/70+1); - for (std::set::const_iterator i = revisions.begin(); + for (set::const_iterator i = revisions.begin(); i != revisions.end(); ++i) { L(FL("checking revision %s\n") % *i); @@ -343,7 +346,7 @@ { read_revision_set(data, rev); } - catch (std::logic_error & e) + catch (logic_error & e) { L(FL("error parsing revision %s: %s") % *i % e.what()); checked_revisions[*i].parseable = false; @@ -401,11 +404,11 @@ // now check for parent revision existence and problems - for (std::map::iterator + for (map::iterator revision = checked_revisions.begin(); revision != checked_revisions.end(); ++revision) { - for (std::set::const_iterator p = revision->second.parents.begin(); + for (set::const_iterator p = revision->second.parents.begin(); p != revision->second.parents.end(); ++p) { if (!checked_revisions[*p].found) @@ -420,9 +423,9 @@ static void check_ancestry(app_state & app, - std::map & checked_revisions) + map & checked_revisions) { - std::multimap graph; + multimap graph; app.db.get_revision_ancestry(graph); L(FL("checking %d ancestry edges\n") % graph.size()); @@ -433,8 +436,8 @@ // graph has revision and associated parents // these two representations of the graph should agree! - std::set seen; - for (std::multimap::const_iterator i = graph.begin(); + set seen; + for (multimap::const_iterator i = graph.begin(); i != graph.end(); ++i) { // ignore the [] -> [...] edges here too @@ -452,9 +455,9 @@ static void check_keys(app_state & app, - std::map & checked_keys) + map & checked_keys) { - std::vector pubkeys; + vector pubkeys; app.db.get_public_keys(pubkeys); @@ -462,7 +465,7 @@ ticker ticks(_("keys"), "k", 1); - for (std::vector::const_iterator i = pubkeys.begin(); + for (vector::const_iterator i = pubkeys.begin(); i != pubkeys.end(); ++i) { app.db.get_key(*i, checked_keys[*i].pub_encoded); @@ -474,12 +477,12 @@ static void check_certs(app_state & app, - std::map & checked_revisions, - std::map & checked_keys, + map & checked_revisions, + map & checked_keys, size_t & total_certs) { - std::vector< revision > certs; + vector< revision > certs; app.db.get_revision_certs(certs); total_certs = certs.size(); @@ -488,7 +491,7 @@ ticker ticks(_("certs"), "c", certs.size()/70+1); - for (std::vector< revision >::const_iterator i = certs.begin(); + for (vector< revision >::const_iterator i = certs.begin(); i != certs.end(); ++i) { checked_cert checked(*i); @@ -496,7 +499,7 @@ if (checked.found_key) { - std::string signed_text; + string signed_text; cert_signable_text(i->inner(), signed_text); checked.good_sig = check_signature(app, i->inner().key, checked_keys[i->inner().key].pub_encoded, @@ -511,11 +514,11 @@ } static void -report_files(std::map const & checked_files, +report_files(map const & checked_files, size_t & missing_files, size_t & unreferenced_files) { - for (std::map::const_iterator + for (map::const_iterator i = checked_files.begin(); i != checked_files.end(); ++i) { checked_file file = i->second; @@ -537,13 +540,13 @@ } static void -report_rosters(std::map const & checked_rosters, +report_rosters(map const & checked_rosters, size_t & unreferenced_rosters, size_t & incomplete_rosters, size_t & non_parseable_rosters, size_t & non_normalized_rosters) { - for (std::map::const_iterator + for (map::const_iterator i = checked_rosters.begin(); i != checked_rosters.end(); ++i) { checked_roster roster = i->second; @@ -585,7 +588,7 @@ } static void -report_revisions(std::map const & checked_revisions, +report_revisions(map const & checked_revisions, size_t & missing_revisions, size_t & incomplete_revisions, size_t & mismatched_parents, @@ -595,7 +598,7 @@ size_t & non_parseable_revisions, size_t & non_normalized_revisions) { - for (std::map::const_iterator + for (map::const_iterator i = checked_revisions.begin(); i != checked_revisions.end(); ++i) { checked_revision revision = i->second; @@ -667,7 +670,7 @@ if (!revision.history_error.empty()) { bad_history++; - std::string tmp = revision.history_error; + string tmp = revision.history_error; if (tmp[tmp.length() - 1] == '\n') tmp.erase(tmp.length() - 1); P(F("revision %s has bad history (%s)\n") @@ -691,10 +694,10 @@ } static void -report_keys(std::map const & checked_keys, +report_keys(map const & checked_keys, size_t & missing_keys) { - for (std::map::const_iterator + for (map::const_iterator i = checked_keys.begin(); i != checked_keys.end(); ++i) { checked_key key = i->second; @@ -716,26 +719,26 @@ } static void -report_certs(std::map const & checked_revisions, +report_certs(map const & checked_revisions, size_t & missing_certs, size_t & mismatched_certs, size_t & unchecked_sigs, size_t & bad_sigs) { - std::set cnames; + set cnames; cnames.insert(cert_name(author_cert_name)); cnames.insert(cert_name(branch_cert_name)); cnames.insert(cert_name(changelog_cert_name)); cnames.insert(cert_name(date_cert_name)); - for (std::map::const_iterator + for (map::const_iterator i = checked_revisions.begin(); i != checked_revisions.end(); ++i) { checked_revision revision = i->second; - std::map cert_counts; + map cert_counts; - for (std::vector::const_iterator checked = revision.checked_certs.begin(); + for (vector::const_iterator checked = revision.checked_certs.begin(); checked != revision.checked_certs.end(); ++checked) { if (!checked->found_key) @@ -758,7 +761,7 @@ cert_counts[checked->rcert.inner().name]++; } - for (std::set::const_iterator n = cnames.begin(); + for (set::const_iterator n = cnames.begin(); n != cnames.end(); ++n) { if (revision.found && cert_counts[*n] == 0) @@ -786,11 +789,11 @@ void check_db(app_state & app) { - std::map checked_files; - std::set found_manifests; - std::map checked_rosters; - std::map checked_revisions; - std::map checked_keys; + map checked_files; + set found_manifests; + map checked_rosters; + map checked_revisions; + map checked_keys; size_t missing_files = 0; size_t unreferenced_files = 0; ============================================================ --- diff_patch.cc c538374230aa5c4eb9c455418cfa55e443af7244 +++ diff_patch.cc 830fa80815a651ce2a0d371aa7ee82ab78410845 @@ -29,7 +29,16 @@ #include "constants.hh" #include "localized_file_io.hh" -using namespace std; +using std::endl; +using std::make_pair; +using std::map; +using std::min; +using std::ostream; +using std::ostream_iterator; +using std::string; +using std::swap; +using std::vector; + using boost::shared_ptr; // @@ -364,9 +373,9 @@ vector merged_interned; interner in; - // for (int i = 0; i < std::min(std::min(left.size(), right.size()), ancestor.size()); ++i) + // for (int i = 0; i < min(min(left.size(), right.size()), ancestor.size()); ++i) // { - // std::cerr << "[" << i << "] " << left[i] << " " << ancestor[i] << " " << right[i] << endl; + // cerr << "[" << i << "] " << left[i] << " " << ancestor[i] << " " << right[i] << endl; // } anc_interned.reserve(ancestor.size()); @@ -389,7 +398,7 @@ edit_script(anc_interned.begin(), anc_interned.end(), left_interned.begin(), left_interned.end(), - std::min(ancestor.size(), left.size()), + min(ancestor.size(), left.size()), left_edits); L(FL("calculating right edit script on %d -> %d lines\n") @@ -397,7 +406,7 @@ edit_script(anc_interned.begin(), anc_interned.end(), right_interned.begin(), right_interned.end(), - std::min(ancestor.size(), right.size()), + min(ancestor.size(), right.size()), right_edits); L(FL("calculating left extents on %d edits\n") % left_edits.size()); @@ -619,7 +628,7 @@ adaptor(adaptor) {} -std::string +string content_merger::get_file_encoding(file_path const & path, roster_t const & ros) { @@ -1121,10 +1130,10 @@ i != lines2.end(); ++i) right_interned.push_back(in.intern(*i)); - lcs.reserve(std::min(lines1.size(),lines2.size())); + lcs.reserve(min(lines1.size(),lines2.size())); longest_common_subsequence(left_interned.begin(), left_interned.end(), right_interned.begin(), right_interned.end(), - std::min(lines1.size(), lines2.size()), + min(lines1.size(), lines2.size()), back_inserter(lcs)); switch (type) @@ -1162,6 +1171,10 @@ #include #include "randomfile.hh" +using std::cerr; +using std::cout; +using std::stringstream; + using boost::lexical_cast; static void dump_incorrect_merge(vector const & expected, @@ -1243,7 +1256,7 @@ file_id(id("0123456789abcdef0123456789abcdef01234567")), file_id(id("abcdef0123456789abcdef0123456789abcdef01")), src_lines, dst_lines, sst, unified_diff); - cout << sst.str() << std::endl; + cout << sst.str() << endl; BOOST_CHECK(sst.str() == ud); } ============================================================ --- enumerator.cc 43edc729be97fabc35880f79fbea7640d109bea0 +++ enumerator.cc e2ebd144f9f66f1dab7a5324c62e2f7d73eb4646 @@ -13,7 +13,6 @@ #include "revision.hh" #include "vocab.hh" -using std::deque; using std::make_pair; using std::map; using std::multimap; @@ -130,7 +129,7 @@ } // Queue up all the file-deltas - for (map >::const_iterator fd + for (map >::const_iterator fd = cs.deltas_applied.begin(); fd != cs.deltas_applied.end(); ++fd) { @@ -179,13 +178,13 @@ revision_enumerator::note_cert(revision_id const & rid, hexenc const & cert_hash) { - revision_certs.insert(std::make_pair(rid, cert_hash)); + revision_certs.insert(make_pair(rid, cert_hash)); } void revision_enumerator::get_revision_certs(revision_id const & rid, - std::vector > & hashes) + vector > & hashes) { hashes.clear(); bool found_one = false; ============================================================ --- epoch.cc 54bd9b44a5daae23e9b188fec591acf6c79bcf90 +++ epoch.cc b150f9d678d4fba5c2b35c4932a1a04a7c4564c0 @@ -10,12 +10,14 @@ #include +using std::string; + void -read_epoch(std::string const & in, +read_epoch(string const & in, cert_value & branch, epoch_data & epoch) { size_t pos = 0; - std::string raw_branch; + string raw_branch; data raw_epoch; extract_variable_length_string(in, raw_branch, pos, "epoch, branch name"); raw_epoch = data(extract_substring(in, pos, constants::epochlen_bytes, @@ -28,7 +30,7 @@ void write_epoch(cert_value const & branch, epoch_data const & epoch, - std::string & out) + string & out) { insert_variable_length_string(branch(), out); data raw_epoch; @@ -40,7 +42,7 @@ epoch_hash_code(cert_value const & branch, epoch_data const & epoch, epoch_id & eid) { - std::string tmp(branch() + ":" + epoch.inner()()); + string tmp(branch() + ":" + epoch.inner()()); data tdat(tmp); hexenc out; calculate_ident(tdat, out); ============================================================ --- file_io.cc 7fc3a9cac7cb770a2a4fa826d3a23797cda1242e +++ file_io.cc 758cd915fad8ada25a51dbce3d0565ed68de0895 @@ -22,7 +22,13 @@ // this file deals with talking to the filesystem, loading and // saving files. -using namespace std; +using std::cin; +using std::ifstream; +using std::ios_base; +using std::ofstream; +using std::runtime_error; +using std::string; +using std::vector; void assert_path_is_nonexistent(any_path const & path) @@ -297,8 +303,8 @@ } void read_directory(any_path const & path, - std::vector & files, - std::vector & dirs) + vector & files, + vector & dirs) { files.clear(); dirs.clear(); @@ -446,7 +452,7 @@ // FIXME: BUG: this screws up charsets p = file_path_internal(rel_entry.normalize().string()); } - catch (std::runtime_error const & c) + catch (runtime_error const & c) { W(F("caught runtime error %s constructing file path for %s\n") % c.what() % rel_entry.string()); ============================================================ --- globish.cc 93e5d9dfe7630bf765164f90363c7d30cc9e4e01 +++ globish.cc 409df5d1f8ff0ad46a144ed6f1344418185d54dc @@ -7,6 +7,11 @@ #include "sanity.hh" #include "globish.hh" +using std::string; +using std::vector; + +using boost::regex_match; + // this converts a globish pattern to a regex. The regex should be usable by // the Boost regex library operating in default mode, i.e., it should be a // valid ECMAscript regex. @@ -29,7 +34,7 @@ // unescaped [. // - ] directly following an unescaped [ is escaped. static void -maybe_quote(char c, std::string & re) +maybe_quote(char c, string & re) { if (!(isalnum(c) || c == '_')) { @@ -39,7 +44,7 @@ } static void -checked_globish_to_regex(std::string const & glob, std::string & regex) +checked_globish_to_regex(string const & glob, string & regex) { int in_braces = 0; // counter for levels if {} @@ -53,7 +58,7 @@ regex = "$.^"; // and the below loop will do nothing } - for (std::string::const_iterator i = glob.begin(); i != glob.end(); ++i) + for (string::const_iterator i = glob.begin(); i != glob.end(); ++i) { char c = *i; @@ -100,15 +105,15 @@ } void -combine_and_check_globish(std::vector const & patterns, utf8 & pattern) +combine_and_check_globish(vector const & patterns, utf8 & pattern) { - std::string p; + string p; if (patterns.size() > 1) p += '{'; bool first = true; - for (std::vector::const_iterator i = patterns.begin(); i != patterns.end(); ++i) + for (vector::const_iterator i = patterns.begin(); i != patterns.end(); ++i) { - std::string tmp; + string tmp; // run for the checking it does checked_globish_to_regex((*i)(), tmp); if (!first) @@ -123,7 +128,7 @@ globish_matcher::globish_matcher(utf8 const & include_pat, utf8 const & exclude_pat) { - std::string re; + string re; checked_globish_to_regex(include_pat(), re); r_inc = re; checked_globish_to_regex(exclude_pat(), re); @@ -131,12 +136,12 @@ } bool -globish_matcher::operator()(std::string const & s) +globish_matcher::operator()(string const & s) { - // regex_match may throw a std::runtime_error, if the regex turns out to be + // regex_match may throw a runtime_error, if the regex turns out to be // really pathological - bool inc_match = boost::regex_match(s, r_inc); - bool exc_match = boost::regex_match(s, r_exc); + bool inc_match = regex_match(s, r_inc); + bool exc_match = regex_match(s, r_exc); bool result = inc_match && !exc_match; L(FL("matching '%s' against '%s' excluding '%s': %s, %s: %s\n") % s % r_inc % r_exc @@ -152,7 +157,7 @@ static void checked_globish_to_regex_test() { - std::string pat; + string pat; checked_globish_to_regex("*", pat); BOOST_CHECK(pat == ".*"); @@ -184,7 +189,7 @@ static void combine_and_check_globish_test() { - std::vector s; + vector s; s.push_back(utf8("a")); s.push_back(utf8("b")); s.push_back(utf8("c")); ============================================================ --- hmac.cc 01430adfa6339a539db4327741755a05191bab7b +++ hmac.cc 3884bf3dd20a12ec2023bc4f5fb6b60eaca69fd6 @@ -7,6 +7,8 @@ #include "vocab.hh" #include "constants.hh" +using std::string; + chained_hmac::chained_hmac(netsync_session_key const & session_key) : hmac_length(constants::sha1_digest_length), key(reinterpret_cast(session_key().data()), session_key().size()) @@ -21,11 +23,11 @@ session_key().size()); } -std::string -chained_hmac::process(std::string const & str, size_t pos, size_t n) +string +chained_hmac::process(string const & str, size_t pos, size_t n) { I(pos < str.size()); - if (n == std::string::npos) + if (n == string::npos) n = str.size() - pos; I(pos + n <= str.size()); @@ -43,11 +45,11 @@ return chain_val; } -std::string +string chained_hmac::process(string_queue const & str, size_t pos, size_t n) { I(pos < str.size()); - if (n == std::string::npos) + if (n == string::npos) n = str.size() - pos; I(pos + n <= str.size()); ============================================================ --- inodeprint.cc 49cfddcee6a39755d3d2f8d6c2bc7fb49c5a556d +++ inodeprint.cc 62b091111b84a22f6de804b3c9d37716e7a06169 @@ -17,6 +17,10 @@ #include "platform.hh" #include "constants.hh" +using std::ostream; +using std::ostringstream; +using std::string; + // this file defines the inodeprint_map structure, and some operations on it. // it is currently heavily based on the old manifest.cc. @@ -26,18 +30,18 @@ read_inodeprint_map(data const & dat, inodeprint_map & ipm) { - std::string::size_type pos = 0; + string::size_type pos = 0; while (pos != dat().size()) { // whenever we get here, pos points to the beginning of a inodeprint // line // inodeprint file has 40 characters hash, then 2 characters space, then // everything until next \n is filename. - std::string ident = dat().substr(pos, constants::idlen); - std::string::size_type file_name_begin = pos + constants::idlen + 2; + string ident = dat().substr(pos, constants::idlen); + string::size_type file_name_begin = pos + constants::idlen + 2; pos = dat().find('\n', file_name_begin); - std::string file_name; - if (pos == std::string::npos) + string file_name; + if (pos == string::npos) file_name = dat().substr(file_name_begin); else file_name = dat().substr(file_name_begin, pos - file_name_begin); @@ -51,8 +55,8 @@ // writing inodeprint_maps -std::ostream & -operator<<(std::ostream & out, inodeprint_entry const & e) +ostream & +operator<<(ostream & out, inodeprint_entry const & e) { return (out << e.second << " " << e.first << "\n"); } @@ -62,7 +66,7 @@ write_inodeprint_map(inodeprint_map const & ipm, data & dat) { - std::ostringstream sstr; + ostringstream sstr; for (inodeprint_map::const_iterator i = ipm.begin(); i != ipm.end(); ++i) sstr << *i; ============================================================ --- key_store.cc 7a33f02a482db43ad119b210848f3fdb9a306ba0 +++ key_store.cc dcdebf60e129b121b78cc0f2c53e3c7a19cf69a9 @@ -6,6 +6,14 @@ #include "keys.hh" #include "globish.hh" +using std::make_pair; +using std::istringstream; +using std::map; +using std::ostringstream; +using std::pair; +using std::string; +using std::vector; + struct keyreader : public packet_consumer { key_store * ks; @@ -36,10 +44,10 @@ L(FL("reading key pair '%s' from key store") % ident); E(!ks->key_pair_exists(ident), F("Key store has multiple keys with id '%s'.") % ident); - ks->keys.insert(std::make_pair(ident, kp)); + ks->keys.insert(make_pair(ident, kp)); hexenc hash; key_hash_code(ident, kp.pub, hash); - ks->hashes.insert(std::make_pair(hash, ident)); + ks->hashes.insert(make_pair(hash, ident)); L(FL("successfully read key pair '%s' from key store") % ident); } }; @@ -63,7 +71,7 @@ void key_store::read_key_dir() { - std::vector key_files, dirs; + vector key_files, dirs; if (directory_exists(key_dir)) { L(FL("reading key dir '%s'") % key_dir); @@ -72,13 +80,13 @@ else L(FL("key dir '%s' does not exist") % key_dir); keyreader kr(this); - for (std::vector::const_iterator i = key_files.begin(); + for (vector::const_iterator i = key_files.begin(); i != key_files.end(); ++i) { L(FL("reading keys from file '%s'") % (*i)); data dat; read_data(key_dir / (*i)(), dat); - std::istringstream is(dat()); + istringstream is(dat()); read_packets(is, kr, *app); } } @@ -101,7 +109,7 @@ L(FL("public key '%s' is already in db, not loading") % ident); return; } - std::map::iterator i = keys.find(ident); + map::iterator i = keys.find(ident); I(i != keys.end()); app->db.put_key(ident, i->second.pub); L(FL("loaded public key '%s' into db") % ident); @@ -110,7 +118,7 @@ bool key_store::try_ensure_in_db(hexenc const & hash) { - std::map, rsa_keypair_id>::const_iterator i = hashes.find(hash); + map, rsa_keypair_id>::const_iterator i = hashes.find(hash); if (i == hashes.end()) return false; ensure_in_database(i->second); @@ -118,8 +126,8 @@ } void -key_store::get_key_ids(std::string const & pattern, - std::vector & priv) +key_store::get_key_ids(string const & pattern, + vector & priv) { maybe_read_key_dir(); priv.clear(); @@ -127,7 +135,7 @@ if (pattern.empty()) inc = utf8("*"); globish_matcher gm(inc, utf8("")); - for (std::map::const_iterator + for (map::const_iterator i = keys.begin(); i != keys.end(); ++i) { if (gm((i->first)())) @@ -136,11 +144,11 @@ } void -key_store::get_keys(std::vector & priv) +key_store::get_keys(vector & priv) { maybe_read_key_dir(); priv.clear(); - for (std::map::const_iterator + for (map::const_iterator i = keys.begin(); i != keys.end(); ++i) { priv.push_back(i->first); @@ -159,7 +167,7 @@ keypair & kp) { maybe_read_key_dir(); - std::map::const_iterator i = keys.find(ident); + map::const_iterator i = keys.find(ident); I(i != keys.end()); kp = i->second; } @@ -169,11 +177,11 @@ // filename is the keypair id, except that some characters can't be put in // filenames (especially on windows). void - get_filename(rsa_keypair_id const & ident, std::string & filename) + get_filename(rsa_keypair_id const & ident, string & filename) { filename = ident(); for (unsigned int i = 0; i < filename.size(); ++i) - if (std::string("+").find(filename[i]) != std::string::npos) + if (string("+").find(filename[i]) != string::npos) filename.at(i) = '_'; } } @@ -182,7 +190,7 @@ key_store::get_key_file(rsa_keypair_id const & ident, system_path & file) { - std::string leaf; + string leaf; get_filename(ident, leaf); file = key_dir / leaf; } @@ -192,7 +200,7 @@ { keypair kp; get_key_pair(ident, kp); - std::ostringstream oss; + ostringstream oss; packet_writer pw(oss); pw.consume_key_pair(ident, kp); data dat(oss.str()); @@ -208,13 +216,13 @@ { maybe_read_key_dir(); L(FL("putting key pair '%s'") % ident); - std::pair::iterator, bool> res; - res = keys.insert(std::make_pair(ident, kp)); + pair::iterator, bool> res; + res = keys.insert(make_pair(ident, kp)); if (res.second) { hexenc hash; key_hash_code(ident, kp.pub, hash); - I(hashes.insert(std::make_pair(hash, ident)).second); + I(hashes.insert(make_pair(hash, ident)).second); write_key(ident); } else @@ -230,12 +238,12 @@ key_store::delete_key(rsa_keypair_id const & ident) { maybe_read_key_dir(); - std::map::iterator i = keys.find(ident); + map::iterator i = keys.find(ident); if (i != keys.end()) { hexenc hash; key_hash_code(ident, i->second.pub, hash); - std::map, rsa_keypair_id>::iterator j = hashes.find(hash); + map, rsa_keypair_id>::iterator j = hashes.find(hash); I(j != hashes.end()); hashes.erase(j); keys.erase(i); ============================================================ --- keys.cc ab0e49cae3664e3aa8f52c652e0825dea72de281 +++ keys.cc bfdcb803f58119ab0c399b553bd69e35fc6e47ce @@ -24,6 +24,9 @@ #include "cert.hh" #include "app_state.hh" +using std::map; +using std::string; + // copyright (C) 2002, 2003, 2004 graydon hoare // all rights reserved. // licensed to the public under the terms of the GNU GPL (>= 2) @@ -65,7 +68,7 @@ // you're making a half-dozen certs during a commit or merge or // something. bool persist_phrase = lua.hook_persist_phrase_ok(); - static std::map phrases; + static map phrases; if (!force_from_user && phrases.find(keyid) != phrases.end()) { @@ -419,7 +422,7 @@ void encrypt_rsa(lua_hooks & lua, rsa_keypair_id const & id, base64 & pub_encoded, - std::string const & plaintext, + string const & plaintext, rsa_oaep_sha_data & ciphertext) { rsa_pub_key pub; @@ -445,7 +448,7 @@ rsa_keypair_id const & id, base64< rsa_priv_key > const & priv, rsa_oaep_sha_data const & ciphertext, - std::string & plaintext) + string & plaintext) { shared_ptr priv_key = get_private_key(lua, id, priv); ============================================================ --- lcs.cc fd29f8174a6718842724caece25b5ea753da1a04 +++ lcs.cc 6c1c76404a788927308bff3b8f52d52f8ae1c12a @@ -45,11 +45,20 @@ #include #include "sanity.hh" +using std::back_inserter; +using std::back_insert_iterator; +using std::copy; +using std::iterator_traits; +using std::max; +using std::min; +using std::sort; +using std::vector; + struct work_vec { long lo; long hi; - static std::vector vec; + static vector vec; work_vec(long lo, long hi) : lo(lo), hi(hi) { @@ -66,7 +75,7 @@ } }; -std::vector work_vec::vec; +vector work_vec::vec; template cost_vec; - typedef std::vector edit_vec; + typedef vector cost_vec; + typedef vector edit_vec; template struct subarray { - typedef typename std::iterator_traits::value_type vt; + typedef typename iterator_traits::value_type vt; T base; // underlying representation long start; // current extent @@ -99,7 +108,7 @@ inline subarray subset(long s, long e) const { - return subarray(base + std::min(start, end), s, e); + return subarray(base + min(start, end), s, e); } inline vt const & operator[](size_t idx) const @@ -119,7 +128,7 @@ long cost = k + 2*p; // do the run - long y = std::max(fp[k-1]+1, fp[k+1]); + long y = max(fp[k-1]+1, fp[k+1]); long x = y - k; I(y >= 0); @@ -131,7 +140,7 @@ long xcst = m - x; if (y < static_cast(CC.size()) && xcst >= 0) { - CC[y] = std::min(xcst + cost, CC[y]); + CC[y] = min(xcst + cost, CC[y]); } if (x < m && y < n && a[x] == b[y]) { @@ -211,11 +220,11 @@ compare (cc, a.subset(start_a, mid_a), (mid_a - start_a), - b.subset(start_b, end_b), len_b, std::min(p_lim, len_a)); + b.subset(start_b, end_b), len_b, min(p_lim, len_a)); compare (rr, a.subset(end_a, mid_a), (end_a - mid_a), - b.subset(end_b, start_b), len_b, std::min(p_lim, len_a)); + b.subset(end_b, start_b), len_b, min(p_lim, len_a)); long b_split = mid_split(len_a, len_b, rr, cc, tcst); @@ -275,11 +284,11 @@ } edit_vec sedits = edits; - std::sort(sedits.begin(), sedits.end()); + sort(sedits.begin(), sedits.end()); long idx0; for (idx0 = 0; idx0 < cost && sedits[idx0] < 0; ++idx0); - long len_a = std::max(0L, -sedits[0]); + long len_a = max(0L, -sedits[0]); long len_b = sedits[cost-1]; long ddx = idx0 - 1; @@ -321,7 +330,7 @@ // trims and calls diff_to_ez static long diff_to_et(subarray const & a, long start_a, long end_a, subarray const & b, long start_b, long end_b, - std::vector & edits, + vector & edits, long edx, long polarity, long p_lim) @@ -363,7 +372,7 @@ static long diff_to_ez(subarray const & a, long start_a, long end_a, subarray const & b, long start_b, long end_b, - std::vector & edits, + vector & edits, long edx1, long polarity, long p_lim) @@ -447,7 +456,7 @@ static void diff_to_edits(subarray const & a, long m, subarray const & b, long n, - std::vector & edits, + vector & edits, long p_lim) { I(m <= n); @@ -462,13 +471,13 @@ I(cost == edit_distance); } - static void edits_to_lcs (std::vector const & edits, + static void edits_to_lcs (vector const & edits, subarray const a, long m, long n, LCS output) { long edx = 0, sdx = 0, adx = 0; - typedef typename std::iterator_traits::value_type vt; - std::vector lcs(((m + n) - edits.size()) / 2); + typedef typename iterator_traits::value_type vt; + vector lcs(((m + n) - edits.size()) / 2); while (true) { long edit = (edx < static_cast(edits.size())) ? edits[edx] : 0; @@ -485,7 +494,7 @@ { lcs[sdx++] = a[adx++]; } } - std::copy(lcs.begin(), lcs.end(), output); + copy(lcs.begin(), lcs.end(), output); } }; @@ -496,7 +505,7 @@ void _edit_script(A begin_a, A end_a, B begin_b, B end_b, long p_lim, - std::vector & edits_out, + vector & edits_out, LCS ignored_out) { typedef jaffer_edit_calculator calc_t; @@ -558,12 +567,12 @@ void -longest_common_subsequence(std::vector::const_iterator begin_a, - std::vector::const_iterator end_a, - std::vector::const_iterator begin_b, - std::vector::const_iterator end_b, +longest_common_subsequence(vector::const_iterator begin_a, + vector::const_iterator end_a, + vector::const_iterator begin_b, + vector::const_iterator end_b, long p_lim, - std::back_insert_iterator< std::vector > lcs) + back_insert_iterator< vector > lcs) { _longest_common_subsequence(begin_a, end_a, begin_b, end_b, @@ -571,14 +580,14 @@ } void -edit_script(std::vector::const_iterator begin_a, - std::vector::const_iterator end_a, - std::vector::const_iterator begin_b, - std::vector::const_iterator end_b, +edit_script(vector::const_iterator begin_a, + vector::const_iterator end_a, + vector::const_iterator begin_b, + vector::const_iterator end_b, long p_lim, - std::vector & edits_out) + vector & edits_out) { - std::vector lcs; + vector lcs; _edit_script(begin_a, end_a, begin_b, end_b, p_lim, edits_out, ============================================================ --- legacy.cc 56eba9490503059bb62f34ca4d04007d3b56bbd5 +++ legacy.cc cb7eb7d67ccf5f3b3d762c3889a90f1e17509222 @@ -8,6 +8,9 @@ #include "app_state.hh" #include "constants.hh" +using std::make_pair; +using std::string; + namespace legacy { namespace @@ -26,7 +29,7 @@ basic_io::tokenizer tok(src); basic_io::parser parser(tok); - std::string file, name, value; + string file, name, value; attr.clear(); @@ -70,7 +73,7 @@ extract_renames(basic_io::parser & parser, renames_map & renames) { revision_id old_rev; - std::string tmp; + string tmp; parser.esym(syms::old_revision); parser.hex(tmp); old_rev = revision_id(tmp); @@ -90,7 +93,7 @@ else if (parser.symp(syms::rename_file) || parser.symp(syms::rename_dir)) { - std::string from_str, to_str; + string from_str, to_str; parser.sym(); parser.str(from_str); parser.esym(syms::to); @@ -128,7 +131,7 @@ basic_io::parser pars(tok); pars.esym(syms::new_manifest); - std::string tmp; + string tmp; pars.hex(tmp); mid = manifest_id(tmp); while (pars.symp(syms::old_revision)) @@ -141,23 +144,23 @@ manifest_map & man) { data const & dat = mdat.inner(); - std::string::size_type pos = 0; + string::size_type pos = 0; while (pos != dat().size()) { // whenever we get here, pos points to the beginning of a manifest // line // manifest file has 40 characters hash, then 2 characters space, then // everything until next \n is filename. - std::string ident = dat().substr(pos, constants::idlen); - std::string::size_type file_name_begin = pos + constants::idlen + 2; + string ident = dat().substr(pos, constants::idlen); + string::size_type file_name_begin = pos + constants::idlen + 2; pos = dat().find('\n', file_name_begin); - std::string file_name; - if (pos == std::string::npos) + string file_name; + if (pos == string::npos) file_name = dat().substr(file_name_begin); else file_name = dat().substr(file_name_begin, pos - file_name_begin); - man.insert(std::make_pair(file_path_internal(file_name), - hexenc(ident))); + man.insert(make_pair(file_path_internal(file_name), + hexenc(ident))); // skip past the '\n' ++pos; } ============================================================ --- lua.cc 8412d7a38d765381e449c100f085a2dbdca3ae63 +++ lua.cc 06e4a9aeca73e87a2617ff8df2d674646bf2cb8e @@ -32,25 +32,29 @@ #include #include +using std::ifstream; +using std::ios_base; +using std::pair; +using std::set; +using std::sort; using std::string; using std::vector; -using std::pair; // adapted from "programming in lua", section 24.2.3 // http://www.lua.org/pil/24.2.3.html // output is from bottom (least accessible) to top (most accessible, where // push and pop happen). -static std::string +static string dump_stack(lua_State * st) { - std::string out; + string out; int i; int top = lua_gettop(st); for (i = 1; i <= top; i++) { /* repeat for each level */ int t = lua_type(st, i); switch (t) { case LUA_TSTRING: /* strings */ - out += (boost::format("`%s'") % std::string(lua_tostring(st, i), lua_strlen(st, i))).str(); + out += (boost::format("`%s'") % string(lua_tostring(st, i), lua_strlen(st, i))).str(); break; case LUA_TBOOLEAN: /* booleans */ @@ -82,7 +86,7 @@ } void -Lua::fail(std::string const & reason) +Lua::fail(string const & reason) { L(FL("lua failure: %s; stack = %s\n") % reason % dump_stack(st)); failed = true; @@ -421,7 +425,7 @@ return *this; } -std::set Lua::missing_functions; +set Lua::missing_functions; @@ -434,7 +438,7 @@ int fd = -1; FILE **pf = NULL; char const *filename = luaL_checkstring (L, -1); - std::string dup(filename); + string dup(filename); fd = monotone_mkstemp(dup); @@ -545,7 +549,7 @@ const char *path = luaL_checkstring(L, -1); N(path, F("%s called with an invalid parameter") % "guess_binary"); - std::ifstream file(path, std::ios_base::binary); + ifstream file(path, ios_base::binary); if (!file) { lua_pushnil(L); @@ -575,7 +579,7 @@ N(path, F("%s called with an invalid parameter") % "Include"); bool res =Lua(L) - .loadfile(std::string(path, lua_strlen(L, -1))) + .loadfile(string(path, lua_strlen(L, -1))) .call(0,1) .ok(); @@ -596,15 +600,15 @@ // directory, iterate over it, skipping subdirs, taking every filename, // sorting them and loading in sorted order fs::directory_iterator it(locpath); - std::vector arr; + vector arr; while (it != fs::directory_iterator()) { if (!fs::is_directory(*it)) arr.push_back(*it); ++it; } - std::sort(arr.begin(), arr.end()); - for (std::vector::iterator i= arr.begin(); i != arr.end(); ++i) + sort(arr.begin(), arr.end()); + for (vector::iterator i= arr.begin(); i != arr.end(); ++i) { bool res =Lua(L) .loadfile(i->string()) ============================================================ --- lua_hooks.cc 2c8a4626208b7b0128a96da8ea532f7d3fce0e85 +++ lua_hooks.cc 348229d0b87e5aad59d452c8dea3f26ca9481031 @@ -35,7 +35,14 @@ #include "test_hooks.h" #include "std_hooks.h" -using namespace std; +using std::make_pair; +using std::map; +using std::pair; +using std::set; +using std::sort; +using std::string; +using std::vector; + using boost::lexical_cast; static int panic_thrower(lua_State * st) @@ -49,7 +56,7 @@ // the command line (and so known only to the app_state), and still be // available to lua // please *don't* use it for complex things that can throw errors -static std::map map_of_lua_to_app; +static map map_of_lua_to_app; extern "C" { @@ -155,15 +162,15 @@ // directory, iterate over it, skipping subdirs, taking every filename, // sorting them and loading in sorted order fs::directory_iterator it(locpath); - std::vector arr; + vector arr; while (it != fs::directory_iterator()) { if (!fs::is_directory(*it)) arr.push_back(*it); ++it; } - std::sort(arr.begin(), arr.end()); - for (std::vector::iterator i= arr.begin(); i != arr.end(); ++i) + sort(arr.begin(), arr.end()); + for (vector::iterator i= arr.begin(); i != arr.end(); ++i) { load_rcfile(system_path(i->native_directory_string()), true); } @@ -225,8 +232,8 @@ } bool -lua_hooks::hook_expand_selector(std::string const & sel, - std::string & exp) +lua_hooks::hook_expand_selector(string const & sel, + string & exp) { return Lua(st) .func("expand_selector") @@ -237,8 +244,8 @@ } bool -lua_hooks::hook_expand_date(std::string const & sel, - std::string & exp) +lua_hooks::hook_expand_date(string const & sel, + string & exp) { exp.clear(); bool res= Lua(st) @@ -306,7 +313,7 @@ } bool -lua_hooks::hook_ignore_branch(std::string const & branch) +lua_hooks::hook_ignore_branch(string const & branch) { bool ignore_it = false; bool exec_ok = Lua(st) @@ -320,7 +327,7 @@ static inline bool shared_trust_function_body(Lua & ll, - std::set const & signers, + set const & signers, hexenc const & id, cert_name const & name, cert_value const & val) @@ -350,7 +357,7 @@ } bool -lua_hooks::hook_get_revision_cert_trust(std::set const & signers, +lua_hooks::hook_get_revision_cert_trust(set const & signers, hexenc const & id, cert_name const & name, cert_value const & val) @@ -361,7 +368,7 @@ } bool -lua_hooks::hook_get_manifest_cert_trust(std::set const & signers, +lua_hooks::hook_get_manifest_cert_trust(set const & signers, hexenc const & id, cert_name const & name, cert_value const & val) @@ -442,9 +449,9 @@ data const & data_new, bool is_binary, bool diff_args_provided, - std::string const & diff_args, - std::string const & oldrev, - std::string const & newrev) + string const & diff_args, + string const & oldrev, + string const & newrev) { Lua ll(st); @@ -486,7 +493,7 @@ } bool -lua_hooks::hook_get_netsync_read_permitted(std::string const & branch, +lua_hooks::hook_get_netsync_read_permitted(string const & branch, rsa_keypair_id const & identity) { bool permitted = false, exec_ok = false; @@ -504,7 +511,7 @@ // Anonymous no-key version bool -lua_hooks::hook_get_netsync_read_permitted(std::string const & branch) +lua_hooks::hook_get_netsync_read_permitted(string const & branch) { bool permitted = false, exec_ok = false; @@ -536,7 +543,7 @@ bool lua_hooks::hook_init_attributes(file_path const & filename, - std::map & attrs) + map & attrs) { Lua ll(st); @@ -602,8 +609,8 @@ bool lua_hooks::hook_get_charset_conv(file_path const & p, - std::string & db, - std::string & ext) + string & db, + string & ext) { Lua ll(st); ll @@ -622,8 +629,8 @@ bool lua_hooks::hook_get_linesep_conv(file_path const & p, - std::string & db, - std::string & ext) + string & db, + string & ext) { Lua ll(st); ll @@ -641,10 +648,10 @@ } bool -lua_hooks::hook_validate_commit_message(std::string const & message, - std::string const & new_manifest_text, +lua_hooks::hook_validate_commit_message(string const & message, + string const & new_manifest_text, bool & validated, - std::string & reason) + string & reason) { validated = true; return Lua(st) @@ -701,7 +708,7 @@ set > > const & certs, - std::string nonce) + string nonce) { Lua ll(st); ll @@ -737,7 +744,7 @@ bool lua_hooks::hook_note_netsync_pubkey_received(rsa_keypair_id const & kid, - std::string nonce) + string nonce) { Lua ll(st); ll @@ -754,7 +761,7 @@ rsa_keypair_id const & kid, cert_name const & name, cert_value const & value, - std::string nonce) + string nonce) { Lua ll(st); ll ============================================================ --- main.cc 0981328eff2cd408bb7d9b13208b16243feec637 +++ main.cc 1b50bf9eefcb967254582b38a5a886f8ad09eea6 @@ -59,6 +59,7 @@ #error "no known OS signal handling interface" #endif +using std::string; // A rough outline of what this file does: // @@ -379,9 +380,9 @@ report_error("C string: ", ex); } - catch (std::string const & ex) + catch (string const & ex) { - report_error("std::string: ", ex.c_str()); + report_error("string: ", ex.c_str()); } catch( std::bad_alloc const & ex ) @@ -495,7 +496,7 @@ } catch (the_one_true_exception const & e) { - ui.fatal(std::string(e.buf) + "\n"); + ui.fatal(string(e.buf) + "\n"); // If we got here, it's because something went _really_ wrong, like an // invariant failure or a segfault. So use a distinctive error code, in // particular so the testsuite can tell whether we detected an error ============================================================ --- merge.cc f129963451cc6c8f1562d84852c6d4e31a211eec +++ merge.cc cc6860bdc2e1ba18713800ef24ceb08c605abab0 @@ -17,8 +17,11 @@ #include "safe_map.hh" #include "transforms.hh" +using std::make_pair; using std::map; -using std::make_pair; +using std::set; +using std::vector; + using boost::shared_ptr; static void @@ -66,13 +69,13 @@ { L(FL("examining content conflicts\n")); - std::vector residual_conflicts; + vector residual_conflicts; for (size_t i = 0; i < result.file_content_conflicts.size(); ++i) { file_content_conflict const & conflict = result.file_content_conflicts[i]; - boost::shared_ptr roster_for_file_lca; + shared_ptr roster_for_file_lca; adaptor.get_ancestral_roster(conflict.nid, roster_for_file_lca); // Now we should certainly have a roster, which has the node. @@ -118,7 +121,7 @@ { roster_t left_roster, right_roster; marking_map left_marking_map, right_marking_map; - std::set left_uncommon_ancestors, right_uncommon_ancestors; + set left_uncommon_ancestors, right_uncommon_ancestors; app.db.get_roster(left_rid, left_roster, left_marking_map); app.db.get_roster(right_rid, right_roster, right_marking_map); @@ -168,13 +171,13 @@ calculate_ident(merged_roster, merged_rev.new_manifest); - boost::shared_ptr left_to_merged(new cset); + shared_ptr left_to_merged(new cset); make_cset(left_roster, merged_roster, *left_to_merged); - safe_insert(merged_rev.edges, std::make_pair(left_rid, left_to_merged)); + safe_insert(merged_rev.edges, make_pair(left_rid, left_to_merged)); - boost::shared_ptr right_to_merged(new cset); + shared_ptr right_to_merged(new cset); make_cset(right_roster, merged_roster, *right_to_merged); - safe_insert(merged_rev.edges, std::make_pair(right_rid, right_to_merged)); + safe_insert(merged_rev.edges, make_pair(right_rid, right_to_merged)); revision_data merged_data; write_revision_set(merged_rev, merged_data); ============================================================ --- merkle_tree.cc 0be64fcc156d10e75e0f235856e9c4c428f1915c +++ merkle_tree.cc 7011e2dbceb1d2e78db31c8c4570d443b383c639 @@ -20,8 +20,13 @@ #include "sanity.hh" #include "transforms.hh" +using std::make_pair; +using std::ostream_iterator; +using std::ostringstream; +using std::set; +using std::string; + using boost::dynamic_bitset; -using namespace std; static void bitset_to_prefix(dynamic_bitset const & pref, @@ -524,6 +529,6 @@ node->total_num_leaves = 1; node->set_slot_state(slotnum, leaf_state); node->set_raw_slot(slotnum, leaf); - tab.insert(std::make_pair(std::make_pair(rawpref, level), node)); + tab.insert(make_pair(make_pair(rawpref, level), node)); } } ============================================================ --- mkstemp.cc a58750be73db167658f8b3df2993d0dec8648a5c +++ mkstemp.cc 97f331512edf52eaa5940a6f891167e4f990c1fc @@ -22,13 +22,15 @@ #define O_BINARY 0 #endif +using std::string; + int -monotone_mkstemp(std::string &tmpl) +monotone_mkstemp(string &tmpl) { unsigned int len = 0; int i = 0; int count = 0, fd = -1; - std::string tmp; + string tmp; static const char letters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; ============================================================ --- monotone.cc 7ce7990a7e4ebb99f1980ccdeca7a6e1b297ea7b +++ monotone.cc e346183d0490498d8bc028de420c85e7ebc55cac @@ -35,9 +35,15 @@ #include "options.hh" #include "paths.hh" -// main option processing and exception handling code +using std::cout; +using std::endl; +using std::ios_base; +using std::ostringstream; +using std::set; +using std::string; +using std::vector; -using namespace std; +// main option processing and exception handling code char * argstr = NULL; long arglong = 0; @@ -260,9 +266,9 @@ // set up some marked strings, so even if our logbuf overflows, we'll get // this data in a crash. - std::string cmdline_string; + string cmdline_string; { - std::ostringstream cmdline_ss; + ostringstream cmdline_ss; for (int i = 0; i < argc; ++i) { if (i) @@ -274,11 +280,11 @@ MM(cmdline_string); L(FL("command line: %s\n") % cmdline_string); - std::string locale_string = (setlocale(LC_ALL, NULL) == NULL ? "n/a" : setlocale(LC_ALL, NULL)); + string locale_string = (setlocale(LC_ALL, NULL) == NULL ? "n/a" : setlocale(LC_ALL, NULL)); MM(locale_string); L(FL("set locale: LC_ALL=%s\n") % locale_string); - std::string full_version_string; + string full_version_string; get_full_version(full_version_string); MM(full_version_string); @@ -497,28 +503,28 @@ case OPT_BIND: { - std::string arg(argstr); - std::string addr_part, port_part; + string arg(argstr); + string addr_part, port_part; size_t l_colon = arg.find(':'); size_t r_colon = arg.rfind(':'); // not an ipv6 address, as that would have at least two colons if (l_colon == r_colon) { - addr_part = (r_colon == std::string::npos ? arg : arg.substr(0, r_colon)); - port_part = (r_colon == std::string::npos ? "" : arg.substr(r_colon+1, arg.size() - r_colon)); + addr_part = (r_colon == string::npos ? arg : arg.substr(0, r_colon)); + port_part = (r_colon == string::npos ? "" : arg.substr(r_colon+1, arg.size() - r_colon)); } else { // IPv6 addresses have a port specified in the style: [2001:388:0:13::]:80 size_t squareb = arg.rfind(']'); - if ((arg.find('[') == 0) && (squareb != std::string::npos)) + if ((arg.find('[') == 0) && (squareb != string::npos)) { if (squareb < r_colon) - port_part = (r_colon == std::string::npos ? "" : arg.substr(r_colon+1, arg.size() - r_colon)); + port_part = (r_colon == string::npos ? "" : arg.substr(r_colon+1, arg.size() - r_colon)); else port_part = ""; - addr_part = (squareb == std::string::npos ? arg.substr(1, arg.size()) : arg.substr(1, squareb-1)); + addr_part = (squareb == string::npos ? arg.substr(1, arg.size()) : arg.substr(1, squareb-1)); } else { @@ -666,7 +672,7 @@ global_sanity.clean_shutdown = true; return 1; } - catch (std::ios_base::failure const & ex) + catch (ios_base::failure const & ex) { global_sanity.clean_shutdown = true; return 1; ============================================================ --- mt_version.cc 45d1e20bb6dc2d490854f8647d9788bc3ae04654 +++ mt_version.cc 244fa7c8fa1c1d2f65c9ee9c2542e95f8e284655 @@ -21,8 +21,13 @@ #include "package_full_revision.h" #include "sanity.hh" +using std::cout; +using std::endl; +using std::ostringstream; +using std::string; + void -get_version(std::string & out) +get_version(string & out) { out = (F("%s (base revision: %s)") % PACKAGE_STRING % package_revision_constant).str(); @@ -31,16 +36,16 @@ void print_version() { - std::string s; + string s; get_version(s); - std::cout << s << std::endl; + cout << s << endl; } void -get_full_version(std::string & out) +get_full_version(string & out) { - std::ostringstream oss; - std::string s; + ostringstream oss; + string s; get_version(s); oss << s << "\n"; get_system_flavour(s); @@ -61,7 +66,7 @@ void print_full_version() { - std::string s; + string s; get_full_version(s); - std::cout << s << std::endl; + cout << s << endl; } ============================================================ --- netcmd.cc da3773c93069c0834ce0b3caf34020305dd7d8b2 +++ netcmd.cc fd1bcbe65cd56e1a9379aa56c6039df9eac81b48 @@ -16,7 +16,7 @@ #include "transforms.hh" #include "hmac.hh" -using namespace std; +using std::string; static netcmd_item_type read_netcmd_item_type(string const & in, @@ -172,7 +172,7 @@ //////////////////////////////////////////// void -netcmd::read_error_cmd(std::string & errmsg) const +netcmd::read_error_cmd(string & errmsg) const { size_t pos = 0; // syntax is: @@ -181,7 +181,7 @@ } void -netcmd::write_error_cmd(std::string const & errmsg) +netcmd::write_error_cmd(string const & errmsg) { cmd_code = error_cmd; payload.clear(); @@ -256,7 +256,7 @@ && role_byte != static_cast(source_and_sink_role)) throw bad_decode(F("unknown role specifier %d") % widen(role_byte)); role = static_cast(role_byte); - std::string pattern_string; + string pattern_string; extract_variable_length_string(payload, pattern_string, pos, "anonymous(hmac) netcmd, include_pattern"); include_pattern = utf8(pattern_string); @@ -302,7 +302,7 @@ && role_byte != static_cast(source_and_sink_role)) throw bad_decode(F("unknown role specifier %d") % widen(role_byte)); role = static_cast(role_byte); - std::string pattern_string; + string pattern_string; extract_variable_length_string(payload, pattern_string, pos, "auth(hmac) netcmd, include_pattern"); include_pattern = utf8(pattern_string); @@ -519,7 +519,7 @@ netcmd::read_usher_cmd(utf8 & greeting) const { size_t pos = 0; - std::string str; + string str; extract_variable_length_string(payload, str, pos, "error netcmd, message"); greeting = utf8(str); assert_end_of_buffer(payload, pos, "error netcmd payload"); ============================================================ --- netsync.cc e56f12d1ea09ad60c675560199cb7819d258c025 +++ netsync.cc cfd4bd5fa05d58c54c8ddf1cfe706120f6212e87 @@ -233,7 +233,16 @@ // interpreting manually anyways. // -using namespace std; +using std::auto_ptr; +using std::deque; +using std::make_pair; +using std::map; +using std::min; +using std::pair; +using std::set; +using std::string; +using std::vector; + using boost::shared_ptr; using boost::lexical_cast; @@ -921,7 +930,7 @@ // ensure that our peer receives the error message. // Affects read_some, write_some, and process . void -session::error(std::string const & errmsg) +session::error(string const & errmsg) { throw netsync_error(errmsg); } @@ -977,7 +986,7 @@ I(!outbuf.empty()); size_t writelen = outbuf.front().first.size() - outbuf.front().second; Netxx::signed_size_type count = str.write(outbuf.front().first.data() + outbuf.front().second, - std::min(writelen, + min(writelen, constants::bufsz)); if (count > 0) { @@ -1804,9 +1813,9 @@ epoch_data epoch; read_epoch(dat, branch, epoch); L(FL("received epoch %s for branch %s\n") % epoch % branch); - std::map epochs; + map epochs; app.db.get_epochs(epochs); - std::map::const_iterator i; + map::const_iterator i; i = epochs.find(branch); if (i == epochs.end()) { @@ -2754,9 +2763,9 @@ id rev_item; decode_hexenc(rid.inner(), rev_item); ref.note_local_item(rev_item); - std::vector parents; + vector parents; rev_enumerator.get_revision_parents(rid, parents); - for (std::vector::const_iterator i = parents.begin(); + for (vector::const_iterator i = parents.begin(); i != parents.end(); ++i) { work.push_back(*i); @@ -2821,19 +2830,19 @@ map epochs; app.db.get_epochs(epochs); - epoch_data epoch_zero(std::string(constants::epochlen, '0')); - for (std::set::const_iterator i = branchnames.begin(); + epoch_data epoch_zero(string(constants::epochlen, '0')); + for (set::const_iterator i = branchnames.begin(); i != branchnames.end(); ++i) { cert_value branch((*i)()); - std::map::const_iterator j; + map::const_iterator j; j = epochs.find(branch); // Set to zero any epoch which is not yet set. if (j == epochs.end()) { L(FL("setting epoch on %s to zero\n") % branch); - epochs.insert(std::make_pair(branch, epoch_zero)); + epochs.insert(make_pair(branch, epoch_zero)); app.db.set_epoch(branch, epoch_zero); } @@ -2849,8 +2858,8 @@ } { - typedef std::vector< std::pair, - std::pair > > cert_idx; + typedef vector< pair, + pair > > cert_idx; cert_idx idx; app.db.get_revision_cert_nobranch_index(idx); @@ -2928,13 +2937,13 @@ utf8 const & exclude_pattern, app_state & app) { - if (include_pattern().find_first_of("'\"") != std::string::npos) + if (include_pattern().find_first_of("'\"") != string::npos) { W(F("include branch pattern contains a quote character:\n" "%s\n") % include_pattern()); } - if (exclude_pattern().find_first_of("'\"") != std::string::npos) + if (exclude_pattern().find_first_of("'\"") != string::npos) { W(F("exclude branch pattern contains a quote character:\n" "%s\n") % exclude_pattern()); ============================================================ --- packet.cc 130498edfbbd9c527c89e6e6c5c2d8d6193d3590 +++ packet.cc dfdefb2d2808183cd0312752b2ee1f840bace11c @@ -20,12 +20,19 @@ #include "keys.hh" #include "cert.hh" -using namespace std; -using boost::shared_ptr; +using std::endl; +using std::istream; +using std::make_pair; +using std::map; +using std::ostream; +using std::pair; +using std::string; + using boost::lexical_cast; using boost::match_default; using boost::match_results; using boost::regex; +using boost::shared_ptr; void packet_consumer::set_on_revision_written(boost::function1::const_iterator a + for (map::const_iterator a = edge_changes(i).files_added.begin(); a != edge_changes(i).files_added.end(); ++a) { @@ -142,7 +149,7 @@ } } - for (std::map >::const_iterator d + for (map >::const_iterator d = edge_changes(i).deltas_applied.begin(); d != edge_changes(i).deltas_applied.end(); ++d) { @@ -321,11 +328,11 @@ app_state & app; size_t & count; packet_consumer & cons; - std::string ident; - std::string key; - std::string certname; - std::string base; - std::string sp; + string ident; + string key; + string certname; + string base; + string sp; feed_packet_consumer(size_t & count, packet_consumer & c, app_state & app_) : app(app_), count(count), cons(c), ident(constants::regex_legal_id_bytes), @@ -338,7 +345,7 @@ { E(x, F("malformed packet")); } - bool operator()(match_results const & res) const + bool operator()(match_results const & res) const { if (res.size() != 4) throw oops("matched impossible packet with " @@ -347,9 +354,9 @@ I(res[1].matched); I(res[2].matched); I(res[3].matched); - std::string type(res[1].first, res[1].second); - std::string args(res[2].first, res[2].second); - std::string body(res[3].first, res[3].second); + string type(res[1].first, res[1].second); + string args(res[2].first, res[2].second); + string body(res[3].first, res[3].second); if (regex_match(type, regex("[fr]data"))) { L(FL("read data packet")); @@ -370,7 +377,7 @@ else if (type == "fdelta") { L(FL("read delta packet")); - match_results matches; + match_results matches; require(regex_match(args, matches, regex(ident + sp + ident))); string src_id(matches[1].first, matches[1].second); string dst_id(matches[2].first, matches[2].second); @@ -385,7 +392,7 @@ else if (type == "rcert") { L(FL("read cert packet")); - match_results matches; + match_results matches; require(regex_match(args, matches, regex(ident + sp + certname + sp + key + sp + base))); string certid(matches[1].first, matches[1].second); @@ -415,7 +422,7 @@ { L(FL("read keypair data packet")); require(regex_match(args, regex(key))); - match_results matches; + match_results matches; require(regex_match(body, matches, regex(base + "#" + base))); string pub_dat(trim_ws(string(matches[1].first, matches[1].second))); string priv_dat(trim_ws(string(matches[2].first, matches[2].second))); @@ -491,6 +498,9 @@ #include "unit_tests.hh" #include "transforms.hh" +using std::istringstream; +using std::ostringstream; + static void packet_roundabout_test() { @@ -516,12 +526,12 @@ // a rdata packet revision_set rev; - rev.new_manifest = manifest_id(std::string("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); + rev.new_manifest = manifest_id(string("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); split_path sp; file_path_internal("").split(sp); shared_ptr cs(new cset); cs->dirs_added.insert(sp); - rev.edges.insert(std::make_pair(revision_id(std::string("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")), + rev.edges.insert(make_pair(revision_id(string("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")), cs)); revision_data rdat; write_revision_set(rev, rdat); ============================================================ --- paths.cc 5680d2c2726d5894fe21cc4c7dd9f149ba1efb32 +++ paths.cc e780082307c87355306be40b824b8827f1db7d43 @@ -19,6 +19,11 @@ #include "charset.hh" #include "simplestring_xform.hh" +using std::exception; +using std::ostream; +using std::ostringstream; +using std::string; + // some structure to ensure we aren't doing anything broken when resolving // filenames. the idea is to make sure // -- we don't depend on the existence of something before it has been set @@ -113,10 +118,10 @@ // -- no trailing / // -- no "." or ".." path components static inline bool -bad_component(std::string const & component) +bad_component(string const & component) { - static const std::string dot("."); - static const std::string dotdot(".."); + static const string dot("."); + static const string dotdot(".."); if (component.empty()) return true; if (component == dot) @@ -127,14 +132,14 @@ } static inline bool -has_bad_chars(std::string const & path) +has_bad_chars(string const & path) { static bool bad_chars_init(false); static u8 bad_table[128] = {0}; if (UNLIKELY(!bad_chars_init)) { - std::string bad_chars = std::string("\\") + constants::illegal_path_bytes + std::string(1, '\0'); - for (std::string::const_iterator b = bad_chars.begin(); b != bad_chars.end(); b++) + string bad_chars = string("\\") + constants::illegal_path_bytes + string(1, '\0'); + for (string::const_iterator b = bad_chars.begin(); b != bad_chars.end(); b++) { u8 x = (u8)*b; I((x) < sizeof(bad_table)); @@ -143,7 +148,7 @@ bad_chars_init = true; } - for (std::string::const_iterator c = path.begin(); c != path.end(); c++) + for (string::const_iterator c = path.begin(); c != path.end(); c++) { u8 x = (u8)*c; if (x < sizeof(bad_table) && bad_table[x]) @@ -156,7 +161,7 @@ // if want_split is set, split_path will be filled with the '/' separated // components of the path. static inline bool -fully_normalized_path_split(std::string const & path, bool want_split, +fully_normalized_path_split(string const & path, bool want_split, split_path & sp) { // empty path is fine @@ -170,21 +175,21 @@ if (has_bad_chars(path)) return false; // now check each component - std::string::size_type start, stop; + string::size_type start, stop; start = 0; while (1) { stop = path.find('/', start); - if (stop == std::string::npos) + if (stop == string::npos) { - std::string const & s(path.substr(start)); + string const & s(path.substr(start)); if (bad_component(s)) return false; if (want_split) sp.push_back(s); break; } - std::string const & s(path.substr(start, stop - start)); + string const & s(path.substr(start, stop - start)); if (bad_component(s)) return false; if (want_split) @@ -195,7 +200,7 @@ } static inline bool -fully_normalized_path(std::string const & path) +fully_normalized_path(string const & path) { split_path sp; return fully_normalized_path_split(path, false, sp); @@ -208,7 +213,7 @@ // -- this prevents all-unix projects from naming things "mt", which is a bit // rude -- but as a temporary security kluge it works. static inline bool -in_bookkeeping_dir(std::string const & path) +in_bookkeeping_dir(string const & path) { if (path.size() == 0 || (path[0] != '_')) return false; @@ -227,7 +232,7 @@ } static inline bool -is_valid_internal(std::string const & path) +is_valid_internal(string const & path) { return (fully_normalized_path(path) && !in_bookkeeping_dir(path)); @@ -236,7 +241,7 @@ // equivalent to file_path_internal(path).split(sp), but // avoids splitting the string twice void -internal_string_to_split_path(std::string const & path, split_path & sp) +internal_string_to_split_path(string const & path, split_path & sp) { I(utf8_validate(path)); I(!in_bookkeeping_dir(path)); @@ -246,7 +251,7 @@ I(fully_normalized_path_split(path, true, sp)); } -file_path::file_path(file_path::source_type type, std::string const & path) +file_path::file_path(file_path::source_type type, string const & path) { MM(path); I(utf8_validate(path)); @@ -277,13 +282,13 @@ relative = fs::path(path, fs::native); out = (base / relative).normalize(); } - catch (std::exception & e) + catch (exception & e) { N(false, F("path '%s' is invalid") % path); } data = utf8(out.string()); if (data() == ".") - data = std::string(""); + data = string(""); N(!relative.has_root_path(), F("absolute path '%s' is invalid") % relative.string()); N(fully_normalized_path(data()), F("path '%s' is invalid") % data); @@ -294,7 +299,7 @@ I(is_valid_internal(data())); } -bookkeeping_path::bookkeeping_path(std::string const & path) +bookkeeping_path::bookkeeping_path(string const & path) { I(fully_normalized_path(path)); I(in_bookkeeping_dir(path)); @@ -302,7 +307,7 @@ } bool -bookkeeping_path::is_bookkeeping_path(std::string const & path) +bookkeeping_path::is_bookkeeping_path(string const & path) { return in_bookkeeping_dir(path); } @@ -329,7 +334,7 @@ split_path::const_iterator i = sp.begin(); I(i != sp.end()); I(null_name(*i)); - std::string tmp; + string tmp; bool start = true; for (++i; i != sp.end(); ++i) { @@ -363,13 +368,13 @@ sp.push_back(the_null_component); if (empty()) return; - std::string::size_type start, stop; + string::size_type start, stop; start = 0; - std::string const & s = data(); + string const & s = data(); while (1) { stop = s.find('/', start); - if (stop == std::string::npos) + if (stop == string::npos) { sp.push_back(s.substr(start)); break; @@ -380,9 +385,9 @@ } template <> -void dump(split_path const & sp, std::string & out) +void dump(split_path const & sp, string & out) { - std::ostringstream oss; + ostringstream oss; for (split_path::const_iterator i = sp.begin(); i != sp.end(); ++i) { @@ -403,7 +408,7 @@ // this code must be superfast when there is no conversion needed /////////////////////////////////////////////////////////////////////////// -std::string +string any_path::as_external() const { #ifdef __APPLE__ @@ -424,15 +429,15 @@ // writing out paths /////////////////////////////////////////////////////////////////////////// -std::ostream & -operator <<(std::ostream & o, any_path const & a) +ostream & +operator <<(ostream & o, any_path const & a) { o << a.as_internal(); return o; } -std::ostream & -operator <<(std::ostream & o, split_path const & sp) +ostream & +operator <<(ostream & o, split_path const & sp) { file_path tmp(sp); return o << tmp; @@ -444,7 +449,7 @@ /////////////////////////////////////////////////////////////////////////// static bool -is_absolute_here(std::string const & path) +is_absolute_here(string const & path) { if (path.empty()) return false; @@ -460,7 +465,7 @@ } static inline bool -is_absolute_somewhere(std::string const & path) +is_absolute_somewhere(string const & path) { if (path.empty()) return false; @@ -474,7 +479,7 @@ } file_path -file_path::operator /(std::string const & to_append) const +file_path::operator /(string const & to_append) const { I(!is_absolute_somewhere(to_append)); if (empty()) @@ -484,7 +489,7 @@ } bookkeeping_path -bookkeeping_path::operator /(std::string const & to_append) const +bookkeeping_path::operator /(string const & to_append) const { I(!is_absolute_somewhere(to_append)); I(!empty()); @@ -492,7 +497,7 @@ } system_path -system_path::operator /(std::string const & to_append) const +system_path::operator /(string const & to_append) const { I(!empty()); I(!is_absolute_here(to_append)); @@ -503,8 +508,8 @@ // system_path /////////////////////////////////////////////////////////////////////////// -static std::string -normalize_out_dots(std::string const & path) +static string +normalize_out_dots(string const & path) { #ifdef WIN32 return fs::path(path, fs::native).normalize().string(); @@ -530,17 +535,17 @@ } } -static inline std::string const_system_path(utf8 const & path) +static inline string const_system_path(utf8 const & path) { N(!path().empty(), F("invalid path ''")); - std::string expanded = tilde_expand(path)(); + string expanded = tilde_expand(path)(); if (is_absolute_here(expanded)) return normalize_out_dots(expanded); else return normalize_out_dots((initial_abs_path.get() / expanded).as_internal()); } -system_path::system_path(std::string const & path) +system_path::system_path(string const & path) { data = const_system_path(path); } @@ -647,6 +652,8 @@ #ifdef BUILD_UNIT_TESTS #include "unit_tests.hh" +using std::logic_error; + static void test_null_name() { BOOST_CHECK(null_name(the_null_component)); @@ -689,13 +696,13 @@ initial_rel_path.set(fs::path(), true); for (char const ** c = baddies; *c; ++c) { - BOOST_CHECK_THROW(file_path_internal(*c), std::logic_error); + BOOST_CHECK_THROW(file_path_internal(*c), logic_error); } initial_rel_path.unset(); initial_rel_path.set(fs::path("blah/blah/blah", fs::native), true); for (char const ** c = baddies; *c; ++c) { - BOOST_CHECK_THROW(file_path_internal(*c), std::logic_error); + BOOST_CHECK_THROW(file_path_internal(*c), logic_error); } BOOST_CHECK(file_path().empty()); @@ -744,7 +751,7 @@ static void check_fp_normalizes_to(char * before, char * after) { L(FL("check_fp_normalizes_to: '%s' -> '%s'") % before % after); - file_path fp = file_path_external(std::string(before)); + file_path fp = file_path_external(string(before)); L(FL(" (got: %s)") % fp); BOOST_CHECK(fp.as_internal() == after); BOOST_CHECK(file_path_internal(fp.as_internal()) == fp); @@ -952,7 +959,7 @@ split_path split4; // this comparison tricks the compiler into not completely eliminating this // code as dead... - BOOST_CHECK_THROW(file_path(split4) == file_path(), std::logic_error); + BOOST_CHECK_THROW(file_path(split4) == file_path(), logic_error); split4.push_back(the_null_component); BOOST_CHECK(file_path(split4) == file_path()); @@ -961,7 +968,7 @@ split4.push_back(split1[1]); // this comparison tricks the compiler into not completely eliminating this // code as dead... - BOOST_CHECK_THROW(file_path(split4) == file_path(), std::logic_error); + BOOST_CHECK_THROW(file_path(split4) == file_path(), logic_error); // split_path with non-first item item null is invalid split4.clear(); @@ -970,7 +977,7 @@ split4.push_back(the_null_component); // this comparison tricks the compiler into not completely eliminating this // code as dead... - BOOST_CHECK_THROW(file_path(split4) == file_path(), std::logic_error); + BOOST_CHECK_THROW(file_path(split4) == file_path(), logic_error); // Make sure that we can't use joining to create a path into the bookkeeping // dir @@ -982,12 +989,12 @@ split_mt2.push_back(the_null_component); split_mt2.push_back(split_mt1[2]); // split_mt2 now contains the component "_MTN" - BOOST_CHECK_THROW(file_path(split_mt2) == file_path(), std::logic_error); + BOOST_CHECK_THROW(file_path(split_mt2) == file_path(), logic_error); split_mt2.push_back(split_mt1[1]); // split_mt2 now contains the components "_MTN", "foo" in that order // this comparison tricks the compiler into not completely eliminating this // code as dead... - BOOST_CHECK_THROW(file_path(split_mt2) == file_path(), std::logic_error); + BOOST_CHECK_THROW(file_path(split_mt2) == file_path(), logic_error); } // and make sure it fails for the klugy security cases -- see comments on // in_bookkeeping_dir @@ -998,12 +1005,12 @@ split_mt2.push_back(the_null_component); split_mt2.push_back(split_mt1[2]); // split_mt2 now contains the component "_mTn" - BOOST_CHECK_THROW(file_path(split_mt2) == file_path(), std::logic_error); + BOOST_CHECK_THROW(file_path(split_mt2) == file_path(), logic_error); split_mt2.push_back(split_mt1[1]); // split_mt2 now contains the components "_mTn", "foo" in that order // this comparison tricks the compiler into not completely eliminating this // code as dead... - BOOST_CHECK_THROW(file_path(split_mt2) == file_path(), std::logic_error); + BOOST_CHECK_THROW(file_path(split_mt2) == file_path(), logic_error); } } @@ -1032,16 +1039,16 @@ "", "a:b", 0 }; - std::string tmp_path_string; + string tmp_path_string; for (char const ** c = baddies; *c; ++c) { L(FL("test_bookkeeping_path baddie: trying '%s'") % *c); - BOOST_CHECK_THROW(bookkeeping_path(tmp_path_string.assign(*c)), std::logic_error); - BOOST_CHECK_THROW(bookkeeping_root / tmp_path_string.assign(*c), std::logic_error); + BOOST_CHECK_THROW(bookkeeping_path(tmp_path_string.assign(*c)), logic_error); + BOOST_CHECK_THROW(bookkeeping_root / tmp_path_string.assign(*c), logic_error); } - BOOST_CHECK_THROW(bookkeeping_path(tmp_path_string.assign("foo/bar")), std::logic_error); - BOOST_CHECK_THROW(bookkeeping_path(tmp_path_string.assign("a")), std::logic_error); + BOOST_CHECK_THROW(bookkeeping_path(tmp_path_string.assign("foo/bar")), logic_error); + BOOST_CHECK_THROW(bookkeeping_path(tmp_path_string.assign("a")), logic_error); check_bk_normalizes_to("a", "_MTN/a"); check_bk_normalizes_to("foo", "_MTN/foo"); @@ -1095,18 +1102,18 @@ check_system_normalizes_to("/foo/..", "/"); // can't do particularly interesting checking of tilde expansion, but at // least we can check that it's doing _something_... - std::string tilde_expanded = system_path("~/foo").as_external(); + string tilde_expanded = system_path("~/foo").as_external(); #ifdef WIN32 BOOST_CHECK(tilde_expanded[1] == ':'); #else BOOST_CHECK(tilde_expanded[0] == '/'); #endif - BOOST_CHECK(tilde_expanded.find('~') == std::string::npos); + BOOST_CHECK(tilde_expanded.find('~') == string::npos); // and check for the weird WIN32 version #ifdef WIN32 - std::string tilde_expanded2 = system_path("~this_user_does_not_exist_anywhere").as_external(); + string tilde_expanded2 = system_path("~this_user_does_not_exist_anywhere").as_external(); BOOST_CHECK(tilde_expanded2[0] = '/'); - BOOST_CHECK(tilde_expanded2.find('~') == std::string::npos); + BOOST_CHECK(tilde_expanded2.find('~') == string::npos); #else BOOST_CHECK_THROW(system_path("~this_user_does_not_exist_anywhere"), informative_failure); #endif @@ -1129,7 +1136,7 @@ BOOST_CHECK(system_path(file_path_internal("foo/bar")).as_internal() == "/working/root/foo/bar"); BOOST_CHECK(working_root.used); - BOOST_CHECK(system_path(file_path_external(std::string("foo/bar"))).as_external() + BOOST_CHECK(system_path(file_path_external(string("foo/bar"))).as_external() == "/working/root/rel/initial/foo/bar"); file_path a_file_path; BOOST_CHECK(system_path(a_file_path).as_external() @@ -1146,23 +1153,23 @@ static void test_access_tracker() { access_tracker a; - BOOST_CHECK_THROW(a.get(), std::logic_error); + BOOST_CHECK_THROW(a.get(), logic_error); a.set(1, false); - BOOST_CHECK_THROW(a.set(2, false), std::logic_error); + BOOST_CHECK_THROW(a.set(2, false), logic_error); a.set(2, true); - BOOST_CHECK_THROW(a.set(3, false), std::logic_error); + BOOST_CHECK_THROW(a.set(3, false), logic_error); BOOST_CHECK(a.get() == 2); - BOOST_CHECK_THROW(a.set(3, true), std::logic_error); + BOOST_CHECK_THROW(a.set(3, true), logic_error); a.unset(); a.may_not_initialize(); - BOOST_CHECK_THROW(a.set(1, false), std::logic_error); - BOOST_CHECK_THROW(a.set(2, true), std::logic_error); + BOOST_CHECK_THROW(a.set(1, false), logic_error); + BOOST_CHECK_THROW(a.set(2, true), logic_error); a.unset(); a.set(1, false); - BOOST_CHECK_THROW(a.may_not_initialize(), std::logic_error); + BOOST_CHECK_THROW(a.may_not_initialize(), logic_error); } -static void test_a_path_ordering(std::string const & left, std::string const & right) +static void test_a_path_ordering(string const & left, string const & right) { MM(left); MM(right); ============================================================ --- rcs_file.cc f5dde1d6e49f0472b11704c24d36a0bcb161f257 +++ rcs_file.cc e6ecf0169b282a6f96e278227893eef9ca10680e @@ -31,14 +31,19 @@ #include +using std::ifstream; +using std::ios_base; +using std::istream; +using std::string; + #ifdef HAVE_MMAP struct file_handle { - std::string const & filename; + string const & filename; off_t length; int fd; - file_handle(std::string const & fn) : + file_handle(string const & fn) : filename(fn), length(0), fd(-1) @@ -59,7 +64,7 @@ }; struct file_source { - std::string const & filename; + string const & filename; int fd; off_t length; off_t pos; @@ -82,7 +87,7 @@ ++pos; return good(); } - file_source(std::string const & fn, + file_source(string const & fn, int f, off_t len) : filename(fn), @@ -105,10 +110,10 @@ struct file_handle { - std::string const & filename; + string const & filename; off_t length; HANDLE fd; - file_handle(std::string const & fn) : + file_handle(string const & fn) : filename(fn), length(0), fd(NULL) @@ -135,7 +140,7 @@ struct file_source { - std::string const & filename; + string const & filename; HANDLE fd,map; off_t length; off_t pos; @@ -158,7 +163,7 @@ ++pos; return good(); } - file_source(std::string const & fn, + file_source(string const & fn, HANDLE f, off_t len) : filename(fn), @@ -184,7 +189,7 @@ }; #else // no mmap at all -typedef std::istream file_source; +typedef istream file_source; #endif typedef enum @@ -212,7 +217,7 @@ static token_type get_token(file_source & ist, - std::string & str, + string & str, size_t & line, size_t & col) { @@ -296,7 +301,7 @@ { file_source & ist; rcs_file & r; - std::string token; + string token; token_type ttype; size_t line, col; @@ -306,7 +311,7 @@ : ist(s), r(r), line(1), col(1) {} - std::string tt2str(token_type tt) + string tt2str(token_type tt) { switch (tt) { @@ -329,13 +334,13 @@ void advance() { ttype = get_token(ist, token, line, col); - // std::cerr << tt2str(ttype) << ": " << token << std::endl; + // cerr << tt2str(ttype) << ": " << token << endl; } bool nump() { return ttype == TOK_NUM; } bool strp() { return ttype == TOK_STRING; } bool symp() { return ttype == TOK_SYMBOL; } - bool symp(std::string const & val) + bool symp(string const & val) { return ttype == TOK_SYMBOL && token == val; } @@ -349,17 +354,17 @@ // basic "expect / extract" functions - void str(std::string & v) { v = token; eat(TOK_STRING); } + void str(string & v) { v = token; eat(TOK_STRING); } void str() { eat(TOK_STRING); } - void sym(std::string & v) { v = token; eat(TOK_SYMBOL); } + void sym(string & v) { v = token; eat(TOK_SYMBOL); } void sym() { eat(TOK_SYMBOL); } - void num(std::string & v) { v = token; eat(TOK_NUM); } + void num(string & v) { v = token; eat(TOK_NUM); } void num() { eat(TOK_NUM); } void semi() { eat(TOK_SEMI); } void colon() { eat(TOK_COLON); } - void expect(std::string const & expected) + void expect(string const & expected) { - std::string tmp; + string tmp; if (!symp(expected)) throw oops((F("parse failure %d:%d: expecting word '%s'\n") % line % col % expected).str()); @@ -381,7 +386,7 @@ advance(); } - void parse_newphrases(std::string const & terminator) + void parse_newphrases(string const & terminator) { while(symp() && !symp(terminator)) { @@ -405,7 +410,7 @@ while(symp() || nump()) { - std::string stmp, ntmp; + string stmp, ntmp; if (symp()) { sym(stmp); colon(); num(ntmp); @@ -436,7 +441,7 @@ expect("branches"); while(nump()) { - std::string tmp; + string tmp; num(tmp); d.branches.push_back(tmp); } @@ -477,14 +482,14 @@ }; void -parse_rcs_file(std::string const & filename, rcs_file & r) +parse_rcs_file(string const & filename, rcs_file & r) { #if defined(HAVE_MMAP) || defined(WIN32) file_handle handle(filename); file_source ifs(filename, handle.fd, handle.length); #else - std::ifstream ifs(filename.c_str()); - ifs.unsetf(std::ios_base::skipws); + ifstream ifs(filename.c_str()); + ifs.unsetf(ios_base::skipws); #endif parser p(ifs, r); p.parse_file(); ============================================================ --- rcs_import.cc 36d442b3ce162881956dffeb17d9ff88d70ea794 +++ rcs_import.cc cc36f7773a0101a51850cc9f218b6f5dd6272a24 @@ -42,9 +42,19 @@ #include "transforms.hh" #include "ui.hh" -using namespace std; -using boost::shared_ptr; +using std::make_pair; +using std::map; +using std::multimap; +using std::out_of_range; +using std::pair; +using std::set; +using std::stack; +using std::string; +using std::vector; + using boost::scoped_ptr; +using boost::shared_ptr; +using boost::lexical_cast; // cvs history recording stuff @@ -292,8 +302,8 @@ struct piece_store { - vector< boost::shared_ptr > texts; - void index_deltatext(boost::shared_ptr const & dt, + vector< shared_ptr > texts; + void index_deltatext(shared_ptr const & dt, vector & pieces); void build_string(vector const & pieces, string & out); @@ -333,7 +343,7 @@ } void -piece_store::index_deltatext(boost::shared_ptr const & dt, +piece_store::index_deltatext(shared_ptr const & dt, vector & pieces) { pieces.clear(); @@ -397,13 +407,13 @@ else throw oops("unknown directive '" + directive + "'"); } - catch (std::out_of_range & oor) + catch (out_of_range & oor) { - throw oops("std::out_of_range while processing " + directive + throw oops("out_of_range while processing " + directive + " with source.size() == " - + boost::lexical_cast(source.size()) + + lexical_cast(source.size()) + " and cursor == " - + boost::lexical_cast(cursor)); + + lexical_cast(cursor)); } } @@ -607,7 +617,7 @@ // recursively follow any branch commits coming from the branchpoint - boost::shared_ptr curr_delta = r.deltas.find(curr_version)->second; + shared_ptr curr_delta = r.deltas.find(curr_version)->second; for(vector::const_iterator i = curr_delta->branches.begin(); i != curr_delta->branches.end(); ++i) { @@ -752,8 +762,8 @@ ui.set_tick_trailer(ss); ss.resize(ss.size() - 2); // remove Attic/ if present - std::string::size_type last_slash=ss.rfind('/'); - if (last_slash!=std::string::npos && last_slash>=5 + string::size_type last_slash=ss.rfind('/'); + if (last_slash!=string::npos && last_slash>=5 && ss.substr(last_slash-5,6)=="Attic/") ss.erase(last_slash-5,6); curr_file = file_path_internal(ss); @@ -765,11 +775,11 @@ branchpoints.clear(); branch_first_entries.clear(); - for (std::multimap::const_iterator i = + for (multimap::const_iterator i = r.admin.symbols.begin(); i != r.admin.symbols.end(); ++i) { - std::string const & num = i->first; - std::string const & sym = i->second; + string const & num = i->first; + string const & sym = i->second; vector components; split_version(num, components); @@ -1450,7 +1460,7 @@ I(!c.entries.empty()); shared_ptr rev(new revision_set()); - boost::shared_ptr cs(new cset()); + shared_ptr cs(new cset()); build_cset(c, *cs); cs->apply_to(editable_ros); ============================================================ --- refiner.cc baa7581b2a14e8f76c65e90aa682bd54a44cb292 +++ refiner.cc f2f64fe6722f3501ce1fea2d85516818070151e2 @@ -17,9 +17,11 @@ #include "netcmd.hh" #include "netsync.hh" -using std::string; +using std::inserter; +using std::make_pair; using std::set; -using std::make_pair; +using std::set_difference; +using std::string; // Our goal is to learn the complete set of items to send. To do this // we exchange two types of refinement commands: queries and responses. @@ -68,7 +70,7 @@ refiner::load_merkle_node(size_t level, prefix const & pref, merkle_ptr & node) { - merkle_table::const_iterator j = table.find(std::make_pair(pref, level)); + merkle_table::const_iterator j = table.find(make_pair(pref, level)); I(j != table.end()); node = j->second; } @@ -77,7 +79,7 @@ refiner::merkle_node_exists(size_t level, prefix const & pref) { - merkle_table::const_iterator j = table.find(std::make_pair(pref, level)); + merkle_table::const_iterator j = table.find(make_pair(pref, level)); return (j != table.end()); } @@ -90,9 +92,9 @@ items_to_send.clear(); items_to_receive = 0; - std::set_difference(local_items.begin(), local_items.end(), - peer_items.begin(), peer_items.end(), - std::inserter(items_to_send, items_to_send.begin())); + set_difference(local_items.begin(), local_items.end(), + peer_items.begin(), peer_items.end(), + inserter(items_to_send, items_to_send.begin())); string typestr; netcmd_item_type_to_string(type, typestr); ============================================================ --- revision.cc e41a1f765fa1a8d68288a62f74da3215864ada44 +++ revision.cc ef6feacfdac32584040843bcd70f3bb66df67ad7 @@ -40,6 +40,21 @@ #include "safe_map.hh" #include "legacy.hh" +using std::back_inserter; +using std::copy; +using std::deque; +using std::list; +using std::make_pair; +using std::map; +using std::max; +using std::multimap; +using std::ostringstream; +using std::pair; +using std::queue; +using std::set; +using std::stack; +using std::string; +using std::vector; void revision_set::check_sane() const { @@ -140,8 +155,8 @@ static void calculate_ancestors_from_graph(interner & intern, revision_id const & init, - std::multimap const & graph, - std::map< ctx, shared_bitmap > & ancestors, + multimap const & graph, + map< ctx, shared_bitmap > & ancestors, shared_bitmap & total_union); void @@ -151,8 +166,8 @@ app_state & app) { interner intern; - std::set leaves; - std::map ancestors; + set leaves; + map ancestors; shared_bitmap isect = shared_bitmap(new bitmap()); shared_bitmap isect_ancs = shared_bitmap(new bitmap()); @@ -161,13 +176,13 @@ leaves.insert(intern.intern(right.inner()())); - std::multimap inverse_graph; + multimap inverse_graph; { - std::multimap graph; + multimap graph; app.db.get_revision_ancestry(graph); - typedef std::multimap::const_iterator gi; + typedef multimap::const_iterator gi; for (gi i = graph.begin(); i != graph.end(); ++i) - inverse_graph.insert(std::make_pair(i->second, i->first)); + inverse_graph.insert(make_pair(i->second, i->first)); } @@ -177,11 +192,11 @@ isect_ancs->clear(); // First intersect all ancestors of current leaf set - for (std::set::const_iterator i = leaves.begin(); i != leaves.end(); ++i) + for (set::const_iterator i = leaves.begin(); i != leaves.end(); ++i) { ctx curr_leaf = *i; shared_bitmap curr_leaf_ancestors; - std::map::const_iterator j = ancestors.find(*i); + map::const_iterator j = ancestors.find(*i); if (j != ancestors.end()) curr_leaf_ancestors = j->second; else @@ -206,7 +221,7 @@ // isect is now the set of common ancestors of leaves, but that is not enough. // We need the set of leaves of isect; to do that we calculate the set of // ancestors of isect, in order to subtract it from isect (below). - std::set new_leaves; + set new_leaves; for (ctx i = 0; i < isect->size(); ++i) { if (isect->test(i)) @@ -239,11 +254,11 @@ template static bool is_ancestor(T const & ancestor_id, T const & descendent_id, - std::multimap const & graph) + multimap const & graph) { - std::set visited; - std::queue queue; + set visited; + queue queue; queue.push(ancestor_id); @@ -256,8 +271,8 @@ return true; else { - typedef typename std::multimap::const_iterator gi; - std::pair children = graph.equal_range(current_id); + typedef typename multimap::const_iterator gi; + pair children = graph.equal_range(current_id); for (gi i = children.first; i != children.second; ++i) { if (visited.find(i->second) == visited.end()) @@ -278,7 +293,7 @@ { L(FL("checking whether %s is an ancestor of %s\n") % ancestor_id % descendent_id); - std::multimap graph; + multimap graph; app.db.get_revision_ancestry(graph); return is_ancestor(ancestor_id, descendent_id, graph); } @@ -299,12 +314,12 @@ static void calculate_ancestors_from_graph(interner & intern, revision_id const & init, - std::multimap const & graph, - std::map< ctx, shared_bitmap > & ancestors, + multimap const & graph, + map< ctx, shared_bitmap > & ancestors, shared_bitmap & total_union) { - typedef std::multimap::const_iterator gi; - std::stack stk; + typedef multimap::const_iterator gi; + stack stk; stk.push(intern.intern(init.inner()())); @@ -313,7 +328,7 @@ ctx us = stk.top(); revision_id rev(hexenc(intern.lookup(us))); - std::pair parents = graph.equal_range(rev); + pair parents = graph.equal_range(rev); bool pushed = false; // first make sure all parents are done @@ -348,13 +363,13 @@ I(ancestors.find(parent) != ancestors.end()); // union them into our map - std::map< ctx, shared_bitmap >::const_iterator j = ancestors.find(parent); + map< ctx, shared_bitmap >::const_iterator j = ancestors.find(parent); I(j != ancestors.end()); add_bitset_to_union(j->second, b); } add_bitset_to_union(b, total_union); - ancestors.insert(std::make_pair(us, b)); + ancestors.insert(make_pair(us, b)); stk.pop(); } } @@ -363,24 +378,24 @@ // passed in set. if anyone ever needs to toposort the whole graph, then, // this function would be a good thing to generalize... void -toposort(std::set const & revisions, - std::vector & sorted, +toposort(set const & revisions, + vector & sorted, app_state & app) { sorted.clear(); - typedef std::multimap::iterator gi; - typedef std::map::iterator pi; - std::multimap graph; + typedef multimap::iterator gi; + typedef map::iterator pi; + multimap graph; app.db.get_revision_ancestry(graph); - std::set leaves; + set leaves; app.db.get_revision_ids(leaves); - std::map pcount; + map pcount; for (gi i = graph.begin(); i != graph.end(); ++i) - pcount.insert(std::make_pair(i->first, 0)); + pcount.insert(make_pair(i->first, 0)); for (gi i = graph.begin(); i != graph.end(); ++i) ++(pcount[i->second]); // first find the set of graph roots - std::list roots; + list roots; for (pi i = pcount.begin(); i != pcount.end(); ++i) if(i->second==0) roots.push_back(i->first); @@ -400,7 +415,7 @@ roots.pop_front(); } I(graph.empty()); - for (std::set::const_iterator i = leaves.begin(); + for (set::const_iterator i = leaves.begin(); i != leaves.end(); ++i) { L(FL("new leaf: %s\n") % (*i)); @@ -413,29 +428,29 @@ // set such that A is an ancestor of B, it erases A. void -erase_ancestors(std::set & revisions, app_state & app) +erase_ancestors(set & revisions, app_state & app) { - typedef std::multimap::const_iterator gi; - std::multimap graph; - std::multimap inverse_graph; + typedef multimap::const_iterator gi; + multimap graph; + multimap inverse_graph; app.db.get_revision_ancestry(graph); for (gi i = graph.begin(); i != graph.end(); ++i) - inverse_graph.insert(std::make_pair(i->second, i->first)); + inverse_graph.insert(make_pair(i->second, i->first)); interner intern; - std::map< ctx, shared_bitmap > ancestors; + map< ctx, shared_bitmap > ancestors; shared_bitmap u = shared_bitmap(new bitmap()); - for (std::set::const_iterator i = revisions.begin(); + for (set::const_iterator i = revisions.begin(); i != revisions.end(); ++i) { calculate_ancestors_from_graph(intern, *i, inverse_graph, ancestors, u); } - std::set tmp; - for (std::set::const_iterator i = revisions.begin(); + set tmp; + for (set::const_iterator i = revisions.begin(); i != revisions.end(); ++i) { ctx id = intern.intern(i->inner()()); @@ -453,25 +468,25 @@ // that's not in the Bs. If the output set if non-empty, then A will // certainly be in it; but the output set might be empty. void -ancestry_difference(revision_id const & a, std::set const & bs, - std::set & new_stuff, +ancestry_difference(revision_id const & a, set const & bs, + set & new_stuff, app_state & app) { new_stuff.clear(); - typedef std::multimap::const_iterator gi; - std::multimap graph; - std::multimap inverse_graph; + typedef multimap::const_iterator gi; + multimap graph; + multimap inverse_graph; app.db.get_revision_ancestry(graph); for (gi i = graph.begin(); i != graph.end(); ++i) - inverse_graph.insert(std::make_pair(i->second, i->first)); + inverse_graph.insert(make_pair(i->second, i->first)); interner intern; - std::map< ctx, shared_bitmap > ancestors; + map< ctx, shared_bitmap > ancestors; shared_bitmap u = shared_bitmap(new bitmap()); - for (std::set::const_iterator i = bs.begin(); + for (set::const_iterator i = bs.begin(); i != bs.end(); ++i) { calculate_ancestors_from_graph(intern, *i, inverse_graph, ancestors, u); @@ -490,8 +505,8 @@ au->set(c); } - au->resize(std::max(au->size(), u->size())); - u->resize(std::max(au->size(), u->size())); + au->resize(max(au->size(), u->size())); + u->resize(max(au->size(), u->size())); *au -= *u; @@ -510,7 +525,7 @@ select_nodes_modified_by_rev(revision_id const & rid, revision_set const & rev, roster_t const new_roster, - std::set & nodes_modified, + set & nodes_modified, app_state & app) { nodes_modified.clear(); @@ -518,7 +533,7 @@ for (edge_map::const_iterator i = rev.edges.begin(); i != rev.edges.end(); ++i) { - std::set edge_nodes_modified; + set edge_nodes_modified; roster_t old_roster; app.db.get_roster(edge_old_revision(i), old_roster); select_nodes_modified_by_cset(edge_changes(i), @@ -526,7 +541,7 @@ new_roster, edge_nodes_modified); - std::copy(edge_nodes_modified.begin(), edge_nodes_modified.end(), + copy(edge_nodes_modified.begin(), edge_nodes_modified.end(), inserter(nodes_modified, nodes_modified.begin())); } } @@ -546,32 +561,32 @@ calculate_ident(new_roster, rev.new_manifest); L(FL("new manifest_id is %s\n") % rev.new_manifest); - safe_insert(rev.edges, std::make_pair(old_rev_id, cs)); + safe_insert(rev.edges, make_pair(old_rev_id, cs)); } // Stuff related to rebuilding the revision graph. Unfortunately this is a // real enough error case that we need support code for it. -typedef std::map, +typedef map, boost::shared_ptr > > parent_roster_map; template <> void -dump(parent_roster_map const & prm, std::string & out) +dump(parent_roster_map const & prm, string & out) { - std::ostringstream oss; + ostringstream oss; for (parent_roster_map::const_iterator i = prm.begin(); i != prm.end(); ++i) { oss << "roster: " << i->first << "\n"; - std::string roster_str, indented_roster_str; + string roster_str, indented_roster_str; dump(*i->second.first, roster_str); prefix_lines_with(" ", roster_str, indented_roster_str); oss << indented_roster_str; oss << "\nroster's marking:\n"; - std::string marking_str, indented_marking_str; + string marking_str, indented_marking_str; dump(*i->second.second, marking_str); prefix_lines_with(" ", marking_str, indented_marking_str); oss << indented_marking_str; @@ -601,20 +616,20 @@ ticker n_revs_out; ticker n_certs_out; - std::map node_to_old_man; - std::map old_man_to_node; + map node_to_old_man; + map old_man_to_node; - std::map node_to_old_rev; - std::map old_rev_to_node; + map node_to_old_rev; + map old_rev_to_node; - std::map node_to_new_rev; - std::map new_rev_to_node; + map node_to_new_rev; + map new_rev_to_node; - std::map node_to_renames; + map node_to_renames; - std::multimap > certs; - std::multimap ancestry; - std::set branches; + multimap > certs; + multimap ancestry; + set branches; void add_node_ancestry(u64 child, u64 parent); void write_certs(); @@ -633,12 +648,12 @@ void anc_graph::add_node_ancestry(u64 child, u64 parent) { L(FL("noting ancestry from child %d -> parent %d\n") % child % parent); - ancestry.insert(std::make_pair(child, parent)); + ancestry.insert(make_pair(child, parent)); } void anc_graph::get_node_manifest(u64 node, manifest_id & man) { - std::map::const_iterator i = node_to_old_man.find(node); + map::const_iterator i = node_to_old_man.find(node); I(i != node_to_old_man.end()); man = i->second; } @@ -648,12 +663,12 @@ { // regenerate epochs on all branches to random states - for (std::set::const_iterator i = branches.begin(); i != branches.end(); ++i) + for (set::const_iterator i = branches.begin(); i != branches.end(); ++i) { char buf[constants::epochlen_bytes]; Botan::Global_RNG::randomize(reinterpret_cast(buf), constants::epochlen_bytes); hexenc hexdata; - encode_hexenc(data(std::string(buf, buf + constants::epochlen_bytes)), hexdata); + encode_hexenc(data(string(buf, buf + constants::epochlen_bytes)), hexdata); epoch_data new_epoch(hexdata); L(FL("setting epoch for %s to %s\n") % *i % new_epoch); app.db.set_epoch(cert_value(*i), new_epoch); @@ -661,14 +676,14 @@ } - typedef std::multimap >::const_iterator ci; + typedef multimap >::const_iterator ci; - for (std::map::const_iterator i = node_to_new_rev.begin(); + for (map::const_iterator i = node_to_new_rev.begin(); i != node_to_new_rev.end(); ++i) { revision_id rev(i->second); - std::pair range = certs.equal_range(i->first); + pair range = certs.equal_range(i->first); for (ci j = range.first; j != range.second; ++j) { @@ -711,16 +726,16 @@ P(F("scanning for bogus merge edges\n")); - std::multimap parent_to_child_map; - for (std::multimap::const_iterator i = ancestry.begin(); + multimap parent_to_child_map; + for (multimap::const_iterator i = ancestry.begin(); i != ancestry.end(); ++i) - parent_to_child_map.insert(std::make_pair(i->second, i->first)); + parent_to_child_map.insert(make_pair(i->second, i->first)); - std::map edges_to_kill; - for (std::multimap::const_iterator i = ancestry.begin(); + map edges_to_kill; + for (multimap::const_iterator i = ancestry.begin(); i != ancestry.end(); ++i) { - std::multimap::const_iterator j = i; + multimap::const_iterator j = i; ++j; u64 child = i->first; // NB: ancestry is a multimap from child->parent(s) @@ -733,20 +748,20 @@ u64 parent1 = i->second; u64 parent2 = j->second; if (is_ancestor (parent1, parent2, parent_to_child_map)) - safe_insert(edges_to_kill, std::make_pair(child, parent1)); + safe_insert(edges_to_kill, make_pair(child, parent1)); else if (is_ancestor (parent2, parent1, parent_to_child_map)) - safe_insert(edges_to_kill, std::make_pair(child, parent2)); + safe_insert(edges_to_kill, make_pair(child, parent2)); } } } - for (std::map::const_iterator i = edges_to_kill.begin(); + for (map::const_iterator i = edges_to_kill.begin(); i != edges_to_kill.end(); ++i) { u64 child = i->first; u64 parent = i->second; bool killed = false; - for (std::multimap::iterator j = ancestry.lower_bound(child); + for (multimap::iterator j = ancestry.lower_bound(child); j->first == child; ++j) { if (j->second == parent) @@ -794,22 +809,22 @@ node = max_node++; ++n_nodes; L(FL("node %d = manifest %s\n") % node % man); - old_man_to_node.insert(std::make_pair(man, node)); - node_to_old_man.insert(std::make_pair(node, man)); + old_man_to_node.insert(make_pair(man, node)); + node_to_old_man.insert(make_pair(node, man)); // load certs - std::vector< manifest > mcerts; + vector< manifest > mcerts; app.db.get_manifest_certs(man, mcerts); erase_bogus_certs(mcerts, app); - for(std::vector< manifest >::const_iterator i = mcerts.begin(); + for(vector< manifest >::const_iterator i = mcerts.begin(); i != mcerts.end(); ++i) { L(FL("loaded '%s' manifest cert for node %s\n") % i->inner().name % node); cert_value tv; decode_base64(i->inner().value, tv); ++n_certs_in; - certs.insert(std::make_pair(node, - std::make_pair(i->inner().name, tv))); + certs.insert(make_pair(node, + make_pair(i->inner().name, tv))); } } else @@ -834,24 +849,24 @@ legacy::get_manifest_and_renames_for_rev(app, rev, man, renames); L(FL("node %d = revision %s = manifest %s\n") % node % rev % man); - old_rev_to_node.insert(std::make_pair(rev, node)); - node_to_old_rev.insert(std::make_pair(node, rev)); - node_to_old_man.insert(std::make_pair(node, man)); - node_to_renames.insert(std::make_pair(node, renames)); + old_rev_to_node.insert(make_pair(rev, node)); + node_to_old_rev.insert(make_pair(node, rev)); + node_to_old_man.insert(make_pair(node, man)); + node_to_renames.insert(make_pair(node, renames)); // load certs - std::vector< revision > rcerts; + vector< revision > rcerts; app.db.get_revision_certs(rev, rcerts); erase_bogus_certs(rcerts, app); - for(std::vector< revision >::const_iterator i = rcerts.begin(); + for(vector< revision >::const_iterator i = rcerts.begin(); i != rcerts.end(); ++i) { L(FL("loaded '%s' revision cert for node %s\n") % i->inner().name % node); cert_value tv; decode_base64(i->inner().value, tv); ++n_certs_in; - certs.insert(std::make_pair(node, - std::make_pair(i->inner().name, tv))); + certs.insert(make_pair(node, + make_pair(i->inner().name, tv))); if (i->inner().name == branch_cert_name) branches.insert(tv()); @@ -868,7 +883,7 @@ static bool not_dead_yet(node_id nid, u64 birth_rev, parent_roster_map const & parent_rosters, - std::multimap const & child_to_parents) + multimap const & child_to_parents) { // Any given node, at each point in the revision graph, is in one of the // states "alive", "unborn", "dead". The invariant we must maintain in @@ -895,8 +910,8 @@ if (!parent->has_node(nid)) { - std::deque work; - std::set seen; + deque work; + set seen; work.push_back(r->first); while (!work.empty()) { @@ -914,8 +929,8 @@ // L(FL("node is dead in %d") % r->first); return false; } - typedef std::multimap::const_iterator ci; - std::pair range = child_to_parents.equal_range(curr); + typedef multimap::const_iterator ci; + pair range = child_to_parents.equal_range(curr); for (ci i = range.first; i != range.second; ++i) { if (i->first != curr) @@ -931,7 +946,7 @@ static split_path -find_old_path_for(std::map const & renames, +find_old_path_for(map const & renames, split_path const & new_path) { split_path leader, trailer; @@ -948,19 +963,19 @@ trailer.insert(trailer.begin(), pc); } split_path result; - std::copy(leader.begin(), leader.end(), std::back_inserter(result)); - std::copy(trailer.begin(), trailer.end(), std::back_inserter(result)); + copy(leader.begin(), leader.end(), back_inserter(result)); + copy(trailer.begin(), trailer.end(), back_inserter(result)); return result; } static split_path -find_new_path_for(std::map const & renames, +find_new_path_for(map const & renames, split_path const & old_path) { - std::map reversed; - for (std::map::const_iterator i = renames.begin(); + map reversed; + for (map::const_iterator i = renames.begin(); i != renames.end(); ++i) - reversed.insert(std::make_pair(i->second, i->first)); + reversed.insert(make_pair(i->second, i->first)); // this is a hackish kluge. seems to work, though. return find_old_path_for(reversed, old_path); } @@ -1028,7 +1043,7 @@ // Map node_id -> birth rev - std::map nodes_in_any_parent; + map nodes_in_any_parent; // Stage 1: collect all nodes (and their birth revs) in any parent. for (parent_roster_map::const_iterator i = parent_rosters.begin(); @@ -1043,18 +1058,18 @@ node_id n = j->first; revision_id birth_rev = safe_get(*parent_marking, n).birth_revision; u64 birth_node = safe_get(new_rev_to_node, birth_rev); - std::map::const_iterator i = nodes_in_any_parent.find(n); + map::const_iterator i = nodes_in_any_parent.find(n); if (i != nodes_in_any_parent.end()) I(i->second == birth_node); else safe_insert(nodes_in_any_parent, - std::make_pair(n, birth_node)); + make_pair(n, birth_node)); } } // Stage 2: For any node which is actually live, try to locate a mapping // from a parent instance of it to a child node. - for (std::map::const_iterator i = nodes_in_any_parent.begin(); + for (map::const_iterator i = nodes_in_any_parent.begin(); i != nodes_in_any_parent.end(); ++i) { node_id n = i->first; @@ -1115,10 +1130,10 @@ }; template <> void -dump(current_rev_debugger const & d, std::string & out) +dump(current_rev_debugger const & d, string & out) { - typedef std::multimap >::const_iterator ci; - std::pair range = d.agraph.certs.equal_range(d.node); + typedef multimap >::const_iterator ci; + pair range = d.agraph.certs.equal_range(d.node); for(ci i = range.first; i != range.second; ++i) { if (i->first == d.node) @@ -1142,22 +1157,22 @@ // need to worry about one side of the frontier advancing faster than // another. - typedef std::multimap::const_iterator ci; - std::multimap parent_to_child_map; - std::deque work; - std::set done; + typedef multimap::const_iterator ci; + multimap parent_to_child_map; + deque work; + set done; { // Set up the parent->child mapping and prime the work queue - std::set children, all; - for (std::multimap::const_iterator i = ancestry.begin(); + set children, all; + for (multimap::const_iterator i = ancestry.begin(); i != ancestry.end(); ++i) { - parent_to_child_map.insert(std::make_pair(i->second, i->first)); + parent_to_child_map.insert(make_pair(i->second, i->first)); children.insert(i->first); } - for (std::map::const_iterator i = node_to_old_man.begin(); + for (map::const_iterator i = node_to_old_man.begin(); i != node_to_old_man.end(); ++i) { all.insert(i->first); @@ -1165,7 +1180,7 @@ set_difference(all.begin(), all.end(), children.begin(), children.end(), - std::back_inserter(work)); + back_inserter(work)); } while (!work.empty()) @@ -1181,8 +1196,8 @@ if (done.find(child) != done.end()) continue; - std::pair parent_range = ancestry.equal_range(child); - std::set parents; + pair parent_range = ancestry.equal_range(child); + set parents; bool parents_all_done = true; for (ci i = parent_range.first; parents_all_done && i != parent_range.second; ++i) { @@ -1225,7 +1240,7 @@ boost::shared_ptr ros = boost::shared_ptr(new roster_t()); boost::shared_ptr mm = boost::shared_ptr(new marking_map()); app.db.get_roster(safe_get(node_to_new_rev, parent), *ros, *mm); - safe_insert(parent_rosters, std::make_pair(parent, std::make_pair(ros, mm))); + safe_insert(parent_rosters, make_pair(parent, make_pair(ros, mm))); } } @@ -1274,13 +1289,13 @@ j->first.split(sp); if (child_roster.has_node(sp)) { - std::map const & + map const & fattrs = j->second; - for (std::map::const_iterator + for (map::const_iterator k = fattrs.begin(); k != fattrs.end(); ++k) { - std::string key = k->first; + string key = k->first; if (app.attrs_to_drop.find(key) != app.attrs_to_drop.end()) { // ignore it @@ -1322,7 +1337,7 @@ boost::shared_ptr cs = boost::shared_ptr(new cset()); MM(*cs); make_cset(*parent_roster, child_roster, *cs); - safe_insert(rev.edges, std::make_pair(parent_rid, cs)); + safe_insert(rev.edges, make_pair(parent_rid, cs)); } // It is possible that we're at a "root" node here -- a node @@ -1337,7 +1352,7 @@ boost::shared_ptr cs = boost::shared_ptr(new cset()); MM(*cs); make_cset(*parent_roster, child_roster, *cs); - safe_insert(rev.edges, std::make_pair (parent_rid, cs)); + safe_insert(rev.edges, make_pair (parent_rid, cs)); } @@ -1346,8 +1361,8 @@ revision_id new_rid; calculate_ident(rev, new_rid); - node_to_new_rev.insert(std::make_pair(child, new_rid)); - new_rev_to_node.insert(std::make_pair(new_rid, child)); + node_to_new_rev.insert(make_pair(child, new_rid)); + new_rev_to_node.insert(make_pair(new_rid, child)); /* P(F("------------------------------------------------\n")); @@ -1355,7 +1370,7 @@ % new_rid % rev.edges.size() % rev.new_manifest); { - std::string rtmp; + string rtmp; data dtmp; dump(dbg, rtmp); write_revision_set(rev, dtmp); @@ -1380,7 +1395,7 @@ safe_insert(done, child); // Extend the work queue with all the children of this child - std::pair grandchild_range = parent_to_child_map.equal_range(child); + pair grandchild_range = parent_to_child_map.equal_range(child); for (ci i = grandchild_range.first; i != grandchild_range.second; ++i) { @@ -1403,7 +1418,7 @@ anc_graph graph(true, app); P(F("converting existing revision graph to new roster-style revisions\n")); - std::multimap existing_graph; + multimap existing_graph; { // early short-circuit to avoid failure after lots of work @@ -1418,11 +1433,11 @@ // committed under it), then we will simply drop it! // This code at least causes this case to throw an assertion; FIXME: make // this case actually work. - std::set all_rev_ids; + set all_rev_ids; app.db.get_revision_ids(all_rev_ids); app.db.get_revision_ancestry(existing_graph); - for (std::multimap::const_iterator i = existing_graph.begin(); + for (multimap::const_iterator i = existing_graph.begin(); i != existing_graph.end(); ++i) { // FIXME: insert for the null id as well, and do the same for the @@ -1438,7 +1453,7 @@ } } - for (std::set::const_iterator i = all_rev_ids.begin(); + for (set::const_iterator i = all_rev_ids.begin(); i != all_rev_ids.end(); ++i) { graph.add_node_for_oldstyle_revision(*i); @@ -1466,11 +1481,11 @@ require_password(key, app); } - std::vector< manifest > tmp; + vector< manifest > tmp; app.db.get_manifest_certs(cert_name("ancestor"), tmp); erase_bogus_certs(tmp, app); - for (std::vector< manifest >::const_iterator i = tmp.begin(); + for (vector< manifest >::const_iterator i = tmp.begin(); i != tmp.end(); ++i) { cert_value tv; @@ -1538,7 +1553,7 @@ MM(*cs); manifest_id old_man; revision_id old_rev; - std::string tmp; + string tmp; parser.esym(syms::old_revision); parser.hex(tmp); @@ -1546,7 +1561,7 @@ parse_cset(parser, *cs); - es.insert(std::make_pair(old_rev, cs)); + es.insert(make_pair(old_rev, cs)); } @@ -1556,7 +1571,7 @@ { MM(rev); rev.edges.clear(); - std::string tmp; + string tmp; parser.esym(syms::format_version); parser.str(tmp); E(tmp == "1", @@ -1602,7 +1617,7 @@ } template <> void -dump(revision_set const & rev, std::string & out) +dump(revision_set const & rev, string & out) { data dat; write_insane_revision_set(rev, dat); @@ -1643,7 +1658,7 @@ static void test_find_old_new_path_for() { - std::map renames; + map renames; split_path foo, foo_bar, foo_baz, quux, quux_baz; file_path_internal("foo").split(foo); file_path_internal("foo/bar").split(foo_bar); ============================================================ --- roster.cc 5955f1339c8276c1ad2964abf5051b7d9cb13890 +++ roster.cc fde433622561c188f726b4b591388c070cc1e391 @@ -30,6 +30,7 @@ using std::inserter; using std::make_pair; using std::map; +using std::ostringstream; using std::pair; using std::reverse; using std::set; @@ -37,15 +38,16 @@ using std::stack; using std::string; using std::vector; + using boost::lexical_cast; /////////////////////////////////////////////////////////////////// template <> void -dump(full_attr_map_t const & val, std::string & out) +dump(full_attr_map_t const & val, string & out) { - std::ostringstream oss; + 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" @@ -54,11 +56,11 @@ } template <> void -dump(std::set const & revids, std::string & out) +dump(set const & revids, string & out) { out.clear(); bool first = true; - for (std::set::const_iterator i = revids.begin(); + for (set::const_iterator i = revids.begin(); i != revids.end(); ++i) { if (!first) @@ -69,17 +71,17 @@ } template <> void -dump(marking_t const & marking, std::string & out) +dump(marking_t const & marking, string & out) { - std::ostringstream oss; - std::string tmp; + ostringstream oss; + string tmp; oss << "birth_revision: " << marking.birth_revision << "\n"; dump(marking.parent_name, tmp); oss << "parent_name: " << tmp << "\n"; dump(marking.file_content, tmp); oss << "file_content: " << tmp << "\n"; oss << "attrs (number: " << marking.attrs.size() << "):\n"; - for (std::map >::const_iterator + for (map >::const_iterator i = marking.attrs.begin(); i != marking.attrs.end(); ++i) { dump(i->second, tmp); @@ -89,15 +91,15 @@ } template <> void -dump(marking_map const & markings, std::string & out) +dump(marking_map const & markings, string & out) { - std::ostringstream oss; + ostringstream oss; for (marking_map::const_iterator i = markings.begin(); i != markings.end(); ++i) { oss << "Marking for " << i->first << ":\n"; - std::string marking_str, indented_marking_str; + string marking_str, indented_marking_str; dump(i->second, marking_str); prefix_lines_with(" ", marking_str, indented_marking_str); oss << indented_marking_str << "\n"; @@ -242,16 +244,16 @@ } template <> void -dump(node_t const & n, std::string & out) +dump(node_t const & n, string & out) { - std::ostringstream oss; - std::string name; + ostringstream oss; + string name; dump(n->name, name); oss << "address: " << n << " (uses: " << n.use_count() << ")\n" << "self: " << n->self << "\n" << "parent: " << n->parent << "\n" << "name: " << name << "\n"; - std::string attr_map_s; + string attr_map_s; dump(n->attrs, attr_map_s); oss << "attrs:\n" << attr_map_s; oss << "type: "; @@ -282,7 +284,7 @@ I(nodes.empty()); for (node_map::const_iterator i = other.nodes.begin(); i != other.nodes.end(); ++i) - safe_insert(nodes, std::make_pair(i->first, i->second->clone())); + safe_insert(nodes, make_pair(i->first, i->second->clone())); for (node_map::iterator i = nodes.begin(); i != nodes.end(); ++i) if (is_dir_t(i->second)) { @@ -714,7 +716,7 @@ // this iterator might point to old_locations.end(), because old_locations // only includes entries for renames, not new nodes - std::map >::iterator + map >::iterator i = old_locations.find(nid); if (null_node(parent) || null_name(name)) @@ -785,9 +787,9 @@ } template <> void -dump(roster_t const & val, std::string & out) +dump(roster_t const & val, string & out) { - std::ostringstream oss; + ostringstream oss; if (val.root_dir) oss << "Root node: " << val.root_dir->self << "\n" << " at " << val.root_dir << ", uses: " << val.root_dir.use_count() << "\n"; @@ -796,7 +798,7 @@ for (node_map::const_iterator i = val.nodes.begin(); i != val.nodes.end(); ++i) { oss << "\nNode " << i->first << "\n"; - std::string node_s; + string node_s; dump(i->second, node_s); oss << node_s; } @@ -875,7 +877,7 @@ I(mi->second.file_content.empty()); full_attr_map_t::const_iterator rai; - std::map >::const_iterator mai; + map >::const_iterator mai; for (rai = ri->second->attrs.begin(), mai = mi->second.attrs.begin(); rai != ri->second->attrs.end() && mai != mi->second.attrs.end(); ++rai, ++mai) @@ -1290,9 +1292,9 @@ new_marking.birth_revision = parent_marking.birth_revision; mark_unmerged_scalar(parent_marking.parent_name, - std::make_pair(parent_n->parent, parent_n->name), + make_pair(parent_n->parent, parent_n->name), new_rid, - std::make_pair(n->parent, n->name), + make_pair(n->parent, n->name), new_marking.parent_name); if (is_file_t(n)) @@ -1334,11 +1336,11 @@ // name mark_merged_scalar(left_marking.parent_name, left_uncommon_ancestors, - std::make_pair(ln->parent, ln->name), + make_pair(ln->parent, ln->name), right_marking.parent_name, right_uncommon_ancestors, - std::make_pair(rn->parent, rn->name), + make_pair(rn->parent, rn->name), new_rid, - std::make_pair(n->parent, n->name), + make_pair(n->parent, n->name), new_marking.parent_name); // content if (is_file_t(n)) @@ -1547,7 +1549,7 @@ { node_id nid = r.get_node(pth)->self; marking_map::iterator marking = markings.find(nid); - std::map >::iterator am = marking->second.attrs.find(name); + map >::iterator am = marking->second.attrs.find(name); if (am == marking->second.attrs.end()) { marking->second.attrs.insert(make_pair(name, set())); @@ -1572,13 +1574,13 @@ roster_t const & left_roster, marking_map const & left_markings, cset const & left_cs, - std::set left_uncommon_ancestors, + set left_uncommon_ancestors, revision_id const & right_rid, roster_t const & right_roster, marking_map const & right_markings, cset const & right_cs, - std::set right_uncommon_ancestors, + set right_uncommon_ancestors, revision_id const & new_rid, roster_t & new_roster, @@ -1996,7 +1998,7 @@ } } - for (std::map::const_iterator i = cs.files_added.begin(); + for (map::const_iterator i = cs.files_added.begin(); i != cs.files_added.end(); ++i) { split_path dir(i->first); @@ -2019,7 +2021,7 @@ select_nodes_modified_by_cset(cset const & cs, roster_t const & old_roster, roster_t const & new_roster, - std::set & nodes_modified) + set & nodes_modified) { nodes_modified.clear(); @@ -2031,7 +2033,7 @@ copy(cs.nodes_deleted.begin(), cs.nodes_deleted.end(), inserter(modified_prestate_nodes, modified_prestate_nodes.begin())); - for (std::map::const_iterator i = cs.nodes_renamed.begin(); + for (map::const_iterator i = cs.nodes_renamed.begin(); i != cs.nodes_renamed.end(); ++i) modified_prestate_nodes.insert(i->first); @@ -2040,23 +2042,23 @@ copy(cs.dirs_added.begin(), cs.dirs_added.end(), inserter(modified_poststate_nodes, modified_poststate_nodes.begin())); - for (std::map::const_iterator i = cs.files_added.begin(); + for (map::const_iterator i = cs.files_added.begin(); i != cs.files_added.end(); ++i) modified_poststate_nodes.insert(i->first); - for (std::map::const_iterator i = cs.nodes_renamed.begin(); + for (map::const_iterator i = cs.nodes_renamed.begin(); i != cs.nodes_renamed.end(); ++i) modified_poststate_nodes.insert(i->second); - for (std::map >::const_iterator i = cs.deltas_applied.begin(); + for (map >::const_iterator i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) modified_poststate_nodes.insert(i->first); - for (std::set >::const_iterator i = cs.attrs_cleared.begin(); + for (set >::const_iterator i = cs.attrs_cleared.begin(); i != cs.attrs_cleared.end(); ++i) modified_poststate_nodes.insert(i->first); - for (std::map, attr_value>::const_iterator i = cs.attrs_set.begin(); + for (map, attr_value>::const_iterator i = cs.attrs_set.begin(); i != cs.attrs_set.end(); ++i) modified_poststate_nodes.insert(i->first.first); @@ -2311,7 +2313,7 @@ for (full_attr_map_t::const_iterator i = curr->attrs.begin(); i != curr->attrs.end(); ++i) { - map >::const_iterator am = mark.attrs.find(i->first); + map >::const_iterator am = mark.attrs.find(i->first); I(am != mark.attrs.end()); for (set::const_iterator j = am->second.begin(); j != am->second.end(); ++j) @@ -2474,7 +2476,7 @@ { pa.esym(syms::format_version); - std::string vers; + string vers; pa.str(vers); I(vers == "1"); } @@ -2625,20 +2627,24 @@ #include #include -using std::string; -using boost::lexical_cast; +using std::logic_error; +using std::rand; +using std::search; +using std::srand; +using boost::shared_ptr; + static void make_fake_marking_for(roster_t const & r, marking_map & mm) { mm.clear(); - revision_id rid(std::string("0123456789abcdef0123456789abcdef01234567")); + revision_id rid(string("0123456789abcdef0123456789abcdef01234567")); for (node_map::const_iterator i = r.all_nodes().begin(); i != r.all_nodes().end(); ++i) { marking_t fake_marks; mark_new_node(rid, i->second, fake_marks); - mm.insert(std::make_pair(i->first, fake_marks)); + mm.insert(make_pair(i->first, fake_marks)); } } @@ -2813,7 +2819,7 @@ bool flip(unsigned n = 2) { - return (std::rand() % n) == 0; + return (rand() % n) == 0; } string new_word() @@ -2823,7 +2829,7 @@ string tmp; do { - tmp += wordchars[std::rand() % wordchars.size()]; + tmp += wordchars[rand() % wordchars.size()]; } while (tmp.size() < 10 && !flip(10)); return tmp + lexical_cast(tick++); @@ -2835,7 +2841,7 @@ string tmp; tmp.reserve(constants::idlen); for (unsigned i = 0; i < constants::idlen; ++i) - tmp += tab[std::rand() % tab.size()]; + tmp += tab[rand() % tab.size()]; return file_id(tmp); } @@ -2865,7 +2871,7 @@ if (p.size() <= c.size()) { split_path::const_iterator c_anchor = - std::search(c.begin(), c.end(), + search(c.begin(), c.end(), p.begin(), p.end()); is_parent = (c_anchor == c.begin()); @@ -2885,7 +2891,7 @@ change_automaton() { - std::srand(0x12345678); + srand(0x12345678); } void perform_random_action(roster_t & r, node_id_source & nis) @@ -2907,7 +2913,7 @@ r.get_name(n->self, pth); // L(FL("considering acting on '%s'\n") % file_path(pth)); - switch (std::rand() % 7) + switch (rand() % 7) { default: case 0: @@ -3034,9 +3040,9 @@ } template <> void -dump(int const & i, std::string & out) +dump(int const & i, string & out) { - out = lexical_cast(i) + "\n"; + out = lexical_cast(i) + "\n"; } static void @@ -3092,51 +3098,51 @@ MM(r); // roster must have a root dir - MAYBE(BOOST_CHECK_THROW(r.check_sane(false), std::logic_error)); - MAYBE(BOOST_CHECK_THROW(r.check_sane(true), std::logic_error)); + MAYBE(BOOST_CHECK_THROW(r.check_sane(false), logic_error)); + MAYBE(BOOST_CHECK_THROW(r.check_sane(true), logic_error)); split_path sp_, sp_foo, sp_foo_bar, sp_foo_baz; file_path().split(sp_); file_path_internal("foo").split(sp_foo); file_path_internal("foo/bar").split(sp_foo_bar); file_path_internal("foo/baz").split(sp_foo_baz); - node_id nid_f = r.create_file_node(file_id(std::string("0000000000000000000000000000000000000000")), + node_id nid_f = r.create_file_node(file_id(string("0000000000000000000000000000000000000000")), nis); // root must be a directory, not a file - MAYBE(BOOST_CHECK_THROW(r.attach_node(nid_f, sp_), std::logic_error)); + MAYBE(BOOST_CHECK_THROW(r.attach_node(nid_f, sp_), logic_error)); node_id root_dir = r.create_dir_node(nis); r.attach_node(root_dir, sp_); // has a root dir, but a detached file - MAYBE(BOOST_CHECK_THROW(r.check_sane(false), std::logic_error)); - MAYBE(BOOST_CHECK_THROW(r.check_sane(true), std::logic_error)); + MAYBE(BOOST_CHECK_THROW(r.check_sane(false), logic_error)); + MAYBE(BOOST_CHECK_THROW(r.check_sane(true), logic_error)); r.attach_node(nid_f, sp_foo); // now should be sane - BOOST_CHECK_NOT_THROW(r.check_sane(false), std::logic_error); - BOOST_CHECK_NOT_THROW(r.check_sane(true), std::logic_error); + BOOST_CHECK_NOT_THROW(r.check_sane(false), logic_error); + BOOST_CHECK_NOT_THROW(r.check_sane(true), logic_error); node_id nid_d = r.create_dir_node(nis); // if "foo" exists, can't attach another node at "foo" - MAYBE(BOOST_CHECK_THROW(r.attach_node(nid_d, sp_foo), std::logic_error)); + MAYBE(BOOST_CHECK_THROW(r.attach_node(nid_d, sp_foo), logic_error)); // if "foo" is a file, can't attach a node at "foo/bar" - MAYBE(BOOST_CHECK_THROW(r.attach_node(nid_d, sp_foo_bar), std::logic_error)); + MAYBE(BOOST_CHECK_THROW(r.attach_node(nid_d, sp_foo_bar), logic_error)); BOOST_CHECK(r.detach_node(sp_foo) == nid_f); r.attach_node(nid_d, sp_foo); r.attach_node(nid_f, sp_foo_bar); - BOOST_CHECK_NOT_THROW(r.check_sane(false), std::logic_error); - BOOST_CHECK_NOT_THROW(r.check_sane(true), std::logic_error); + BOOST_CHECK_NOT_THROW(r.check_sane(false), logic_error); + BOOST_CHECK_NOT_THROW(r.check_sane(true), logic_error); temp_node_id_source nis_tmp; node_id nid_tmp = r.create_dir_node(nis_tmp); // has a detached node - MAYBE(BOOST_CHECK_THROW(r.check_sane(false), std::logic_error)); - MAYBE(BOOST_CHECK_THROW(r.check_sane(true), std::logic_error)); + MAYBE(BOOST_CHECK_THROW(r.check_sane(false), logic_error)); + MAYBE(BOOST_CHECK_THROW(r.check_sane(true), logic_error)); r.attach_node(nid_tmp, sp_foo_baz); // now has no detached nodes, but one temp node - MAYBE(BOOST_CHECK_THROW(r.check_sane(false), std::logic_error)); - BOOST_CHECK_NOT_THROW(r.check_sane(true), std::logic_error); + MAYBE(BOOST_CHECK_THROW(r.check_sane(false), logic_error)); + BOOST_CHECK_NOT_THROW(r.check_sane(true), logic_error); } #undef MAYBE @@ -3167,7 +3173,7 @@ node_id nid_bar = r.create_dir_node(nis); r.attach_node(nid_foo, nid_bar, foo_bar[1]); r.attach_node(nid_bar, nid_foo, foo_bar[2]); - BOOST_CHECK_THROW(r.check_sane(true), std::logic_error); + BOOST_CHECK_THROW(r.check_sane(true), logic_error); } static void @@ -3183,18 +3189,18 @@ node_id other_nid = other.create_dir_node(nis); dir_t root_n = downcast_to_dir_t(r.get_node(root)); root_n->children.insert(make_pair(*(foo.end()-1), other.get_node(other_nid))); - BOOST_CHECK_THROW(r.check_sane(), std::logic_error); + BOOST_CHECK_THROW(r.check_sane(), logic_error); // well, but that one was easy, actually, because a dir traversal will hit // more nodes than actually exist... so let's make it harder, by making sure // that a dir traversal will hit exactly as many nodes as actually exist. node_id distractor_nid = r.create_dir_node(nis); - BOOST_CHECK_THROW(r.check_sane(), std::logic_error); + BOOST_CHECK_THROW(r.check_sane(), logic_error); // and even harder, by making that node superficially valid too dir_t distractor_n = downcast_to_dir_t(r.get_node(distractor_nid)); distractor_n->parent = distractor_nid; distractor_n->name = *(foo.end()-1); distractor_n->children.insert(make_pair(distractor_n->name, distractor_n)); - BOOST_CHECK_THROW(r.check_sane(), std::logic_error); + BOOST_CHECK_THROW(r.check_sane(), logic_error); } static void @@ -3206,13 +3212,13 @@ file_path().split(root); r.attach_node(r.create_dir_node(nis), root); BOOST_CHECK_THROW(r.set_attr(root, attr_key("test_key1"), - std::make_pair(false, attr_value("invalid"))), - std::logic_error); - BOOST_CHECK_NOT_THROW(r.check_sane(true), std::logic_error); + make_pair(false, attr_value("invalid"))), + logic_error); + BOOST_CHECK_NOT_THROW(r.check_sane(true), logic_error); safe_insert(r.get_node(root)->attrs, make_pair(attr_key("test_key2"), make_pair(false, attr_value("invalid")))); - BOOST_CHECK_THROW(r.check_sane(true), std::logic_error); + BOOST_CHECK_THROW(r.check_sane(true), logic_error); } //////////////////////////////////////////////////////////////////////// @@ -3298,18 +3304,18 @@ namespace { - template std::set + template set singleton(T const & t) { - std::set s; + set s; s.insert(t); return s; } - template std::set + template set doubleton(T const & t1, T const & t2) { - std::set s; + set s; s.insert(t1); s.insert(t2); return s; @@ -3321,7 +3327,7 @@ revision_id new_rid(string("4444444444444444444444444444444444444444")); split_path - split(std::string const & s) + split(string const & s) { split_path sp; file_path_internal(s).split(sp); @@ -3336,7 +3342,7 @@ scalar_none, scalar_none_2 } scalar_val; void - dump(scalar_val const & val, std::string & out) + dump(scalar_val const & val, string & out) { switch (val) { @@ -3352,7 +3358,7 @@ struct a_scalar { virtual void set(revision_id const & scalar_origin_rid, - scalar_val val, std::set const & this_scalar_mark, + scalar_val val, set const & this_scalar_mark, roster_t & roster, marking_map & markings) = 0; virtual ~a_scalar() {}; @@ -3374,11 +3380,11 @@ safe_insert(markings, make_pair(root_nid, marking)); } - virtual std::string my_type() const = 0; + virtual string my_type() const = 0; - virtual void dump(std::string & out) const + virtual void dump(string & out) const { - std::ostringstream oss; + ostringstream oss; oss << "type: " << my_type() << "\n" << "root_nid: " << root_nid << "\n" << "obj_under_test_nid: " << obj_under_test_nid << "\n"; @@ -3387,7 +3393,7 @@ }; void - dump(a_scalar const & s, std::string & out) + dump(a_scalar const & s, string & out) { s.dump(out); } @@ -3428,9 +3434,9 @@ struct file_content_scalar : public a_scalar { - virtual std::string my_type() const { return "file_content_scalar"; } + virtual string my_type() const { return "file_content_scalar"; } - std::map values; + map values; file_content_scalar(node_id_source & nis) : a_scalar(nis) { @@ -3465,9 +3471,9 @@ template struct X_basename_scalar : public a_scalar { - virtual std::string my_type() const { return "X_basename_scalar"; } + virtual string my_type() const { return "X_basename_scalar"; } - std::map values; + map values; X_basename_scalar(node_id_source & nis) : a_scalar(nis) { @@ -3494,9 +3500,9 @@ template struct X_parent_scalar : public a_scalar { - virtual std::string my_type() const { return "X_parent_scalar"; } + virtual string my_type() const { return "X_parent_scalar"; } - std::map values; + map values; node_id const a_nid, b_nid, c_nid; X_parent_scalar(node_id_source & nis) : a_scalar(nis), a_nid(nis.next()), b_nid(nis.next()), c_nid(nis.next()) @@ -3543,9 +3549,9 @@ template struct X_attr_existing_node_scalar : public a_scalar { - virtual std::string my_type() const { return "X_attr_scalar"; } + virtual string my_type() const { return "X_attr_scalar"; } - std::map > values; + map > values; X_attr_existing_node_scalar(node_id_source & nis) : a_scalar(nis) { @@ -3578,9 +3584,9 @@ template struct X_attr_new_node_scalar : public a_scalar { - virtual std::string my_type() const { return "X_attr_scalar"; } + virtual string my_type() const { return "X_attr_scalar"; } - std::map > values; + map > values; X_attr_new_node_scalar(node_id_source & nis) : a_scalar(nis) { @@ -3606,20 +3612,20 @@ } }; - typedef std::vector > scalars; + typedef vector > scalars; scalars all_scalars(node_id_source & nis) { scalars ss; - ss.push_back(boost::shared_ptr(new file_content_scalar(nis))); - ss.push_back(boost::shared_ptr(new X_basename_scalar(nis))); - ss.push_back(boost::shared_ptr(new X_basename_scalar(nis))); - ss.push_back(boost::shared_ptr(new X_parent_scalar(nis))); - ss.push_back(boost::shared_ptr(new X_parent_scalar(nis))); - ss.push_back(boost::shared_ptr(new X_attr_existing_node_scalar(nis))); - ss.push_back(boost::shared_ptr(new X_attr_existing_node_scalar(nis))); - ss.push_back(boost::shared_ptr(new X_attr_new_node_scalar(nis))); - ss.push_back(boost::shared_ptr(new X_attr_new_node_scalar(nis))); + ss.push_back(shared_ptr(new file_content_scalar(nis))); + ss.push_back(shared_ptr(new X_basename_scalar(nis))); + ss.push_back(shared_ptr(new X_basename_scalar(nis))); + ss.push_back(shared_ptr(new X_parent_scalar(nis))); + ss.push_back(shared_ptr(new X_parent_scalar(nis))); + ss.push_back(shared_ptr(new X_attr_existing_node_scalar(nis))); + ss.push_back(shared_ptr(new X_attr_existing_node_scalar(nis))); + ss.push_back(shared_ptr(new X_attr_new_node_scalar(nis))); + ss.push_back(shared_ptr(new X_attr_new_node_scalar(nis))); return ss; } } @@ -3631,7 +3637,7 @@ static void run_with_0_roster_parents(a_scalar & s, revision_id scalar_origin_rid, scalar_val new_val, - std::set const & new_mark_set, + set const & new_mark_set, node_id_source & nis) { MM(s); @@ -3662,9 +3668,9 @@ run_with_1_roster_parent(a_scalar & s, revision_id scalar_origin_rid, scalar_val parent_val, - std::set const & parent_mark_set, + set const & parent_mark_set, scalar_val new_val, - std::set const & new_mark_set, + set const & new_mark_set, node_id_source & nis) { MM(s); @@ -3698,11 +3704,11 @@ run_with_2_roster_parents(a_scalar & s, revision_id scalar_origin_rid, scalar_val left_val, - std::set const & left_mark_set, + set const & left_mark_set, scalar_val right_val, - std::set const & right_mark_set, + set const & right_mark_set, scalar_val new_val, - std::set const & new_mark_set, + set const & new_mark_set, node_id_source & nis) { MM(s); @@ -3729,9 +3735,9 @@ make_cset(left_roster, expected_roster, left_cs); make_cset(right_roster, expected_roster, right_cs); - std::set left_uncommon_ancestors; MM(left_uncommon_ancestors); + set left_uncommon_ancestors; MM(left_uncommon_ancestors); left_uncommon_ancestors.insert(left_rid); - std::set right_uncommon_ancestors; MM(right_uncommon_ancestors); + set right_uncommon_ancestors; MM(right_uncommon_ancestors); right_uncommon_ancestors.insert(right_rid); roster_t new_roster; MM(new_roster); @@ -3760,11 +3766,11 @@ static void run_a_2_scalar_parent_mark_scenario_exact(revision_id const & scalar_origin_rid, scalar_val left_val, - std::set const & left_mark_set, + set const & left_mark_set, scalar_val right_val, - std::set const & right_mark_set, + set const & right_mark_set, scalar_val new_val, - std::set const & new_mark_set) + set const & new_mark_set) { testing_node_id_source nis; scalars ss = all_scalars(nis); @@ -3803,11 +3809,11 @@ static void run_a_2_scalar_parent_mark_scenario(revision_id const & scalar_origin_rid, scalar_val left_val, - std::set const & left_mark_set, + set const & left_mark_set, scalar_val right_val, - std::set const & right_mark_set, + set const & right_mark_set, scalar_val new_val, - std::set const & new_mark_set) + set const & new_mark_set) { // run both what we're given... run_a_2_scalar_parent_mark_scenario_exact(scalar_origin_rid, @@ -3818,9 +3824,9 @@ // because the exact stuff has hard-coded the names of the various // revisions and their uncommon ancestor sets. { - std::set flipped_left_mark_set = flip_revision_set(left_mark_set); - std::set flipped_right_mark_set = flip_revision_set(right_mark_set); - std::set flipped_new_mark_set = flip_revision_set(new_mark_set); + set flipped_left_mark_set = flip_revision_set(left_mark_set); + set flipped_right_mark_set = flip_revision_set(right_mark_set); + set flipped_new_mark_set = flip_revision_set(new_mark_set); run_a_2_scalar_parent_mark_scenario_exact(flip_revision_id(scalar_origin_rid), right_val, flipped_right_mark_set, @@ -3831,11 +3837,11 @@ static void run_a_2_scalar_parent_mark_scenario(scalar_val left_val, - std::set const & left_mark_set, + set const & left_mark_set, scalar_val right_val, - std::set const & right_mark_set, + set const & right_mark_set, scalar_val new_val, - std::set const & new_mark_set) + set const & new_mark_set) { run_a_2_scalar_parent_mark_scenario(old_rid, left_val, left_mark_set, @@ -3845,9 +3851,9 @@ static void run_a_1_scalar_parent_mark_scenario(scalar_val parent_val, - std::set const & parent_mark_set, + set const & parent_mark_set, scalar_val new_val, - std::set const & new_mark_set) + set const & new_mark_set) { { testing_node_id_source nis; @@ -3862,7 +3868,7 @@ // both ways run_a_2_scalar_parent_mark_scenario(left_rid, parent_val, parent_mark_set, - scalar_none, std::set(), + scalar_none, set(), new_val, new_mark_set); } @@ -3876,12 +3882,12 @@ { run_with_0_roster_parents(**i, old_rid, scalar_a, singleton(old_rid), nis); run_with_1_roster_parent(**i, new_rid, - scalar_none, std::set(), + scalar_none, set(), scalar_a, singleton(new_rid), nis); run_with_2_roster_parents(**i, new_rid, - scalar_none, std::set(), - scalar_none, std::set(), + scalar_none, set(), + scalar_none, set(), scalar_a, singleton(new_rid), nis); } @@ -4083,9 +4089,9 @@ template struct X_attr_mixed_scalar : public a_scalar { - virtual std::string my_type() const { return "X_attr_scalar"; } + virtual string my_type() const { return "X_attr_scalar"; } - std::map > values; + map > values; X_attr_mixed_scalar(node_id_source & nis) : a_scalar(nis) { @@ -4125,8 +4131,8 @@ testing_node_id_source nis; X_attr_mixed_scalar s(nis); run_with_2_roster_parents(s, left_rid, - scalar_none_2, std::set(), - scalar_none, std::set(), + scalar_none_2, set(), + scalar_none, set(), scalar_a, singleton(new_rid), nis); } @@ -4134,8 +4140,8 @@ testing_node_id_source nis; X_attr_mixed_scalar s(nis); run_with_2_roster_parents(s, left_rid, - scalar_none_2, std::set(), - scalar_none, std::set(), + scalar_none_2, set(), + scalar_none, set(), scalar_a, singleton(new_rid), nis); } @@ -4143,8 +4149,8 @@ testing_node_id_source nis; X_attr_mixed_scalar s(nis); run_with_2_roster_parents(s, right_rid, - scalar_none, std::set(), - scalar_none_2, std::set(), + scalar_none, set(), + scalar_none_2, set(), scalar_a, singleton(new_rid), nis); } @@ -4152,8 +4158,8 @@ testing_node_id_source nis; X_attr_mixed_scalar s(nis); run_with_2_roster_parents(s, right_rid, - scalar_none, std::set(), - scalar_none_2, std::set(), + scalar_none, set(), + scalar_none_2, set(), scalar_a, singleton(new_rid), nis); } @@ -4222,7 +4228,7 @@ singleton(right_rid), new_rid, new_roster, new_markings, nis), - std::logic_error); + logic_error); BOOST_CHECK_THROW( make_roster_for_merge(right_rid, right_roster, right_markings, right_cs, singleton(right_rid), @@ -4230,7 +4236,7 @@ singleton(left_rid), new_rid, new_roster, new_markings, nis), - std::logic_error); + logic_error); } // nodes can't change type file->dir or dir->file // make_cset fails @@ -4271,8 +4277,8 @@ file_roster.check_sane_against(file_markings); cset cs; MM(cs); - BOOST_CHECK_THROW(make_cset(dir_roster, file_roster, cs), std::logic_error); - BOOST_CHECK_THROW(make_cset(file_roster, dir_roster, cs), std::logic_error); + BOOST_CHECK_THROW(make_cset(dir_roster, file_roster, cs), logic_error); + BOOST_CHECK_THROW(make_cset(file_roster, dir_roster, cs), logic_error); cset left_cs; MM(left_cs); cset right_cs; MM(right_cs); @@ -4285,7 +4291,7 @@ singleton(right_rid), new_rid, new_roster, new_markings, nis), - std::logic_error); + logic_error); BOOST_CHECK_THROW( make_roster_for_merge(left_rid, file_roster, file_markings, left_cs, singleton(left_rid), @@ -4293,7 +4299,7 @@ singleton(right_rid), new_rid, new_roster, new_markings, nis), - std::logic_error); + logic_error); } @@ -4388,7 +4394,7 @@ )); MM(expected); - BOOST_CHECK_NOT_THROW( I(expected == mdat), std::logic_error); + BOOST_CHECK_NOT_THROW( I(expected == mdat), logic_error); } { @@ -4446,7 +4452,7 @@ )); MM(expected); - BOOST_CHECK_NOT_THROW( I(expected == rdat), std::logic_error); + BOOST_CHECK_NOT_THROW( I(expected == rdat), logic_error); } } @@ -4483,7 +4489,7 @@ r.attach_node(nid, bar); // missing the marking - BOOST_CHECK_THROW(r.check_sane_against(mm), std::logic_error); + BOOST_CHECK_THROW(r.check_sane_against(mm), logic_error); } { @@ -4507,7 +4513,7 @@ mark_new_node(rid, r.get_node(nid), mm[nid]); r.detach_node(bar); - BOOST_CHECK_THROW(r.check_sane_against(mm), std::logic_error); + BOOST_CHECK_THROW(r.check_sane_against(mm), logic_error); } { @@ -4526,7 +4532,7 @@ mark_new_node(rid, r.get_node(nid), mm[nid]); mm[nid].birth_revision = revision_id(); - BOOST_CHECK_THROW(r.check_sane_against(mm), std::logic_error); + BOOST_CHECK_THROW(r.check_sane_against(mm), logic_error); } { @@ -4545,7 +4551,7 @@ mark_new_node(rid, r.get_node(nid), mm[nid]); mm[nid].parent_name.clear(); - BOOST_CHECK_THROW(r.check_sane_against(mm), std::logic_error); + BOOST_CHECK_THROW(r.check_sane_against(mm), logic_error); } { @@ -4564,7 +4570,7 @@ mark_new_node(rid, r.get_node(nid), mm[nid]); mm[nid].file_content.clear(); - BOOST_CHECK_THROW(r.check_sane_against(mm), std::logic_error); + BOOST_CHECK_THROW(r.check_sane_against(mm), logic_error); } { @@ -4583,7 +4589,7 @@ mark_new_node(rid, r.get_node(nid), mm[nid]); mm[nid].file_content.insert(rid); - BOOST_CHECK_THROW(r.check_sane_against(mm), std::logic_error); + BOOST_CHECK_THROW(r.check_sane_against(mm), logic_error); } { @@ -4598,7 +4604,7 @@ mark_new_node(rid, r.get_node(nid), mm[nid]); r.set_attr(root, attr_key("my_key"), attr_value("my_value")); - BOOST_CHECK_THROW(r.check_sane_against(mm), std::logic_error); + BOOST_CHECK_THROW(r.check_sane_against(mm), logic_error); } { @@ -4613,7 +4619,7 @@ mark_new_node(rid, r.get_node(nid), mm[nid]); mm[nid].attrs[attr_key("my_key")].clear(); - BOOST_CHECK_THROW(r.check_sane_against(mm), std::logic_error); + BOOST_CHECK_THROW(r.check_sane_against(mm), logic_error); } { @@ -4628,7 +4634,7 @@ mark_new_node(rid, r.get_node(nid), mm[nid]); mm[nid].attrs[attr_key("my_second_key")].insert(rid); - BOOST_CHECK_THROW(r.check_sane_against(mm), std::logic_error); + BOOST_CHECK_THROW(r.check_sane_against(mm), logic_error); } } @@ -4650,7 +4656,7 @@ roster_t & right_ros, set & right_new_nodes) { - size_t n_nodes = 10 + (std::rand() % 30); + size_t n_nodes = 10 + (rand() % 30); editable_roster_base left_er(left_ros, nis); editable_roster_base right_er(right_ros, nis); @@ -4732,7 +4738,7 @@ L(FL("TEST: begin checking unification of rosters (end to end, ids)")); revision_id has_rid = left_rid; revision_id has_not_rid = right_rid; - file_id my_fid(std::string("9012901290129012901290129012901290129012")); + file_id my_fid(string("9012901290129012901290129012901290129012")); testing_node_id_source nis; @@ -4811,7 +4817,7 @@ L(FL("TEST: begin checking unification of rosters (end to end, attr corpses)")); revision_id first_rid = left_rid; revision_id second_rid = right_rid; - file_id my_fid(std::string("9012901290129012901290129012901290129012")); + file_id my_fid(string("9012901290129012901290129012901290129012")); testing_node_id_source nis; ============================================================ --- roster_merge.cc 282aa6d4625b5276c3997aa6aca10faf15f69eea +++ roster_merge.cc ff845578375e028041eb8731d2f870ebfcad9eeb @@ -11,6 +11,11 @@ #include "parallel_iter.hh" #include "safe_map.hh" +using std::make_pair; +using std::pair; +using std::set; +using std::string; + bool roster_merge_result::is_clean() const { @@ -31,7 +36,7 @@ } static void -debug_describe_conflicts(roster_merge_result const & result, std::string & out) +debug_describe_conflicts(roster_merge_result const & result, string & out) { out = (FL("unclean roster_merge: %d name conflicts, %d content conflicts, %d attr conflicts, " "%d orphaned node conflicts, %d rename target conflicts, %d directory loop conflicts\n") @@ -100,10 +105,10 @@ } template <> void -dump(roster_merge_result const & result, std::string & out) +dump(roster_merge_result const & result, string & out) { debug_describe_conflicts(result, out); - std::string roster_part; + string roster_part; dump(result.roster, roster_part); out += "\n\n"; out += roster_part; @@ -112,7 +117,7 @@ void roster_merge_result::log_conflicts() const { - std::string str; + string str; debug_describe_conflicts(*this, str); L(FL("%s") % str); } @@ -184,10 +189,10 @@ // _b_, so the previous statement is the same as saying that _no_ // members of b_marks is an _uncommon_ ancestor of _b_. bool - a_wins(std::set const & b_marks, - std::set const & b_uncommon_ancestors) + a_wins(set const & b_marks, + set const & b_uncommon_ancestors) { - for (std::set::const_iterator i = b_marks.begin(); + for (set::const_iterator i = b_marks.begin(); i != b_marks.end(); ++i) if (b_uncommon_ancestors.find(*i) != b_uncommon_ancestors.end()) return false; @@ -198,11 +203,11 @@ // ('conflict_descriptor' is valid). template bool merge_scalar(T const & left, - std::set const & left_marks, - std::set const & left_uncommon_ancestors, + set const & left_marks, + set const & left_uncommon_ancestors, T const & right, - std::set const & right_marks, - std::set const & right_uncommon_ancestors, + set const & right_marks, + set const & right_uncommon_ancestors, T & result, C & conflict_descriptor) { @@ -257,7 +262,7 @@ inline void insert_if_unborn(node_t const & n, marking_map const & markings, - std::set const & uncommon_ancestors, + set const & uncommon_ancestors, roster_t & new_roster) { revision_id const & birth = safe_get(markings, n->self).birth_revision; @@ -304,7 +309,7 @@ rename_target_conflict c; c.nid1 = nid; c.nid2 = result.roster.root()->self; - c.parent_name = std::make_pair(parent, name); + c.parent_name = make_pair(parent, name); split_path root_sp; file_path().split(root_sp); result.roster.detach_node(root_sp); @@ -319,7 +324,7 @@ { orphaned_node_conflict c; c.nid = nid; - c.parent_name = std::make_pair(parent, name); + c.parent_name = make_pair(parent, name); result.orphaned_node_conflicts.push_back(c); return; } @@ -340,7 +345,7 @@ rename_target_conflict c; c.nid1 = nid; c.nid2 = p->get_child(name)->self; - c.parent_name = std::make_pair(parent, name); + c.parent_name = make_pair(parent, name); p->detach_child(name); result.rename_target_conflicts.push_back(c); return; @@ -350,7 +355,7 @@ { directory_loop_conflict c; c.nid = nid; - c.parent_name = std::make_pair(parent, name); + c.parent_name = make_pair(parent, name); result.directory_loop_conflicts.push_back(c); return; } @@ -375,10 +380,10 @@ void roster_merge(roster_t const & left_parent, marking_map const & left_markings, - std::set const & left_uncommon_ancestors, + set const & left_uncommon_ancestors, roster_t const & right_parent, marking_map const & right_markings, - std::set const & right_uncommon_ancestors, + set const & right_uncommon_ancestors, roster_merge_result & result) { result.clear(); @@ -473,12 +478,12 @@ node_t const & new_n = new_i->second; // merge name { - std::pair new_name; + pair new_name; node_name_conflict conflict(new_n->self); - if (merge_scalar(std::make_pair(left_n->parent, left_n->name), + if (merge_scalar(make_pair(left_n->parent, left_n->name), left_marking.parent_name, left_uncommon_ancestors, - std::make_pair(right_n->parent, right_n->name), + make_pair(right_n->parent, right_n->name), right_marking.parent_name, right_uncommon_ancestors, new_name, conflict)) @@ -533,7 +538,7 @@ safe_insert(new_n->attrs, attr_i.right_value()); break; case parallel::in_both: - std::pair new_value; + pair new_value; node_attr_conflict conflict(new_n->self); conflict.key = attr_i.left_key(); I(conflict.key == attr_i.right_key()); @@ -550,7 +555,7 @@ { // successful merge safe_insert(new_n->attrs, - std::make_pair(attr_i.left_key(), + make_pair(attr_i.left_key(), new_value)); } else @@ -678,7 +683,7 @@ // two nodes that both want "" split_path -split(std::string const & s) +split(string const & s) { split_path sp; file_path_internal(s).split(sp); @@ -688,7 +693,7 @@ typedef enum { scalar_a, scalar_b, scalar_conflict } scalar_val; template <> void -dump(scalar_val const & v, std::string & out) +dump(scalar_val const & v, string & out) { switch (v) { @@ -704,22 +709,22 @@ } } -void string_to_set(std::string const & from, std::set & to) +void string_to_set(string const & from, set & to) { to.clear(); - for (std::string::const_iterator i = from.begin(); i != from.end(); ++i) + for (string::const_iterator i = from.begin(); i != from.end(); ++i) { - std::string rid_str(40, *i); + string rid_str(40, *i); to.insert(revision_id(rid_str)); } } template void -test_a_scalar_merge_impl(scalar_val left_val, std::string const & left_marks_str, - std::string const & left_uncommon_str, - scalar_val right_val, std::string const & right_marks_str, - std::string const & right_uncommon_str, +test_a_scalar_merge_impl(scalar_val left_val, string const & left_marks_str, + string const & left_uncommon_str, + scalar_val right_val, string const & right_marks_str, + string const & right_uncommon_str, scalar_val expected_outcome) { MM(left_val); @@ -733,10 +738,10 @@ S scalar; roster_t left_parent, right_parent; marking_map left_markings, right_markings; - std::set left_uncommon_ancestors, right_uncommon_ancestors; + set left_uncommon_ancestors, right_uncommon_ancestors; roster_merge_result result; - std::set left_marks, right_marks; + set left_marks, right_marks; MM(left_parent); MM(right_parent); @@ -763,8 +768,8 @@ scalar.check_result(left_val, right_val, result, expected_outcome); } -static const revision_id root_rid = revision_id(std::string("0000000000000000000000000000000000000000")); -static const file_id arbitrary_file = file_id(std::string("0000000000000000000000000000000000000000")); +static const revision_id root_rid = revision_id(string("0000000000000000000000000000000000000000")); +static const file_id arbitrary_file = file_id(string("0000000000000000000000000000000000000000")); struct base_scalar { @@ -775,18 +780,18 @@ {} void - make_dir(std::string const & name, node_id nid, roster_t & r, marking_map & markings) + make_dir(string const & name, node_id nid, roster_t & r, marking_map & markings) { r.create_dir_node(nid); r.attach_node(nid, split(name)); marking_t marking; marking.birth_revision = root_rid; marking.parent_name.insert(root_rid); - safe_insert(markings, std::make_pair(nid, marking)); + safe_insert(markings, make_pair(nid, marking)); } void - make_file(std::string const & name, node_id nid, roster_t & r, marking_map & markings) + make_file(string const & name, node_id nid, roster_t & r, marking_map & markings) { r.create_file_node(arbitrary_file, nid); r.attach_node(nid, split(name)); @@ -794,7 +799,7 @@ marking.birth_revision = root_rid; marking.parent_name.insert(root_rid); marking.file_content.insert(root_rid); - safe_insert(markings, std::make_pair(nid, marking)); + safe_insert(markings, make_pair(nid, marking)); } void @@ -857,8 +862,8 @@ case scalar_conflict: node_name_conflict const & c = idx(result.node_name_conflicts, 0); I(c.nid == thing_nid); - I(c.left == std::make_pair(parent_for(left_val), pc_for(left_val))); - I(c.right == std::make_pair(parent_for(right_val), pc_for(right_val))); + I(c.left == make_pair(parent_for(left_val), pc_for(left_val))); + I(c.right == make_pair(parent_for(right_val), pc_for(right_val))); I(null_node(result.roster.get_node(thing_nid)->parent)); I(null_name(result.roster.get_node(thing_nid)->name)); // resolve the conflict, thus making sure that resolution works and @@ -891,7 +896,7 @@ } void - setup_parent(scalar_val val, std::set marks, + setup_parent(scalar_val val, set marks, roster_t & r, marking_map & markings) { this->T::make_thing(r, markings); @@ -922,7 +927,7 @@ } void - setup_parent(scalar_val val, std::set marks, + setup_parent(scalar_val val, set marks, roster_t & r, marking_map & markings) { this->T::make_thing(r, markings); @@ -946,7 +951,7 @@ } void - setup_parent(scalar_val val, std::set marks, + setup_parent(scalar_val val, set marks, roster_t & r, marking_map & markings) { this->T::make_thing(r, markings); @@ -964,14 +969,14 @@ { case scalar_a: case scalar_b: I(result.roster.get_node(thing_nid)->attrs[attr_key("test_key")] - == std::make_pair(true, attr_value_for(expected_val))); + == make_pair(true, attr_value_for(expected_val))); break; case scalar_conflict: node_attr_conflict const & c = idx(result.node_attr_conflicts, 0); I(c.nid == thing_nid); I(c.key == attr_key("test_key")); - I(c.left == std::make_pair(true, attr_value_for(left_val))); - I(c.right == std::make_pair(true, attr_value_for(right_val))); + I(c.left == make_pair(true, attr_value_for(left_val))); + I(c.right == make_pair(true, attr_value_for(right_val))); full_attr_map_t const & attrs = result.roster.get_node(thing_nid)->attrs; I(attrs.find(attr_key("test_key")) == attrs.end()); // resolve the conflict, thus making sure that resolution works and @@ -992,13 +997,13 @@ file_id content_for(scalar_val val) { I(val != scalar_conflict); - return file_id(std::string((val == scalar_a) + return file_id(string((val == scalar_a) ? "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" : "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")); } void - setup_parent(scalar_val val, std::set marks, + setup_parent(scalar_val val, set marks, roster_t & r, marking_map & markings) { make_thing(r, markings); @@ -1027,7 +1032,7 @@ I(null_id(content)); // resolve the conflict, thus making sure that resolution works and // that this was the only conflict signaled - content = file_id(std::string("ffffffffffffffffffffffffffffffffffffffff")); + content = file_id(string("ffffffffffffffffffffffffffffffffffffffff")); result.file_content_conflicts.pop_back(); break; } @@ -1038,10 +1043,10 @@ }; void -test_a_scalar_merge(scalar_val left_val, std::string const & left_marks_str, - std::string const & left_uncommon_str, - scalar_val right_val, std::string const & right_marks_str, - std::string const & right_uncommon_str, +test_a_scalar_merge(scalar_val left_val, string const & left_marks_str, + string const & left_uncommon_str, + scalar_val right_val, string const & right_marks_str, + string const & right_uncommon_str, scalar_val expected_outcome) { test_a_scalar_merge_impl >(left_val, left_marks_str, left_uncommon_str, @@ -1180,36 +1185,36 @@ namespace { - const revision_id a_uncommon1 = revision_id(std::string("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); - const revision_id a_uncommon2 = revision_id(std::string("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")); - const revision_id b_uncommon1 = revision_id(std::string("cccccccccccccccccccccccccccccccccccccccc")); - const revision_id b_uncommon2 = revision_id(std::string("dddddddddddddddddddddddddddddddddddddddd")); - const revision_id common1 = revision_id(std::string("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")); - const revision_id common2 = revision_id(std::string("ffffffffffffffffffffffffffffffffffffffff")); + const revision_id a_uncommon1 = revision_id(string("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); + const revision_id a_uncommon2 = revision_id(string("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")); + const revision_id b_uncommon1 = revision_id(string("cccccccccccccccccccccccccccccccccccccccc")); + const revision_id b_uncommon2 = revision_id(string("dddddddddddddddddddddddddddddddddddddddd")); + const revision_id common1 = revision_id(string("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")); + const revision_id common2 = revision_id(string("ffffffffffffffffffffffffffffffffffffffff")); - const file_id fid1 = file_id(std::string("1111111111111111111111111111111111111111")); - const file_id fid2 = file_id(std::string("2222222222222222222222222222222222222222")); + const file_id fid1 = file_id(string("1111111111111111111111111111111111111111")); + const file_id fid2 = file_id(string("2222222222222222222222222222222222222222")); } static void make_dir(roster_t & r, marking_map & markings, revision_id const & birth_rid, revision_id const & parent_name_rid, - std::string const & name, node_id nid) + string const & name, node_id nid) { r.create_dir_node(nid); r.attach_node(nid, split(name)); marking_t marking; marking.birth_revision = birth_rid; marking.parent_name.insert(parent_name_rid); - safe_insert(markings, std::make_pair(nid, marking)); + safe_insert(markings, make_pair(nid, marking)); } static void make_file(roster_t & r, marking_map & markings, revision_id const & birth_rid, revision_id const & parent_name_rid, revision_id const & file_content_rid, - std::string const & name, file_id const & content, + string const & name, file_id const & content, node_id nid) { r.create_file_node(content, nid); @@ -1218,12 +1223,12 @@ marking.birth_revision = birth_rid; marking.parent_name.insert(parent_name_rid); marking.file_content.insert(file_content_rid); - safe_insert(markings, std::make_pair(nid, marking)); + safe_insert(markings, make_pair(nid, marking)); } static void make_node_lifecycle_objs(roster_t & r, marking_map & markings, revision_id const & uncommon, - std::string const & name, node_id common_dir_nid, node_id common_file_nid, + string const & name, node_id common_dir_nid, node_id common_file_nid, node_id & safe_dir_nid, node_id & safe_file_nid, node_id_source & nis) { make_dir(r, markings, common1, common1, "common_old_dir", common_dir_nid); @@ -1242,7 +1247,7 @@ { roster_t a_roster, b_roster; marking_map a_markings, b_markings; - std::set a_uncommon, b_uncommon; + set a_uncommon, b_uncommon; // boilerplate to get uncommon revision sets... a_uncommon.insert(a_uncommon1); a_uncommon.insert(a_uncommon2); @@ -1297,7 +1302,7 @@ MM(left_markings); MM(right_roster); MM(right_markings); - std::set old_revs, left_revs, right_revs; + set old_revs, left_revs, right_revs; string_to_set("0", old_revs); string_to_set("1", left_revs); string_to_set("2", right_revs); @@ -1313,30 +1318,30 @@ // put one live and one dead attr on each thing on each side, with uncommon // marks on them safe_insert(left_roster.get_node(dir_nid)->attrs, - std::make_pair(attr_key("left_live"), std::make_pair(true, attr_value("left_live")))); - safe_insert(left_markings[dir_nid].attrs, std::make_pair(attr_key("left_live"), left_revs)); + make_pair(attr_key("left_live"), make_pair(true, attr_value("left_live")))); + safe_insert(left_markings[dir_nid].attrs, make_pair(attr_key("left_live"), left_revs)); safe_insert(left_roster.get_node(dir_nid)->attrs, - std::make_pair(attr_key("left_dead"), std::make_pair(false, attr_value("")))); - safe_insert(left_markings[dir_nid].attrs, std::make_pair(attr_key("left_dead"), left_revs)); + make_pair(attr_key("left_dead"), make_pair(false, attr_value("")))); + safe_insert(left_markings[dir_nid].attrs, make_pair(attr_key("left_dead"), left_revs)); safe_insert(left_roster.get_node(file_nid)->attrs, - std::make_pair(attr_key("left_live"), std::make_pair(true, attr_value("left_live")))); - safe_insert(left_markings[file_nid].attrs, std::make_pair(attr_key("left_live"), left_revs)); + make_pair(attr_key("left_live"), make_pair(true, attr_value("left_live")))); + safe_insert(left_markings[file_nid].attrs, make_pair(attr_key("left_live"), left_revs)); safe_insert(left_roster.get_node(file_nid)->attrs, - std::make_pair(attr_key("left_dead"), std::make_pair(false, attr_value("")))); - safe_insert(left_markings[file_nid].attrs, std::make_pair(attr_key("left_dead"), left_revs)); + make_pair(attr_key("left_dead"), make_pair(false, attr_value("")))); + safe_insert(left_markings[file_nid].attrs, make_pair(attr_key("left_dead"), left_revs)); safe_insert(right_roster.get_node(dir_nid)->attrs, - std::make_pair(attr_key("right_live"), std::make_pair(true, attr_value("right_live")))); - safe_insert(right_markings[dir_nid].attrs, std::make_pair(attr_key("right_live"), right_revs)); + make_pair(attr_key("right_live"), make_pair(true, attr_value("right_live")))); + safe_insert(right_markings[dir_nid].attrs, make_pair(attr_key("right_live"), right_revs)); safe_insert(right_roster.get_node(dir_nid)->attrs, - std::make_pair(attr_key("right_dead"), std::make_pair(false, attr_value("")))); - safe_insert(right_markings[dir_nid].attrs, std::make_pair(attr_key("right_dead"), right_revs)); + make_pair(attr_key("right_dead"), make_pair(false, attr_value("")))); + safe_insert(right_markings[dir_nid].attrs, make_pair(attr_key("right_dead"), right_revs)); safe_insert(right_roster.get_node(file_nid)->attrs, - std::make_pair(attr_key("right_live"), std::make_pair(true, attr_value("right_live")))); - safe_insert(right_markings[file_nid].attrs, std::make_pair(attr_key("right_live"), right_revs)); + make_pair(attr_key("right_live"), make_pair(true, attr_value("right_live")))); + safe_insert(right_markings[file_nid].attrs, make_pair(attr_key("right_live"), right_revs)); safe_insert(right_roster.get_node(file_nid)->attrs, - std::make_pair(attr_key("right_dead"), std::make_pair(false, attr_value("")))); - safe_insert(right_markings[file_nid].attrs, std::make_pair(attr_key("right_dead"), right_revs)); + make_pair(attr_key("right_dead"), make_pair(false, attr_value("")))); + safe_insert(right_markings[file_nid].attrs, make_pair(attr_key("right_dead"), right_revs)); roster_merge_result result; MM(result); @@ -1345,22 +1350,22 @@ result); I(result.roster.all_nodes().size() == 2); I(result.roster.get_node(dir_nid)->attrs.size() == 4); - I(safe_get(result.roster.get_node(dir_nid)->attrs, attr_key("left_live")) == std::make_pair(true, attr_value("left_live"))); - I(safe_get(result.roster.get_node(dir_nid)->attrs, attr_key("left_dead")) == std::make_pair(false, attr_value(""))); - I(safe_get(result.roster.get_node(dir_nid)->attrs, attr_key("right_live")) == std::make_pair(true, attr_value("right_live"))); - I(safe_get(result.roster.get_node(dir_nid)->attrs, attr_key("left_dead")) == std::make_pair(false, attr_value(""))); + I(safe_get(result.roster.get_node(dir_nid)->attrs, attr_key("left_live")) == make_pair(true, attr_value("left_live"))); + I(safe_get(result.roster.get_node(dir_nid)->attrs, attr_key("left_dead")) == make_pair(false, attr_value(""))); + I(safe_get(result.roster.get_node(dir_nid)->attrs, attr_key("right_live")) == make_pair(true, attr_value("right_live"))); + I(safe_get(result.roster.get_node(dir_nid)->attrs, attr_key("left_dead")) == make_pair(false, attr_value(""))); I(result.roster.get_node(file_nid)->attrs.size() == 4); - I(safe_get(result.roster.get_node(file_nid)->attrs, attr_key("left_live")) == std::make_pair(true, attr_value("left_live"))); - I(safe_get(result.roster.get_node(file_nid)->attrs, attr_key("left_dead")) == std::make_pair(false, attr_value(""))); - I(safe_get(result.roster.get_node(file_nid)->attrs, attr_key("right_live")) == std::make_pair(true, attr_value("right_live"))); - I(safe_get(result.roster.get_node(file_nid)->attrs, attr_key("left_dead")) == std::make_pair(false, attr_value(""))); + I(safe_get(result.roster.get_node(file_nid)->attrs, attr_key("left_live")) == make_pair(true, attr_value("left_live"))); + I(safe_get(result.roster.get_node(file_nid)->attrs, attr_key("left_dead")) == make_pair(false, attr_value(""))); + I(safe_get(result.roster.get_node(file_nid)->attrs, attr_key("right_live")) == make_pair(true, attr_value("right_live"))); + I(safe_get(result.roster.get_node(file_nid)->attrs, attr_key("left_dead")) == make_pair(false, attr_value(""))); } struct structural_conflict_helper { roster_t left_roster, right_roster; marking_map left_markings, right_markings; - std::set old_revs, left_revs, right_revs; + set old_revs, left_revs, right_revs; revision_id old_rid, left_rid, right_rid; testing_node_id_source nis; node_id root_nid; @@ -1416,7 +1421,7 @@ rename_target_conflict const & c = idx(result.rename_target_conflicts, 0); I((c.nid1 == left_nid && c.nid2 == right_nid) || (c.nid1 == right_nid && c.nid2 == left_nid)); - I(c.parent_name == std::make_pair(root_nid, idx(split("thing"), 1))); + I(c.parent_name == make_pair(root_nid, idx(split("thing"), 1))); // this tests that they were detached, implicitly result.roster.attach_node(left_nid, split("left")); result.roster.attach_node(right_nid, split("right")); @@ -1447,8 +1452,8 @@ { I(!result.is_clean()); directory_loop_conflict const & c = idx(result.directory_loop_conflicts, 0); - I((c.nid == left_top_nid && c.parent_name == std::make_pair(right_top_nid, idx(split("bottom"), 1))) - || (c.nid == right_top_nid && c.parent_name == std::make_pair(left_top_nid, idx(split("bottom"), 1)))); + I((c.nid == left_top_nid && c.parent_name == make_pair(right_top_nid, idx(split("bottom"), 1))) + || (c.nid == right_top_nid && c.parent_name == make_pair(left_top_nid, idx(split("bottom"), 1)))); // this tests it was detached, implicitly result.roster.attach_node(c.nid, split("resolved")); result.directory_loop_conflicts.pop_back(); @@ -1496,9 +1501,9 @@ b = idx(result.orphaned_node_conflicts, 0); } I(a.nid == a_live_child_nid); - I(a.parent_name == std::make_pair(a_dead_parent_nid, idx(split("a_child"), 1))); + I(a.parent_name == make_pair(a_dead_parent_nid, idx(split("a_child"), 1))); I(b.nid == b_live_child_nid); - I(b.parent_name == std::make_pair(b_dead_parent_nid, idx(split("b_child"), 1))); + I(b.parent_name == make_pair(b_dead_parent_nid, idx(split("b_child"), 1))); // this tests it was detached, implicitly result.roster.attach_node(a.nid, split("resolved_a")); result.roster.attach_node(b.nid, split("resolved_b")); @@ -1536,7 +1541,7 @@ I(!result.is_clean()); illegal_name_conflict const & c = idx(result.illegal_name_conflicts, 0); I(c.nid == bad_dir_nid); - I(c.parent_name == std::make_pair(new_root_nid, bookkeeping_root_component)); + I(c.parent_name == make_pair(new_root_nid, bookkeeping_root_component)); // this tests it was detached, implicitly result.roster.attach_node(bad_dir_nid, split("dir_formerly_known_as__MTN")); result.illegal_name_conflicts.pop_back(); @@ -1604,7 +1609,7 @@ node_id name_conflict_nid; node_id left_parent, right_parent; path_component left_name, right_name; - void make_nn_conflict(std::string const & left_path, std::string const & right_path) + void make_nn_conflict(string const & left_path, string const & right_path) { name_conflict_nid = nis.next(); make_dir(left_roster, left_markings, old_rid, left_rid, left_path, name_conflict_nid); @@ -1619,8 +1624,8 @@ I(!result.is_clean()); node_name_conflict const & c = idx(result.node_name_conflicts, 0); I(c.nid == name_conflict_nid); - I(c.left == std::make_pair(left_parent, left_name)); - I(c.right == std::make_pair(right_parent, right_name)); + I(c.left == make_pair(left_parent, left_name)); + I(c.right == make_pair(right_parent, right_name)); result.roster.attach_node(name_conflict_nid, split("totally_other_name")); result.node_name_conflicts.pop_back(); I(result.is_clean()); @@ -1737,12 +1742,12 @@ void check_helper(node_name_conflict const & left_c, node_name_conflict const & right_c) { I(left_c.nid == left_root_nid); - I(left_c.left == std::make_pair(the_null_node, the_null_component)); - I(left_c.right == std::make_pair(right_root_nid, idx(split("left_root"), 1))); + I(left_c.left == make_pair(the_null_node, the_null_component)); + I(left_c.right == make_pair(right_root_nid, idx(split("left_root"), 1))); I(right_c.nid == right_root_nid); - I(right_c.left == std::make_pair(left_root_nid, idx(split("right_root"), 1))); - I(right_c.right == std::make_pair(the_null_node, the_null_component)); + I(right_c.left == make_pair(left_root_nid, idx(split("right_root"), 1))); + I(right_c.right == make_pair(the_null_node, the_null_component)); } virtual void check() { @@ -1791,7 +1796,7 @@ rename_target_conflict const & c = idx(result.rename_target_conflicts, 0); I((c.nid1 == left_root_nid && c.nid2 == right_root_nid) || (c.nid1 == right_root_nid && c.nid2 == left_root_nid)); - I(c.parent_name == std::make_pair(the_null_node, the_null_component)); + I(c.parent_name == make_pair(the_null_node, the_null_component)); I(result.missing_root_dir); ============================================================ --- sanity.cc d10487eb6479f58640483c72bb8c207903b0ade1 +++ sanity.cc eb02236fb3eb72ac83d3b4a30cadad147aec9895 @@ -22,7 +22,15 @@ #include "simplestring_xform.hh" #include "ui.hh" -using namespace std; +using std::exception; +using std::logic_error; +using std::ofstream; +using std::ostream; +using std::ostream_iterator; +using std::ostringstream; +using std::string; +using std::vector; + using boost::format; // debugging / logging system @@ -33,7 +41,7 @@ debug(false), quiet(false), reallyquiet(false), relaxed(false), logbuf(0xffff), already_dumping(false), clean_shutdown(false) { - std::string flavour; + string flavour; get_system_flavour(flavour); L(FL("started up on %s\n") % flavour); } @@ -122,7 +130,7 @@ { return fmt.str(); } - catch (std::exception & e) + catch (exception & e) { ui.inform(F("fatal: formatter failed on %s:%d: %s") % file @@ -251,12 +259,12 @@ } already_dumping = true; L(FL("saving current work set: %i items") % musings.size()); - std::ostringstream out; + ostringstream out; out << F("Current work set: %i items\n") % musings.size(); - for (std::vector::const_iterator + for (vector::const_iterator i = musings.begin(); i != musings.end(); ++i) { - std::string tmp; + string tmp; try { (*i)->gasp(tmp); @@ -301,20 +309,20 @@ } template <> void -dump(std::string const & obj, std::string & out) +dump(string const & obj, string & out) { out = obj; } -void MusingBase::gasp_head(std::string & out) const +void MusingBase::gasp_head(string & out) const { out = (boost::format("----- begin '%s' (in %s, at %s:%d)\n") % name % func % file % line ).str(); } -void MusingBase::gasp_body(const std::string & objstr, std::string & out) const +void MusingBase::gasp_body(const string & objstr, string & out) const { out += (boost::format("%s%s" "----- end '%s' (in %s, at %s:%d)\n") @@ -330,19 +338,19 @@ { } -i18n_format::i18n_format(std::string const & localized_pattern) +i18n_format::i18n_format(string const & localized_pattern) : fmt(localized_pattern, get_user_locale()) { } -std::string +string i18n_format::str() const { return fmt.str(); } -std::ostream & -operator<<(std::ostream & os, i18n_format const & fmt) +ostream & +operator<<(ostream & os, i18n_format const & fmt) { return os << fmt.str(); } ============================================================ --- schema_migration.cc f820f10c5c4992df47354a9653d89a6de21c3a87 +++ schema_migration.cc e26608a79f5d7cef3cc41da156dfc6d5f5f840db @@ -22,6 +22,8 @@ #include "keys.hh" #include "transforms.hh" +using std::string; + // this file knows how to migrate schema databases. the general strategy is // to hash each schema we ever use, and make a list of the SQL commands // required to get from one hash value to the next. when you do a @@ -181,7 +183,7 @@ // assert_sqlite3_ok() in database.cc string errmsg(sqlite3_errmsg(sql)); L(FL("calculate_schema_id sqlite error: %d: %s") % res % errmsg); - std::string auxiliary_message = ""; + string auxiliary_message = ""; if (res == SQLITE_ERROR) { auxiliary_message += _("make sure database and containing directory are writeable\n" ============================================================ --- selectors.cc a179c48e93ea4c6e98558ce1f4b76da04ae88e61 +++ selectors.cc 6e4fa17b861b28cc469b4adcdcdc58206ab2d654 @@ -9,20 +9,26 @@ #include "app_state.hh" #include "constants.hh" +using std::make_pair; +using std::pair; +using std::set; +using std::string; +using std::vector; + namespace selectors { static void - decode_selector(std::string const & orig_sel, + decode_selector(string const & orig_sel, selector_type & type, - std::string & sel, + string & sel, app_state & app) { sel = orig_sel; L(FL("decoding selector '%s'\n") % sel); - std::string tmp; + string tmp; if (sel.size() < 2 || sel[1] != ':') { if (!app.lua.hook_expand_selector(sel, tmp)) @@ -94,29 +100,29 @@ } void - complete_selector(std::string const & orig_sel, - std::vector > const & limit, + complete_selector(string const & orig_sel, + vector > const & limit, selector_type & type, - std::set & completions, + set & completions, app_state & app) { - std::string sel; + string sel; decode_selector(orig_sel, type, sel, app); app.db.complete(type, sel, limit, completions); } - std::vector > - parse_selector(std::string const & str, + vector > + parse_selector(string const & str, app_state & app) { - std::vector > sels; + vector > sels; // this rule should always be enabled, even if the user specifies // --norc: if you provide a revision id, you get a revision id. - if (str.find_first_not_of(constants::legal_id_bytes) == std::string::npos + if (str.find_first_not_of(constants::legal_id_bytes) == string::npos && str.size() == constants::idlen) { - sels.push_back(std::make_pair(sel_ident, str)); + sels.push_back(make_pair(sel_ident, str)); } else { @@ -124,17 +130,17 @@ boost::escaped_list_separator slash("\\", "/", ""); tokenizer tokens(str, slash); - std::vector selector_strings; + vector selector_strings; copy(tokens.begin(), tokens.end(), back_inserter(selector_strings)); - for (std::vector::const_iterator i = selector_strings.begin(); + for (vector::const_iterator i = selector_strings.begin(); i != selector_strings.end(); ++i) { - std::string sel; + string sel; selector_type type = sel_unknown; decode_selector(*i, type, sel, app); - sels.push_back(std::make_pair(type, sel)); + sels.push_back(make_pair(type, sel)); } } ============================================================ --- simplestring_xform.cc b6d21fa059da420562b8dfea0e833b1806d7766d +++ simplestring_xform.cc dcf9e39b1a9c1bb565447a90f6068bdf82a7ee68 @@ -43,11 +43,11 @@ return n; } -void split_into_lines(std::string const & in, - std::string const & encoding, - std::vector & out) +void split_into_lines(string const & in, + string const & encoding, + vector & out) { - std::string lc_encoding = lowercase(encoding); + string lc_encoding = lowercase(encoding); out.clear(); // note: this function does not handle ISO-2022-X, Shift-JIS, and @@ -61,19 +61,19 @@ // ASCII, and UTF-8 families of encodings. if (lc_encoding == constants::default_encoding - || lc_encoding.find("ascii") != std::string::npos - || lc_encoding.find("8859") != std::string::npos - || lc_encoding.find("euc") != std::string::npos - || lc_encoding.find("koi") != std::string::npos - || lc_encoding.find("gb") != std::string::npos + || lc_encoding.find("ascii") != string::npos + || lc_encoding.find("8859") != string::npos + || lc_encoding.find("euc") != string::npos + || lc_encoding.find("koi") != string::npos + || lc_encoding.find("gb") != string::npos || lc_encoding == "utf-8" || lc_encoding == "utf_8" || lc_encoding == "utf8") { - std::string::size_type begin = 0; - std::string::size_type end = in.find_first_of("\r\n", begin); + string::size_type begin = 0; + string::size_type end = in.find_first_of("\r\n", begin); - while (end != std::string::npos && end >= begin) + while (end != string::npos && end >= begin) { out.push_back(in.substr(begin, end-begin)); if (in.at(end) == '\r' @@ -123,11 +123,11 @@ void prefix_lines_with(string const & prefix, string const & lines, string & out) { - std::vector msgs; + vector msgs; split_into_lines(lines, msgs); ostringstream oss; - for (std::vector::const_iterator i = msgs.begin(); + for (vector::const_iterator i = msgs.begin(); i != msgs.end();) { oss << prefix << *i; ============================================================ --- ui.cc 180abc6a7a5e1e7c552abc05d8d1806aebcae786 +++ ui.cc cd43c58d97f3b15c45109e37c1fdad43ba84284a @@ -23,11 +23,23 @@ #include #include -using namespace std; +using std::clog; +using std::cout; +using std::endl; +using std::ios_base; +using std::locale; +using std::make_pair; +using std::map; +using std::max; +using std::ofstream; +using std::string; +using std::vector; + using boost::lexical_cast; + struct user_interface ui; -ticker::ticker(string const & tickname, std::string const & s, size_t mod, +ticker::ticker(string const & tickname, string const & s, size_t mod, bool kilocount) : ticks(0), mod(mod), @@ -192,7 +204,7 @@ tick->set_count_size(count_width); } - size_t max_width = std::max(title_width, tick->count_size); + size_t max_width = max(title_width, tick->count_size); string name; name.append(max_width - title_width, ' '); @@ -404,7 +416,7 @@ { if (issued_warnings.find(warning) == issued_warnings.end()) { - std::string message; + string message; prefix_lines_with(_("warning: "), warning, message); inform(message); } @@ -422,13 +434,13 @@ } void -user_interface::set_prog_name(std::string const & name) +user_interface::set_prog_name(string const & name) { prog_name = name; I(!prog_name.empty()); } -std::string +string user_interface::output_prefix() { if (prog_name.empty()) { ============================================================ --- unit_tests.cc 9b3d3fd11212c735e093314f79e5fbd76977ebab +++ unit_tests.cc 56038ad7f4260307ce03f9e4313720c59466f564 @@ -14,6 +14,9 @@ #include #include +using std::set; +using std::string; + static bool clean_shutdown; void dumper() { @@ -38,9 +41,9 @@ test_suite * suite = BOOST_TEST_SUITE("monotone unit tests"); I(suite); - std::set t; + set t; if (argc > 1) - t = std::set(argv+1, argv+argc); + t = set(argv+1, argv+argc); // call all the adders here ============================================================ --- vocab.cc 734ef82435e130f3ba3674573a142a8a980de91c +++ vocab.cc cd9e884668636ad1bb7cd1607d5d2fd0015fd307 @@ -11,9 +11,9 @@ #include "sanity.hh" #include "vocab.hh" -// verifiers for various types of data +using std::string; -using namespace std; +// verifiers for various types of data // the verify() stuff gets a little complicated; there doesn't seem to be a // really nice way to achieve what we want with c++'s type system. the @@ -162,17 +162,17 @@ // counter of activations, and when there is an activation, the // members of the ATOMIC type initialize their internal string using a // copy of the string found in the symtab. Since some (all?) C++ -// std::string implementations are copy-on-write, this has the affect +// string implementations are copy-on-write, this has the affect // of making the ATOMIC(foo) values constructed within a symbol table // scope share string storage. struct symtab_impl { - typedef hashmap::hash_set hset; + typedef hashmap::hash_set hset; hset vals; symtab_impl() : vals() {} void clear() { vals.clear(); } - std::string const & unique(std::string const & in) + string const & unique(string const & in) { // This produces a pair where iter points to an // element of the table; the bool indicates whether the element is @@ -202,25 +202,25 @@ template -void dump(base64 const&, std::string &); +void dump(base64 const&, string &); template -void dump(revision_id const & r, std::string &); +void dump(revision_id const & r, string &); template -void dump(roster_id const & r, std::string &); +void dump(roster_id const & r, string &); template -void dump(manifest_id const & r, std::string &); +void dump(manifest_id const & r, string &); template -void dump(file_id const & r, std::string &); +void dump(file_id const & r, string &); template -void dump(hexenc const & r, std::string &); +void dump(hexenc const & r, string &); template -void dump(roster_data const & d, std::string &); +void dump(roster_data const & d, string &); // the rest is unit tests ============================================================ --- vocab_macros.hh 5f7434315d7ad936ca9bf09abe40899eb7e44d49 +++ vocab_macros.hh c82a27c1bc1c60037141f7e4bc26c00edc7d61a4 @@ -103,20 +103,6 @@ inline void verify(ty &) {} - - - - - - - - - - - - - - //CC @@ -140,8 +126,8 @@ { s = other.s; ok = other.ok; \ verify(*this); return *this; } \ \ -ostream & operator<<(ostream & o, \ - ty const & a) \ + std::ostream & operator<<(std::ostream & o,\ + ty const & a) \ { return (o << a.s); } \ \ template <> \ @@ -186,7 +172,8 @@ verify(*this); return *this;} \ \ template \ -ostream & operator<<(ostream & o, enc const & e) \ +std::ostream & operator<<(std::ostream & o, \ + enc const & e) \ { return (o << e.i); } \ \ template \ @@ -212,7 +199,8 @@ verify(*this); return *this;} \ \ template \ -ostream & operator<<(ostream & o, dec const & d) \ +std::ostream & operator<<(std::ostream & o, \ + dec const & d) \ { return (o << d.i); } \ \ template \ ============================================================ --- work.cc 0d47dba0c23494d21067c094cca9cba8acd71f3b +++ work.cc afe3d7f65d252d2874181c2c43d50f95d51c8d61 @@ -23,9 +23,16 @@ #include "work.hh" #include "revision.hh" -// workspace / book-keeping file code +using std::deque; +using std::exception; +using std::make_pair; +using std::map; +using std::pair; +using std::set; +using std::string; +using std::vector; -using namespace std; +// workspace / book-keeping file code static string const attr_file_name(".mt-attrs"); static string const inodeprints_file_name("inodeprints"); @@ -263,7 +270,7 @@ // where, when processing 'foo', we need to know whether or not it is empty // (and thus legal to remove) - std::deque todo; + deque todo; path_set::const_reverse_iterator i = paths.rbegin(); todo.push_back(*i); ++i; @@ -480,8 +487,8 @@ } cset cs; - safe_insert(cs.nodes_renamed, std::make_pair(root_sp, put_old_sp)); - safe_insert(cs.nodes_renamed, std::make_pair(new_root_sp, root_sp)); + safe_insert(cs.nodes_renamed, make_pair(root_sp, put_old_sp)); + safe_insert(cs.nodes_renamed, make_pair(new_root_sp, root_sp)); { editable_roster_base e(new_roster, nis); @@ -556,7 +563,7 @@ // revision file name -std::string revision_file_name("revision"); +string revision_file_name("revision"); static void get_revision_path(bookkeeping_path & m_path) { @@ -580,7 +587,7 @@ { read_data(c_path, c_data); } - catch(std::exception & e) + catch(exception & e) { N(false, F("Problem with workspace: %s is unreadable") % c_path); } @@ -724,7 +731,7 @@ // don't clear the options which will have settings from the command line // options.clear(); - std::string opt, val; + string opt, val; while (parser.symp()) { parser.sym(opt); @@ -862,7 +869,7 @@ static inline bookkeeping_path path_for_nid(node_id nid) { - return bookkeeping_root / "tmp" / boost::lexical_cast(nid); + return bookkeeping_root / "tmp" / boost::lexical_cast(nid); } // Attaching/detaching the root directory: @@ -896,11 +903,11 @@ { // root dir detach, so we move contents, rather than the dir itself mkdir_p(dst_pth); - std::vector files, dirs; + vector files, dirs; read_directory(src_pth, files, dirs); - for (std::vector::const_iterator i = files.begin(); i != files.end(); ++i) + for (vector::const_iterator i = files.begin(); i != files.end(); ++i) move_file(src_pth / (*i)(), dst_pth / (*i)()); - for (std::vector::const_iterator i = dirs.begin(); i != dirs.end(); ++i) + for (vector::const_iterator i = dirs.begin(); i != dirs.end(); ++i) if (!bookkeeping_path::is_bookkeeping_path((*i)())) move_dir(src_pth / (*i)(), dst_pth / (*i)()); root_dir_attached = false; @@ -914,7 +921,7 @@ editable_working_tree::drop_detached_node(node_id nid) { bookkeeping_path pth = path_for_nid(nid); - std::map::const_iterator i + map::const_iterator i = rename_add_drop_map.find(pth); I(i != rename_add_drop_map.end()); P(F("dropping %s") % i->second); @@ -957,7 +964,7 @@ if (!path_exists(src_pth)) { I(root_dir_attached); - std::map::const_iterator i + map::const_iterator i = written_content.find(src_pth); if (i != written_content.end()) { @@ -980,7 +987,7 @@ F("path '%s' already exists, cannot create") % dst_pth); // If we get here, we're doing a file/dir rename, or a dir-create. - std::map::const_iterator i + map::const_iterator i = rename_add_drop_map.find(src_pth); if (i != rename_add_drop_map.end()) { @@ -992,14 +999,14 @@ if (dst_pth == file_path()) { // root dir attach, so we move contents, rather than the dir itself - std::vector files, dirs; + vector files, dirs; read_directory(src_pth, files, dirs); - for (std::vector::const_iterator i = files.begin(); i != files.end(); ++i) + for (vector::const_iterator i = files.begin(); i != files.end(); ++i) { I(!bookkeeping_path::is_bookkeeping_path((*i)())); move_file(src_pth / (*i)(), dst_pth / (*i)()); } - for (std::vector::const_iterator i = dirs.begin(); i != dirs.end(); ++i) + for (vector::const_iterator i = dirs.begin(); i != dirs.end(); ++i) { I(!bookkeeping_path::is_bookkeeping_path((*i)())); move_dir(src_pth / (*i)(), dst_pth / (*i)()); ============================================================ --- xdelta.cc 0dba3763bd06fe89479c0c91d649eaba2b9e37ba +++ xdelta.cc 0d2c397234e43b065c82f446ac4192803dec1146 @@ -35,7 +35,14 @@ #include "sanity.hh" #include "xdelta.hh" -using namespace std; +using std::make_pair; +using std::min; +using std::ostream; +using std::ostringstream; +using std::pair; +using std::set; +using std::string; +using std::vector; struct identity {size_t operator()(u32 const & v) const { return static_cast(v);}}; typedef pair extent; @@ -340,9 +347,9 @@ void apply_delta(boost::shared_ptr da, - std::string const & delta) + string const & delta) { - std::string::const_iterator i = delta.begin(); + string::const_iterator i = delta.begin(); while (i != delta.end() && (*i == 'I' || *i == 'C')) { if (*i == 'I') @@ -398,20 +405,20 @@ { u64 & sz; size_accumulating_delta_applicator(u64 & s) : sz(s) {} - virtual void begin(std::string const & base) {} + virtual void begin(string const & base) {} virtual void next() {} - virtual void finish(std::string & out) {} + virtual void finish(string & out) {} - virtual void copy(std::string::size_type pos, - std::string::size_type len) + virtual void copy(string::size_type pos, + string::size_type len) { sz += len; } - virtual void insert(std::string const & str) + virtual void insert(string const & str) { sz += str.size(); } }; u64 -measure_delta_target_size(std::string const & delta) +measure_delta_target_size(string const & delta) { u64 sz = 0; boost::shared_ptr da(new size_accumulating_delta_applicator(sz)); @@ -686,9 +693,9 @@ new_pos(0) {} - virtual void begin(std::string const & base) {} + virtual void begin(string const & base) {} virtual void next() {} - virtual void finish(std::string & out) + virtual void finish(string & out) { // We are trying to write a delta instruction stream which // produces 'old' from 'new'. We don't care what was in 'new', @@ -737,15 +744,15 @@ write_delta_insns(delta_insns, out); } - virtual void copy(std::string::size_type old_pos, - std::string::size_type len) + virtual void copy(string::size_type old_pos, + string::size_type len) { I(old_pos < old.size()); copied_extents.insert(copied_extent(old_pos, new_pos, len)); new_pos += len; } - virtual void insert(std::string const & str) + virtual void insert(string const & str) { new_pos += str.size(); }