# # # patch "ChangeLog" # from [35e34c28ec8501d85401273cd5a75829c775d545] # to [850c931a795a24580e7fcf2e2ee0a710f502eac5] # # patch "adler32.hh" # from [adf2c488c4b0062c31b89b0e7b31d0ce840d2e08] # to [c00437287b948bba66b6195ef74749615512df46] # # patch "annotate.cc" # from [7655d63779fde07e30bbd6b2b4a5c74378175a5d] # to [7bc1472f79bea8bc5b5b2370e35d63b676dd6569] # # patch "annotate.hh" # from [2c21ed973503781e799cb80b18ea83a3398010d1] # to [e7a6458c2750aa879f7bb7612e15fa7e84931459] # # patch "app_state.cc" # from [fe9a80dc99e8deb846577ba557e4e4a20addf1c0] # to [a941f16101beb709145100ba58cc9726c7dacbf2] # # patch "app_state.hh" # from [1e1011728a2da0db22589ac19fe9de5b00d08680] # to [a6cba0558a4c377dda413b557c10781cd33668c1] # # patch "automate.cc" # from [fb597bb9483f7531adbb6e2501188d74063bf60a] # to [8b18ec025d8bd4fe2a1a100de6f4bc8243911933] # # patch "basic_io.cc" # from [d7e7798e323fe76518a577010d4eef1f7639a0b1] # to [a15ef15ce8808a455ee8f9a7edeeb2ba23eddc67] # # patch "basic_io.hh" # from [c40999a46e70901ea3964b4c378d8cb368437dd2] # to [a690f850ad0a49bd2309216008f8bf931bd0b017] # # patch "cert.cc" # from [6e1ffc5b990cf82e6ee2a7d1492127b2f71aa105] # to [00b0049d57be97e2f990812639b0d917913eaef2] # # patch "cert.hh" # from [6ccf880b677340a2460ced453c93700b7bae07b3] # to [442db182fbe3a8f3c1313ddcc34f911b05371f02] # # patch "charset.cc" # from [f55e73d42872fbbf269b3cd9f41af9217030f1a6] # to [fc0b370c50ee32b1bc3bb110e4181f3a841edbae] # # patch "cleanup.hh" # from [a450ba2ba4311f0a298c1e102bd5c5f0c5fb2258] # to [5af6a253b76166eafdaf7a6bb0b27b08469ca10e] # # patch "cmd.hh" # from [76fe4ececf8426484d8a4aca7c54237c49ce6100] # to [b3216c27888503db9b3d33aed451f013f54e240a] # # patch "cmd_automate.cc" # from [37baff9dc561c7fad66b88559fda15b14f2a4f55] # to [6f285920e44f4c8c2d262c08b7e06de1f4b4ae65] # # patch "cmd_db.cc" # from [7403b1a1bb54a12e01dee5fcbbc3db7aaf8ba557] # to [556cb1dad30d2b6ad3a50fd7951927afdf5ce6d2] # # patch "cmd_diff_log.cc" # from [c2d375111f402eac0c82134f174627d88608dcb0] # to [4d963e42f2b37a325e6afb0e3f0f9ee6995f2525] # # patch "cmd_files.cc" # from [22b692fc7848cf47a7572d4df48b0ffeeaa56c5c] # to [088fb68e4513fb18130184937b3bfcaf4e23155a] # # patch "cmd_key_cert.cc" # from [4f07a55505d99f4a1680313d47e7a813a4bd1517] # to [aea641cf1bcdfb372b147d99a5f908cca3c12188] # # patch "cmd_list.cc" # from [5edf0ae19d13ccc9d25490eb64576bff4ad907ca] # to [5b4ecf0d3b3fac90a4cb8eea9b30b31bc335d082] # # patch "cmd_merging.cc" # from [6745bfc6317dad3cf1828d17600aca164accf0e5] # to [3c99bc7044aba855f37df212ca11959ed6881bec] # # patch "cmd_netsync.cc" # from [3679d67d1590ae6a8731ab565132cd148b427b0b] # to [2b0b6da8e33bf1c3a5c7eec9de9218f20cbe1a80] # # patch "cmd_othervcs.cc" # from [47651b6f63bd48be121a30eec4d1746238151fd2] # to [f97235e360354ab14ae9749e45b274acfc30c35e] # # patch "cmd_ws_commit.cc" # from [b334deaf56946d327559cb7db10fc82de170da5c] # to [ed419208149db21c8a754df43d443c143b2e7544] # # patch "commands.cc" # from [579d73cf72936f2493bfe1fa4cec133d42106469] # to [534869eb75c5f57575dc842d1d7e24461b4a3a8c] # # patch "commands.hh" # from [c6c8f7e3146a242c1578c35818116aba48e0d6a6] # to [815d331acde28ddbd64107f92e52aad1f9f199f1] # # patch "constants.cc" # from [b175c8ae9c808089d3e9f7216896be26714703db] # to [e0fe679a5b53cdee258b2588fec97fece2ec632c] # # patch "constants.hh" # from [e24a1a631a2717ee866ca20e5cb4ede9d2ba3d8a] # to [eb79289a66344262b16a0fe67ec63b3979fe34f2] # # patch "crypto_tests.cc" # from [5f2ad6110bb7f9a10978ede2c860ad44b24ffed0] # to [70cc3f3681395ae674799976432b968d1f79ef52] # # patch "cset.cc" # from [bf3abceb49091cfed0d14d02c1188d14378b8f6e] # to [71b4052c7b0658142edd83e596cfaa8f3be18f2a] # # patch "cset.hh" # from [2d06997a4c2475aa45550dbe967c09397575d908] # to [6410b0b216aed5a227e15a4537ca08d5f673a81f] # # patch "cycle_detector.hh" # from [624eaa84d3bc3281a0d6280cbecb1e654f0bc723] # to [79f9f0af66246c9cb770c5e3b57172c8c1b4b6e9] # # patch "database.cc" # from [77592832b55b0c42a0d4afb23875dc242d3d67b4] # to [ae0895605e5a1b6745b3b034a2836f1ad0e8001e] # # patch "database.hh" # from [1222e43cb9911d432296a70d25b51f53462afd7e] # to [f2225237fc9dec0d6e9781c207b2375047c980ce] # # patch "database_check.cc" # from [1354e4948560a3e9197df485a0d6d4208c7d442c] # to [2df826436ffc2376ebf5d95a3b0159b02b9bd2ce] # # patch "database_check.hh" # from [98374bcba5840ad01efdec5f36a0159568e124d7] # to [7a319e994d382e74c3f6dceee3462a2a6bfe8153] # # patch "diff_patch.cc" # from [b854d0d4444480e98b9ed8e2aa936d700de1cc22] # to [f05f8aa967ed88dae6b96efecdf44c45f288537d] # # patch "diff_patch.hh" # from [845e486548ebc492296e0a441557ad6ae96c741f] # to [bd951a22eea247856e6f5971cadc165a82f56a3a] # # patch "enumerator.cc" # from [e2ebd144f9f66f1dab7a5324c62e2f7d73eb4646] # to [ec047b5f698ad0fb305210e16361c0008e010da4] # # patch "enumerator.hh" # from [4f3ce29808f2bf2c0f65701e64ae379e369ab9fb] # to [03863f83479e729dbcad98faee6140049f9e8768] # # patch "file_io.cc" # from [7c50a2a9534b3e6a0f0f876f785b5a638d419f95] # to [b7b388fa5f4935c5e91038513ca1366b172fe154] # # patch "globish.cc" # from [409df5d1f8ff0ad46a144ed6f1344418185d54dc] # to [febd0cd30ba4ec07bf0012a8f51081b953928132] # # patch "hash_map.hh" # from [98827ec1d7ba91683c64e731820f434f022fdbe0] # to [e2f34bc96b7ca591a50dc687cc42e3c84f8507a7] # # patch "hmac.cc" # from [668380c352db46c0cefbababed90462db529f486] # to [472764cfd31f8de5fa089b2ba56f399e52a69c67] # # patch "hmac.hh" # from [e3082711a437a693ba707ca763e1c2f6755efaba] # to [ad2e9fd10edb10a0c65839da6312ca71ce711c24] # # patch "inodeprint.cc" # from [62b091111b84a22f6de804b3c9d37716e7a06169] # to [adf50d2f722a8a5e13d28c8203162d6d0b7bba14] # # patch "inodeprint.hh" # from [3db3005b0230aa489265417b80cba28a74dc406e] # to [5854a71f0c57d01e06cb736bfb4edc66d34f40b2] # # patch "interner.hh" # from [70ca14f55628cab86911c21d846931cb64d3319d] # to [f80a165b21302d7384cac0c7564f06999bbe9c60] # # patch "key_store.cc" # from [dcdebf60e129b121b78cc0f2c53e3c7a19cf69a9] # to [489c4d61423a5d93788c13358311a6f710cf432f] # # patch "key_store.hh" # from [6821800c3a5f562b7d8aa747e8b232e0b37a9bda] # to [08c0ac89d69b00b55cccad9fde8ee2e30229e1f9] # # patch "keys.cc" # from [3d835d4757415bf43f821941e2a37bdbc1c4f2db] # to [a72e7d7009481fac53ef5086f2f2ccea4b14f5c6] # # patch "keys.hh" # from [8ef7487642f3f7cc3e9bfa80ce88770467edac3d] # to [55a0ad2a67a0c6f30b3fc16ac1dd9a904ebd400f] # # patch "lcs.cc" # from [11c987c3b32ff3c1c860030dc298b5a5547fc2fa] # to [5534a43bd5c14750bf13fde28cfc80b14af0e9fb] # # patch "lcs.hh" # from [8fd9c138a9fb9baa870ebdf56723bb5ef189a081] # to [dfdece3a1525237aa7ac5996a76cf0d64671e59f] # # patch "legacy.cc" # from [cb7eb7d67ccf5f3b3d762c3889a90f1e17509222] # to [fef9d94af73fe443c3ec75ae2a47c01ab826377f] # # patch "legacy.hh" # from [4759323523ca05da97a2d525c629b3b0e446a674] # to [ca42f4646c6f80ec2bf9f8d332efa8aebdd92f85] # # patch "localized_file_io.cc" # from [a224f91ef63f02d73e12173351f918b30c526075] # to [8d36617800f80f983c2e9be3724555b6c9eea95d] # # patch "localized_file_io.hh" # from [9cdb8ca069e30a6dbf3e02d53337b4e2407e6bdd] # to [92af84cfbe868c3cefbaf45bb479cc5f465e405a] # # patch "lua.cc" # from [510492e0a3d30022cff1fcf325ddf6de32a899f4] # to [e08614b229eb4cddd3a9820ea729d5cb33d58489] # # patch "lua.hh" # from [54e0054144207e223df17764f6da0e6134cb6a02] # to [6b805dfc204b315a49e7be86ad8f3ca8519ffdaa] # # patch "lua_hooks.cc" # from [a61adade16562803f2118f96bdd2d5b2b8c391bd] # to [f6958169c7ac3b2cba99da60c075dfd9f8f766d4] # # patch "lua_hooks.hh" # from [4808b67b1e1cf6250e423ffd16d2153cba51ca78] # to [5e33a2a94befbcd2969d80363fdfc8a09994565b] # # patch "main.cc" # from [1b50bf9eefcb967254582b38a5a886f8ad09eea6] # to [14ebc50eeeaf3248b88c1a79d45586ecb2e22f2d] # # patch "merge.cc" # from [cc6860bdc2e1ba18713800ef24ceb08c605abab0] # to [cb10f705835971e69ada0c322e42ab635f8388cb] # # patch "merge.hh" # from [ba5196326f988aa8d857e7aa3b138ff17afbe06b] # to [87e2852d5ba1ef5e8c0d615b70688223a1cb095c] # # patch "merkle_tree.cc" # from [7011e2dbceb1d2e78db31c8c4570d443b383c639] # to [888e9121fb11a391bc924b2da6fa186353f24cd3] # # patch "merkle_tree.hh" # from [af2fed86c559da7f86f0d9a0f6189ab385ee8c08] # to [21726c0cadb872365e5b32361d87d5c450a4e019] # # patch "mkstemp.cc" # from [84c177af02e8c9cde94a596461bdc5d837512fd4] # to [cbcbd1d3b07c4207bb3e474397a0b07a95f2f0d6] # # patch "monotone.cc" # from [47ee3ca3d15e6e3a261fdaace69671e05f7cba01] # to [33fac939423bd5f1f6286e2fddd4b546df8067bf] # # patch "mt_version.cc" # from [936a7e6ad5c7ef202f0bdbc0f0bfc7ebc380ff27] # to [672188a1ba9293f6cc3fa56411521403022b1644] # # patch "netcmd.cc" # from [bd6ee0d97bdb27879e1d8342d6bc64899a6971e7] # to [f344ffb3dcd799f0b4ec4c6796dbc5db9f1a64e7] # # patch "netcmd.hh" # from [e290b45f5acb01bfe181832d4750275e05b2f98f] # to [06cdc51d8a9a6eb0b38cc17b810ededb0121d5e1] # # patch "netio.hh" # from [3177bc0e70e1d2333e7ffeee004b01f2d114ccfb] # to [e37bb9cfb163aac2a2ac4e63a29f233bab47c9c0] # # patch "netsync.cc" # from [790c8fceb436ee65f0ade641aefe3a60d10893d9] # to [a65ecca750cb7342ee8ab24f152ea92ff208eba0] # # patch "netsync.hh" # from [276fdfd34e38b36adc1a45d012792fd43db07a2c] # to [7307b7f9d4053a98d543ff7068d2767689dcc249] # # patch "netxx_pipe.cc" # from [bf56e7d54b7cd63656f6ec741a848d4df3e86bf8] # to [6af839b4682d91c62c38d6393d83bb9f04f65177] # # patch "netxx_pipe.hh" # from [720992e155fa3f850ed0c46aaa1d224e25c95efe] # to [54d564cba3c9ca9952c6d739f2b3e5d279b7ed5c] # # patch "packet.cc" # from [dfdefb2d2808183cd0312752b2ee1f840bace11c] # to [cfef3e3f3868a9c41f6cce65f0a3325515de73df] # # patch "packet.hh" # from [97e6723f3b4974aa36826b5391b2018870ad4eb3] # to [287d928c5429c8c9d1c16a9fb4588eb9ec87001b] # # patch "parallel_iter.hh" # from [a00fa825f37d7c08c98cdc99a45d7304c4e64fd2] # to [686f6f5be905ac6b2b4b45eac9e3ce217096ce94] # # patch "paths.cc" # from [cef87a9f72cc5011f93bb8bfa7d9ac6f6d0eeadd] # to [48db23c7a770cf3743c971b3fd31431356e8b186] # # patch "paths.hh" # from [b97148599d5823bd41c4be253a363dbaf64e2411] # to [e084737c12b8cbff745ff1ea5b49092360edad43] # # patch "po/it.po" # from [a548b1b52dc1b491a42cb4aa38355868a116512d] # to [ee2152af52bae06b3db4e103b4082b18bf9f255b] # # patch "quick_alloc.hh" # from [597049a62d0a2e6af7df0b19f4945ec7d6458727] # to [2df81e1736db37f310079c13ac4ef7dd98d42980] # # patch "randomfile.hh" # from [b1f6e5652eaa4a22cef5061e97930ad6ecb0ade7] # to [00d68b5949086027d0005fa67a4a433802fb9990] # # patch "rcs_file.cc" # from [e6ecf0169b282a6f96e278227893eef9ca10680e] # to [7e9f91d6c2d5dd3012ad17ea84b7545e28fc48f4] # # patch "rcs_file.hh" # from [be175e779bb2c3dfb0a22a72013d1c25523cbe2d] # to [7cf27d862430efb640e00330ab59226d4feb6538] # # patch "rcs_import.cc" # from [45f1588e753d5220aa502425e5c32500f3069d7c] # to [7f7c2ab405b7b8d5758d74713c510fc567191c0f] # # patch "refiner.cc" # from [f2f64fe6722f3501ce1fea2d85516818070151e2] # to [e286ca0e353379af8a9b3ebf4c0fbf8fd6679e9e] # # patch "refiner.hh" # from [785a738e8476f63f8f8b0c5ecfee085dbd764ade] # to [cb3b7386d2d3c0836382814daebb8ff4074cf04e] # # patch "restrictions.cc" # from [d7c60923a328aefb9a8429ecb6654586ce31a3f9] # to [7419cd1cb2303f5a839b67594d6de2943a57309c] # # patch "restrictions.hh" # from [797c6f69647ff3a63870f7870b88353840cf9200] # to [2559135fa63540e2fe96c33eb01cf846bcb8519e] # # patch "revision.cc" # from [8b358213321192d8a1f65992915ed1b20dd2cbbe] # to [201081607e581bf1fcf2416486399d2840189617] # # patch "revision.hh" # from [f31cef31d418dc6585a24fc61267b9ff47b0cdf5] # to [e765cc1218de6df527126268ea5aa8569812e4a0] # # patch "roster.cc" # from [fde433622561c188f726b4b591388c070cc1e391] # to [2bf3101b93e77a6c51c1267d799220a69a2f5a9d] # # patch "roster.hh" # from [5ff1e7a09081ccdf029648256e717075140eba34] # to [0dcd64e317aa7842ea2529178f98782569c060c5] # # patch "roster_merge.cc" # from [ff845578375e028041eb8731d2f870ebfcad9eeb] # to [08c28631640c674a9f6da7b5915786ee6afe27fc] # # patch "roster_merge.hh" # from [6d06c48935d0fb8f0058b3392facca870d8912c7] # to [481dde9bcf40c4ba63e24f36758fece7b0c18b2b] # # patch "safe_map.hh" # from [b41faf022ccd9f384f6a58f58372cec23e9899d4] # to [1cf84b0e0943f513d935dc30b5a1f3d0cea63783] # # patch "sanity.cc" # from [eb9f4d9b41e1e2342303e4a618fe5481c10c1eae] # to [f61b26fbfbb19efc4f9f4f6860d4fafbca57dcb7] # # patch "sanity.hh" # from [be515df1539fe9df44d44091a19e7d3b22927bdf] # to [675bca26fedbc70535f81d4e3ca66b87527c344e] # # patch "schema_migration.cc" # from [3b14626a3cf5917254ec38dc54edd63b03a2c6f2] # to [692358550bd9c536ef97ae69eb8893daf3dfb880] # # patch "selectors.cc" # from [6e4fa17b861b28cc469b4adcdcdc58206ab2d654] # to [ebc515a9552d1eb547de8b220e33eeec2e1059ff] # # patch "simplestring_xform.cc" # from [dcf9e39b1a9c1bb565447a90f6068bdf82a7ee68] # to [b48839ca2a3f88b7db657c8aaf5a1fd58a29e1f6] # # patch "simplestring_xform.hh" # from [5226320784043474c9f5fd799b8e86ca2f070d8d] # to [ba15cb86a7300ac69a921bf855a8b8587cf748f9] # # patch "smap.hh" # from [d4acf13bff4208cfe2d87cb93fcb182a290d77f8] # to [a7675c8e99c425c7ed3531189f8efd74d4eac41a] # # patch "tester.cc" # from [cee71a1f004e66cdd9447c23f1c16f9bfdb0c246] # to [285226d2e10fb2785ff38afedec7f1c256321ec2] # # patch "transforms.cc" # from [a4754b188afa931450b7dc5b49d077a5a39e8073] # to [cbf74915e0e547291ea34f948331114d3859383d] # # patch "txt2c.cc" # from [85a07a8bc034fbd6be456d6d5028ba26f362303a] # to [1298b1829b7a8d0d1c1881913f4f3d407ed850fe] # # patch "ui.cc" # from [cd43c58d97f3b15c45109e37c1fdad43ba84284a] # to [61e835372390db1152c2b34a71dbba52e27881f5] # # patch "ui.hh" # from [0f806f7ebf686e12e5a67297b39ffeb030abe2dc] # to [ff05469e55ddf9a1773f13104f61ba27d8820d57] # # patch "unit_tests.cc" # from [5d04490cb15e14a015830a4061607e7985d6e9a6] # to [dbf88f87be0394902e8c2ddb827c080a95e3361e] # # patch "update.cc" # from [a6ab1750719839bd9da8ac0db8c9181b60167890] # to [d27699ab18a2f417a8c154d329c2328b92d8750a] # # patch "update.hh" # from [f2eabe7487e1b3b6892cc490575fe271d2c0e675] # to [e30e90bf8b5165dbcac0041953ed9c0ee20273c1] # # patch "uri.cc" # from [bee5841639bfb4eb75f876c0113d32a2501e313f] # to [bb529301045c715375306d7577c190a32b8abc82] # # patch "vocab.cc" # from [cd9e884668636ad1bb7cd1607d5d2fd0015fd307] # to [b709a27fe572e529cafa55bbb31dde0eaddfb6cd] # # patch "vocab.hh" # from [d39554c722d3487a36bbab7cb996e89435153a29] # to [cac208eacc144d4a80801643162e3e1d235824df] # # patch "vocab_terms.hh" # from [5442a9adf37051de74795ca8d6f5b25ed92ab301] # to [1db914a9c7154295844d74eb2650ea52fe160a82] # # patch "work.cc" # from [9e2f2b5bf64d0d0b40ce813e21cfd194cdca64d0] # to [b60e9e0bdf1b336ccc569e0aa8f493118413b9b4] # # patch "work.hh" # from [021506c51a9be289cdffa8872a694b0e9b266c74] # to [516b8168864623e72df409a791516b2e76e88a84] # # patch "xdelta.cc" # from [a532e5e2f722fc479b28d09deae78cfdc5938368] # to [4badced7bdde6de4a2c6b89d47503e88979603b3] # # patch "xdelta.hh" # from [a6335a827b6d8ef7d7123d2cf7bacc83c63ead47] # to [5699839f590c4ce2585dc0ff89429437c59099e9] # ============================================================ --- ChangeLog 35e34c28ec8501d85401273cd5a75829c775d545 +++ ChangeLog 850c931a795a24580e7fcf2e2ee0a710f502eac5 @@ -1,3 +1,10 @@ +2006-06-03 Lapo Luchini + + * *.cc *.hh: removed extra "\n" from translatable strings. + removed trailing spaces. + + * po/it.po: Updated to the new newline-less strings. + 2006-06-03 Matthew Gregan * win32/os_strerror.cc (os_strerror): Trim trailing newlines from ============================================================ --- adler32.hh adf2c488c4b0062c31b89b0e7b31d0ce840d2e08 +++ adler32.hh c00437287b948bba66b6195ef74749615512df46 @@ -13,7 +13,7 @@ #include #include "numeric_vocab.hh" -struct +struct adler32 { u32 s1, s2, len; @@ -42,8 +42,8 @@ --len; } - adler32() - : s1(1), s2(0), len(0), mask(widen(0xffff)) + adler32() + : s1(1), s2(0), len(0), mask(widen(0xffff)) {} adler32(u8 const * ch, std::string::size_type count) ============================================================ --- annotate.cc 7655d63779fde07e30bbd6b2b4a5c74378175a5d +++ annotate.cc 7bc1472f79bea8bc5b5b2370e35d63b676dd6569 @@ -47,7 +47,7 @@ class annotate_lineage_mapping; -class annotate_context +class annotate_context { public: annotate_context(file_id fid, app_state & app); @@ -105,7 +105,7 @@ where in the ultimate descendent of interest (UDOI) the line came from (a line not present in the UDOI is represented as -1). */ -class annotate_lineage_mapping +class annotate_lineage_mapping { public: annotate_lineage_mapping(file_data const & data); @@ -150,7 +150,7 @@ the annotations for a given childrev, considering all the childrev -> parentrevN edges. */ -struct annotate_node_work +struct annotate_node_work { annotate_node_work(shared_ptr annotations_, shared_ptr lineage_, @@ -175,39 +175,39 @@ }; -class lineage_merge_node +class lineage_merge_node { public: typedef shared_ptr splm; lineage_merge_node(lineage_merge_node const & m) - : work(m.work), - incoming_edges(m.incoming_edges), + : work(m.work), + incoming_edges(m.incoming_edges), completed_edges(m.completed_edges) {} lineage_merge_node(annotate_node_work wu, size_t incoming) - : work(wu), - incoming_edges(incoming), + : work(wu), + incoming_edges(incoming), completed_edges(1) {} - void merge(splm incoming, + void merge(splm incoming, shared_ptr const & acp) { work.lineage->merge(*incoming, acp); completed_edges++; } - bool iscomplete() const - { - I(completed_edges <= incoming_edges); - return incoming_edges == completed_edges; + bool iscomplete() const + { + I(completed_edges <= incoming_edges); + return incoming_edges == completed_edges; } - annotate_node_work get_work() const - { - I(iscomplete()); - return work; + annotate_node_work get_work() const + { + I(iscomplete()); + return work; } private: @@ -248,7 +248,7 @@ shared_ptr annotate_context::initial_lineage() const { - shared_ptr + shared_ptr res(new annotate_lineage_mapping(file_lines)); return res; } @@ -268,26 +268,26 @@ inserter(credit_lines, credit_lines.begin())); set::const_iterator i; - for (i = credit_lines.begin(); i != credit_lines.end(); i++) + for (i = credit_lines.begin(); i != credit_lines.end(); i++) { I(*i < annotations.size()); - if (annotations[*i] == nullid) + if (annotations[*i] == nullid) { - + // L(FL("evaluate setting annotations[%d] -> %s, since " // "touched_lines contained %d, copied_lines didn't and " // "annotations[%d] was nullid\n") % *i % rev % *i % *i); - + annotations[*i] = rev; annotated_lines_completed++; - } - else + } + else { - //L(FL("evaluate LEAVING annotations[%d] -> %s\n") + //L(FL("evaluate LEAVING annotations[%d] -> %s") // % *i % annotations[*i]); } } - + copied_lines.clear(); touched_lines.clear(); } @@ -295,7 +295,7 @@ void annotate_context::set_copied(int index) { - //L(FL("annotate_context::set_copied %d\n") % index); + //L(FL("annotate_context::set_copied %d") % index); if (index == -1) return; @@ -307,7 +307,7 @@ void annotate_context::set_touched(int index) { - //L(FL("annotate_context::set_touched %d\n") % index); + //L(FL("annotate_context::set_touched %d") % index); if (index == -1) return; @@ -329,12 +329,12 @@ { revision_id null_id; - for (size_t i=0; i::const_iterator j = equivalent_lines.find(i); - if (j == equivalent_lines.end()) + if (j == equivalent_lines.end()) { L(FL("annotate_equivalent_lines unable to find " "equivalent for line %d\n") % i); @@ -389,14 +389,14 @@ void annotate_context::build_revisions_to_annotations -(app_state & app, +(app_state & app, map & revs_to_notations) const { I(annotations.size() == file_lines.size()); // build set of unique revisions present in annotations set seen; - for (vector::const_iterator i = annotations.begin(); + for (vector::const_iterator i = annotations.begin(); i != annotations.end(); i++) { seen.insert(*i); @@ -405,17 +405,17 @@ size_t max_note_length = 0; // build revision -> annotation string mapping - for (set::const_iterator i = seen.begin(); + for (set::const_iterator i = seen.begin(); i != seen.end(); i++) { vector< revision > certs; app.db.get_revision_certs(*i, certs); erase_bogus_certs(certs, app); - string author(cert_string_value(certs, author_cert_name, + string author(cert_string_value(certs, author_cert_name, true, false, "@< ")); - string date(cert_string_value(certs, date_cert_name, + string date(cert_string_value(certs, date_cert_name, true, false, "T")); string result; @@ -426,14 +426,14 @@ result.append(date); result.append(": "); - max_note_length = ((result.size() > max_note_length) - ? result.size() + max_note_length = ((result.size() > max_note_length) + ? result.size() : max_note_length); revs_to_notations[*i] = result; } // justify annotation strings - for (map::iterator i = revs_to_notations.begin(); + for (map::iterator i = revs_to_notations.begin(); i != revs_to_notations.end(); i++) { size_t l = i->second.size(); @@ -464,15 +464,15 @@ if (global_sanity.brief) { if (lastid == annotations[i]) - cout << empty_note << ": " + cout << empty_note << ": " << file_lines[i] << endl; else - cout << revs_to_notations[annotations[i]] + cout << revs_to_notations[annotations[i]] << file_lines[i] << endl; lastid = annotations[i]; } else - cout << annotations[i] << ": " + cout << annotations[i] << ": " << file_lines[i] << endl; } } @@ -496,7 +496,7 @@ /* bool -annotate_lineage_mapping::equal_interned +annotate_lineage_mapping::equal_interned (annotate_lineage_mapping const & rhs) const { bool result = true; @@ -509,9 +509,9 @@ } size_t limit = min(file_interned.size(), rhs.file_interned.size()); - for (size_t i=0; i::const_iterator i; - for (count=0, i = lines.begin(); i != lines.end(); i++, count++) + for (count=0, i = lines.begin(); i != lines.end(); i++, count++) { file_interned.push_back(in.intern(*i)); mapping.push_back(count); @@ -551,7 +551,7 @@ file_data const & parent_data) const { bool verbose = false; - shared_ptr + shared_ptr parent_lineage(new annotate_lineage_mapping(parent_data)); vector lcs; @@ -560,7 +560,7 @@ file_interned.end(), parent_lineage->file_interned.begin(), parent_lineage->file_interned.end(), - min(file_interned.size(), + min(file_interned.size(), parent_lineage->file_interned.size()), back_inserter(lcs)); @@ -569,8 +569,8 @@ "file_lines.size() == %d, " "parent.file_lines.size() == %d, " "lcs.size() == %d\n") - % file_interned.size() - % parent_lineage->file_interned.size() + % file_interned.size() + % parent_lineage->file_interned.size() % lcs.size()); // do the copied lines thing for our annotate_context @@ -578,38 +578,38 @@ lcs_src_lines.resize(lcs.size()); size_t i, j; i = j = 0; - while (i < file_interned.size() && j < lcs.size()) + while (i < file_interned.size() && j < lcs.size()) { //if (verbose) if (file_interned[i] == 14) - L(FL("%s file_interned[%d]: %ld\tlcs[%d]: %ld\tmapping[%d]: %ld\n") + L(FL("%s file_interned[%d]: %ld\tlcs[%d]: %ld\tmapping[%d]: %ld") % parent_rev % i % file_interned[i] % j % lcs[j] % i % mapping[i]); - - if (file_interned[i] == lcs[j]) + + if (file_interned[i] == lcs[j]) { acp->set_copied(mapping[i]); lcs_src_lines[j] = mapping[i]; j++; - } - else + } + else { acp->set_touched(mapping[i]); } - + i++; } if (verbose) - L(FL("loop ended with i: %d, j: %d, lcs.size(): %d\n") + L(FL("loop ended with i: %d, j: %d, lcs.size(): %d") % i % j % lcs.size()); I(j == lcs.size()); // set touched for the rest of the lines in the file - while (i < file_interned.size()) + while (i < file_interned.size()) { acp->set_touched(mapping[i]); i++; } - + // determine the mapping for parent lineage if (verbose) L(FL("build_parent_lineage: building mapping now " @@ -619,30 +619,30 @@ while (i < parent_lineage->file_interned.size() && j < lcs.size()) { - if (parent_lineage->file_interned[i] == lcs[j]) + if (parent_lineage->file_interned[i] == lcs[j]) { parent_lineage->mapping[i] = lcs_src_lines[j]; j++; - } - else + } + else { parent_lineage->mapping[i] = -1; } if (verbose) - L(FL("mapping[%d] -> %d\n") % i % parent_lineage->mapping[i]); - + L(FL("mapping[%d] -> %d") % i % parent_lineage->mapping[i]); + i++; } I(j == lcs.size()); // set mapping for the rest of the lines in the file - while (i < parent_lineage->file_interned.size()) + while (i < parent_lineage->file_interned.size()) { parent_lineage->mapping[i] = -1; if (verbose) - L(FL("mapping[%d] -> %d\n") % i % parent_lineage->mapping[i]); + L(FL("mapping[%d] -> %d") % i % parent_lineage->mapping[i]); i++; } - + return parent_lineage; } @@ -655,15 +655,15 @@ I(mapping.size() == other.mapping.size()); //I(equal_interned(other)); // expensive check - for (size_t i=0; i= 0) mapping[i] = other.mapping[i]; - if (mapping[i] >= 0 && other.mapping[i] >= 0) + if (mapping[i] >= 0 && other.mapping[i] >= 0) { //I(mapping[i] == other.mapping[i]); - if (mapping[i] != other.mapping[i]) + if (mapping[i] != other.mapping[i]) { // a given line in the current merged mapping will split // and become multiple lines in the UDOI. so we have to @@ -681,7 +681,7 @@ (shared_ptr acp) const { vector::const_iterator i; - for (i=mapping.begin(); i != mapping.end(); i++) + for (i=mapping.begin(); i != mapping.end(); i++) { acp->set_touched(*i); } @@ -693,7 +693,7 @@ (shared_ptr acp) const { vector::const_iterator i; - for (i=mapping.begin(); i != mapping.end(); i++) + for (i=mapping.begin(); i != mapping.end(); i++) { acp->set_copied(*i); } @@ -709,7 +709,7 @@ map const & paths_to_nodes, map & pending_merge_nodes) { - L(FL("do_annotate_node for node %s\n") % work_unit.revision); + L(FL("do_annotate_node for node %s") % work_unit.revision); I(nodes_complete.find(work_unit.revision) == nodes_complete.end()); // nodes_seen.insert(make_pair(work_unit.revision, work_unit.lineage)); @@ -718,14 +718,14 @@ app.db.get_roster(work_unit.revision, roster, markmap); marking_t marks; - map::const_iterator mmi = + map::const_iterator mmi = markmap.find(work_unit.fid); I(mmi != markmap.end()); marks = mmi->second; if (marks.file_content.size() == 0) { - L(FL("found empty content-mark set at rev %s\n") + L(FL("found empty content-mark set at rev %s") % work_unit.revision); work_unit.lineage->credit_mapped_lines(work_unit.annotations); work_unit.annotations->evaluate(work_unit.revision); @@ -762,7 +762,7 @@ roster_t parent_roster; marking_map parent_marks; - L(FL("do_annotate_node processing edge from parent %s to child %s\n") + L(FL("do_annotate_node processing edge from parent %s to child %s") % parent_revision % work_unit.revision); I(!(work_unit.revision == parent_revision)); @@ -770,16 +770,16 @@ if (!parent_roster.has_node(work_unit.fid)) { - L(FL("file added in %s, continuing\n") % work_unit.revision); + L(FL("file added in %s, continuing") % work_unit.revision); added_in_parent_count++; continue; } // The node was live in the parent, so this represents a delta. - file_t file_in_child = + file_t file_in_child = downcast_to_file_t(roster.get_node(work_unit.fid)); - file_t file_in_parent = + file_t file_in_parent = downcast_to_file_t(parent_roster.get_node(work_unit.fid)); shared_ptr parent_lineage; @@ -795,9 +795,9 @@ { file_data data; app.db.get_file_version(file_in_parent->content, data); - L(FL("building parent lineage for parent file %s\n") + L(FL("building parent lineage for parent file %s") % file_in_parent->content); - parent_lineage + parent_lineage = work_unit.lineage->build_parent_lineage(work_unit.annotations, parent_revision, data); @@ -843,33 +843,33 @@ // Already a pending node, so we just have to merge the lineage // and decide whether to move it over to the nodes_to_process // queue. - L(FL("merging lineage from node %s to parent %s\n") + L(FL("merging lineage from node %s to parent %s") % work_unit.revision % parent_revision); lmn->second.merge(parent_lineage, work_unit.annotations); //L(FL("after merging from work revision %s to parent %s" // " lineage_merge_node is:\n") % work_unit.revision // % parent_revision); lmn->second.dump(); - if (lmn->second.iscomplete()) + if (lmn->second.iscomplete()) { nodes_to_process.push_back(lmn->second.get_work()); pending_merge_nodes.erase(lmn); } } } - + if (added_in_parent_count == parents.size()) { work_unit.lineage->credit_mapped_lines(work_unit.annotations); } - + work_unit.annotations->evaluate(work_unit.revision); nodes_complete.insert(work_unit.revision); } void -find_ancestors(app_state & app, - revision_id rid, +find_ancestors(app_state & app, + revision_id rid, map & paths_to_nodes) { vector frontier; @@ -885,7 +885,7 @@ for (set::const_iterator i = parents.begin(); i != parents.end(); ++i) { - map::iterator found + map::iterator found = paths_to_nodes.find(*i); if (found == paths_to_nodes.end()) @@ -905,13 +905,13 @@ void do_annotate (app_state &app, file_t file_node, revision_id rid) { - L(FL("annotating file %s with content %s in revision %s\n") + L(FL("annotating file %s with content %s in revision %s") % file_node->self % file_node->content % rid); - shared_ptr + shared_ptr acp(new annotate_context(file_node->content, app)); - shared_ptr lineage + shared_ptr lineage = acp->initial_lineage(); set nodes_complete; @@ -921,7 +921,7 @@ // build node work unit deque nodes_to_process; - annotate_node_work workunit(acp, lineage, rid, file_node->self); + annotate_node_work workunit(acp, lineage, rid, file_node->self); nodes_to_process.push_back(workunit); auto_ptr revs_ticker(new ticker(N_("revs done"), "r", 1)); @@ -931,7 +931,7 @@ { annotate_node_work work = nodes_to_process.front(); nodes_to_process.pop_front(); - do_annotate_node(work, app, nodes_to_process, nodes_complete, + do_annotate_node(work, app, nodes_to_process, nodes_complete, paths_to_nodes, pending_merge_nodes); ++(*revs_ticker); } ============================================================ --- annotate.hh 2c21ed973503781e799cb80b18ea83a3398010d1 +++ annotate.hh e7a6458c2750aa879f7bb7612e15fa7e84931459 @@ -15,7 +15,7 @@ #include "revision.hh" #include "app_state.hh" -void +void do_annotate(app_state &app, file_t file_node, revision_id rid); #endif // defined __ANNOTATE_HH__ ============================================================ --- app_state.cc fe9a80dc99e8deb846577ba557e4e4a20addf1c0 +++ app_state.cc a941f16101beb709145100ba58cc9726c7dacbf2 @@ -40,19 +40,19 @@ static string const key_option("key"); static string const keydir_option("keydir"); -app_state::app_state() - : branch_name(""), db(system_path()), +app_state::app_state() + : branch_name(""), db(system_path()), keys(this), recursive(false), stdhooks(true), rcfiles(true), diffs(false), - no_merges(false), set_default(false), + no_merges(false), set_default(false), verbose(false), date_set(false), search_root(current_root_path()), - depth(-1), last(-1), next(-1), + depth(-1), last(-1), next(-1), diff_format(unified_diff), diff_args_provided(false), - execute(false), bind_address(""), bind_port(""), - bind_stdio(false), use_transport_auth(true), + execute(false), bind_address(""), bind_port(""), + bind_stdio(false), use_transport_auth(true), missing(false), unknown(false), - confdir(get_default_confdir()), + confdir(get_default_confdir()), have_set_key_dir(false), no_files(false) { db.set_app(this); @@ -82,10 +82,10 @@ void app_state::allow_workspace() { - L(FL("initializing from directory %s\n") % fs::initial_path().string()); + L(FL("initializing from directory %s") % fs::initial_path().string()); found_workspace = find_and_go_to_workspace(search_root); - if (found_workspace) + if (found_workspace) { // We read the options, but we don't process them here. That's // done with process_options(). @@ -95,7 +95,7 @@ { bookkeeping_path dump_path; get_local_dump_path(dump_path); - L(FL("setting dump path to %s\n") % dump_path); + L(FL("setting dump path to %s") % dump_path); // The 'true' means that, e.g., if we're running checkout, // then it's okay for dumps to go into our starting working // dir's _MTN rather than the new workspace dir's _MTN. @@ -105,7 +105,7 @@ load_rcfiles(); } -void +void app_state::process_options() { if (found_workspace) { @@ -124,15 +124,15 @@ if (branch_name().empty() && !options[branch_option]().empty()) branch_name = options[branch_option]; - L(FL("branch name is '%s'\n") % branch_name()); + L(FL("branch name is '%s'") % branch_name()); if (!options[key_option]().empty()) - internalize_rsa_keypair_id(options[key_option], + internalize_rsa_keypair_id(options[key_option], signing_key); } } -void +void app_state::require_workspace(string const & explanation) { N(found_workspace, @@ -141,21 +141,21 @@ write_options(); } -void +void app_state::create_workspace(system_path const & new_dir) { N(!new_dir.empty(), F("invalid directory ''")); - L(FL("creating workspace in %s\n") % new_dir); - + L(FL("creating workspace in %s") % new_dir); + mkdir_p(new_dir); go_to_workspace(new_dir); N(!directory_exists(bookkeeping_root), - F("monotone bookkeeping directory '%s' already exists in '%s'\n") + F("monotone bookkeeping directory '%s' already exists in '%s'\n") % bookkeeping_root % new_dir); - L(FL("creating bookkeeping directory '%s' for workspace in '%s'\n") + L(FL("creating bookkeeping directory '%s' for workspace in '%s'") % bookkeeping_root % new_dir); mkdir_p(bookkeeping_root); @@ -172,7 +172,7 @@ load_rcfiles(); } -void +void app_state::set_database(system_path const & filename) { if (!filename.empty()) db.set_filename(filename); @@ -180,7 +180,7 @@ options[database_option] = filename.as_internal(); } -void +void app_state::set_key_dir(system_path const & filename) { if (!filename.empty()) @@ -192,7 +192,7 @@ options[keydir_option] = filename.as_internal(); } -void +void app_state::set_branch(utf8 const & branch) { branch_name = branch(); @@ -212,7 +212,7 @@ } } -void +void app_state::set_signing_key(utf8 const & key) { internalize_rsa_keypair_id(key, signing_key); @@ -220,7 +220,7 @@ options[key_option] = key; } -void +void app_state::add_key_to_push(utf8 const & key) { rsa_keypair_id k; @@ -228,7 +228,7 @@ keys_to_push.push_back(k); } -void +void app_state::set_root(system_path const & path) { require_path_is_directory @@ -236,7 +236,7 @@ F("search root '%s' does not exist") % path, F("search root '%s' is not a directory\n") % path); search_root = path; - L(FL("set search root to %s\n") % search_root); + L(FL("set search root to %s") % search_root); } void @@ -268,7 +268,7 @@ } catch (exception &e) { - N(false, F("failed to parse date string '%s': %s") + N(false, F("failed to parse date string '%s': %s") % d % e.what()); } } @@ -439,7 +439,7 @@ } } -void +void app_state::write_options() { bookkeeping_path o_path; ============================================================ --- app_state.hh 1e1011728a2da0db22589ac19fe9de5b00d08680 +++ app_state.hh a6cba0558a4c377dda413b557c10781cd33668c1 @@ -88,7 +88,7 @@ // Set if the value of the flag was explicitly given on the command // line. - std::map explicit_option_map; + std::map explicit_option_map; void set_is_explicit_option (int option_id); bool is_explicit_option(int option_id) const; @@ -98,7 +98,7 @@ // called. std::map, + std::pair, boost::shared_ptr > > signers; std::map, ============================================================ --- automate.cc fb597bb9483f7531adbb6e2501188d74063bf60a +++ automate.cc 8b18ec025d8bd4fe2a1a100de6f4bc8243911933 @@ -68,7 +68,7 @@ { if (args.size() != 0) throw usage(help_name); - + output << interface_version << endl; } @@ -258,7 +258,7 @@ // a filename was given, if it has attributes, print them split_path path; file_path_external(idx(args,0)).split(path); - + if (current.has_node(path)) { node_t n = current.get_node(path); @@ -386,10 +386,10 @@ app.db.get_revision_ids(leaves); multimap graph; app.db.get_revision_ancestry(graph); - for (multimap::const_iterator + for (multimap::const_iterator i = graph.begin(); i != graph.end(); ++i) leaves.erase(i->first); - for (set::const_iterator i = leaves.begin(); + for (set::const_iterator i = leaves.begin(); i != leaves.end(); ++i) output << (*i).inner()() << endl; } @@ -466,7 +466,7 @@ // The first would indicate that 07804171823d963f78d6a0ff1763d694dd74ff40 // was a root node; the second would indicate that it had one parent, and // the third would indicate that it had two parents, i.e., was a merge. -// +// // The output as a whole is alphabetically sorted; additionally, the parents // within each line are alphabetically sorted. // Error conditions: None. @@ -497,7 +497,7 @@ j->second.insert(i->first); } - for (map >::const_iterator + for (map >::const_iterator i = child_to_parents.begin(); i != child_to_parents.end(); ++i) { @@ -508,7 +508,7 @@ output << endl; } } - + // Name: select // Arguments: // 1: selector @@ -555,20 +555,20 @@ struct inventory_item { // pre/post rearrangement state - enum pstate - { UNCHANGED_PATH, ADDED_PATH, DROPPED_PATH, RENAMED_PATH } + enum pstate + { UNCHANGED_PATH, ADDED_PATH, DROPPED_PATH, RENAMED_PATH } pre_state, post_state; enum nstate - { UNCHANGED_NODE, PATCHED_NODE, MISSING_NODE, - UNKNOWN_NODE, IGNORED_NODE } + { UNCHANGED_NODE, PATCHED_NODE, MISSING_NODE, + UNKNOWN_NODE, IGNORED_NODE } node_state; size_t pre_id, post_id; inventory_item(): - pre_state(UNCHANGED_PATH), post_state(UNCHANGED_PATH), - node_state(UNCHANGED_NODE), + pre_state(UNCHANGED_PATH), post_state(UNCHANGED_PATH), + node_state(UNCHANGED_NODE), pre_id(0), post_id(0) {} }; @@ -579,15 +579,15 @@ static void inventory_pre_state(inventory_map & inventory, path_set const & paths, - inventory_item::pstate pre_state, + inventory_item::pstate pre_state, size_t rename_id) { for (path_set::const_iterator i = paths.begin(); i != paths.end(); i++) { - L(FL("%d %d %s\n") % inventory[*i].pre_state % pre_state % file_path(*i)); + L(FL("%d %d %s") % inventory[*i].pre_state % pre_state % file_path(*i)); I(inventory[*i].pre_state == inventory_item::UNCHANGED_PATH); inventory[*i].pre_state = pre_state; - if (rename_id != 0) + if (rename_id != 0) { I(inventory[*i].pre_id == 0); inventory[*i].pre_id = rename_id; @@ -598,16 +598,16 @@ static void inventory_post_state(inventory_map & inventory, path_set const & paths, - inventory_item::pstate post_state, + inventory_item::pstate post_state, size_t rename_id) { for (path_set::const_iterator i = paths.begin(); i != paths.end(); i++) { - L(FL("%d %d %s\n") % inventory[*i].post_state + L(FL("%d %d %s") % inventory[*i].post_state % post_state % file_path(*i)); I(inventory[*i].post_state == inventory_item::UNCHANGED_PATH); inventory[*i].post_state = post_state; - if (rename_id != 0) + if (rename_id != 0) { I(inventory[*i].post_id == 0); inventory[*i].post_id = rename_id; @@ -622,7 +622,7 @@ { for (path_set::const_iterator i = paths.begin(); i != paths.end(); i++) { - L(FL("%d %d %s\n") % inventory[*i].node_state + L(FL("%d %d %s") % inventory[*i].node_state % node_state % file_path(*i)); I(inventory[*i].node_state == inventory_item::UNCHANGED_NODE); inventory[*i].node_state = node_state; @@ -638,7 +638,7 @@ static size_t rename_id = 1; - for (rename_map::const_iterator i = renames.begin(); + for (rename_map::const_iterator i = renames.begin(); i != renames.end(); i++) { old_name.clear(); @@ -647,9 +647,9 @@ old_name.insert(i->first); new_name.insert(i->second); - inventory_pre_state(inventory, old_name, + inventory_pre_state(inventory, old_name, inventory_item::RENAMED_PATH, rename_id); - inventory_post_state(inventory, new_name, + inventory_post_state(inventory, new_name, inventory_item::RENAMED_PATH, rename_id); rename_id++; @@ -657,10 +657,10 @@ } static void -extract_added_file_paths(addition_map const & additions, path_set & paths) +extract_added_file_paths(addition_map const & additions, path_set & paths) { - for (addition_map::const_iterator i = additions.begin(); - i != additions.end(); ++i) + for (addition_map::const_iterator i = additions.begin(); + i != additions.end(); ++i) { paths.insert(i->first); } @@ -692,7 +692,7 @@ // 'I' the node is ignored and not included in the roster // 'M' the node is missing but is included in the roster // -// Output format: Each path is printed on its own line, prefixed by three +// Output format: Each path is printed on its own line, prefixed by three // status characters as described above. The status is followed by a // single space and two numbers, each separated by a single space, // used for identifying renames. The numbers are followed by a @@ -736,10 +736,10 @@ path_set nodes_added(cs.dirs_added); extract_added_file_paths(cs.files_added, nodes_added); - inventory_pre_state(inventory, cs.nodes_deleted, + inventory_pre_state(inventory, cs.nodes_deleted, inventory_item::DROPPED_PATH, 0); inventory_renames(inventory, cs.nodes_renamed); - inventory_post_state(inventory, nodes_added, + inventory_post_state(inventory, nodes_added, inventory_item::ADDED_PATH, 0); classify_roster_paths(curr, unchanged, changed, missing, app); @@ -749,30 +749,30 @@ file_itemizer u(app, known, unknown, ignored, mask); walk_tree(file_path(), u); - inventory_node_state(inventory, unchanged, + inventory_node_state(inventory, unchanged, inventory_item::UNCHANGED_NODE); - inventory_node_state(inventory, changed, + inventory_node_state(inventory, changed, inventory_item::PATCHED_NODE); - inventory_node_state(inventory, missing, + inventory_node_state(inventory, missing, inventory_item::MISSING_NODE); - inventory_node_state(inventory, unknown, + inventory_node_state(inventory, unknown, inventory_item::UNKNOWN_NODE); - inventory_node_state(inventory, ignored, + inventory_node_state(inventory, ignored, inventory_item::IGNORED_NODE); // FIXME: do we want to report on attribute changes here?!? - for (inventory_map::const_iterator i = inventory.begin(); + for (inventory_map::const_iterator i = inventory.begin(); i != inventory.end(); ++i) { string path_suffix; - if (curr.has_node(i->first)) + if (curr.has_node(i->first)) { // Explicitly skip the root dir for now. The trailing / dir // format isn't going to work here. @@ -785,7 +785,7 @@ path_suffix = "/"; } - switch (i->second.pre_state) + switch (i->second.pre_state) { case inventory_item::UNCHANGED_PATH: output << " "; break; case inventory_item::DROPPED_PATH: output << "D"; break; @@ -793,7 +793,7 @@ default: I(false); // invalid pre_state } - switch (i->second.post_state) + switch (i->second.post_state) { case inventory_item::UNCHANGED_PATH: output << " "; break; case inventory_item::RENAMED_PATH: output << "R"; break; @@ -801,7 +801,7 @@ default: I(false); // invalid post_state } - switch (i->second.node_state) + switch (i->second.node_state) { case inventory_item::UNCHANGED_NODE: output << " "; break; case inventory_item::PATCHED_NODE: output << "P"; break; @@ -811,24 +811,24 @@ default: I(false); // invalid node_state } - output << " " << i->second.pre_id - << " " << i->second.post_id + output << " " << i->second.pre_id + << " " << i->second.post_id << " " << i->first; // FIXME: it's possible that a directory was deleted and a file // was added in it's place (or vice-versa) so we need something // like pre/post node type indicators rather than a simple path // suffix! ugh. - + output << path_suffix; output << endl; } } -namespace +namespace { - namespace syms + namespace syms { symbol const key("key"); symbol const signature("signature"); @@ -847,12 +847,12 @@ // Arguments: // 1: a revision id // Added in: 1.0 -// Purpose: Prints all certificates associated with the given revision +// Purpose: Prints all certificates associated with the given revision // ID. Each certificate is contained in a basic IO stanza. For each // certificate, the following values are provided: -// +// // 'key' : a string indicating the key used to sign this certificate. -// 'signature': a string indicating the status of the signature. +// 'signature': a string indicating the status of the signature. // Possible values of this string are: // 'ok' : the signature is correct // 'bad' : the signature is invalid @@ -882,9 +882,9 @@ throw usage(help_name); vector certs; - + transaction_guard guard(app.db, false); - + revision_id rid(idx(args, 0)()); N(app.db.revision_exists(rid), F("No such revision %s") % rid); hexenc ident(rid.inner()); @@ -895,17 +895,17 @@ certs.push_back(idx(ts, i).inner()); { - set checked; + set checked; for (size_t i = 0; i < certs.size(); ++i) { if (checked.find(idx(certs, i).key) == checked.end() && !app.db.public_key_exists(idx(certs, i).key)) - W(F("no public key '%s' found in database\n") + W(F("no public key '%s' found in database") % idx(certs, i).key); checked.insert(idx(certs, i).key); } } - + // Make the output deterministic; this is useful for the test suite, // in particular. sort(certs.begin(), certs.end()); @@ -916,7 +916,7 @@ { basic_io::stanza st; cert_status status = check_cert(app, idx(certs, i)); - cert_value tv; + cert_value tv; cert_name name = idx(certs, i).name(); set signers; @@ -925,7 +925,7 @@ rsa_keypair_id keyid = idx(certs, i).key(); signers.insert(keyid); - bool trusted = + bool trusted = app.lua.hook_get_revision_cert_trust(signers, ident, name, tv); @@ -959,7 +959,7 @@ // Name: get_revision // Arguments: -// 1: a revision id (optional, determined from the workspace if +// 1: a revision id (optional, determined from the workspace if // non-existant) // Added in: 1.0 @@ -968,11 +968,11 @@ // described by a different basic_io stanza. The first string pair // of each stanza indicates the type of change represented. // -// All stanzas are formatted by basic_io. Stanzas are separated -// by a blank line. Values will be escaped, '\' to '\\' and +// All stanzas are formatted by basic_io. Stanzas are separated +// by a blank line. Values will be escaped, '\' to '\\' and // '"' to '\"'. // -// Possible values of this first value are along with an ordered list of +// Possible values of this first value are along with an ordered list of // basic_io formatted stanzas that will be provided are: // // 'format_version' @@ -1039,7 +1039,7 @@ revision_id old_revision_id; revision_set rev; - app.require_workspace(); + app.require_workspace(); get_base_and_current_roster_shape(old_roster, new_roster, nis, app); update_current_roster_from_filesystem(new_roster, app); @@ -1057,7 +1057,7 @@ app.db.get_revision(ident, dat); } - L(FL("dumping revision %s\n") % ident); + L(FL("dumping revision %s") % ident); output.write(dat.inner()().data(), dat.inner()().size()); } @@ -1108,8 +1108,8 @@ revision_id old_revision_id, new_revision_id; revision_set rev; temp_node_id_source nis; - - app.require_workspace(); + + app.require_workspace(); get_base_and_current_roster_shape(old_roster, new_roster, nis, app); update_current_roster_from_filesystem(new_roster, app); @@ -1132,11 +1132,11 @@ // There is one basic_io stanza for each file or directory in the // manifest. // -// All stanzas are formatted by basic_io. Stanzas are separated -// by a blank line. Values will be escaped, '\' to '\\' and +// All stanzas are formatted by basic_io. Stanzas are separated +// by a blank line. Values will be escaped, '\' to '\\' and // '"' to '\"'. // -// Possible values of this first value are along with an ordered list of +// Possible values of this first value are along with an ordered list of // basic_io formatted stanzas that will be provided are: // // 'format_version' @@ -1180,7 +1180,7 @@ { revision_id old_revision_id; - app.require_workspace(); + app.require_workspace(); get_base_and_current_roster_shape(old_roster, new_roster, nis, app); update_current_roster_from_filesystem(new_roster, app); } @@ -1194,7 +1194,7 @@ calculate_ident(new_roster, mid); write_manifest_of_roster(new_roster, dat); - L(FL("dumping manifest %s\n") % mid); + L(FL("dumping manifest %s") % mid); output.write(dat.inner()().data(), dat.inner()().size()); } @@ -1207,7 +1207,7 @@ // // Output format: The file contents are output without modification. // -// Error conditions: If the file id specified is unknown or invalid prints +// 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(vector args, @@ -1223,7 +1223,7 @@ F("no file version %s found in database") % ident); file_data dat; - L(FL("dumping file %s\n") % ident); + L(FL("dumping file %s") % ident); app.db.get_file_version(ident, dat); output.write(dat.inner()().data(), dat.inner()().size()); } @@ -1282,7 +1282,7 @@ revision_id r_id(idx(args, 0)()); vector< revision > certs; - + N(app.db.revision_exists(r_id), F("no such revision '%s'") % r_id); app.db.get_revision_certs(r_id, certs); @@ -1313,7 +1313,7 @@ file_id f_id(idx(args, 0)()); file_data f_data; - + N(app.db.file_version_exists(f_id), F("no such file '%s'") % f_id); app.db.get_file_version(f_id, f_data); @@ -1345,7 +1345,7 @@ file_id f_old_id(idx(args, 0)()); file_id f_new_id(idx(args, 1)()); file_data f_old_data, f_new_data; - + N(app.db.file_version_exists(f_old_id), F("no such revision '%s'") % f_old_id); N(app.db.file_version_exists(f_new_id), @@ -1483,9 +1483,9 @@ static ssize_t automate_stdio_read(int d, void *buf, size_t nbytes) { ssize_t rv; - + rv = read(d, buf, nbytes); - + E(rv >= 0, F("read from client failed with error code: %d") % rv); return rv; } @@ -1652,7 +1652,7 @@ { keypair kp; hexenc privhash, pubhash; - app.keys.get_key_pair(*i, kp); + app.keys.get_key_pair(*i, kp); key_hash_code(*i, kp.pub, pubhash); key_hash_code(*i, kp.priv, privhash); items[(*i)()].get<0>() = pubhash; ============================================================ --- basic_io.cc d7e7798e323fe76518a577010d4eef1f7639a0b1 +++ basic_io.cc a15ef15ce8808a455ee8f9a7edeeb2ba23eddc67 @@ -30,7 +30,7 @@ void basic_io::input_source::err(string const & s) { L(FL("error in %s:%d:%d:E: %s") % name % line % col % s); - throw logic_error((F("error in %s:%d:%d:E: %s") + throw logic_error((F("error in %s:%d:%d:E: %s") % name % line % col % s).str()); } @@ -40,7 +40,7 @@ in.err(s); } -string +string basic_io::escape(string const & s) { string escaped; @@ -75,8 +75,8 @@ indent = k().size(); } -void basic_io::stanza::push_hex_triple(symbol const & k, - string const & n, +void basic_io::stanza::push_hex_triple(symbol const & k, + string const & n, hexenc const & v) { entries.push_back(make_pair(k, escape(n) + " " + "[" + v() + "]")); @@ -114,7 +114,7 @@ indent = k().size(); } -void basic_io::stanza::push_str_triple(symbol const & k, +void basic_io::stanza::push_str_triple(symbol const & k, string const & n, string const & v) { @@ -126,7 +126,7 @@ string basic_io::printer::buf; -basic_io::printer::printer() +basic_io::printer::printer() { buf.clear(); } ============================================================ --- basic_io.hh c40999a46e70901ea3964b4c378d8cb368437dd2 +++ basic_io.hh a690f850ad0a49bd2309216008f8bf931bd0b017 @@ -36,7 +36,7 @@ TOK_NONE } token_type; - struct + struct input_source { size_t line, col; @@ -46,20 +46,20 @@ int lookahead; char c; input_source(std::string const & in, std::string const & nm) - : line(1), col(1), in(in), curr(in.begin()), + : line(1), col(1), in(in), curr(in.begin()), name(nm), lookahead(0), c('\0') {} - inline void peek() - { + inline void peek() + { if (LIKELY(curr != in.end())) - lookahead = *curr; + lookahead = *curr; else lookahead = EOF; } - inline void advance() - { + inline void advance() + { if (LIKELY(curr != in.end())) { c = *curr; @@ -71,14 +71,14 @@ ++line; } } - peek(); + peek(); } void err(std::string const & s); }; struct tokenizer - { + { input_source & in; std::string::const_iterator begin; std::string::const_iterator end; @@ -91,7 +91,7 @@ begin = in.curr; end = begin; } - + inline void advance() { in.advance(); @@ -106,7 +106,7 @@ inline token_type get_token(std::string & val) { in.peek(); - + while (true) { if (UNLIKELY(in.lookahead == EOF)) @@ -136,7 +136,7 @@ in.err("non-hex character in hex string"); advance(); } - + store(val); if (UNLIKELY(static_cast(in.lookahead) != ']')) @@ -163,13 +163,13 @@ // So first, store what we have *before* the escape. store(val); - + // Then skip over the escape backslash. in.advance(); // Make sure it's an escape we recognize. - if (UNLIKELY(!(static_cast(in.lookahead) == '"' - || + if (UNLIKELY(!(static_cast(in.lookahead) == '"' + || static_cast(in.lookahead) == '\\'))) in.err("unrecognized character escape"); @@ -185,10 +185,10 @@ if (UNLIKELY(static_cast(in.lookahead) == '\\')) { // Skip over any further escape marker. - in.advance(); + in.advance(); if (UNLIKELY - (!(static_cast(in.lookahead) == '"' - || + (!(static_cast(in.lookahead) == '"' + || static_cast(in.lookahead) == '\\'))) in.err("unrecognized character escape"); } @@ -199,18 +199,18 @@ if (static_cast(in.lookahead) != '"') in.err("string did not end with '\"'"); in.advance(); - + return basic_io::TOK_STRING; } advance(); } - + store(val); if (UNLIKELY(static_cast(in.lookahead) != '"')) in.err("string did not end with '\"'"); in.advance(); - + return basic_io::TOK_STRING; } else @@ -221,24 +221,24 @@ std::string escape(std::string const & s); - struct + struct stanza { stanza(); - size_t indent; + size_t indent; std::vector > entries; void push_hex_pair(symbol const & k, hexenc const & v); - void push_hex_triple(symbol const & k, std::string const & n, + void push_hex_triple(symbol const & k, std::string const & n, hexenc const & v); void push_str_pair(symbol const & k, std::string const & v); - void push_str_triple(symbol const & k, std::string const & n, + void push_str_triple(symbol const & k, std::string const & n, std::string const & v); void push_file_pair(symbol const & k, file_path const & v); void push_str_multi(symbol const & k, std::vector const & v); }; - struct + struct printer { static std::string buf; @@ -255,13 +255,13 @@ token.reserve(128); advance(); } - + std::string token; token_type ttype; void err(std::string const & s); std::string tt2str(token_type tt); - + inline void advance() { ttype = tok.get_token(token); @@ -270,37 +270,37 @@ inline void eat(token_type want) { if (ttype != want) - err("wanted " + err("wanted " + tt2str(want) + ", got " + tt2str(ttype) - + (token.empty() - ? std::string("") + + (token.empty() + ? std::string("") : (std::string(" with value ") + token))); advance(); } - + inline void str() { eat(basic_io::TOK_STRING); } inline void sym() { eat(basic_io::TOK_SYMBOL); } inline void hex() { eat(basic_io::TOK_HEX); } - + inline void str(std::string & v) { v = token; str(); } inline void sym(std::string & v) { v = token; sym(); } inline void hex(std::string & v) { v = token; hex(); } inline bool symp() { return ttype == basic_io::TOK_SYMBOL; } - inline bool symp(symbol const & val) + inline bool symp(symbol const & val) { return ttype == basic_io::TOK_SYMBOL && token == val(); } inline void esym(symbol const & val) { if (!(ttype == basic_io::TOK_SYMBOL && token == val())) - err("wanted symbol '" + err("wanted symbol '" + val() + + "', got " + tt2str(ttype) - + (token.empty() - ? std::string("") + + (token.empty() + ? std::string("") : (std::string(" with value ") + token))); advance(); } ============================================================ --- cert.cc 6e1ffc5b990cf82e6ee2a7d1492127b2f71aa105 +++ cert.cc 00b0049d57be97e2f990812639b0d917913eaef2 @@ -56,25 +56,25 @@ // FIXME: the bogus-cert family of functions is ridiculous // and needs to be replaced, or at least factored. -struct +struct bogus_cert_p { app_state & app; bogus_cert_p(app_state & a) : app(a) {}; - + bool cert_is_bogus(cert const & c) const { cert_status status = check_cert(app, c); if (status == cert_ok) { - L(FL("cert ok\n")); + L(FL("cert ok")); return false; } else if (status == cert_bad) { string txt; cert_signable_text(c, txt); - W(F("ignoring bad signature by '%s' on '%s'\n") % c.key() % txt); + W(F("ignoring bad signature by '%s' on '%s'") % c.key() % txt); return true; } else @@ -82,24 +82,24 @@ I(status == cert_unknown); string txt; cert_signable_text(c, txt); - W(F("ignoring unknown signature by '%s' on '%s'\n") % c.key() % txt); + W(F("ignoring unknown signature by '%s' on '%s'") % c.key() % txt); return true; } } - bool operator()(revision const & c) const + bool operator()(revision const & c) const { return cert_is_bogus(c.inner()); } - bool operator()(manifest const & c) const + bool operator()(manifest const & c) const { return cert_is_bogus(c.inner()); } }; -void +void erase_bogus_certs(vector< manifest > & certs, app_state & app) { @@ -139,20 +139,20 @@ get<1>(i->first), decoded_value)) { - L(FL("trust function liked %d signers of %s cert on manifest %s\n") + L(FL("trust function liked %d signers of %s cert on manifest %s") % i->second.first->size() % get<1>(i->first) % get<0>(i->first)); tmp_certs.push_back(*(i->second.second)); } else { - W(F("trust function disliked %d signers of %s cert on manifest %s\n") + W(F("trust function disliked %d signers of %s cert on manifest %s") % i->second.first->size() % get<1>(i->first) % get<0>(i->first)); } } certs = tmp_certs; } -void +void erase_bogus_certs(vector< revision > & certs, app_state & app) { @@ -192,13 +192,13 @@ get<1>(i->first), decoded_value)) { - L(FL("trust function liked %d signers of %s cert on revision %s\n") + L(FL("trust function liked %d signers of %s cert on revision %s") % i->second.first->size() % get<1>(i->first) % get<0>(i->first)); tmp_certs.push_back(*(i->second.second)); } else { - W(F("trust function disliked %d signers of %s cert on revision %s\n") + W(F("trust function disliked %d signers of %s cert on revision %s") % i->second.first->size() % get<1>(i->first) % get<0>(i->first)); } } @@ -208,7 +208,7 @@ // cert-managing routines -cert::cert() +cert::cert() {} cert::cert(hexenc const & ident, @@ -218,7 +218,7 @@ : ident(ident), name(name), value(value), key(key) {} -cert::cert(hexenc const & ident, +cert::cert(hexenc const & ident, cert_name const & name, base64 const & value, rsa_keypair_id const & key, @@ -226,23 +226,23 @@ : ident(ident), name(name), value(value), key(key), sig(sig) {} -bool +bool cert::operator<(cert const & other) const { return (ident < other.ident) || ((ident == other.ident) && name < other.name) - || (((ident == other.ident) && name == other.name) - && value < other.value) - || ((((ident == other.ident) && name == other.name) + || (((ident == other.ident) && name == other.name) + && value < other.value) + || ((((ident == other.ident) && name == other.name) && value == other.value) && key < other.key) - || (((((ident == other.ident) && name == other.name) + || (((((ident == other.ident) && name == other.name) && value == other.value) && key == other.key) && sig < other.sig); } -bool +bool cert::operator==(cert const & other) const { - return + return (ident == other.ident) && (name == other.name) && (value == other.value) @@ -251,24 +251,24 @@ } // netio support - -void + +void read_cert(string const & in, cert & t) { size_t pos = 0; - id hash = extract_substring(in, pos, - constants::merkle_hash_length_in_bytes, + id hash = extract_substring(in, pos, + constants::merkle_hash_length_in_bytes, "cert hash"); - id ident = extract_substring(in, pos, - constants::merkle_hash_length_in_bytes, + id ident = extract_substring(in, pos, + constants::merkle_hash_length_in_bytes, "cert ident"); string name, val, key, sig; extract_variable_length_string(in, name, pos, "cert name"); extract_variable_length_string(in, val, pos, "cert val"); extract_variable_length_string(in, key, pos, "cert key"); extract_variable_length_string(in, sig, pos, "cert sig"); - assert_end_of_buffer(in, pos, "cert"); - + assert_end_of_buffer(in, pos, "cert"); + hexenc hid; base64 bval; base64 bsig; @@ -293,9 +293,9 @@ t = tmp; } -void +void write_cert(cert const & t, string & out) -{ +{ string name, key; hexenc hash; id ident_decoded, hash_decoded; @@ -316,15 +316,15 @@ insert_variable_length_string(sig_decoded(), out); } -void +void cert_signable_text(cert const & t, string & out) { out = (FL("address@hidden:%s]") % t.name % t.ident % remove_ws(t.value())).str(); - L(FL("cert: signable text %s\n") % out); + L(FL("cert: signable text %s") % out); } -void +void cert_hash_code(cert const & t, hexenc & out) { string tmp(t.ident() @@ -371,7 +371,7 @@ } } -void +void calculate_cert(app_state & app, cert & t) { string signed_text; @@ -385,7 +385,7 @@ make_signature(app, t.key, kp.priv, signed_text, t.sig); } -cert_status +cert_status check_cert(app_state & app, cert const & t) { @@ -437,7 +437,7 @@ if (app.lua.hook_get_branch_key(branch, key)) return; } - + vector all_privkeys; app.keys.get_keys(all_privkeys); N(!all_privkeys.empty(), F("you have no private key to make signatures with\n" @@ -445,10 +445,10 @@ N(all_privkeys.size() == 1, F("you have multiple private keys\n" "pick one to use for signatures by adding '-k' to your command")); - key = all_privkeys[0]; + key = all_privkeys[0]; } -void +void guess_branch(revision_id const & ident, app_state & app, cert_value & branchname) @@ -468,20 +468,20 @@ app.db.get_revision_certs(ident, branch, certs); erase_bogus_certs(certs, app); - N(certs.size() != 0, + N(certs.size() != 0, F("no branch certs found for revision %s, " "please provide a branch name") % ident); - + N(certs.size() == 1, F("multiple branch certs found for revision %s, " "please provide a branch name") % ident); - + decode_base64(certs[0].inner().value, branchname); app.set_branch(branchname()); } } -void +void make_simple_cert(hexenc const & id, cert_name const & nm, cert_value const & cv, @@ -497,7 +497,7 @@ c = t; } -static void +static void put_simple_revision_cert(revision_id const & id, cert_name const & nm, cert_value const & val, @@ -510,8 +510,8 @@ pc.consume_revision_cert(cc); } -void -cert_revision_in_branch(revision_id const & rev, +void +cert_revision_in_branch(revision_id const & rev, cert_value const & branchname, app_state & app, packet_consumer & pc) @@ -520,7 +520,7 @@ branchname, app, pc); } -void +void get_branch_heads(cert_value const & branchname, app_state & app, set & heads) @@ -554,8 +554,8 @@ string const testresult_cert_name = "testresult"; -void -cert_revision_date_time(revision_id const & m, +void +cert_revision_date_time(revision_id const & m, boost::posix_time::ptime t, app_state & app, packet_consumer & pc) @@ -564,38 +564,38 @@ put_simple_revision_cert(m, date_cert_name, val, app, pc); } -void -cert_revision_date_time(revision_id const & m, +void +cert_revision_date_time(revision_id const & m, time_t t, app_state & app, packet_consumer & pc) { // make sure you do all your CVS conversions by 2038! - boost::posix_time::ptime tmp(boost::gregorian::date(1970,1,1), + boost::posix_time::ptime tmp(boost::gregorian::date(1970,1,1), boost::posix_time::seconds(static_cast(t))); cert_revision_date_time(m, tmp, app, pc); } -void -cert_revision_date_now(revision_id const & m, +void +cert_revision_date_now(revision_id const & m, app_state & app, packet_consumer & pc) { cert_revision_date_time(m, boost::posix_time::second_clock::universal_time(), app, pc); } -void -cert_revision_author(revision_id const & m, +void +cert_revision_author(revision_id const & m, string const & author, app_state & app, packet_consumer & pc) { - put_simple_revision_cert(m, author_cert_name, - author, app, pc); + put_simple_revision_cert(m, author_cert_name, + author, app, pc); } -void -cert_revision_author_default(revision_id const & m, +void +cert_revision_author_default(revision_id const & m, app_state & app, packet_consumer & pc) { @@ -609,39 +609,39 @@ cert_revision_author(m, author, app, pc); } -void -cert_revision_tag(revision_id const & m, +void +cert_revision_tag(revision_id const & m, string const & tagname, app_state & app, packet_consumer & pc) { - put_simple_revision_cert(m, tag_cert_name, - tagname, app, pc); + put_simple_revision_cert(m, tag_cert_name, + tagname, app, pc); } -void -cert_revision_changelog(revision_id const & m, +void +cert_revision_changelog(revision_id const & m, string const & changelog, app_state & app, packet_consumer & pc) { - put_simple_revision_cert(m, changelog_cert_name, - changelog, app, pc); + put_simple_revision_cert(m, changelog_cert_name, + changelog, app, pc); } -void -cert_revision_comment(revision_id const & m, +void +cert_revision_comment(revision_id const & m, string const & comment, app_state & app, packet_consumer & pc) { - put_simple_revision_cert(m, comment_cert_name, - comment, app, pc); + put_simple_revision_cert(m, comment_cert_name, + comment, app, pc); } -void -cert_revision_testresult(revision_id const & r, +void +cert_revision_testresult(revision_id const & r, string const & results, app_state & app, packet_consumer & pc) @@ -660,10 +660,10 @@ else throw informative_failure("could not interpret test results, tried '0/1' 'yes/no', 'true/false', 'pass/fail'"); - put_simple_revision_cert(r, testresult_cert_name, lexical_cast(passed), app, pc); + put_simple_revision_cert(r, testresult_cert_name, lexical_cast(passed), app, pc); } - + #ifdef BUILD_UNIT_TESTS #include "unit_tests.hh" ============================================================ --- cert.hh 6ccf880b677340a2460ced453c93700b7bae07b3 +++ cert.hh 442db182fbe3a8f3c1313ddcc34f911b05371f02 @@ -80,13 +80,13 @@ extern std::string const branch_cert_name; -void -cert_revision_in_branch(revision_id const & ctx, +void +cert_revision_in_branch(revision_id const & ctx, cert_value const & branchname, app_state & app, packet_consumer & pc); -void +void get_branch_heads(cert_value const & branchname, app_state & app, std::set & heads); @@ -99,7 +99,7 @@ void get_user_key(rsa_keypair_id & key, app_state & app); -void +void guess_branch(revision_id const & id, app_state & app, cert_value & branchname); @@ -111,54 +111,54 @@ extern std::string const comment_cert_name; extern std::string const testresult_cert_name; -void -cert_revision_date_now(revision_id const & m, +void +cert_revision_date_now(revision_id const & m, app_state & app, packet_consumer & pc); -void -cert_revision_date_time(revision_id const & m, +void +cert_revision_date_time(revision_id const & m, boost::posix_time::ptime t, app_state & app, packet_consumer & pc); -void -cert_revision_date_time(revision_id const & m, +void +cert_revision_date_time(revision_id const & m, time_t time, app_state & app, packet_consumer & pc); -void -cert_revision_author(revision_id const & m, +void +cert_revision_author(revision_id const & m, std::string const & author, app_state & app, packet_consumer & pc); -void -cert_revision_author_default(revision_id const & m, +void +cert_revision_author_default(revision_id const & m, app_state & app, packet_consumer & pc); -void -cert_revision_tag(revision_id const & m, +void +cert_revision_tag(revision_id const & m, std::string const & tagname, app_state & app, packet_consumer & pc); -void -cert_revision_changelog(revision_id const & m, +void +cert_revision_changelog(revision_id const & m, std::string const & changelog, app_state & app, packet_consumer & pc); -void -cert_revision_comment(revision_id const & m, +void +cert_revision_comment(revision_id const & m, std::string const & comment, app_state & app, packet_consumer & pc); -void -cert_revision_testresult(revision_id const & m, +void +cert_revision_testresult(revision_id const & m, std::string const & results, app_state & app, packet_consumer & pc); ============================================================ --- charset.cc f55e73d42872fbbf269b3cd9f41af9217030f1a6 +++ charset.cc fc0b370c50ee32b1bc3bb110e4181f3a841edbae @@ -17,7 +17,7 @@ // general character code conversion routines -static string +static string system_charset() { char const * locale_charset_name = stringprep_locale_charset (); @@ -26,17 +26,17 @@ return sys_charset; } -void +void charset_convert(string const & src_charset, string const & dst_charset, - string const & src, + string const & src, string & dst) { if (src_charset == dst_charset) dst = src; else { - L(FL("converting %d bytes from %s to %s\n") % src.size() + L(FL("converting %d bytes from %s to %s") % src.size() % src_charset % dst_charset); char * converted = stringprep_convert(src.c_str(), dst_charset.c_str(), @@ -49,7 +49,7 @@ } } -void +void system_to_utf8(external const & ext, utf8 & utf) { string out; @@ -71,7 +71,7 @@ // A UTF-8 escape: consume the full escape. ++i; ++sz; - while (i != u.end() + while (i != u.end() && (static_cast(*i) & static_cast(0x80)) && (!(static_cast(*i) & static_cast(0x40)))) ++i; @@ -143,7 +143,7 @@ } // this function must be fast. do not make it slow. -void +void utf8_to_system(utf8 const & utf, string & ext) { if (system_charset_is_utf8()) @@ -155,7 +155,7 @@ charset_convert("UTF-8", system_charset(), utf(), ext); } -void +void utf8_to_system(utf8 const & utf, external & ext) { string out; @@ -246,7 +246,7 @@ return true; } -static string +static string decode_idna_error(int err) { switch (static_cast(err)) @@ -266,11 +266,11 @@ return "unknown error"; } -void +void ace_to_utf8(ace const & a, utf8 & utf) { char *out = NULL; - L(FL("converting %d bytes from IDNA ACE to UTF-8\n") % a().size()); + L(FL("converting %d bytes from IDNA ACE to UTF-8") % a().size()); int res = idna_to_unicode_8z8z(a().c_str(), &out, IDNA_USE_STD3_ASCII_RULES); N(res == IDNA_SUCCESS || res == IDNA_NO_ACE_PREFIX, F("error converting %d UTF-8 bytes to IDNA ACE: %s") @@ -280,11 +280,11 @@ free(out); } -void +void utf8_to_ace(utf8 const & utf, ace & a) { char *out = NULL; - L(FL("converting %d bytes from UTF-8 to IDNA ACE\n") % utf().size()); + L(FL("converting %d bytes from UTF-8 to IDNA ACE") % utf().size()); int res = idna_to_ascii_8z(utf().c_str(), &out, IDNA_USE_STD3_ASCII_RULES); N(res == IDNA_SUCCESS, F("error converting %d UTF-8 bytes to IDNA ACE: %s") @@ -294,7 +294,7 @@ free(out); } -void +void internalize_cert_name(utf8 const & utf, cert_name & c) { ace a; @@ -302,7 +302,7 @@ c = a(); } -void +void internalize_cert_name(external const & ext, cert_name & c) { utf8 utf; @@ -310,25 +310,25 @@ internalize_cert_name(utf, c); } -void +void externalize_cert_name(cert_name const & c, utf8 & utf) { ace_to_utf8(ace(c()), utf); } -void +void externalize_cert_name(cert_name const & c, external & ext) { utf8 utf; externalize_cert_name(c, utf); - utf8_to_system(utf, ext); + utf8_to_system(utf, ext); } -void +void internalize_rsa_keypair_id(utf8 const & utf, rsa_keypair_id & key) { string tmp; - typedef boost::tokenizer > + typedef boost::tokenizer > tokenizer; char_separator sep("", ".@", boost::keep_empty_tokens); tokenizer tokens(utf(), sep); @@ -349,7 +349,7 @@ key = tmp; } -void +void internalize_rsa_keypair_id(external const & ext, rsa_keypair_id & key) { utf8 utf; @@ -357,11 +357,11 @@ internalize_rsa_keypair_id(utf, key); } -void +void externalize_rsa_keypair_id(rsa_keypair_id const & key, utf8 & utf) { string tmp; - typedef boost::tokenizer > + typedef boost::tokenizer > tokenizer; char_separator sep("", ".@", boost::keep_empty_tokens); tokenizer tokens(key(), sep); @@ -383,7 +383,7 @@ utf = tmp; } -void +void externalize_rsa_keypair_id(rsa_keypair_id const & key, external & ext) { utf8 utf; @@ -391,7 +391,7 @@ utf8_to_system(utf, ext); } -void +void internalize_var_domain(utf8 const & utf, var_domain & d) { ace a; @@ -399,7 +399,7 @@ d = a(); } -void +void internalize_var_domain(external const & ext, var_domain & d) { utf8 utf; @@ -407,18 +407,18 @@ internalize_var_domain(utf, d); } -void +void externalize_var_domain(var_domain const & d, utf8 & utf) { ace_to_utf8(ace(d()), utf); } -void +void externalize_var_domain(var_domain const & d, external & ext) { utf8 utf; externalize_var_domain(d, utf); - utf8_to_system(utf, ext); + utf8_to_system(utf, ext); } @@ -429,7 +429,7 @@ #define IDNA_ACE_PREFIX "xn--" #define IDNA_SUCCESS 0 -struct +struct idna { char *name; @@ -588,7 +588,7 @@ IDNA_SUCCESS, IDNA_SUCCESS}, }; -static void +static void check_idna_encoding() { putenv("CHARSET=UTF-8"); @@ -598,8 +598,8 @@ BOOST_CHECKPOINT("IDNA language: " + string(idna_vec[i].name)); size_t p, q; - char *uc = stringprep_ucs4_to_utf8(idna_vec[i].in, - idna_vec[i].inlen, + char *uc = stringprep_ucs4_to_utf8(idna_vec[i].in, + idna_vec[i].inlen, &p, &q); utf8 utf = string(uc); utf8 tutf; @@ -608,7 +608,7 @@ ace a = string(idna_vec[i].out); ace tace; utf8_to_ace(utf, tace); - L(FL("ACE-encoded %s: '%s'\n") % idna_vec[i].name % tace()); + L(FL("ACE-encoded %s: '%s'") % idna_vec[i].name % tace()); BOOST_CHECK(lowercase(a()) == lowercase(tace())); ace_to_utf8(a, tutf); BOOST_CHECK(lowercase(utf()) == lowercase(tutf())); @@ -844,7 +844,7 @@ } -void +void add_charset_tests(test_suite * suite) { I(suite); ============================================================ --- cleanup.hh a450ba2ba4311f0a298c1e102bd5c5f0c5fb2258 +++ cleanup.hh 5af6a253b76166eafdaf7a6bb0b27b08469ca10e @@ -14,12 +14,12 @@ T ptr; R (* cleanup)(T); explicit cleanup_ptr(T p, R (*c)(T)) : ptr(p), cleanup(c) {} - ~cleanup_ptr() + ~cleanup_ptr() { if (cleanup && ptr) cleanup(ptr); } - T operator()() + T operator()() { return ptr; } ============================================================ --- cmd.hh 76fe4ececf8426484d8a4aca7c54237c49ce6100 +++ cmd.hh b3216c27888503db9b3d33aed451f013f54e240a @@ -24,7 +24,7 @@ }; extern const no_opts OPT_NONE; - struct command + struct command { // NB: these strings are stred _un_translated // because we cannot translate them until after main starts, by which time @@ -46,7 +46,7 @@ }; }; -std::string +std::string get_stdin(); std::string @@ -54,20 +54,20 @@ revision_id const & id); void -complete(app_state & app, +complete(app_state & app, std::string const & str, revision_id & completion, bool must_exist=true); -void -complete(app_state & app, +void +complete(app_state & app, std::string const & str, std::set & completion, bool must_exist=true); template -static void -complete(app_state & app, +static void +complete(app_state & app, std::string const & str, ID & completion) { @@ -90,8 +90,8 @@ err += (i->inner()() + "\n"); N(completions.size() == 1, i18n_format(err)); } - completion = *(completions.begin()); - P(F("expanded partial id '%s' to '%s'\n") + completion = *(completions.begin()); + P(F("expanded partial id '%s' to '%s'") % str % completion); } ============================================================ --- cmd_automate.cc 37baff9dc561c7fad66b88559fda15b14f2a4f55 +++ cmd_automate.cc 6f285920e44f4c8c2d262c08b7e06de1f4b4ae65 @@ -35,7 +35,7 @@ "packet_for_fdata FILEID\n" "packet_for_fdelta OLD_FILE NEW_FILE\n" "keys\n"), - N_("automation interface"), + N_("automation interface"), OPT_NONE) { if (args.size() == 0) ============================================================ --- cmd_db.cc 7403b1a1bb54a12e01dee5fcbbc3db7aaf8ba557 +++ cmd_db.cc 556cb1dad30d2b6ad3a50fd7951927afdf5ce6d2 @@ -32,7 +32,7 @@ app.db.delete_existing_rev_and_certs(ident); } -CMD(db, N_("database"), +CMD(db, N_("database"), N_("init\n" "info\n" "version\n" @@ -46,7 +46,7 @@ "check\n" "changesetify\n" "rosterify\n" - "set_epoch BRANCH EPOCH\n"), + "set_epoch BRANCH EPOCH\n"), N_("manipulate database state"), OPT_DROP_ATTR) { @@ -149,7 +149,7 @@ F("non-hex digits in partial id")); if (idx(args, 0)() == "revision") - { + { set completions; app.db.complete(idx(args, 1)(), completions); for (set::const_iterator i = completions.begin(); @@ -181,6 +181,6 @@ } } else - throw usage(name); + throw usage(name); } ============================================================ --- cmd_diff_log.cc c2d375111f402eac0c82134f174627d88608dcb0 +++ cmd_diff_log.cc 4d963e42f2b37a325e6afb0e3f0f9ee6995f2525 @@ -38,7 +38,7 @@ void print(ostream & os, size_t max_cols) const; }; -changes_summary::changes_summary(void) +changes_summary::changes_summary(void) { } @@ -53,30 +53,30 @@ // are not really sensible to union; they refer to different trees // so mixing them up in a single set is potentially ambiguous. - copy(c.nodes_deleted.begin(), c.nodes_deleted.end(), + copy(c.nodes_deleted.begin(), c.nodes_deleted.end(), inserter(cs.nodes_deleted, cs.nodes_deleted.begin())); - copy(c.files_added.begin(), c.files_added.end(), + copy(c.files_added.begin(), c.files_added.end(), inserter(cs.files_added, cs.files_added.begin())); - copy(c.dirs_added.begin(), c.dirs_added.end(), + copy(c.dirs_added.begin(), c.dirs_added.end(), inserter(cs.dirs_added, cs.dirs_added.begin())); - copy(c.nodes_renamed.begin(), c.nodes_renamed.end(), + copy(c.nodes_renamed.begin(), c.nodes_renamed.end(), inserter(cs.nodes_renamed, cs.nodes_renamed.begin())); - copy(c.deltas_applied.begin(), c.deltas_applied.end(), + copy(c.deltas_applied.begin(), c.deltas_applied.end(), inserter(cs.deltas_applied, cs.deltas_applied.begin())); - copy(c.attrs_cleared.begin(), c.attrs_cleared.end(), + copy(c.attrs_cleared.begin(), c.attrs_cleared.end(), inserter(cs.attrs_cleared, cs.attrs_cleared.begin())); - copy(c.attrs_set.begin(), c.attrs_set.end(), + copy(c.attrs_set.begin(), c.attrs_set.end(), inserter(cs.attrs_set, cs.attrs_set.begin())); } -static void -print_indented_set(ostream & os, +static void +print_indented_set(ostream & os, path_set const & s, size_t max_cols) { @@ -89,7 +89,7 @@ if (cols > 8 && cols + str.size() + 1 >= max_cols) { cols = 8; - os << "\n" << " "; + os << "\n" << " "; } os << " " << str; cols += str.size() + 1; @@ -106,7 +106,7 @@ os << "Deleted entries:" << "\n"; print_indented_set(os, cs.nodes_deleted, max_cols); } - + if (! cs.nodes_renamed.empty()) { os << "Renamed entries:" << "\n"; @@ -163,7 +163,7 @@ app_state & app, bool new_is_archived) { - for (map >::const_iterator + for (map >::const_iterator i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) { @@ -202,7 +202,7 @@ } } -static void +static void dump_diffs(cset const & cs, app_state & app, bool new_is_archived, @@ -213,7 +213,7 @@ // 60 is somewhat arbitrary, but less than 80 string patch_sep = string(60, '='); - for (map::const_iterator + for (map::const_iterator i = cs.files_added.begin(); i != cs.files_added.end(); ++i) { @@ -223,7 +223,7 @@ cout << patch_sep << "\n"; data unpacked; vector lines; - + if (new_is_archived) { file_data dat; @@ -235,17 +235,17 @@ read_localized_data(file_path(i->first), unpacked, app.lua); } - + if (guess_binary(unpacked())) cout << "# " << file_path(i->first) << " is binary\n"; else - { + { split_into_lines(unpacked(), lines); if (! lines.empty()) { - cout << (FL("--- %s\t%s\n") % file_path(i->first) % i->second) - << (FL("+++ %s\t%s\n") % file_path(i->first) % i->second) - << (FL("@@ -0,0 +1,%d @@\n") % lines.size()); + cout << (FL("--- %s\t%s") % file_path(i->first) % i->second) + << (FL("+++ %s\t%s") % file_path(i->first) % i->second) + << (FL("@@ -0,0 +1,%d @@") % lines.size()); for (vector::const_iterator j = lines.begin(); j != lines.end(); ++j) { @@ -257,14 +257,14 @@ map reverse_rename_map; - for (map::const_iterator + for (map::const_iterator i = cs.nodes_renamed.begin(); i != cs.nodes_renamed.end(); ++i) { reverse_rename_map.insert(make_pair(i->second, i->first)); } - for (map >::const_iterator + for (map >::const_iterator i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) { @@ -276,10 +276,10 @@ vector old_lines, new_lines; cout << patch_sep << "\n"; - + app.db.get_file_version(delta_entry_src(i), f_old); data_old = f_old.inner(); - + if (new_is_archived) { file_data f_new; @@ -288,11 +288,11 @@ } else { - read_localized_data(file_path(delta_entry_path(i)), + read_localized_data(file_path(delta_entry_path(i)), data_new, app.lua); } - - if (guess_binary(data_new()) || + + if (guess_binary(data_new()) || guess_binary(data_old())) cout << "# " << file_path(delta_entry_path(i)) << " is binary\n"; else @@ -309,8 +309,8 @@ if (re != reverse_rename_map.end()) src_path = re->second; - make_diff(file_path(src_path).as_internal(), - file_path(dst_path).as_internal(), + make_diff(file_path(src_path).as_internal(), + file_path(dst_path).as_internal(), delta_entry_src(i), delta_entry_dst(i), old_lines, new_lines, @@ -319,7 +319,7 @@ } } -static void +static void dump_diffs(cset const & cs, app_state & app, bool new_is_archived, @@ -329,7 +329,7 @@ dump_diffs(cs, app, new_is_archived, type, dummy); } -CMD(diff, N_("informative"), N_("[PATH]..."), +CMD(diff, N_("informative"), N_("[PATH]..."), N_("show current diffs on stdout.\n" "If one revision is given, the diff between the workspace and\n" "that revision is shown. If two revisions are given, the diff between\n" @@ -391,7 +391,7 @@ // N(r_new.edges.size() == 1, F("current revision has no ancestor")); restriction mask(args, app.exclude_patterns, old_roster, new_roster, app); - + update_current_roster_from_filesystem(new_roster, mask, app); make_restricted_csets(old_roster, new_roster, included, excluded, mask); check_restricted_cset(old_roster, included); @@ -416,12 +416,12 @@ app.db.get_roster(r_new_id, new_roster); restriction mask(args, app.exclude_patterns, old_roster, new_roster, app); - + // FIXME: this is *possibly* a UI bug, insofar as we // look at the restriction name(s) you provided on the command // line in the context of new and old, *not* the working copy. // One way of "fixing" this is to map the filenames on the command - // line to node_ids, and then restrict based on those. This + // line to node_ids, and then restrict based on those. This // might be more intuitive; on the other hand it would make it // impossible to restrict to paths which are dead in the working // copy but live between old and new. So ... no rush to "fix" it; @@ -429,14 +429,14 @@ // // let the discussion begin... // - // - "map filenames on the command line to node_ids" needs to be done + // - "map filenames on the command line to node_ids" needs to be done // in the context of some roster, possibly the working copy base or // the current working copy (or both) - // - diff with two --revision's may be done with no working copy - // - some form of "peg" revision syntax for paths that would allow + // - diff with two --revision's may be done with no working copy + // - some form of "peg" revision syntax for paths that would allow // for each path to specify which revision it is relevant to is // probably the "right" way to go eventually. something like address@hidden - // (which fails for paths with @'s in them) or possibly //rev/file + // (which fails for paths with @'s in them) or possibly //rev/file // since versioned paths are required to be relative. make_restricted_csets(old_roster, new_roster, included, excluded, mask); @@ -449,14 +449,14 @@ throw usage(name); } - + data summary; write_cset(included, summary); vector lines; split_into_lines(summary(), lines); cout << "# " << "\n"; - if (summary().size() > 0) + if (summary().size() > 0) { cout << header.str() << "# " << "\n"; for (vector::iterator i = lines.begin(); i != lines.end(); ++i) @@ -548,7 +548,7 @@ else { for (vector::const_iterator i = app.revision_selectors.begin(); - i != app.revision_selectors.end(); i++) + i != app.revision_selectors.end(); i++) { set rids; complete(app, (*i)(), rids); @@ -559,7 +559,7 @@ } restriction mask(app); - + if (args.size() > 0) { // User wants to trace only specific files @@ -568,7 +568,7 @@ if (app.revision_selectors.size() == 0) get_base_and_current_roster_shape(old_roster, new_roster, nis, app); else - app.db.get_roster(first_rid, new_roster); + app.db.get_roster(first_rid, new_roster); // FIXME_RESTRICTIONS: should this add paths from the rosters of all selected revs? mask = restriction(args, app.exclude_patterns, old_roster, new_roster, app); @@ -594,10 +594,10 @@ while(! frontier.empty() && (last == -1 || last > 0) && (next == -1 || next > 0)) { set next_frontier; - + for (set::const_iterator i = frontier.begin(); i != frontier.end(); ++i) - { + { revision_id rid = *i; bool print_this = mask.empty(); @@ -616,14 +616,14 @@ // TODO: stop if the restriction is pre-dated by the current roster // i.e. the restriction's nodes are not born in the current roster roster_t roster; - app.db.get_roster(rid, roster); + app.db.get_roster(rid, roster); set nodes_modified; select_nodes_modified_by_rev(rid, rev, roster, - nodes_modified, + nodes_modified, app); - - for (set::const_iterator n = nodes_modified.begin(); + + for (set::const_iterator n = nodes_modified.begin(); n != nodes_modified.end(); ++n) { if (!roster.has_node(*n)) @@ -631,7 +631,7 @@ // include all deleted nodes print_this = true; } - else if (mask.includes(roster, *n)) + else if (mask.includes(roster, *n)) { print_this = true; if (app.diffs) @@ -648,20 +648,20 @@ { set children; app.db.get_revision_children(rid, children); - copy(children.begin(), children.end(), + copy(children.begin(), children.end(), inserter(next_frontier, next_frontier.end())); } else // work backwards by default { set parents; app.db.get_revision_parents(rid, parents); - copy(parents.begin(), parents.end(), + copy(parents.begin(), parents.end(), inserter(next_frontier, next_frontier.end())); } if (app.no_merges && rev.is_merge_node()) print_this = false; - + if (print_this) { if (global_sanity.brief) @@ -714,7 +714,7 @@ for (edge_map::const_iterator e = rev.edges.begin(); e != rev.edges.end(); ++e) { - dump_diffs(edge_changes(e), app, true, unified_diff, + dump_diffs(edge_changes(e), app, true, unified_diff, diff_paths, !mask.empty()); } } ============================================================ --- cmd_files.cc 22b692fc7848cf47a7572d4df48b0ffeeaa56c5c +++ cmd_files.cc 088fb68e4513fb18130184937b3bfcaf4e23155a @@ -23,11 +23,11 @@ file_id f_id; file_data f_data(s); - + calculate_ident (f_data, f_id); - + packet_db_writer dbw(app); - dbw.consume_file_data(f_id, f_data); + dbw.consume_file_data(f_id, f_data); } CMD(fmerge, N_("debug"), N_(" "), @@ -60,7 +60,7 @@ split_into_lines(right.inner()(), right_lines); N(merge3(anc_lines, left_lines, right_lines, merged_lines), F("merge failed")); copy(merged_lines.begin(), merged_lines.end(), ostream_iterator(cout, "\n")); - + } CMD(annotate, N_("informative"), N_("PATH"), @@ -81,13 +81,13 @@ if (app.revision_selectors.size() == 0) get_revision_id(rid); - else + else complete(app, idx(app.revision_selectors, 0)(), rid); N(!null_id(rid), F("no revision for file '%s' in database") % file); N(app.db.revision_exists(rid), F("no such revision '%s'") % rid); - L(FL("annotate file file_path '%s'\n") % file); + L(FL("annotate file file_path '%s'") % file); // find the version of the file requested roster_t roster; @@ -98,7 +98,7 @@ N(is_file_t(node), F("'%s' in revision '%s' is not a file") % file % rid); file_t file_node = downcast_to_file_t(node); - L(FL("annotate for file_id %s\n") % file_node->self); + L(FL("annotate for file_id %s") % file_node->self); do_annotate(app, file_node, rid); } @@ -119,7 +119,7 @@ { dat = get_stdin(); } - + hexenc ident; calculate_ident(dat, ident); cout << ident << "\n"; @@ -141,7 +141,7 @@ revision_id rid; if (app.revision_selectors.size() == 0) get_revision_id(rid); - else + else complete(app, idx(app.revision_selectors, 0)(), rid); N(app.db.revision_exists(rid), F("no such revision '%s'") % rid); @@ -155,14 +155,14 @@ roster_t roster; marking_map marks; app.db.get_roster(rid, roster, marks); - N(roster.has_node(sp), F("no file '%s' found in revision '%s'\n") % fp % rid); + N(roster.has_node(sp), F("no file '%s' found in revision '%s'") % fp % rid); node_t node = roster.get_node(sp); - N((!null_node(node->self) && is_file_t(node)), F("no file '%s' found in revision '%s'\n") % fp % rid); + N((!null_node(node->self) && is_file_t(node)), F("no file '%s' found in revision '%s'") % fp % rid); file_t file_node = downcast_to_file_t(node); - file_id ident = file_node->content; + file_id ident = file_node->content; file_data dat; - L(FL("dumping file '%s'\n") % ident); + L(FL("dumping file '%s'") % ident); app.db.get_file_version(ident, dat); cout.write(dat.inner()().data(), dat.inner()().size()); ============================================================ --- cmd_key_cert.cc 4f07a55505d99f4a1680313d47e7a813a4bd1517 +++ cmd_key_cert.cc aea641cf1bcdfb372b147d99a5f908cca3c12188 @@ -31,7 +31,7 @@ } N(!exists, F("key '%s' already exists") % ident); - + keypair kp; P(F("generating key-pair '%s'") % ident); generate_key_pair(app.lua, ident, kp); @@ -42,7 +42,7 @@ CMD(dropkey, N_("key and cert"), N_("KEYID"), N_("drop a public and private key"), OPT_NONE) { bool key_deleted = false; - + if (args.size() != 1) throw usage(name); @@ -53,7 +53,7 @@ transaction_guard guard(app.db); if (app.db.public_key_exists(ident)) { - P(F("dropping public key '%s' from database\n") % ident); + P(F("dropping public key '%s' from database") % ident); app.db.delete_public_key(ident); key_deleted = true; } @@ -63,7 +63,7 @@ if (app.keys.key_pair_exists(ident)) { - P(F("dropping key pair '%s' from keystore\n") % ident); + P(F("dropping key pair '%s' from keystore") % ident); app.keys.delete_key(ident); key_deleted = true; } @@ -94,7 +94,7 @@ change_key_passphrase(app.lua, ident, key.priv); app.keys.delete_key(ident); app.keys.put_key_pair(ident, key); - P(F("passphrase changed\n")); + P(F("passphrase changed")); } CMD(cert, N_("key and cert"), N_("REVISION CERTNAME [CERTVAL]"), @@ -109,13 +109,13 @@ revision_id rid; complete(app, idx(args, 0)(), rid); ident = rid.inner(); - + cert_name name; internalize_cert_name(idx(args, 1), name); rsa_keypair_id key; get_user_key(key, app); - + cert_value val; if (args.size() == 3) val = cert_value(idx(args, 2)()); @@ -144,10 +144,10 @@ revision_id rid; complete(app, idx(args, 0)(), rid, false); hexenc ident(rid.inner()); - + cert_name name; internalize_cert_name(idx(args, 1), name); - + cert_value value(idx(args, 2)()); set signers; @@ -157,8 +157,8 @@ internalize_rsa_keypair_id(idx(args, i), keyid); signers.insert(keyid); } - - + + bool trusted = app.lua.hook_get_revision_cert_trust(signers, ident, name, value); @@ -192,7 +192,7 @@ } -CMD(testresult, N_("review"), N_("ID (pass|fail|true|false|yes|no|1|0)"), +CMD(testresult, N_("review"), N_("ID (pass|fail|true|false|yes|no|1|0)"), N_("note the results of running a test on a revision"), OPT_NONE) { if (args.size() != 2) @@ -205,19 +205,19 @@ } -CMD(approve, N_("review"), N_("REVISION"), +CMD(approve, N_("review"), N_("REVISION"), N_("approve of a particular revision"), OPT_BRANCH_NAME) { if (args.size() != 1) - throw usage(name); + throw usage(name); revision_id r; complete(app, idx(args, 0)(), r); packet_db_writer dbw(app); cert_value branchname; guess_branch(r, app, branchname); - N(app.branch_name() != "", F("need --branch argument for approval")); + N(app.branch_name() != "", F("need --branch argument for approval")); cert_revision_in_branch(r, app.branch_name(), app, dbw); } @@ -231,10 +231,10 @@ if (args.size() == 2) comment = idx(args, 1)(); else - N(app.lua.hook_edit_comment("", "", comment), + N(app.lua.hook_edit_comment("", "", comment), F("edit comment failed")); - - N(comment.find_first_not_of(" \r\t\n") != string::npos, + + N(comment.find_first_not_of("\n\r\t ") != string::npos, F("empty comment")); revision_id r; ============================================================ --- cmd_list.cc 5edf0ae19d13ccc9d25490eb64576bff4ad907ca +++ cmd_list.cc 5b4ecf0d3b3fac90a4cb8eea9b30b31bc335d082 @@ -26,16 +26,16 @@ using std::string; using std::vector; -static void +static void ls_certs(string const & name, app_state & app, vector const & args) { if (args.size() != 1) throw usage(name); vector certs; - + transaction_guard guard(app.db, false); - + revision_id ident; complete(app, idx(args, 0)(), ident); vector< revision > ts; @@ -44,7 +44,7 @@ certs.push_back(idx(ts, i).inner()); { - set checked; + set checked; for (size_t i = 0; i < certs.size(); ++i) { if (checked.find(idx(certs, i).key) == checked.end() && @@ -54,7 +54,7 @@ checked.insert(idx(certs, i).key); } } - + // Make the output deterministic; this is useful for the test suite, in // particular. sort(certs.begin(), certs.end()); @@ -77,7 +77,7 @@ for (size_t i = 0; i < certs.size(); ++i) { cert_status status = check_cert(app, idx(certs, i)); - cert_value tv; + cert_value tv; decode_base64(idx(certs, i).value, tv); string washed; if (guess_binary(tv())) @@ -113,10 +113,10 @@ % stat % idx(certs, i).name() % idx(lines, 0)); - + for (size_t i = 1; i < lines.size(); ++i) cout << (i18n_format(extra_str) % idx(lines, i)); - } + } if (certs.size() > 0) cout << "\n"; @@ -148,7 +148,7 @@ for (vector::const_iterator i = pubs.begin(); i != pubs.end(); i++) pubkeys[*i] = true; - + bool all_in_db = true; for (vector::const_iterator i = privkeys.begin(); i != privkeys.end(); i++) @@ -172,7 +172,7 @@ bool indb = i->second; if (indb) - app.db.get_key(keyid, pub_encoded); + app.db.get_key(keyid, pub_encoded); else { keypair kp; @@ -198,7 +198,7 @@ { keypair kp; hexenc hash_code; - app.keys.get_key_pair(*i, kp); + app.keys.get_key_pair(*i, kp); key_hash_code(*i, kp.priv, hash_code); cout << hash_code << " " << *i << "\n"; } @@ -209,13 +209,13 @@ privkeys.size() == 0) { if (args.size() == 0) - P(F("no keys found\n")); + P(F("no keys found")); else - W(F("no keys found matching '%s'\n") % idx(args, 0)()); + W(F("no keys found matching '%s'") % idx(args, 0)()); } } -static void +static void ls_branches(string name, app_state & app, vector const & args) { utf8 inc("*"); @@ -235,7 +235,7 @@ cout << idx(names, i) << "\n"; } -static void +static void ls_epochs(string name, app_state & app, vector const & args) { map epochs; @@ -255,13 +255,13 @@ ++i) { map::const_iterator j = epochs.find(cert_value((*i)())); - N(j != epochs.end(), F("no epoch for branch %s\n") % *i); + N(j != epochs.end(), F("no epoch for branch %s") % *i); cout << j->second << " " << j->first << "\n"; } - } + } } -static void +static void ls_tags(string name, app_state & app, vector const & args) { vector< revision > certs; @@ -277,11 +277,11 @@ decode_base64(c.value, name); sorted_vals.insert(make_pair(name, make_pair(c.ident, c.key))); } - for (set > >::const_iterator i = sorted_vals.begin(); i != sorted_vals.end(); ++i) { - cout << i->first << " " + cout << i->first << " " << i->second.first << " " << i->second.second << "\n"; } @@ -384,7 +384,7 @@ get_base_and_current_roster_shape(old_roster, new_roster, nis, app); restriction mask(args, app.exclude_patterns, old_roster, new_roster, app); - + update_current_roster_from_filesystem(new_roster, mask, app); make_restricted_csets(old_roster, new_roster, included, excluded, mask); check_restricted_cset(old_roster, included); @@ -399,7 +399,7 @@ if (mask.includes(*i)) files.insert(file_path(*i)); } - for (map::const_iterator + for (map::const_iterator i = included.nodes_renamed.begin(); i != included.nodes_renamed.end(); ++i) { @@ -420,7 +420,7 @@ files.insert(file_path(i->first)); } for (map >::const_iterator - i = included.deltas_applied.begin(); i != included.deltas_applied.end(); + i = included.deltas_applied.begin(); i != included.deltas_applied.end(); ++i) { if (mask.includes(i->first)) ============================================================ --- cmd_merging.cc 6745bfc6317dad3cf1828d17600aca164accf0e5 +++ cmd_merging.cc 3c99bc7044aba855f37df212ca11959ed6881bec @@ -20,7 +20,7 @@ using boost::shared_ptr; -struct update_source +struct update_source : public file_content_source { map & temporary_store; @@ -77,7 +77,7 @@ calculate_ident(r_working, r_working_id); I(r_working.edges.size() == 1); r_old_id = edge_old_revision(r_working.edges.begin()); - make_roster_for_base_plus_cset(r_old_id, + make_roster_for_base_plus_cset(r_old_id, edge_changes(r_working.edges.begin()), r_working_id, working_roster, working_mm, nis, app); @@ -113,19 +113,19 @@ } notify_if_multiple_heads(app); - + if (r_old_id == r_chosen_id) { - P(F("already up to date at %s\n") % r_old_id); + P(F("already up to date at %s") % r_old_id); // do still switch the workspace branch, in case they have used // update to switch branches. if (!app.branch_name().empty()) app.make_branch_sticky(); return; } - - P(F("selected update target %s\n") % r_chosen_id); + P(F("selected update target %s") % r_chosen_id); + bool switched_branch = false; { // figure out which branches the target is in @@ -134,7 +134,7 @@ erase_bogus_certs(certs, app); set< utf8 > branches; - for (vector< revision >::const_iterator i = certs.begin(); + for (vector< revision >::const_iterator i = certs.begin(); i != certs.end(); i++) { cert_value b; @@ -153,7 +153,7 @@ { // multiple non-matching branchnames string branch_list; - for (set::const_iterator i = branches.begin(); + for (set::const_iterator i = branches.begin(); i != branches.end(); i++) branch_list += "\n " + (*i)(); N(false, F("target revision is in multiple branches:%s\n\n" @@ -178,8 +178,8 @@ app.db.get_roster(r_chosen_id, chosen_roster, chosen_mm); - set - working_uncommon_ancestors, + set + working_uncommon_ancestors, chosen_uncommon_ancestors; if (is_ancestor(r_old_id, r_chosen_id, app)) @@ -188,7 +188,7 @@ target_mm = chosen_mm; r_target_id = r_chosen_id; app.db.get_uncommon_ancestors(r_old_id, r_chosen_id, - working_uncommon_ancestors, + working_uncommon_ancestors, chosen_uncommon_ancestors); } else @@ -198,7 +198,7 @@ // just pick something, all that's important is that it not // match the work revision or any ancestors of the base revision. r_target_id = revision_id(hexenc("5432100000000000000000000500000000000000")); - make_roster_for_base_plus_cset(r_old_id, + make_roster_for_base_plus_cset(r_old_id, transplant, r_target_id, target_roster, target_mm, nis, app); @@ -211,9 +211,9 @@ working_uncommon_ancestors.insert(r_working_id); - // Now merge the working roster with the chosen target. + // Now merge the working roster with the chosen target. - roster_merge_result result; + roster_merge_result result; roster_merge(working_roster, working_mm, working_uncommon_ancestors, target_roster, target_mm, chosen_uncommon_ancestors, result); @@ -233,7 +233,7 @@ // we have the following // // old --> working - // | | + // | | // V V // chosen --> merged // @@ -241,10 +241,10 @@ // - working is based on old and includes the workspace's changes // - chosen is the revision we're updating to and will end up in _MTN/revision // - merged is the merge of working and chosen - // - // we apply the working to merged cset to the workspace + // + // we apply the working to merged cset to the workspace // and write the cset from chosen to merged changeset in _MTN/work - + cset update, remaining; make_cset(working_roster, merged_roster, update); make_cset(target_roster, merged_roster, remaining); @@ -254,15 +254,15 @@ // write_cset(update, t1); // write_cset(remaining, t2); // write_manifest_of_roster(merged_roster, t3); - // P(F("updating workspace with [[[\n%s\n]]]\n") % t1); - // P(F("leaving residual work [[[\n%s\n]]]\n") % t2); - // P(F("merged roster [[[\n%s\n]]]\n") % t3); + // P(F("updating workspace with [[[\n%s\n]]]") % t1); + // P(F("leaving residual work [[[\n%s\n]]]") % t2); + // P(F("merged roster [[[\n%s\n]]]") % t3); // } update_source fsource(wca.temporary_store, app); editable_working_tree ewt(app, fsource); update.apply_to(ewt); - + // small race condition here... // nb: we write out r_chosen, not r_new, because the revision-on-disk // is the basis of the workspace, not the workspace itself. @@ -273,7 +273,7 @@ } if (switched_branch) P(F("switched branch; next commit will use branch %s") % app.branch_name()); - P(F("updated to base revision %s\n") % r_chosen_id); + P(F("updated to base revision %s") % r_chosen_id); put_work_cset(remaining); update_any_attrs(app); @@ -296,10 +296,10 @@ get_branch_heads(app.branch_name(), app, heads); - N(heads.size() != 0, F("branch '%s' is empty\n") % app.branch_name); + N(heads.size() != 0, F("branch '%s' is empty") % app.branch_name); if (heads.size() == 1) { - P(F("branch '%s' is already merged\n") % app.branch_name); + P(F("branch '%s' is already merged") % app.branch_name); return; } @@ -307,18 +307,18 @@ revision_id left = *i; revision_id ancestor; size_t count = 1; - P(F("starting with revision 1 / %d\n") % heads.size()); + P(F("starting with revision 1 / %d") % heads.size()); for (++i; i != heads.end(); ++i, ++count) { revision_id right = *i; - P(F("merging with revision %d / %d\n") % (count + 1) % heads.size()); - P(F("[source] %s\n") % left); - P(F("[source] %s\n") % right); + P(F("merging with revision %d / %d") % (count + 1) % heads.size()); + P(F("[source] %s") % left); + P(F("[source] %s") % right); revision_id merged; transaction_guard guard(app.db); interactive_merge_and_store(left, right, merged, app); - + // merged 1 edge; now we commit this, update merge source and // try next one @@ -328,15 +328,15 @@ string log = (FL("merge of %s\n" " and %s\n") % left % right).str(); cert_revision_changelog(merged, log, app, dbw); - + guard.commit(); - P(F("[merged] %s\n") % merged); + P(F("[merged] %s") % merged); left = merged; } - P(F("note: your workspaces have not been updated\n")); + P(F("note: your workspaces have not been updated")); } -CMD(propagate, N_("tree"), N_("SOURCE-BRANCH DEST-BRANCH"), +CMD(propagate, N_("tree"), N_("SOURCE-BRANCH DEST-BRANCH"), N_("merge from one branch to another asymmetrically"), OPT_DATE % OPT_AUTHOR % OPT_MESSAGE % OPT_MSGFILE) { @@ -347,7 +347,7 @@ process(app, "merge_into_dir", a); } -CMD(merge_into_dir, N_("tree"), N_("SOURCE-BRANCH DEST-BRANCH DIR"), +CMD(merge_into_dir, N_("tree"), N_("SOURCE-BRANCH DEST-BRANCH DIR"), N_("merge one branch into a subdirectory in another branch"), OPT_DATE % OPT_AUTHOR % OPT_MESSAGE % OPT_MSGFILE) { @@ -376,7 +376,7 @@ // if dir is not the empty string, rename the root of N1 to have the name // 'dir' in the merged tree. (ie, it has name "basename(dir)", and its // parent node is "N2.get_node(dirname(dir))") - + set src_heads, dst_heads; if (args.size() != 3) @@ -385,29 +385,29 @@ get_branch_heads(idx(args, 0)(), app, src_heads); get_branch_heads(idx(args, 1)(), app, dst_heads); - N(src_heads.size() != 0, F("branch '%s' is empty\n") % idx(args, 0)()); - N(src_heads.size() == 1, F("branch '%s' is not merged\n") % idx(args, 0)()); + N(src_heads.size() != 0, F("branch '%s' is empty") % idx(args, 0)()); + N(src_heads.size() == 1, F("branch '%s' is not merged") % idx(args, 0)()); - N(dst_heads.size() != 0, F("branch '%s' is empty\n") % idx(args, 1)()); - N(dst_heads.size() == 1, F("branch '%s' is not merged\n") % idx(args, 1)()); + N(dst_heads.size() != 0, F("branch '%s' is empty") % idx(args, 1)()); + N(dst_heads.size() == 1, F("branch '%s' is not merged") % idx(args, 1)()); set::const_iterator src_i = src_heads.begin(); set::const_iterator dst_i = dst_heads.begin(); - - P(F("propagating %s -> %s\n") % idx(args,0) % idx(args,1)); - P(F("[source] %s\n") % *src_i); - P(F("[target] %s\n") % *dst_i); + P(F("propagating %s -> %s") % idx(args,0) % idx(args,1)); + P(F("[source] %s") % *src_i); + P(F("[target] %s") % *dst_i); + // check for special cases if (*src_i == *dst_i || is_ancestor(*src_i, *dst_i, app)) { - P(F("branch '%s' is up-to-date with respect to branch '%s'\n") + P(F("branch '%s' is up-to-date with respect to branch '%s'") % idx(args, 1)() % idx(args, 0)()); - P(F("no action taken\n")); + P(F("no action taken")); } else if (is_ancestor(*dst_i, *src_i, app)) { - P(F("no merge necessary; putting %s in branch '%s'\n") + P(F("no merge necessary; putting %s in branch '%s'") % (*src_i) % idx(args, 1)()); transaction_guard guard(app.db); packet_db_writer dbw(app); @@ -492,8 +492,8 @@ cert_revision_changelog(merged, log_message, app, dbw); - guard.commit(); - P(F("[merged] %s\n") % merged); + guard.commit(); + P(F("[merged] %s") % merged); } } @@ -511,7 +511,7 @@ complete(app, idx(args, 0)(), left); complete(app, idx(args, 1)(), right); branch = idx(args, 2)(); - + N(!(left == right), F("%s and %s are the same revision, aborting") % left % right); N(!is_ancestor(left, right, app), @@ -520,26 +520,26 @@ F("%s is already an ancestor of %s") % right % left); // Somewhat redundant, but consistent with output of plain "merge" command. - P(F("[source] %s\n") % left); - P(F("[source] %s\n") % right); + P(F("[source] %s") % left); + P(F("[source] %s") % right); revision_id merged; transaction_guard guard(app.db); interactive_merge_and_store(left, right, merged, app); - + packet_db_writer dbw(app); - + cert_revision_in_branch(merged, branch, app, dbw); - + string log = (FL("explicit_merge of '%s'\n" " and '%s'\n" " to branch '%s'\n") % left % right % branch).str(); - + cert_revision_changelog(merged, log, app, dbw); - - guard.commit(); - P(F("[merged] %s\n") % merged); + + guard.commit(); + P(F("[merged] %s") % merged); } CMD(show_conflicts, N_("informative"), N_("REV REV"), N_("Show what conflicts would need to be resolved to merge the given revisions."), @@ -560,7 +560,7 @@ app.db.get_roster(r_id, r_roster, r_marking); set l_uncommon_ancestors, r_uncommon_ancestors; app.db.get_uncommon_ancestors(l_id, r_id, - l_uncommon_ancestors, + l_uncommon_ancestors, r_uncommon_ancestors); roster_merge_result result; roster_merge(l_roster, l_marking, l_uncommon_ancestors, @@ -588,13 +588,13 @@ get_branch_heads(app.branch_name(), app, heads); if (heads.size() == 0) - P(F("branch '%s' is empty\n") % app.branch_name); + P(F("branch '%s' is empty") % app.branch_name); else if (heads.size() == 1) - P(F("branch '%s' is currently merged:\n") % app.branch_name); + P(F("branch '%s' is currently merged:") % app.branch_name); else - P(F("branch '%s' is currently unmerged:\n") % app.branch_name); - - for (set::const_iterator i = heads.begin(); + P(F("branch '%s' is currently unmerged:") % app.branch_name); + + for (set::const_iterator i = heads.begin(); i != heads.end(); ++i) cout << describe_revision(app, *i) << "\n"; } @@ -608,11 +608,11 @@ revision_id rid; complete(app, idx(args, 0)(), rid); - + roster_t roster; marking_map mm; app.db.get_roster(rid, roster, mm); - + roster_data dat; write_roster_and_marking(roster, mm, dat); cout << dat; ============================================================ --- cmd_netsync.cc 3679d67d1590ae6a8731ab565132cd148b427b0b +++ cmd_netsync.cc 2b0b6da8e33bf1c3a5c7eec9de9218f20cbe1a80 @@ -37,7 +37,7 @@ if (use_defaults && (!app.db.var_exists(default_server_key) || app.set_default)) { - P(F("setting default server to %s\n") % addr); + P(F("setting default server to %s") % addr); app.db.set_var(default_server_key, var_value(addr())); } } @@ -49,7 +49,7 @@ var_value addr_value; app.db.get_var(default_server_key, addr_value); addr = utf8(addr_value()); - L(FL("using default server address: %s\n") % addr); + L(FL("using default server address: %s") % addr); } } @@ -64,13 +64,13 @@ if (use_defaults && (!app.db.var_exists(default_include_pattern_key) || app.set_default)) { - P(F("setting default branch include pattern to '%s'\n") % include_pattern); + P(F("setting default branch include pattern to '%s'") % include_pattern); app.db.set_var(default_include_pattern_key, var_value(include_pattern())); } if (use_defaults && (!app.db.var_exists(default_exclude_pattern_key) || app.set_default)) { - P(F("setting default branch exclude pattern to '%s'\n") % exclude_pattern); + P(F("setting default branch exclude pattern to '%s'") % exclude_pattern); app.db.set_var(default_exclude_pattern_key, var_value(exclude_pattern())); } } @@ -82,7 +82,7 @@ var_value pattern_value; app.db.get_var(default_include_pattern_key, pattern_value); include_pattern = utf8(pattern_value()); - L(FL("using default branch include pattern: '%s'\n") % include_pattern); + L(FL("using default branch include pattern: '%s'") % include_pattern); if (app.db.var_exists(default_exclude_pattern_key)) { app.db.get_var(default_exclude_pattern_key, pattern_value); @@ -90,7 +90,7 @@ } else exclude_pattern = utf8(""); - L(FL("excluding: %s\n") % exclude_pattern); + L(FL("excluding: %s") % exclude_pattern); } } @@ -106,7 +106,7 @@ app.signing_key = key; run_netsync_protocol(client_voice, source_role, addr, - include_pattern, exclude_pattern, app); + include_pattern, exclude_pattern, app); } CMD(pull, N_("network"), N_("[ADDRESS[:PORTNUMBER] [PATTERN]]"), @@ -117,10 +117,10 @@ process_netsync_args(name, args, addr, include_pattern, exclude_pattern, true, false, app); if (app.signing_key() == "") - P(F("doing anonymous pull; use -kKEYNAME if you need authentication\n")); - + P(F("doing anonymous pull; use -kKEYNAME if you need authentication")); + run_netsync_protocol(client_voice, sink_role, addr, - include_pattern, exclude_pattern, app); + include_pattern, exclude_pattern, app); } CMD(sync, N_("network"), N_("[ADDRESS[:PORTNUMBER] [PATTERN]]"), @@ -135,7 +135,7 @@ app.signing_key = key; run_netsync_protocol(client_voice, source_and_sink_role, addr, - include_pattern, exclude_pattern, app); + include_pattern, exclude_pattern, app); } @@ -200,5 +200,5 @@ utf8 dummy_addr, include_pattern, exclude_pattern; process_netsync_args(name, args, dummy_addr, include_pattern, exclude_pattern, false, true, app); run_netsync_protocol(server_voice, source_and_sink_role, app.bind_address, - include_pattern, exclude_pattern, app); + include_pattern, exclude_pattern, app); } ============================================================ --- cmd_othervcs.cc 47651b6f63bd48be121a30eec4d1746238151fd2 +++ cmd_othervcs.cc f97235e360354ab14ae9749e45b274acfc30c35e @@ -12,7 +12,7 @@ { if (args.size() < 1) throw usage(name); - + for (vector::const_iterator i = args.begin(); i != args.end(); ++i) { ============================================================ --- cmd_ws_commit.cc b334deaf56946d327559cb7db10fc82de170da5c +++ cmd_ws_commit.cc ed419208149db21c8a754df43d443c143b2e7544 @@ -21,8 +21,8 @@ using boost::shared_ptr; -static void -get_log_message_interactively(revision_set const & cs, +static void +get_log_message_interactively(revision_set const & cs, app_state & app, string & log_message) { @@ -41,8 +41,8 @@ F("edit of log message failed")); } -CMD(revert, N_("workspace"), N_("[PATH]..."), - N_("revert file(s), dir(s) or entire workspace (\".\")"), +CMD(revert, N_("workspace"), N_("[PATH]..."), + N_("revert file(s), dir(s) or entire workspace (\".\")"), OPT_DEPTH % OPT_EXCLUDE % OPT_MISSING) { if (args.size() < 1) @@ -53,7 +53,7 @@ cset included, excluded; app.require_workspace(); - + vector includes; vector excludes; @@ -69,7 +69,7 @@ L(FL("no missing files in restriction.")); return; } - + for (path_set::const_iterator i = missing.begin(); i != missing.end(); i++) { file_path fp(*i); @@ -103,7 +103,7 @@ split_path sp; old_roster.get_name(nid, sp); file_path fp(sp); - + if (!mask.includes(old_roster, nid)) continue; @@ -115,19 +115,19 @@ hexenc ident; calculate_ident(fp, ident, app.lua); // don't touch unchanged files - if (ident == f->content.inner()) + if (ident == f->content.inner()) continue; } - + P(F("reverting %s") % fp); - L(FL("reverting %s to [%s]\n") % fp % f->content); - + L(FL("reverting %s to [%s]") % fp % f->content); + N(app.db.file_version_exists(f->content), F("no file version %s found in database for %s") % f->content % fp); - + file_data dat; - L(FL("writing file %s to %s\n") + L(FL("writing file %s to %s") % f->content % fp); app.db.get_file_version(f->content, dat); write_localized_data(fp, dat.inner(), app.lua); @@ -152,7 +152,7 @@ maybe_update_inodeprints(app); } -CMD(disapprove, N_("review"), N_("REVISION"), +CMD(disapprove, N_("review"), N_("REVISION"), N_("disapprove of a particular revision"), OPT_BRANCH_NAME) { @@ -165,13 +165,13 @@ complete(app, idx(args, 0)(), r); app.db.get_revision(r, rev); - N(rev.edges.size() == 1, + N(rev.edges.size() == 1, F("revision '%s' has %d changesets, cannot invert\n") % r % rev.edges.size()); cert_value branchname; guess_branch(r, app, branchname); - N(app.branch_name() != "", F("need --branch argument for disapproval")); - + N(app.branch_name() != "", F("need --branch argument for disapproval")); + edge_entry const & old_edge (*rev.edges.begin()); app.db.get_revision_manifest(edge_old_revision(old_edge), rev_inverse.new_manifest); @@ -193,8 +193,8 @@ write_revision_set(rev_inverse, rdat); calculate_ident(rdat, inv_id); dbw.consume_revision_data(inv_id, rdat); - - cert_revision_in_branch(inv_id, branchname, app, dbw); + + cert_revision_in_branch(inv_id, branchname, app, dbw); cert_revision_date_now(inv_id, app, dbw); cert_revision_author_default(inv_id, app, dbw); cert_revision_changelog(inv_id, (FL("disapproval of revision '%s'") % r).str(), app, dbw); @@ -225,7 +225,7 @@ paths.insert(sp); } - bool add_recursive = !app.unknown; + bool add_recursive = !app.unknown; perform_additions(paths, app, add_recursive); } @@ -254,7 +254,7 @@ ALIAS(rm, drop); -CMD(rename, N_("workspace"), +CMD(rename, N_("workspace"), N_("SRC DEST\n" "SRC1 [SRC2 [...]] DEST_DIR"), N_("rename entries in the workspace"), @@ -262,7 +262,7 @@ { if (args.size() < 2) throw usage(name); - + app.require_workspace(); file_path dst_path = file_path_external(args.back()); @@ -326,27 +326,27 @@ { I(rev.edges.size() == 1); cset const & cs = edge_changes(rev.edges.begin()); - + for (path_set::const_iterator i = cs.nodes_deleted.begin(); - i != cs.nodes_deleted.end(); ++i) + i != cs.nodes_deleted.end(); ++i) cout << "dropped " << *i << "\n"; - for (map::const_iterator + for (map::const_iterator i = cs.nodes_renamed.begin(); - i != cs.nodes_renamed.end(); ++i) - cout << "renamed " << i->first << "\n" + i != cs.nodes_renamed.end(); ++i) + cout << "renamed " << i->first << "\n" << " to " << i->second << "\n"; for (path_set::const_iterator i = cs.dirs_added.begin(); - i != cs.dirs_added.end(); ++i) + i != cs.dirs_added.end(); ++i) cout << "added " << *i << "\n"; for (map::const_iterator i = cs.files_added.begin(); - i != cs.files_added.end(); ++i) + i != cs.files_added.end(); ++i) cout << "added " << i->first << "\n"; - for (map >::const_iterator - i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) + for (map >::const_iterator + i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) cout << "patched " << i->first << "\n"; } else @@ -403,7 +403,7 @@ { P(F("branch %s has multiple heads:") % app.branch_name); for (set::const_iterator i = heads.begin(); i != heads.end(); ++i) - P(i18n_format(" %s\n") % describe_revision(app, *i)); + P(i18n_format(" %s") % describe_revision(app, *i)); P(F("choose one with '%s checkout -r'") % app.prog_name); E(false, F("branch %s has multiple heads") % app.branch_name); } @@ -415,7 +415,7 @@ complete(app, idx(app.revision_selectors, 0)(), ident); N(app.db.revision_exists(ident), F("no such revision '%s'") % ident); - + cert_value b; guess_branch(ident, app, b); @@ -423,30 +423,30 @@ cert_value branch_name(app.branch_name()); base64 branch_encoded; encode_base64(branch_name, branch_encoded); - + vector< revision > certs; app.db.get_revision_certs(ident, branch_cert_name, branch_encoded, certs); - - L(FL("found %d %s branch certs on revision %s\n") + + L(FL("found %d %s branch certs on revision %s") % certs.size() % app.branch_name % ident); - - N(certs.size() != 0, F("revision %s is not a member of branch %s\n") + + N(certs.size() != 0, F("revision %s is not a member of branch %s") % ident % app.branch_name); } app.create_workspace(dir); - + file_data data; roster_t ros; marking_map mm; - + put_revision_id(ident); - - L(FL("checking out revision %s to directory %s\n") % ident % dir); + + L(FL("checking out revision %s to directory %s") % ident % dir); app.db.get_roster(ident, ros, mm); - + node_map const & nodes = ros.all_nodes(); for (node_map::const_iterator i = nodes.begin(); i != nodes.end(); ++i) { @@ -468,9 +468,9 @@ N(app.db.file_version_exists(file->content), F("no file %s found in database for %s") % file->content % path); - + file_data dat; - L(FL("writing file %s to %s\n") + L(FL("writing file %s to %s") % file->content % path); app.db.get_file_version(file->content, dat); write_localized_data(path, dat.inner(), app.lua); @@ -484,7 +484,7 @@ ALIAS(co, checkout) -CMD(attr, N_("workspace"), N_("set PATH ATTR VALUE\nget PATH [ATTR]\ndrop PATH [ATTR]"), +CMD(attr, N_("workspace"), N_("set PATH ATTR VALUE\nget PATH [ATTR]\ndrop PATH [ATTR]"), N_("set, get or drop file attributes"), OPT_NONE) { @@ -497,7 +497,7 @@ app.require_workspace(); get_base_and_current_roster_shape(old_roster, new_roster, nis, app); - + file_path path = file_path_external(idx(args,1)); split_path sp; path.split(sp); @@ -531,7 +531,7 @@ { attr_key a_key = idx(args, 2)(); N(node->attrs.find(a_key) != node->attrs.end(), - F("Path '%s' does not have attribute '%s'\n") + F("Path '%s' does not have attribute '%s'\n") % path % a_key); node->attrs[a_key] = make_pair(false, ""); } @@ -562,7 +562,7 @@ else if (args.size() == 3) { attr_key a_key = idx(args, 2)(); - full_attr_map_t::const_iterator i = node->attrs.find(a_key); + full_attr_map_t::const_iterator i = node->attrs.find(a_key); if (i != node->attrs.end() && i->second.first) cout << path << " : " << i->first << "=" << i->second.second << "\n"; else @@ -571,15 +571,15 @@ else throw usage(name); } - else + else throw usage(name); } -CMD(commit, N_("workspace"), N_("[PATH]..."), +CMD(commit, N_("workspace"), N_("[PATH]..."), N_("commit workspace to database"), - OPT_BRANCH_NAME % OPT_MESSAGE % OPT_MSGFILE % OPT_DATE % + OPT_BRANCH_NAME % OPT_MESSAGE % OPT_MSGFILE % OPT_DATE % OPT_AUTHOR % OPT_DEPTH % OPT_EXCLUDE) { string log_message(""); @@ -609,8 +609,8 @@ calculate_ident(restricted_rev, restricted_rev_id); - N(restricted_rev.is_nontrivial(), F("no changes to commit\n")); - + N(restricted_rev.is_nontrivial(), F("no changes to commit")); + cert_value branchname; I(restricted_rev.edges.size() == 1); @@ -618,24 +618,24 @@ get_branch_heads(app.branch_name(), app, heads); unsigned int old_head_size = heads.size(); - if (app.branch_name() != "") + if (app.branch_name() != "") branchname = app.branch_name(); - else + else guess_branch(edge_old_revision(restricted_rev.edges.begin()), app, branchname); - P(F("beginning commit on branch '%s'\n") % branchname); + P(F("beginning commit on branch '%s'") % branchname); L(FL("new manifest '%s'\n" "new revision '%s'\n") % restricted_rev.new_manifest % restricted_rev_id); process_commit_message_args(log_message_given, log_message, app); - + N(!(log_message_given && has_contents_user_log()), F("_MTN/log is non-empty and log message was specified on command line\n" "perhaps move or delete _MTN/log,\n" "or remove --message/--message-file from the command line?")); - + if (!log_message_given) { // this call handles _MTN/log @@ -643,7 +643,7 @@ // we only check for empty log messages when the user entered them // interactively. Consensus was that if someone wanted to explicitly // type --message="", then there wasn't any reason to stop them. - N(log_message.find_first_not_of(" \r\t\n") != string::npos, + N(log_message.find_first_not_of("\n\r\t ") != string::npos, F("empty log message; commit canceled")); // we save interactively entered log messages to _MTN/log, so if // something goes wrong, the next commit will pop up their old log @@ -663,7 +663,7 @@ app.lua.hook_validate_commit_message(log_message, new_manifest_text, message_validated, reason); - N(message_validated, F("log message rejected: %s\n") % reason); + N(message_validated, F("log message rejected: %s") % reason); { transaction_guard guard(app.db); @@ -671,12 +671,12 @@ if (app.db.revision_exists(restricted_rev_id)) { - W(F("revision %s already in database\n") % restricted_rev_id); + W(F("revision %s already in database") % restricted_rev_id); } else { // new revision - L(FL("inserting new revision %s\n") % restricted_rev_id); + L(FL("inserting new revision %s") % restricted_rev_id); I(restricted_rev.edges.size() == 1); edge_map::const_iterator edge = restricted_rev.edges.begin(); @@ -694,12 +694,12 @@ if (app.db.file_version_exists(new_content)) { - L(FL("skipping file delta %s, already in database\n") + L(FL("skipping file delta %s, already in database") % delta_entry_dst(i)); } else if (app.db.file_version_exists(old_content)) { - L(FL("inserting delta %s -> %s\n") + L(FL("inserting delta %s -> %s") % old_content % new_content); file_data old_data; data new_data; @@ -713,8 +713,8 @@ % path); delta del; diff(old_data.inner(), new_data, del); - dbw.consume_file_delta(old_content, - new_content, + dbw.consume_file_delta(old_content, + new_content, file_delta(del)); } else @@ -729,7 +729,7 @@ file_path path(i->first); file_id new_content = i->second; - L(FL("inserting full version %s\n") % new_content); + L(FL("inserting full version %s") % new_content); data new_data; read_localized_data(path, new_data, app.lua); // sanity check @@ -745,8 +745,8 @@ revision_data rdat; write_revision_set(restricted_rev, rdat); dbw.consume_revision_data(restricted_rev_id, rdat); - - cert_revision_in_branch(restricted_rev_id, branchname, app, dbw); + + cert_revision_in_branch(restricted_rev_id, branchname, app, dbw); if (app.date_set) cert_revision_date_time(restricted_rev_id, app.date, app, dbw); else @@ -758,21 +758,21 @@ cert_revision_changelog(restricted_rev_id, log_message, app, dbw); guard.commit(); } - + // small race condition here... put_work_cset(excluded); put_revision_id(restricted_rev_id); - P(F("committed revision %s\n") % restricted_rev_id); - + P(F("committed revision %s") % restricted_rev_id); + blank_user_log(); get_branch_heads(app.branch_name(), app, heads); if (heads.size() > old_head_size && old_head_size > 0) { P(F("note: this revision creates divergence\n" - "note: you may (or may not) wish to run '%s merge'") + "note: you may (or may not) wish to run '%s merge'") % app.prog_name); } - + update_any_attrs(app); maybe_update_inodeprints(app); ============================================================ --- commands.cc 579d73cf72936f2493bfe1fa4cec133d42106469 +++ commands.cc 534869eb75c5f57575dc842d1d7e24461b4a3a8c @@ -32,7 +32,7 @@ // we might expose this blunt command interface to scripting someday. but // not today. -namespace commands +namespace commands { using std::map; // This must be a pointer. @@ -73,7 +73,7 @@ }; }; -namespace commands +namespace commands { using std::endl; using std::greater; @@ -88,11 +88,11 @@ } - string complete_command(string const & cmd) + string complete_command(string const & cmd) { if (cmd.length() == 0 || (*cmds).find(cmd) != (*cmds).end()) return cmd; - L(FL("expanding command '%s'\n") % cmd); + L(FL("expanding command '%s'") % cmd); vector matched; @@ -111,10 +111,10 @@ F("unknown command '%s'\n") % cmd); // one matched command - if (matched.size() == 1) + if (matched.size() == 1) { string completed = *matched.begin(); - L(FL("expanded command to '%s'") % completed); + L(FL("expanded command to '%s'") % completed); return completed; } @@ -165,7 +165,7 @@ { sorted.push_back(i->second); } - + sort(sorted.begin(), sorted.end(), greater()); string curr_group; @@ -205,7 +205,7 @@ { if ((*cmds).find(cmd) != (*cmds).end()) { - L(FL("executing command '%s'\n") % cmd); + L(FL("executing command '%s'") % cmd); // at this point we process the data from _MTN/options if // the command needs it. @@ -217,7 +217,7 @@ } else { - P(F("unknown command '%s'\n") % cmd); + P(F("unknown command '%s'") % cmd); return 1; } } @@ -242,11 +242,11 @@ { if (args.size() < 1) throw usage(""); - + string full_cmd = complete_command(idx(args, 0)()); if ((*cmds).find(full_cmd) == (*cmds).end()) throw usage(""); - + throw usage(full_cmd); } @@ -281,7 +281,7 @@ { split_path sp; new_roster.get_name(nid, sp); - file_path fp(sp); + file_path fp(sp); hexenc ip; if (inodeprint_file(fp, ip)) ipm_new.insert(inodeprint_entry(fp, ip)); @@ -294,7 +294,7 @@ write_inodeprints(dat); } -string +string get_stdin() { char buf[constants::bufsz]; @@ -345,8 +345,8 @@ } -void -complete(app_state & app, +void +complete(app_state & app, string const & str, set & completion, bool must_exist) @@ -369,7 +369,7 @@ vector > sels(selectors::parse_selector(str, app)); - P(F("expanding selection '%s'\n") % str); + P(F("expanding selection '%s'") % str); // we jam through an "empty" selection on sel_ident type set completions; @@ -383,13 +383,13 @@ i != completions.end(); ++i) { pair::const_iterator, bool> p = completion.insert(revision_id(*i)); - P(F("expanded to '%s'\n") % *(p.first)); + P(F("expanded to '%s'") % *(p.first)); } } void -complete(app_state & app, +complete(app_state & app, string const & str, revision_id & completion, bool must_exist) @@ -437,7 +437,7 @@ // can't have both a --message and a --message-file ... N(app.message().length() == 0 || app.message_file().length() == 0, F("--message and --message-file are mutually exclusive")); - + if (app.is_explicit_option(OPT_MESSAGE)) { log_message = app.message(); ============================================================ --- commands.hh c6c8f7e3146a242c1578c35818116aba48e0d6a6 +++ commands.hh 815d331acde28ddbd64107f92e52aad1f9f199f1 @@ -17,7 +17,7 @@ class app_state; class utf8; -struct usage +struct usage { usage(std::string const & w) : which(w) {} std::string which; ============================================================ --- constants.cc b175c8ae9c808089d3e9f7216896be26714703db +++ constants.cc e0fe679a5b53cdee258b2588fec97fece2ec632c @@ -21,11 +21,11 @@ size_t const automate_stdio_size = 1024; // number of bits in an RSA key we use - size_t const keylen = 1024; + size_t const keylen = 1024; // number of seconds in window, in which to consider CVS commits equivalent // if they have otherwise compatible contents (author, changelog) - time_t const cvs_window = 60 * 5; + time_t const cvs_window = 60 * 5; // size of a line of database traffic logging, beyond which lines will be // truncated. @@ -46,18 +46,18 @@ size_t const log_line_sz = 0x300; // all the ASCII characters (bytes) which are legal in a packet. - char const * const legal_packet_bytes = + char const * const legal_packet_bytes = // LDH characters "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789" + "0123456789" "-" // extra base64 codes "+/=" // separators "address@hidden" // whitespace - " \r\n\t" + " \r\n\t" ; string const regex_legal_packet_bytes("([a-zA-Z0-9+/=[:space:]]+)"); @@ -79,13 +79,13 @@ // label separators ".@" ; - + // all the ASCII characters (bytes) which can occur in cert names char const * const legal_cert_name_bytes = // LDH characters "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789" + "0123456789" "-" ; @@ -96,7 +96,7 @@ // LDH characters "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789" + "0123456789" "-" // other non-shell, non-selector metacharacters allowed in (unquoted) local // parts by RFC2821/RFC2822. The full list is !#$%&'*+-/=?^_`|{}~. @@ -109,12 +109,12 @@ // all the ASCII characters (bytes) which are illegal in a (file|local)_path - char const illegal_path_bytes_arr[33] = - { - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + char const illegal_path_bytes_arr[33] = + { + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x7f, 0x00 } ; @@ -146,7 +146,7 @@ BOOST_STATIC_ASSERT((merkle_bitmap_length_in_bits % 8) == 0); u8 const netcmd_current_protocol_version = 6; - + size_t const netcmd_minimum_bytes_to_bother_with_gzip = 0xfff; size_t const netsync_session_key_length_in_bytes = 20; // 160 bits ============================================================ --- constants.hh e24a1a631a2717ee866ca20e5cb4ede9d2ba3d8a +++ constants.hh eb79289a66344262b16a0fe67ec63b3979fe34f2 @@ -20,10 +20,10 @@ extern size_t const automate_stdio_size; // number of bits in an RSA key we use - extern size_t const keylen; + extern size_t const keylen; // number of characters in a SHA1 id - static size_t const idlen = 40; + static size_t const idlen = 40; // number of characters in an encoded epoch static size_t const epochlen = idlen; @@ -33,7 +33,7 @@ // number of seconds in window, in which to consider CVS commits equivalent // if they have otherwise compatible contents (author, changelog) - extern time_t const cvs_window; + extern time_t const cvs_window; // number of bytes in a password buffer. further bytes will be dropped. static size_t const maxpasswd = 0xfff; @@ -119,7 +119,7 @@ + 1 // cmd code + 1); // smallest uleb possible - + // largest command *payload* allowed in a netcmd // in practice, this sets the size of the largest compressed file static size_t const netcmd_payload_limit = 2 << 27; ============================================================ --- crypto_tests.cc 5f2ad6110bb7f9a10978ede2c860ad44b24ffed0 +++ crypto_tests.cc 70cc3f3681395ae674799976432b968d1f79ef52 @@ -1015,15 +1015,15 @@ "25f67e9875a90aee60bf1dc1b26c2750294aa7b7", "8fa552efdcb67d98b5e0189144e99607f5a807fe" }; -static void +static void calculate_ident_test() { - // NIST checks all SHA implementations using a test system + // NIST checks all SHA implementations using a test system // outlined in the SHA Verification System PDF obtained at // http://csrc.nist.gov/cryptval/shs/SHAVS.pdf // There are three tests outlined: - // - Short Message Test: A small message is provided as + // - Short Message Test: A small message is provided as // an input with a pre-computed digest. If the crypto // module under test produces a HASH that matches the // known digest, the test passes @@ -1037,13 +1037,13 @@ // // - Monte Carlo Test: This tests the usage of SHA in // PRNGs. A known 'seed' is provided. This 'seed' is - // hashed and used as input into the next iteration. + // hashed and used as input into the next iteration. // This continues for 100,000 iterations. After every // 1000 hashes, the computed hash is compared to a known // one. If they match, the test succeeds. - // This test has been updated to include a defined Short + // This test has been updated to include a defined Short // Message test, and the Monte Carlo Test. The Long Message // test has been dropped as suitable, pre-computed values, are // not available. Also, instead of the expected 100,000 @@ -1058,21 +1058,21 @@ calculate_ident(input, output); - //L(FL(" Input: %s\n") % input); - //L(FL("Output: %s\n") % output); + //L(FL(" Input: %s") % input); + //L(FL("Output: %s") % output); BOOST_CHECK(output() == ident); L(FL("SHA Short Message Test: Passed\n\n")); //SHA Monte Carlo Test - // + // //INPUT: Seed - A random seed n bits long // // for (j=0; j<100; j++) { // // MD0 = MD1 = MD2 = Seed; - // + // // for (i=3; i<1003; i++) { // Mi = MDi-3 || MDi-2 || MDi-1; // MDi = SHA(Mi); @@ -1088,29 +1088,29 @@ string MD[1003]; - for (int j = 0; j < 1000; j++) + for (int j = 0; j < 1000; j++) { MD[0] = Seed; MD[1] = Seed; MD[2] = Seed; - for (int i = 3; i < 1003; i++) + for (int i = 3; i < 1003; i++) { string messageString = MD[i - 3] + MD[i - 2] + MD[i - 1]; - // L(FL("messageString: %s\n") % messageString ); + // L(FL("messageString: %s") % messageString ); data messageData(decode_hexenc(messageString)); - // L(FL("message: %s\n") % messageString ); + // L(FL("message: %s") % messageString ); calculate_ident(messageData, output2); - // L(FL("output: %s\n") % output2 ); + // L(FL("output: %s") % output2 ); MD[i] = output2(); } - - L(FL(" %03d: %s\n") % j % output2 ); - + + L(FL(" %03d: %s") % j % output2 ); + BOOST_CHECK(output2() == expected_SHA_MCT[j]); MD[j] = output2(); ============================================================ --- cset.cc bf3abceb49091cfed0d14d02c1188d14378b8f6e +++ cset.cc 71b4052c7b0658142edd83e596cfaa8f3be18f2a @@ -49,7 +49,7 @@ I(false); } } - + // no file+attr pair appears in both the "set" list and the "cleared" list { set >::const_iterator c = cs.attrs_cleared.begin(); @@ -70,8 +70,8 @@ bool cset::empty() const { - return - nodes_deleted.empty() + return + nodes_deleted.empty() && dirs_added.empty() && files_added.empty() && nodes_renamed.empty() @@ -95,18 +95,18 @@ struct detach { - detach(split_path const & src) - : src_path(src), - reattach(false) + detach(split_path const & src) + : src_path(src), + reattach(false) {} - - detach(split_path const & src, - split_path const & dst) - : src_path(src), - reattach(true), - dst_path(dst) + + detach(split_path const & src, + split_path const & dst) + : src_path(src), + reattach(true), + dst_path(dst) {} - + split_path src_path; bool reattach; split_path dst_path; @@ -123,8 +123,8 @@ struct attach { - attach(node_id n, - split_path const & p) + attach(node_id n, + split_path const & p) : node(n), path(p) {} @@ -140,7 +140,7 @@ } }; -void +void cset::apply_to(editable_tree & t) const { // SPEEDUP?: use vectors and sort them once, instead of maintaining sorted @@ -179,9 +179,9 @@ // bottom-up. for (path_set::const_iterator i = nodes_deleted.begin(); - i != nodes_deleted.end(); ++i) + i != nodes_deleted.end(); ++i) safe_insert(detaches, detach(*i)); - + for (map::const_iterator i = nodes_renamed.begin(); i != nodes_renamed.end(); ++i) safe_insert(detaches, detach(i->first, i->second)); @@ -190,7 +190,7 @@ // Execute all the detaches, rescheduling the results of each detach // for either attaching or dropping. - for (set::const_iterator i = detaches.begin(); + for (set::const_iterator i = detaches.begin(); i != detaches.end(); ++i) { node_id n = t.detach_node(i->src_path); @@ -253,7 +253,7 @@ } } -void +void print_cset(basic_io::printer & printer, cset const & cs) { @@ -335,7 +335,7 @@ file_path_internal(s).split(sp); } -void +void parse_cset(basic_io::parser & parser, cset & cs) { @@ -346,13 +346,13 @@ split_path p1, p2; MM(p1); MM(p2); - + split_path prev_path; MM(prev_path); pair prev_pair; MM(prev_pair.first); MM(prev_pair.second); - + // we make use of the fact that a valid split_path is never empty prev_path.clear(); while (parser.symp(syms::delete_node)) @@ -409,11 +409,11 @@ parser.hex(t1); parser.esym(syms::to); parser.hex(t2); - safe_insert(cs.deltas_applied, + safe_insert(cs.deltas_applied, make_pair(p1, make_pair(file_id(t1), file_id(t2)))); } - prev_pair.first.clear(); + prev_pair.first.clear(); while (parser.symp(syms::clear)) { parser.sym(); @@ -426,7 +426,7 @@ safe_insert(cs.attrs_cleared, new_pair); } - prev_pair.first.clear(); + prev_pair.first.clear(); while (parser.symp(syms::set)) { parser.sym(); @@ -485,7 +485,7 @@ // the file has attr "attr_file=value_file", and the dir has // "attr_dir=value_dir". r = roster_t(); - + { split_path sp; file_path().split(sp); @@ -508,7 +508,7 @@ static void cset_written_test() { - { + { L(FL("TEST: cset reading - operation misordering")); // bad cset, add_dir should be before add_file string s("delete \"foo\"\n" @@ -715,9 +715,9 @@ cs.nodes_renamed.insert(make_pair(fish, womble)); cs.deltas_applied.insert(make_pair(womble, make_pair(f2, f3))); cs.attrs_cleared.insert(make_pair(policeman, attr_key("yodel"))); - cs.attrs_set.insert(make_pair(make_pair(policeman, + cs.attrs_set.insert(make_pair(make_pair(policeman, attr_key("axolotyl")), attr_value("fruitily"))); - cs.attrs_set.insert(make_pair(make_pair(policeman, + cs.attrs_set.insert(make_pair(make_pair(policeman, attr_key("spin")), attr_value("capybara"))); data dat; MM(dat); @@ -766,7 +766,7 @@ MM(r); editable_roster_base tree(r, nis); - + file_id f1(string("0000000000000000000000000000000000000001")); file_id f2(string("0000000000000000000000000000000000000002")); @@ -851,7 +851,7 @@ L(FL("TEST: set attr")); setup_roster(r, f1, nis); cset cs; MM(cs); - cs.attrs_set.insert(make_pair(make_pair(foo_bar, attr_key("ping")), + cs.attrs_set.insert(make_pair(make_pair(foo_bar, attr_key("ping")), attr_value("klang"))); BOOST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); @@ -868,11 +868,11 @@ L(FL("TEST: clear attr file")); setup_roster(r, f1, nis); cset cs; MM(cs); - cs.attrs_set.insert(make_pair(make_pair(foo_bar, attr_key("ping")), + 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), logic_error); - BOOST_CHECK((r.get_node(foo_bar))->attrs[attr_key("attr_file")] + BOOST_CHECK((r.get_node(foo_bar))->attrs[attr_key("attr_file")] == make_pair(false, attr_value(""))); BOOST_CHECK(r.all_nodes().size() == 3); } @@ -881,7 +881,7 @@ { L(FL("TEST: renaming at different levels")); setup_roster(r, f1, nis); - split_path quux_sub, foo_sub, foo_sub_deep, foo_subsub, + split_path quux_sub, foo_sub, foo_sub_deep, foo_subsub, foo_subsub_deep, quux_bar, foo_bar, quux_sub_thing, foo_sub_thing; file_path_internal("quux/bar").split(quux_bar); @@ -946,7 +946,7 @@ roster_t r; MM(r); editable_roster_base tree(r, nis); - + file_id f1(string("0000000000000000000000000000000000000001")); file_id f2(string("0000000000000000000000000000000000000002")); @@ -1121,7 +1121,7 @@ roster_t r; MM(r); editable_roster_base tree(r, nis); - + file_id f1(string("0000000000000000000000000000000000000001")); split_path root, baz; ============================================================ --- cset.hh 2d06997a4c2475aa45550dbe967c09397575d908 +++ cset.hh 6410b0b216aed5a227e15a4537ca08d5f673a81f @@ -37,8 +37,8 @@ virtual void attach_node(node_id nid, split_path const & dst) = 0; // Modifying elements in-place - virtual void apply_delta(split_path const & pth, - file_id const & old_id, + virtual void apply_delta(split_path const & pth, + file_id const & old_id, file_id const & new_id) = 0; virtual void clear_attr(split_path const & pth, attr_key const & name) = 0; @@ -52,9 +52,9 @@ }; -// In-memory representation of a change set. +// In-memory representation of a change set. -struct cset +struct cset { // Deletions. path_set nodes_deleted; @@ -84,25 +84,25 @@ && attrs_set == other.attrs_set ; } - + void apply_to(editable_tree & t) const; bool empty() const; void clear(); }; -inline split_path const & +inline split_path const & delta_entry_path(std::map >::const_iterator i) { return i->first; } -inline file_id const & +inline file_id const & delta_entry_src(std::map >::const_iterator i) { return i->second.first; } -inline file_id const & +inline file_id const & delta_entry_dst(std::map >::const_iterator i) { return i->second.second; @@ -111,14 +111,14 @@ namespace basic_io { struct printer; struct parser; } -void +void print_cset(basic_io::printer & printer, cset const & cs); void write_cset(cset const & cs, data & dat); -void +void parse_cset(basic_io::parser & parser, cset & cs); ============================================================ --- cycle_detector.hh 624eaa84d3bc3281a0d6280cbecb1e654f0bc723 +++ cycle_detector.hh 79f9f0af66246c9cb770c5e3b57172c8c1b4b6e9 @@ -16,13 +16,13 @@ template struct cycle_detector { - + typedef std::vector< T > edge_vec; typedef std::vector edge_map; - typedef std::pair state; typedef std::stack edge_stack; - + edge_map edges; edge_stack stk; std::set global_in_edges; @@ -39,8 +39,8 @@ src_edges.push_back(dst); global_in_edges.insert(dst); } - + bool edge_makes_cycle(T const & src, T const & dst) { if (src == dst) @@ -69,7 +69,7 @@ { return true; } - if (val < edges.size() && ! edges.at(val).empty() + if (val < edges.size() && ! edges.at(val).empty() && visited.find(val) == visited.end()) { visited.insert(val); ============================================================ --- database.cc 77592832b55b0c42a0d4afb23875dc242d3d67b4 +++ database.cc ae0895605e5a1b6745b3b034a2836f1ad0e8001e @@ -75,7 +75,7 @@ int const any_rows = -1; int const any_cols = -1; -namespace +namespace { struct query_param { @@ -93,17 +93,17 @@ }; return q; } - + query_param blob(string const & blb) { - query_param q = { + query_param q = { query_param::blob, blb, }; return q; } - + // track all open databases for close_all_databases() handler set sql_contexts; } @@ -116,13 +116,13 @@ query() {} - + query & operator %(query_param const & qp) { args.push_back(qp); return *this; } - + vector args; string sql_cmd; }; @@ -149,10 +149,10 @@ return same; } -void +void database::check_schema() { - string db_schema_id; + string db_schema_id; calculate_schema_id (__sql, db_schema_id); N (schema == db_schema_id, F("layout of database %s doesn't match this version of monotone\n" @@ -258,12 +258,12 @@ static void -assert_sqlite3_ok(sqlite3 *s) +assert_sqlite3_ok(sqlite3 *s) { int errcode = sqlite3_errcode(s); if (errcode == SQLITE_OK) return; - + const char * errmsg = sqlite3_errmsg(s); // sometimes sqlite is not very helpful @@ -289,7 +289,7 @@ F("sqlite error: %s\n%s") % errmsg % auxiliary_message); } -struct sqlite3 * +struct sqlite3 * database::sql(bool init, bool migrating_format) { if (! __sql) @@ -325,14 +325,14 @@ return __sql; } -void +void database::initialize() { if (__sql) throw oops("cannot initialize database while it is open"); require_path_is_nonexistent(filename, - F("could not initialize database: %s: already exists") + F("could not initialize database: %s: already exists") % filename); system_path journal(filename.as_internal() + "-journal"); @@ -347,7 +347,7 @@ } -struct +struct dump_request { dump_request() : sql(), out() {}; @@ -373,7 +373,7 @@ out << encode_hexenc(string(val,val+bytes)); out << "'"; } - else + else { const unsigned char *val = sqlite3_column_text(stmt, i); if (val == NULL) @@ -392,10 +392,10 @@ } } } - out << ");\n"; + out << ");\n"; } -static int +static int dump_table_cb(void *data, int n, char **vals, char **cols) { dump_request *dump = reinterpret_cast(data); @@ -419,7 +419,7 @@ { stepresult = sqlite3_step(stmt); I(stepresult == SQLITE_DONE || stepresult == SQLITE_ROW); - if (stepresult == SQLITE_ROW) + if (stepresult == SQLITE_ROW) dump_row(*(dump->out), stmt, table_name); } while (stepresult == SQLITE_ROW); @@ -429,7 +429,7 @@ return 0; } -static int +static int dump_index_cb(void *data, int n, char **vals, char **cols) { dump_request *dump = reinterpret_cast(data); @@ -445,7 +445,7 @@ return 0; } -void +void database::dump(ostream & out) { // don't care about schema checking etc. @@ -478,7 +478,7 @@ close(); } -void +void database::load(istream & in) { string line; @@ -511,7 +511,7 @@ } -void +void database::debug(string const & sql, ostream & out) { results res; @@ -540,7 +540,7 @@ } } -void +void database::info(ostream & out) { string id; @@ -641,45 +641,45 @@ close(); } -void +void database::ensure_open() { sqlite3 *s = sql(); I(s != NULL); } -void +void database::ensure_open_for_format_changes() { sqlite3 *s = sql(false, true); I(s != NULL); } -database::~database() +database::~database() { - L(FL("statement cache statistics\n")); - L(FL("prepared %d statements\n") % statement_cache.size()); + L(FL("statement cache statistics")); + L(FL("prepared %d statements") % statement_cache.size()); - for (map::const_iterator i = statement_cache.begin(); + for (map::const_iterator i = statement_cache.begin(); i != statement_cache.end(); ++i) - L(FL("%d executions of %s\n") % i->second.count % i->first); + L(FL("%d executions of %s") % i->second.count % i->first); // trigger destructors to finalize cached statements statement_cache.clear(); close(); } -void +void database::execute(query const & query) { results res; fetch(res, 0, 0, query); } -void -database::fetch(results & res, - int const want_cols, - int const want_rows, +void +database::fetch(results & res, + int const want_cols, + int const want_rows, query const & query) { int nrow; @@ -690,7 +690,7 @@ res.resize(0); map::iterator i = statement_cache.find(query.sql_cmd); - if (i == statement_cache.end()) + if (i == statement_cache.end()) { statement_cache.insert(make_pair(query.sql_cmd, statement())); i = statement_cache.find(query.sql_cmd); @@ -699,16 +699,16 @@ const char * tail; sqlite3_prepare(sql(), query.sql_cmd.c_str(), -1, i->second.stmt.paddr(), &tail); assert_sqlite3_ok(sql()); - L(FL("prepared statement %s\n") % query.sql_cmd); + L(FL("prepared statement %s") % query.sql_cmd); // no support for multiple statements here - E(*tail == 0, + E(*tail == 0, F("multiple statements in query: %s\n") % query.sql_cmd); } ncol = sqlite3_column_count(i->second.stmt()); - E(want_cols == any_cols || want_cols == ncol, + E(want_cols == any_cols || want_cols == ncol, F("wanted %d columns got %d in query: %s\n") % want_cols % ncol % query.sql_cmd); // bind parameters for this execution @@ -720,7 +720,7 @@ // profiling finds this logging to be quite expensive if (global_sanity.debug) - L(FL("binding %d parameters for %s\n") % params % query.sql_cmd); + L(FL("binding %d parameters for %s") % params % query.sql_cmd); for (int param = 1; param <= params; param++) { @@ -728,11 +728,11 @@ if (global_sanity.debug) { string log = query.args[param-1].data; - + if (log.size() > constants::log_line_sz) log = log.substr(0, constants::log_line_sz); - - L(FL("binding %d with value '%s'\n") % param % log); + + L(FL("binding %d with value '%s'") % param % log); } switch (idx(query.args, param - 1).type) @@ -753,28 +753,28 @@ default: I(false); } - + assert_sqlite3_ok(sql()); } // execute and process results nrow = 0; - for (rescode = sqlite3_step(i->second.stmt()); rescode == SQLITE_ROW; + for (rescode = sqlite3_step(i->second.stmt()); rescode == SQLITE_ROW; rescode = sqlite3_step(i->second.stmt())) { vector row; - for (int col = 0; col < ncol; col++) + for (int col = 0; col < ncol; col++) { 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); + E(value, F("null result in query: %s") % query.sql_cmd); row.push_back(string(value, value + bytes)); - //L(FL("row %d col %d value='%s'\n") % nrow % col % value); + //L(FL("row %d col %d value='%s'") % nrow % col % value); } res.push_back(row); } - + if (rescode != SQLITE_DONE) assert_sqlite3_ok(sql()); @@ -791,15 +791,15 @@ // general application-level logic -void +void database::set_filename(system_path const & file) { I(!__sql); filename = file; } -void -database::begin_transaction(bool exclusive) +void +database::begin_transaction(bool exclusive) { if (transaction_level == 0) { @@ -820,26 +820,26 @@ } -bool +bool database::have_pending_write(string const & tab, hexenc const & id) { return pending_writes.find(make_pair(tab, id)) != pending_writes.end(); } -void +void database::load_pending_write(string const & tab, hexenc const & id, data & dat) { dat = safe_get(pending_writes, make_pair(tab, id)); } -void +void database::cancel_pending_write(string const & tab, hexenc const & id) { safe_erase(pending_writes, make_pair(tab, id)); } -void -database::schedule_write(string const & tab, +void +database::schedule_write(string const & tab, hexenc const & id, data const & dat) { @@ -847,7 +847,7 @@ safe_insert(pending_writes, make_pair(make_pair(tab, id), dat)); } -void +void database::commit_transaction() { if (transaction_level == 1) @@ -863,7 +863,7 @@ transaction_level--; } -void +void database::rollback_transaction() { if (transaction_level == 1) @@ -875,7 +875,7 @@ } -bool +bool database::exists(hexenc const & ident, string const & table) { @@ -890,7 +890,7 @@ } -bool +bool database::delta_exists(hexenc const & ident, string const & table) { @@ -906,7 +906,7 @@ results res; query q("SELECT COUNT(*) FROM " + table); fetch(res, one_col, one_row, q); - return lexical_cast(res[0][0]); + return lexical_cast(res[0][0]); } unsigned long @@ -942,7 +942,7 @@ } void -database::get_ids(string const & table, set< hexenc > & ids) +database::get_ids(string const & table, set< hexenc > & ids) { results res; query q("SELECT id FROM " + table); @@ -954,7 +954,7 @@ } } -void +void database::get(hexenc const & ident, data & dat, string const & table) @@ -981,7 +981,7 @@ dat = rdata_unpacked; } -void +void database::get_delta(hexenc const & ident, hexenc const & base, delta & del, @@ -997,7 +997,7 @@ decode_gzip(del_packed, del); } -void +void database::put(hexenc const & ident, data const & dat, string const & table) @@ -1012,13 +1012,13 @@ gzip dat_packed; encode_gzip(dat, dat_packed); - + string insert = "INSERT INTO " + table + " VALUES(?, ?)"; - execute(query(insert) - % text(ident()) + execute(query(insert) + % text(ident()) % blob(dat_packed())); } -void +void database::put_delta(hexenc const & ident, hexenc const & base, delta const & del, @@ -1032,7 +1032,7 @@ encode_gzip(del, del_packed); string insert = "INSERT INTO "+table+" VALUES(?, ?, ?)"; - execute(query(insert) + execute(query(insert) % text(ident()) % text(base()) % blob(del_packed())); @@ -1040,19 +1040,19 @@ // static ticker cache_hits("vcache hits", "h", 1); -struct datasz +struct datasz { unsigned long operator()(data const & t) { return t().size(); } }; -static LRUCache, data, datasz> +static LRUCache, data, datasz> vcache(constants::db_version_cache_sz); typedef vector< hexenc > version_path; static void -extend_path_if_not_cycle(string table_name, - shared_ptr p, +extend_path_if_not_cycle(string table_name, + shared_ptr p, hexenc const & ext, set< hexenc > & seen_nodes, vector< shared_ptr > & next_paths) @@ -1060,19 +1060,19 @@ for (version_path::const_iterator i = p->begin(); i != p->end(); ++i) { if ((*i)() == ext()) - throw oops("cycle in table '" + table_name + "', at node " + throw oops("cycle in table '" + table_name + "', at node " + (*i)() + " <- " + ext()); } if (seen_nodes.find(ext) == seen_nodes.end()) - { + { p->push_back(ext); next_paths.push_back(p); seen_nodes.insert(ext); } } -void +void database::get_version(hexenc const & ident, data & dat, string const & data_table, @@ -1107,8 +1107,8 @@ // node, so it much cheaper in terms of memory. // // we also maintain a cycle-detecting set, just to be safe - - L(FL("reconstructing %s in %s\n") % ident % delta_table); + + L(FL("reconstructing %s in %s") % ident % delta_table); I(delta_exists(ident, delta_table)); // Our reconstruction algorithm involves keeping a set of parallel @@ -1117,7 +1117,7 @@ // // On each iteration, we extend every active path by one step. If our // extension involves a fork, we duplicate the path. If any path - // contains a cycle, we fault. + // contains a cycle, we fault. // // If, by extending a path C, we enter a node which another path // D has already seen, we kill path C. This avoids the possibility of @@ -1129,7 +1129,7 @@ string delta_query = "SELECT base FROM " + delta_table + " WHERE id = ?"; { - shared_ptr pth0 = shared_ptr(new version_path()); + shared_ptr pth0 = shared_ptr(new version_path()); pth0->push_back(ident); live_paths.push_back(pth0); } @@ -1155,8 +1155,8 @@ else { // This tip is not a root, so extend the path. - results res; - fetch(res, one_col, any_rows, + results res; + fetch(res, one_col, any_rows, query(delta_query) % text(tip())); @@ -1165,15 +1165,15 @@ // Replicate the path if there's a fork. for (size_t k = 1; k < res.size(); ++k) { - shared_ptr pthN + shared_ptr pthN = shared_ptr(new version_path(*pth)); - extend_path_if_not_cycle(delta_table, pthN, + extend_path_if_not_cycle(delta_table, pthN, hexenc(res[k][0]), seen_nodes, next_paths); } // And extend the base path we're examining. - extend_path_if_not_cycle(delta_table, pth, + extend_path_if_not_cycle(delta_table, pth, hexenc(res[0][0]), seen_nodes, next_paths); } @@ -1203,7 +1203,7 @@ shared_ptr app = new_piecewise_applicator(); app->begin(begin()); - + for (version_path::reverse_iterator i = selected_path->rbegin(); i != selected_path->rend(); ++i) { @@ -1216,11 +1216,11 @@ vcache.insert(curr, tmp); } - L(FL("following delta %s -> %s\n") % curr % nxt); + L(FL("following delta %s -> %s") % curr % nxt); delta del; get_delta(nxt, curr, del, delta_table); apply_delta (app, del()); - + app->next(); curr = nxt; } @@ -1237,15 +1237,15 @@ } -void -database::drop(hexenc const & ident, +void +database::drop(hexenc const & ident, string const & table) { string drop = "DELETE FROM " + table + " WHERE id = ?"; execute(query(drop) % text(ident())); } -void +void database::put_version(hexenc const & old_id, hexenc const & new_id, delta const & del, @@ -1255,7 +1255,7 @@ data old_data, new_data; delta reverse_delta; - + get_version(old_id, old_data, data_table, delta_table); patch(old_data, del, new_data); { @@ -1268,7 +1268,7 @@ calculate_ident(old_tmp, old_tmp_id); I(old_tmp_id == old_id); } - + transaction_guard guard(*this); if (exists(old_id, data_table)) { @@ -1284,7 +1284,7 @@ guard.commit(); } -void +void database::remove_version(hexenc const & target_id, string const & data_table, string const & delta_table) @@ -1296,13 +1296,13 @@ // // 2. pre: older <- target (a root) // post: older (a root) - // + // // In case 1 we want to build new deltas bypassing the target we're // removing. In case 2 we just promote the older object to a root. transaction_guard guard(*this); - I(exists(target_id, data_table) + I(exists(target_id, data_table) || delta_exists(target_id, delta_table)); map, data> older; @@ -1327,7 +1327,7 @@ if (delta_exists(target_id, delta_table)) { if (!older.empty()) - { + { // Case 1: need to re-deltify all the older values against a newer // member of the delta chain. Doesn't really matter which newer // element (we have no good heuristic for guessing a good one @@ -1377,21 +1377,21 @@ // -- -- // ------------------------------------------------------------ -bool +bool database::file_version_exists(file_id const & id) { - return delta_exists(id.inner(), "file_deltas") + return delta_exists(id.inner(), "file_deltas") || exists(id.inner(), "files"); } -bool +bool database::roster_version_exists(roster_id const & id) { - return delta_exists(id.inner(), "roster_deltas") + return delta_exists(id.inner(), "roster_deltas") || exists(id.inner(), "rosters"); } -bool +bool database::revision_exists(revision_id const & id) { return exists(id.inner(), "revisions"); @@ -1401,7 +1401,7 @@ database::roster_link_exists_for_revision(revision_id const & rev_id) { results res; - fetch(res, one_col, any_rows, + fetch(res, one_col, any_rows, query("SELECT roster_id FROM revision_roster WHERE rev_id = ? ") % text(rev_id.inner()())); I((res.size() == 1) || (res.size() == 0)); @@ -1412,14 +1412,14 @@ database::roster_exists_for_revision(revision_id const & rev_id) { results res; - fetch(res, one_col, any_rows, + fetch(res, one_col, any_rows, query("SELECT roster_id FROM revision_roster WHERE rev_id = ? ") % text(rev_id.inner()())); I((res.size() == 1) || (res.size() == 0)); return (res.size() == 1) && roster_version_exists(roster_id(res[0][0])); } -void +void database::get_roster_links(map & links) { links.clear(); @@ -1427,13 +1427,13 @@ fetch(res, 2, any_rows, query("SELECT rev_id, roster_id FROM revision_roster")); for (size_t i = 0; i < res.size(); ++i) { - links.insert(make_pair(revision_id(res[i][0]), + links.insert(make_pair(revision_id(res[i][0]), roster_id(res[i][1]))); } } -void -database::get_file_ids(set & ids) +void +database::get_file_ids(set & ids) { ids.clear(); set< hexenc > tmp; @@ -1442,8 +1442,8 @@ ids.insert(tmp.begin(), tmp.end()); } -void -database::get_revision_ids(set & ids) +void +database::get_revision_ids(set & ids) { ids.clear(); set< hexenc > tmp; @@ -1451,8 +1451,8 @@ ids.insert(tmp.begin(), tmp.end()); } -void -database::get_roster_ids(set & ids) +void +database::get_roster_ids(set & ids) { ids.clear(); set< hexenc > tmp; @@ -1461,7 +1461,7 @@ ids.insert(tmp.begin(), tmp.end()); } -void +void database::get_file_version(file_id const & id, file_data & dat) { @@ -1470,7 +1470,7 @@ dat = tmp; } -void +void database::get_manifest_version(manifest_id const & id, manifest_data & dat) { @@ -1479,7 +1479,7 @@ dat = tmp; } -void +void database::get_roster_version(roster_id const & id, roster_data & dat) { @@ -1488,23 +1488,23 @@ dat = tmp; } -void +void database::put_file(file_id const & id, file_data const & dat) { schedule_write("files", id.inner(), dat.inner()); } -void +void database::put_file_version(file_id const & old_id, file_id const & new_id, file_delta const & del) { - put_version(old_id.inner(), new_id.inner(), del.inner(), + put_version(old_id.inner(), new_id.inner(), del.inner(), "files", "file_deltas"); } -void +void database::get_arbitrary_file_delta(file_id const & src_id, file_id const & dst_id, file_delta & del) @@ -1514,7 +1514,7 @@ results res; query q1("SELECT delta FROM file_deltas " "WHERE base = ? AND id = ?"); - fetch(res, one_col, any_rows, + fetch(res, one_col, any_rows, q1 % text(src_id.inner()()) % text(dst_id.inner()())); if (!res.empty()) @@ -1528,12 +1528,12 @@ query q2("SELECT delta FROM file_deltas " "WHERE id = ? AND base = ?"); - fetch(res, one_col, any_rows, + fetch(res, one_col, any_rows, q2 % text(dst_id.inner()()) % text(src_id.inner()())); if (!res.empty()) { - // We have a delta from dst -> src; we need to + // We have a delta from dst -> src; we need to // invert this to a delta from src -> dst. gzip del_packed(res[0][0]); decode_gzip(del_packed, dtmp); @@ -1544,7 +1544,7 @@ del = file_delta(fwd_delta); return; } - + // No deltas of use; just load both versions and diff. file_data fd1, fd2; get_file_version(src_id, fd1); @@ -1554,46 +1554,46 @@ } -void +void database::get_revision_ancestry(multimap & graph) { results res; graph.clear(); - fetch(res, 2, any_rows, + fetch(res, 2, any_rows, query("SELECT parent,child FROM revision_ancestry")); for (size_t i = 0; i < res.size(); ++i) graph.insert(make_pair(revision_id(res[i][0]), revision_id(res[i][1]))); } -void +void database::get_revision_parents(revision_id const & id, set & parents) { I(!null_id(id)); results res; parents.clear(); - fetch(res, one_col, any_rows, + fetch(res, one_col, any_rows, query("SELECT parent FROM revision_ancestry WHERE child = ?") % text(id.inner()())); for (size_t i = 0; i < res.size(); ++i) parents.insert(revision_id(res[i][0])); } -void +void database::get_revision_children(revision_id const & id, set & children) { results res; children.clear(); - fetch(res, one_col, any_rows, + fetch(res, one_col, any_rows, query("SELECT child FROM revision_ancestry WHERE parent = ?") % text(id.inner()())); for (size_t i = 0; i < res.size(); ++i) children.insert(revision_id(res[i][0])); } -void +void database::get_revision_manifest(revision_id const & rid, manifest_id & mid) { @@ -1602,7 +1602,7 @@ mid = rev.new_manifest; } -void +void database::get_revision(revision_id const & id, revision_set & rev) { @@ -1611,13 +1611,13 @@ read_revision_set(d, rev); } -void +void database::get_revision(revision_id const & id, revision_data & dat) { I(!null_id(id)); results res; - fetch(res, one_col, one_row, + fetch(res, one_col, one_row, query("SELECT data FROM revisions WHERE id = ?") % text(id.inner()())); @@ -1674,7 +1674,7 @@ } -void +void database::put_revision(revision_id const & new_id, revision_set const & rev) { @@ -1698,7 +1698,7 @@ } transaction_guard guard(*this); - + // Phase 2: construct a new roster and sanity-check its manifest_id // against the manifest_id of the revision you're writing. roster_t ros; @@ -1722,7 +1722,7 @@ for (edge_map::const_iterator e = rev.edges.begin(); e != rev.edges.end(); ++e) { - execute(query("INSERT INTO revision_ancestry VALUES(?, ?)") + execute(query("INSERT INTO revision_ancestry VALUES(?, ?)") % text(edge_old_revision(e).inner()()) % text(new_id.inner()())); } @@ -1746,7 +1746,7 @@ } -void +void database::delete_existing_revs_and_certs() { execute(query("DELETE FROM revisions")); @@ -1761,7 +1761,7 @@ execute(query("DELETE FROM manifest_deltas")); } -/// Deletes one revision from the local database. +/// Deletes one revision from the local database. /// @see kill_rev_locally void database::delete_existing_rev_and_certs(revision_id const & rid) @@ -1773,25 +1773,25 @@ set children; get_revision_children(rid, children); I(!children.size()); - - L(FL("Killing revision %s locally\n") % rid); + L(FL("Killing revision %s locally") % rid); + // Kill the certs, ancestry, and rev itself. - execute(query("DELETE from revision_certs WHERE id = ?") + execute(query("DELETE from revision_certs WHERE id = ?") % text(rid.inner()())); - execute(query("DELETE from revision_ancestry WHERE child = ?") + execute(query("DELETE from revision_ancestry WHERE child = ?") % text(rid.inner()())); - execute(query("DELETE from revisions WHERE id = ?") + execute(query("DELETE from revisions WHERE id = ?") % text(rid.inner()())); - + // Find the associated roster and count the number of links to it roster_id ros_id; - size_t link_count = 0; + size_t link_count = 0; get_roster_id_for_revision(rid, ros_id); - { + { results res; fetch(res, 2, any_rows, query("SELECT rev_id, roster_id FROM revision_roster " @@ -1799,7 +1799,7 @@ I(res.size() > 0); link_count = res.size(); } - + // Delete our link. execute(query("DELETE from revision_roster WHERE rev_id = ?") % text(rid.inner()())); @@ -1811,29 +1811,29 @@ guard.commit(); } -/// Deletes all certs referring to a particular branch. +/// Deletes all certs referring to a particular branch. void database::delete_branch_named(cert_value const & branch) { - L(FL("Deleting all references to branch %s\n") % branch); + L(FL("Deleting all references to branch %s") % branch); execute(query("DELETE FROM revision_certs WHERE name='branch' AND value =?") % blob(branch())); execute(query("DELETE FROM branch_epochs WHERE branch=?") % blob(branch())); } -/// Deletes all certs referring to a particular tag. +/// Deletes all certs referring to a particular tag. void database::delete_tag_named(cert_value const & tag) { - L(FL("Deleting all references to tag %s\n") % tag); + L(FL("Deleting all references to tag %s") % tag); execute(query("DELETE FROM revision_certs WHERE name='tag' AND value =?") % blob(tag())); } // crypto key management -void +void database::get_key_ids(string const & pattern, vector & pubkeys) { @@ -1841,18 +1841,18 @@ results res; if (pattern != "") - fetch(res, one_col, any_rows, + fetch(res, one_col, any_rows, query("SELECT id FROM public_keys WHERE id GLOB ?") % text(pattern)); else - fetch(res, one_col, any_rows, + fetch(res, one_col, any_rows, query("SELECT id FROM public_keys")); for (size_t i = 0; i < res.size(); ++i) pubkeys.push_back(res[i][0]); } -void +void database::get_keys(string const & table, vector & keys) { keys.clear(); @@ -1862,64 +1862,64 @@ keys.push_back(res[i][0]); } -void +void database::get_public_keys(vector & keys) { get_keys("public_keys", keys); } -bool +bool database::public_key_exists(hexenc const & hash) { results res; - fetch(res, one_col, any_rows, + fetch(res, one_col, any_rows, query("SELECT id FROM public_keys WHERE hash = ?") % text(hash())); I((res.size() == 1) || (res.size() == 0)); - if (res.size() == 1) + if (res.size() == 1) return true; return false; } -bool +bool database::public_key_exists(rsa_keypair_id const & id) { results res; - fetch(res, one_col, any_rows, + fetch(res, one_col, any_rows, query("SELECT id FROM public_keys WHERE id = ?") % text(id())); I((res.size() == 1) || (res.size() == 0)); - if (res.size() == 1) + if (res.size() == 1) return true; return false; } -void -database::get_pubkey(hexenc const & hash, +void +database::get_pubkey(hexenc const & hash, rsa_keypair_id & id, base64 & pub_encoded) { results res; - fetch(res, 2, one_row, + fetch(res, 2, one_row, query("SELECT id, keydata FROM public_keys WHERE hash = ?") % text(hash())); id = res[0][0]; encode_base64(rsa_pub_key(res[0][1]), pub_encoded); } -void -database::get_key(rsa_keypair_id const & pub_id, +void +database::get_key(rsa_keypair_id const & pub_id, base64 & pub_encoded) { results res; - fetch(res, one_col, one_row, + fetch(res, one_col, one_row, query("SELECT keydata FROM public_keys WHERE id = ?") % text(pub_id())); encode_base64(rsa_pub_key(res[0][0]), pub_encoded); } -void -database::put_key(rsa_keypair_id const & pub_id, +void +database::put_key(rsa_keypair_id const & pub_id, base64 const & pub_encoded) { hexenc thash; @@ -1944,7 +1944,7 @@ // cert management -bool +bool database::cert_exists(cert const & t, string const & table) { @@ -1955,7 +1955,7 @@ decode_base64(t.sig, sig); query q = query("SELECT id FROM " + table + " WHERE id = ? " "AND name = ? " - "AND value = ? " + "AND value = ? " "AND keypair = ? " "AND signature = ?") % text(t.ident()) @@ -1965,12 +1965,12 @@ % blob(sig()); fetch(res, 1, any_rows, q); - + I(res.size() == 0 || res.size() == 1); return res.size() == 1; } -void +void database::put_cert(cert const & t, string const & table) { @@ -1986,13 +1986,13 @@ execute(query(insert) % text(thash()) % text(t.ident()) - % text(t.name()) + % text(t.name()) % blob(value()) % text(t.key()) % blob(sig())); } -void +void database::results_to_certs(results const & res, vector & certs) { @@ -2004,7 +2004,7 @@ encode_base64(cert_value(res[i][2]), value); base64 sig; encode_base64(rsa_sha1_signature(res[i][4]), sig); - t = cert(hexenc(res[i][0]), + t = cert(hexenc(res[i][0]), cert_name(res[i][1]), value, rsa_keypair_id(res[i][3]), @@ -2045,8 +2045,8 @@ */ } -void -database::get_certs(vector & certs, +void +database::get_certs(vector & certs, string const & table) { results res; @@ -2056,13 +2056,13 @@ } -void -database::get_certs(hexenc const & ident, - vector & certs, +void +database::get_certs(hexenc const & ident, + vector & certs, string const & table) { results res; - query q("SELECT id, name, value, keypair, signature FROM " + table + + query q("SELECT id, name, value, keypair, signature FROM " + table + " WHERE id = ?"); fetch(res, 5, any_rows, q % text(ident())); @@ -2070,22 +2070,22 @@ } -void -database::get_certs(cert_name const & name, +void +database::get_certs(cert_name const & name, vector & certs, string const & table) { results res; - query q("SELECT id, name, value, keypair, signature FROM " + table + + query q("SELECT id, name, value, keypair, signature FROM " + table + " WHERE name = ?"); fetch(res, 5, any_rows, q % text(name())); results_to_certs(res, certs); } -void -database::get_certs(hexenc const & ident, - cert_name const & name, +void +database::get_certs(hexenc const & ident, + cert_name const & name, vector & certs, string const & table) { @@ -2093,20 +2093,20 @@ query q("SELECT id, name, value, keypair, signature FROM " + table + " WHERE id = ? AND name = ?"); - fetch(res, 5, any_rows, + fetch(res, 5, any_rows, q % text(ident()) % text(name())); results_to_certs(res, certs); } -void +void database::get_certs(cert_name const & name, - base64 const & val, + base64 const & val, vector & certs, string const & table) { results res; - query q("SELECT id, name, value, keypair, signature FROM " + table + + query q("SELECT id, name, value, keypair, signature FROM " + table + " WHERE name = ? AND value = ?"); cert_value binvalue; @@ -2118,20 +2118,20 @@ } -void -database::get_certs(hexenc const & ident, - cert_name const & name, +void +database::get_certs(hexenc const & ident, + cert_name const & name, base64 const & value, vector & certs, string const & table) { results res; - query q("SELECT id, name, value, keypair, signature FROM " + table + + query q("SELECT id, name, value, keypair, signature FROM " + table + " WHERE id = ? AND name = ? AND value = ?"); cert_value binvalue; decode_base64(value, binvalue); - fetch(res, 5, any_rows, + fetch(res, 5, any_rows, q % text(ident()) % text(name()) % blob(binvalue())); @@ -2140,23 +2140,23 @@ -bool +bool database::revision_cert_exists(revision const & cert) -{ - return cert_exists(cert.inner(), "revision_certs"); +{ + return cert_exists(cert.inner(), "revision_certs"); } -void +void database::put_revision_cert(revision const & cert) -{ - put_cert(cert.inner(), "revision_certs"); +{ + put_cert(cert.inner(), "revision_certs"); } void database::get_revision_cert_nobranch_index(vector< pair, pair > > & idx) { results res; - fetch(res, 3, any_rows, + fetch(res, 3, any_rows, query("SELECT hash, id, keypair " "FROM 'revision_certs' WHERE name != 'branch'")); @@ -2164,113 +2164,113 @@ idx.reserve(res.size()); for (results::const_iterator i = res.begin(); i != res.end(); ++i) { - idx.push_back(make_pair(hexenc((*i)[0]), + idx.push_back(make_pair(hexenc((*i)[0]), make_pair(revision_id((*i)[1]), rsa_keypair_id((*i)[2])))); } } -void +void database::get_revision_certs(vector< revision > & ts) { vector certs; get_certs(certs, "revision_certs"); ts.clear(); - copy(certs.begin(), certs.end(), back_inserter(ts)); + copy(certs.begin(), certs.end(), back_inserter(ts)); } -void +void database::get_revision_certs(cert_name const & name, vector< revision > & ts) { vector certs; get_certs(name, certs, "revision_certs"); ts.clear(); - copy(certs.begin(), certs.end(), back_inserter(ts)); + copy(certs.begin(), certs.end(), back_inserter(ts)); } -void -database::get_revision_certs(revision_id const & id, - cert_name const & name, +void +database::get_revision_certs(revision_id const & id, + cert_name const & name, vector< revision > & ts) { vector certs; get_certs(id.inner(), name, certs, "revision_certs"); ts.clear(); - copy(certs.begin(), certs.end(), back_inserter(ts)); + copy(certs.begin(), certs.end(), back_inserter(ts)); } -void -database::get_revision_certs(revision_id const & id, +void +database::get_revision_certs(revision_id const & id, cert_name const & name, - base64 const & val, + base64 const & val, vector< revision > & ts) { vector certs; get_certs(id.inner(), name, val, certs, "revision_certs"); ts.clear(); - copy(certs.begin(), certs.end(), back_inserter(ts)); + copy(certs.begin(), certs.end(), back_inserter(ts)); } -void +void database::get_revision_certs(cert_name const & name, - base64 const & val, + base64 const & val, vector< revision > & ts) { vector certs; get_certs(name, val, certs, "revision_certs"); ts.clear(); - copy(certs.begin(), certs.end(), back_inserter(ts)); + copy(certs.begin(), certs.end(), back_inserter(ts)); } -void -database::get_revision_certs(revision_id const & id, +void +database::get_revision_certs(revision_id const & id, vector< revision > & ts) -{ +{ vector certs; - get_certs(id.inner(), certs, "revision_certs"); + get_certs(id.inner(), certs, "revision_certs"); ts.clear(); copy(certs.begin(), certs.end(), back_inserter(ts)); } -void -database::get_revision_certs(revision_id const & ident, +void +database::get_revision_certs(revision_id const & ident, vector< hexenc > & ts) -{ +{ results res; vector certs; - fetch(res, one_col, any_rows, + fetch(res, one_col, any_rows, query("SELECT hash " "FROM revision_certs " - "WHERE id = ?") + "WHERE id = ?") % text(ident.inner()())); ts.clear(); for (size_t i = 0; i < res.size(); ++i) ts.push_back(hexenc(res[i][0])); } -void +void database::get_revision_cert(hexenc const & hash, revision & c) { results res; vector certs; - fetch(res, 5, one_row, + fetch(res, 5, one_row, query("SELECT id, name, value, keypair, signature " "FROM revision_certs " - "WHERE hash = ?") + "WHERE hash = ?") % text(hash())); results_to_certs(res, certs); I(certs.size() == 1); c = revision(certs[0]); } -bool +bool database::revision_cert_exists(hexenc const & hash) { results res; vector certs; - fetch(res, one_col, any_rows, + fetch(res, one_col, any_rows, query("SELECT id " "FROM revision_certs " "WHERE hash = ?") @@ -2279,30 +2279,30 @@ return (res.size() == 1); } -void -database::get_manifest_certs(manifest_id const & id, +void +database::get_manifest_certs(manifest_id const & id, vector< manifest > & ts) -{ +{ vector certs; - get_certs(id.inner(), certs, "manifest_certs"); + get_certs(id.inner(), certs, "manifest_certs"); ts.clear(); copy(certs.begin(), certs.end(), back_inserter(ts)); } -void -database::get_manifest_certs(cert_name const & name, +void +database::get_manifest_certs(cert_name const & name, vector< manifest > & ts) { vector certs; get_certs(name, certs, "manifest_certs"); ts.clear(); - copy(certs.begin(), certs.end(), back_inserter(ts)); + copy(certs.begin(), certs.end(), back_inserter(ts)); } // completions -void +void database::complete(string const & partial, set & completions) { @@ -2314,13 +2314,13 @@ fetch(res, 1, any_rows, query("SELECT id FROM revisions WHERE id GLOB ?") % text(pattern)); - + for (size_t i = 0; i < res.size(); ++i) - completions.insert(revision_id(res[i][0])); + completions.insert(revision_id(res[i][0])); } -void +void database::complete(string const & partial, set & completions) { @@ -2334,8 +2334,8 @@ % text(pattern)); for (size_t i = 0; i < res.size(); ++i) - completions.insert(file_id(res[i][0])); - + completions.insert(file_id(res[i][0])); + res.clear(); fetch(res, 1, any_rows, @@ -2343,10 +2343,10 @@ % text(pattern)); for (size_t i = 0; i < res.size(); ++i) - completions.insert(file_id(res[i][0])); + completions.insert(file_id(res[i][0])); } -void +void database::complete(string const & partial, set< pair > & completions) { @@ -2406,7 +2406,7 @@ vector > const & limit, set & completions) { - //L(FL("database::complete for partial '%s'\n") % partial); + //L(FL("database::complete for partial '%s'") % partial); completions.clear(); // step 1: the limit is transformed into an SQL select statement which @@ -2430,7 +2430,7 @@ first_limit = false; else lim.sql_cmd += " INTERSECT "; - + if (i->first == selectors::sel_ident) { lim.sql_cmd += "SELECT id FROM revision_certs WHERE id GLOB ?"; @@ -2468,7 +2468,7 @@ lim.sql_cmd += " AND CAST(value AS TEXT) glob ?"; lim % text(i->second + "*"); } - else if (i->first == selectors::sel_head) + else if (i->first == selectors::sel_head) { // get branch names vector branch_names; @@ -2497,7 +2497,7 @@ set branch_heads; get_branch_heads(*bn, *__app, branch_heads); heads.insert(branch_heads.begin(), branch_heads.end()); - L(FL("after get_branch_heads for %s, heads has %d entries\n") % (*bn) % heads.size()); + L(FL("after get_branch_heads for %s, heads has %d entries") % (*bn) % heads.size()); } lim.sql_cmd += "SELECT id FROM revision_certs WHERE id IN ("; @@ -2522,13 +2522,13 @@ string prefix; string suffix; selector_to_certname(i->first, certname, prefix, suffix); - L(FL("processing selector type %d with i->second '%s'\n") % ty % i->second); + L(FL("processing selector type %d with i->second '%s'") % ty % i->second); if ((i->first == selectors::sel_branch) && (i->second.size() == 0)) { __app->require_workspace("the empty branch selector b: refers to the current branch"); lim.sql_cmd += "SELECT id FROM revision_certs WHERE name=? AND CAST(value AS TEXT) glob ?"; lim % text(branch_cert_name) % text(__app->branch_name()); - L(FL("limiting to current branch '%s'\n") % __app->branch_name); + L(FL("limiting to current branch '%s'") % __app->branch_name); } else { @@ -2551,11 +2551,11 @@ } } } - //L(FL("found selector type %d, selecting_head is now %d\n") % i->first % selecting_head); + //L(FL("found selector type %d, selecting_head is now %d") % i->first % selecting_head); } } lim.sql_cmd += ")"; - + // step 2: depending on what we've been asked to disambiguate, we // will complete either some idents, or cert values, or "unknown" // which generally means "author, tag or branch" @@ -2564,13 +2564,13 @@ { lim.sql_cmd = "SELECT id FROM " + lim.sql_cmd; } - else + else { string prefix = "*"; string suffix = "*"; lim.sql_cmd = "SELECT value FROM revision_certs WHERE"; if (ty == selectors::sel_unknown) - { + { lim.sql_cmd += " (name=? OR name=? OR name=?)"; lim % text(author_cert_name) % text(tag_cert_name) % text(branch_cert_name); } @@ -2581,7 +2581,7 @@ lim.sql_cmd += " (name=?)"; lim % text(certname); } - + lim.sql_cmd += " AND (CAST(value AS TEXT) GLOB ?) AND (id IN " + lim.sql_cmd + ")"; lim % text(prefix + partial + suffix); } @@ -2590,7 +2590,7 @@ fetch(res, one_col, any_rows, lim); for (size_t i = 0; i < res.size(); ++i) { - if (ty == selectors::sel_ident) + if (ty == selectors::sel_ident) completions.insert(res[i][0]); else { @@ -2600,16 +2600,16 @@ } } -// epochs +// epochs -void +void database::get_epochs(map & epochs) { epochs.clear(); results res; fetch(res, 2, any_rows, query("SELECT branch, epoch FROM branch_epochs")); for (results::const_iterator i = res.begin(); i != res.end(); ++i) - { + { cert_value decoded(idx(*i, 0)); I(epochs.find(decoded) == epochs.end()); epochs.insert(make_pair(decoded, epoch_data(idx(*i, 1)))); @@ -2642,7 +2642,7 @@ return res.size() == 1; } -void +void database::set_epoch(cert_value const & branch, epoch_data const & epo) { epoch_id eid; @@ -2654,7 +2654,7 @@ % text(epo.inner()())); } -void +void database::clear_epoch(cert_value const & branch) { execute(query("DELETE FROM branch_epochs WHERE branch = ?") @@ -2754,26 +2754,26 @@ } results res; - query q("SELECT roster_id FROM revision_roster WHERE rev_id = ? "); + query q("SELECT roster_id FROM revision_roster WHERE rev_id = ? "); fetch(res, one_col, any_rows, q % text(rev_id.inner()())); I(res.size() == 1); ros_id = roster_id(res[0][0]); } -void -database::get_roster(revision_id const & rev_id, +void +database::get_roster(revision_id const & rev_id, roster_t & roster) { marking_map mm; get_roster(rev_id, roster, mm); } -static LRUCache > > +static LRUCache > > rcache(constants::db_roster_cache_sz); -void -database::get_roster(revision_id const & rev_id, +void +database::get_roster(revision_id const & rev_id, roster_t & roster, marking_map & marks) { @@ -2837,7 +2837,7 @@ % text(rev_id.inner()()) % text(new_id.inner()())); - if (exists(new_id.inner(), data_table) + if (exists(new_id.inner(), data_table) || delta_exists(new_id.inner(), delta_table)) { guard.commit(); @@ -2858,7 +2858,7 @@ i != parents.end(); ++i) { if (null_id(*i)) - continue; + continue; revision_id old_rev = *i; get_roster_id_for_revision(old_rev, old_id); if (exists(new_id.inner(), data_table)) @@ -2878,7 +2878,7 @@ typedef hashmap::hash_multimap ancestry_map; -static void +static void transitive_closure(string const & x, ancestry_map const & m, set & results) @@ -2906,7 +2906,7 @@ } } -void +void database::get_uncommon_ancestors(revision_id const & a, revision_id const & b, set & a_uncommon_ancs, @@ -2924,7 +2924,7 @@ a_uncommon_ancs.clear(); b_uncommon_ancs.clear(); - fetch(res, 2, any_rows, + fetch(res, 2, any_rows, query("SELECT parent,child FROM revision_ancestry")); set a_ancs, b_ancs; @@ -2935,17 +2935,17 @@ transitive_closure(a.inner()(), child_to_parent_map, a_ancs); transitive_closure(b.inner()(), child_to_parent_map, b_ancs); - - set_difference(a_ancs.begin(), a_ancs.end(), + + set_difference(a_ancs.begin(), a_ancs.end(), b_ancs.begin(), b_ancs.end(), inserter(a_uncommon_ancs, a_uncommon_ancs.begin())); - set_difference(b_ancs.begin(), b_ancs.end(), + set_difference(b_ancs.begin(), b_ancs.end(), a_ancs.begin(), a_ancs.end(), inserter(b_uncommon_ancs, b_uncommon_ancs.begin())); } -node_id +node_id database::next_node_id() { transaction_guard guard(*this); @@ -2953,9 +2953,9 @@ // We implement this as a fixed db var. - fetch(res, one_col, any_rows, + fetch(res, one_col, any_rows, query("SELECT node FROM next_roster_node_number")); - + node_id n; if (res.empty()) { @@ -2970,7 +2970,7 @@ ++n; execute (query("UPDATE next_roster_node_number SET node = ?") % text(lexical_cast(n))); - + } guard.commit(); return n; @@ -3035,7 +3035,7 @@ transaction_guard::transaction_guard(database & d, bool exclusive, size_t checkpoint_batch_size, - size_t checkpoint_batch_bytes) + size_t checkpoint_batch_bytes) : committed(false), db(d), exclusive(exclusive), checkpoint_batch_size(checkpoint_batch_size), checkpoint_batch_bytes(checkpoint_batch_bytes), @@ -3053,7 +3053,7 @@ db.rollback_transaction(); } -void +void transaction_guard::do_checkpoint() { db.commit_transaction(); @@ -3062,7 +3062,7 @@ checkpointed_bytes = 0; } -void +void transaction_guard::maybe_checkpoint(size_t nbytes) { checkpointed_calls += 1; @@ -3072,7 +3072,7 @@ do_checkpoint(); } -void +void transaction_guard::commit() { committed = true; ============================================================ --- database.hh 1222e43cb9911d432296a70d25b51f53462afd7e +++ database.hh f2225237fc9dec0d6e9781c207b2375047c980ce @@ -36,7 +36,7 @@ // deals with two sorts of version relationships. the versions // stored in the database are all *backwards* from those the program // sees. so for example if you have two versions of a file -// +// // file.1, file.2 // // where file.2 was a modification of file.1, then as far as the rest of @@ -61,7 +61,7 @@ // express this in the type system some day, but not presently. // // the key phrase to keep repeating when working on this code is: -// +// // "base files are new, derived files are old" // // it makes the code confusing, I know. this is possibly the worst part of @@ -93,7 +93,7 @@ void load_pending_write(std::string const & tab, hexenc const & id, data & dat); void cancel_pending_write(std::string const & tab, hexenc const & id); void schedule_write(std::string const & tab, hexenc const & id, data const & dat); - + app_state * __app; struct sqlite3 * __sql; struct sqlite3 * sql(bool init = false, bool migrating_format = false); @@ -104,15 +104,15 @@ void install_views(); typedef std::vector< std::vector > results; - + void execute(query const & q); - - void fetch(results & res, - int const want_cols, - int const want_rows, + + void fetch(results & res, + int const want_cols, + int const want_rows, query const & q); - - bool exists(hexenc const & ident, + + bool exists(hexenc const & ident, std::string const & table); bool delta_exists(hexenc const & ident, std::string const & table); @@ -123,7 +123,7 @@ unsigned int page_size(); unsigned int cache_size(); - void get_ids(std::string const & table, std::set< hexenc > & ids); + void get_ids(std::string const & table, std::set< hexenc > & ids); void get(hexenc const & new_id, data & dat, @@ -136,7 +136,7 @@ data & dat, std::string const & data_table, std::string const & delta_table); - + void put(hexenc const & new_id, data const & dat, std::string const & table); @@ -159,34 +159,34 @@ bool cert_exists(cert const & t, std::string const & table); - void put_cert(cert const & t, std::string const & table); + void put_cert(cert const & t, std::string const & table); void results_to_certs(results const & res, std::vector & certs); void get_certs(std::vector< cert > & certs, - std::string const & table); + std::string const & table); - void get_certs(hexenc const & ident, + void get_certs(hexenc const & ident, std::vector< cert > & certs, - std::string const & table); + std::string const & table); - void get_certs(cert_name const & name, + void get_certs(cert_name const & name, std::vector< cert > & certs, std::string const & table); void get_certs(hexenc const & ident, cert_name const & name, std::vector< cert > & certs, - std::string const & table); + std::string const & table); void get_certs(hexenc const & ident, cert_name const & name, - base64 const & val, + base64 const & val, std::vector< cert > & certs, - std::string const & table); + std::string const & table); void get_certs(cert_name const & name, - base64 const & val, + base64 const & val, std::vector & certs, std::string const & table); @@ -225,7 +225,7 @@ void ensure_open_for_format_changes(); void check_is_not_rosterified(); bool database_specified(); - + bool file_version_exists(file_id const & ident); bool roster_version_exists(roster_id const & ident); bool revision_exists(revision_id const & ident); @@ -241,7 +241,7 @@ bool check_integrity(); void set_app(app_state * app); - + // get plain version if it exists, or reconstruct version // from deltas (if they exist) void get_file_version(file_id const & ident, @@ -261,7 +261,7 @@ file_delta & del); // get plain version if it exists, or reconstruct version - // from deltas (if they exist). + // from deltas (if they exist). void get_manifest_version(manifest_id const & ident, manifest_data & dat); @@ -289,13 +289,13 @@ void put_revision(revision_id const & new_id, revision_data const & dat); - + void delete_existing_revs_and_certs(); void delete_existing_manifests(); void delete_existing_rev_and_certs(revision_id const & rid); - + void delete_branch_named(cert_value const & branch); void delete_tag_named(cert_value const & tag); @@ -310,19 +310,19 @@ bool public_key_exists(hexenc const & hash); bool public_key_exists(rsa_keypair_id const & ident); - - void get_pubkey(hexenc const & hash, + + void get_pubkey(hexenc const & hash, rsa_keypair_id & ident, base64 & pub_encoded); - void get_key(rsa_keypair_id const & ident, + void get_key(rsa_keypair_id const & ident, base64 & pub_encoded); - void put_key(rsa_keypair_id const & ident, + void put_key(rsa_keypair_id const & ident, base64 const & pub_encoded); void delete_public_key(rsa_keypair_id const & pub_id); - + // note: this section is ridiculous. please do something about it. bool revision_cert_exists(revision const & cert); @@ -336,49 +336,49 @@ void get_revision_certs(std::vector< revision > & certs); - void get_revision_certs(cert_name const & name, + void get_revision_certs(cert_name const & name, std::vector< revision > & certs); - void get_revision_certs(revision_id const & ident, - cert_name const & name, + void get_revision_certs(revision_id const & ident, + cert_name const & name, std::vector< revision > & certs); void get_revision_certs(cert_name const & name, - base64 const & val, + base64 const & val, std::vector< revision > & certs); - void get_revision_certs(revision_id const & ident, - cert_name const & name, + void get_revision_certs(revision_id const & ident, + cert_name const & name, base64 const & value, std::vector< revision > & certs); - void get_revision_certs(revision_id const & ident, + void get_revision_certs(revision_id const & ident, std::vector< revision > & certs); - void get_revision_certs(revision_id const & ident, + void get_revision_certs(revision_id const & ident, std::vector< hexenc > & hashes); void get_revision_cert(hexenc const & hash, revision & c); - - void get_manifest_certs(manifest_id const & ident, + + void get_manifest_certs(manifest_id const & ident, std::vector< manifest > & certs); - void get_manifest_certs(cert_name const & name, + void get_manifest_certs(cert_name const & name, std::vector< manifest > & certs); - // epochs + // epochs void get_epochs(std::map & epochs); void get_epoch(epoch_id const & eid, cert_value & branch, epoch_data & epo); - + bool epoch_exists(epoch_id const & eid); - void set_epoch(cert_value const & branch, epoch_data const & epo); + void set_epoch(cert_value const & branch, epoch_data const & epo); void clear_epoch(cert_value const & branch); - + // vars void get_vars(std::map & vars); @@ -398,10 +398,10 @@ void get_roster_id_for_revision(revision_id const & rev_id, roster_id & ros_id); - void get_roster(revision_id const & rid, + void get_roster(revision_id const & rid, roster_t & roster); - void get_roster(revision_id const & rid, + void get_roster(revision_id const & rid, roster_t & roster, marking_map & marks); @@ -412,9 +412,9 @@ revision_id const & b, std::set & a_uncommon_ancs, std::set & b_uncommon_ancs); - + node_id next_node_id(); - + // completion stuff void complete(std::string const & partial, @@ -428,10 +428,10 @@ void complete(selectors::selector_type ty, std::string const & partial, - std::vector > const & limit, std::set & completions); - + ~database(); }; @@ -446,7 +446,7 @@ // another process is accessing the database an exception will be thrown - // uglier and more confusing for the user - however no data inconsistency // should result. -// +// // An exception is thrown if an exclusive transaction_guard is created // while a non-exclusive transaction_guard exists. // ============================================================ --- database_check.cc 1354e4948560a3e9197df485a0d6d4208c7d442c +++ database_check.cc 2df826436ffc2376ebf5d95a3b0159b02b9bd2ce @@ -23,9 +23,9 @@ // +---+---+ // | | // keys revisions -// | +// | // rosters -// | +// | // files // @@ -71,18 +71,18 @@ manifest_id man_id; // manifest id of this roster's public part - checked_roster(): - found(false), revision_refs(0), + checked_roster(): + found(false), revision_refs(0), missing_files(0), missing_mark_revs(0), parseable(false), normalized(false), man_id() {} }; // the number of times a revision is referenced (revision_refs) -// should match the number of times it is listed as a parent in +// should match the number of times it is listed as a parent in // the ancestry cache (ancestry_parent_refs) // // the number of parents a revision has should match the number -// of times it is listed as a child in the ancestry cache +// of times it is listed as a child in the ancestry cache // (ancestry_child_refs) struct checked_revision { @@ -91,14 +91,14 @@ size_t ancestry_parent_refs; // number of references to this revision by ancestry parent size_t ancestry_child_refs; // number of references to this revision by ancestry child size_t marking_refs; // number of references to this revision by roster markings - + bool found_roster_link; // the revision->roster link for this revision exists bool found_roster; // the roster for this revision exists bool manifest_mismatch; // manifest doesn't match the roster for this revision - bool incomplete_roster; // the roster for this revision is missing files + bool incomplete_roster; // the roster for this revision is missing files size_t missing_manifests; // number of missing manifests referenced by this revision size_t missing_revisions; // number of missing revisions referenced by this revision - + size_t cert_refs; // number of references to this revision by revision certs; bool parseable; // read_revision_set does not throw @@ -109,12 +109,12 @@ set parents; vector checked_certs; - checked_revision(): + checked_revision(): found(false), - revision_refs(0), ancestry_parent_refs(0), ancestry_child_refs(0), + revision_refs(0), ancestry_parent_refs(0), ancestry_child_refs(0), marking_refs(0), found_roster(false), manifest_mismatch(false), incomplete_roster(false), - missing_manifests(0), missing_revisions(0), + missing_manifests(0), missing_revisions(0), cert_refs(0), parseable(false), normalized(false) {} }; @@ -135,14 +135,14 @@ set files; app.db.get_file_ids(files); - L(FL("checking %d files\n") % files.size()); + L(FL("checking %d files") % files.size()); ticker ticks(_("files"), "f", files.size()/70+1); for (set::const_iterator i = files.begin(); - i != files.end(); ++i) + i != files.end(); ++i) { - L(FL("checking file %s\n") % *i); + L(FL("checking file %s") % *i); file_data data; app.db.get_file_version(*i, data); checked_files[*i].found = true; @@ -152,7 +152,7 @@ I(checked_files.size() == files.size()); } -// first phase of roster checking, checks manifest-related parts of the +// first phase of roster checking, checks manifest-related parts of the // roster, and general parsability/normalisation static void check_rosters_manifest(app_state & app, @@ -164,15 +164,15 @@ set rosters; app.db.get_roster_ids(rosters); - L(FL("checking %d rosters, manifest pass\n") % rosters.size()); + L(FL("checking %d rosters, manifest pass") % rosters.size()); ticker ticks(_("rosters"), "r", rosters.size()/70+1); for (set::const_iterator i = rosters.begin(); - i != rosters.end(); ++i) + i != rosters.end(); ++i) { - L(FL("checking roster %s\n") % *i); + L(FL("checking roster %s") % *i); roster_data dat; app.db.get_roster_version(*i, dat); checked_rosters[*i].found = true; @@ -190,7 +190,7 @@ continue; } checked_rosters[*i].parseable = true; - + // normalisation check { roster_id norm_ident; @@ -231,15 +231,15 @@ map & checked_rosters, map & checked_revisions) { - L(FL("checking %d rosters, marking pass\n") % checked_rosters.size()); + L(FL("checking %d rosters, marking pass") % checked_rosters.size()); ticker ticks(_("markings"), "m", checked_rosters.size()/70+1); - for (map::const_iterator i + for (map::const_iterator i = checked_rosters.begin(); i != checked_rosters.end(); i++) { roster_id ros_id = i->first; - L(FL("checking roster %s\n") % i->first); + L(FL("checking roster %s") % i->first); if (!i->second.parseable) continue; @@ -249,7 +249,7 @@ roster_t ros; marking_map mm; read_roster_and_marking(dat, ros, mm); - + for (node_map::const_iterator n = ros.all_nodes().begin(); n != ros.all_nodes().end(); n++) { @@ -275,7 +275,7 @@ checked_rosters[ros_id].missing_mark_revs++; } - for (map >::const_iterator attr = + for (map >::const_iterator attr = mark.attrs.begin(); attr != mark.attrs.end(); attr++) for (set::const_iterator r = attr->second.begin(); r != attr->second.end(); r++) @@ -289,8 +289,8 @@ } } -static void -check_roster_links(app_state & app, +static void +check_roster_links(app_state & app, map & checked_revisions, map & checked_rosters, size_t & unreferenced_roster_links, @@ -307,12 +307,12 @@ revision_id rev(i->first); roster_id ros(i->second); - map::const_iterator j + map::const_iterator j = checked_revisions.find(rev); if (j == checked_revisions.end() || (!j->second.found)) ++unreferenced_roster_links; - map::const_iterator k + map::const_iterator k = checked_rosters.find(ros); if (k == checked_rosters.end() || (!k->second.found)) ++missing_rosters; @@ -321,7 +321,7 @@ static void -check_revisions(app_state & app, +check_revisions(app_state & app, map & checked_revisions, map & checked_rosters, set const & found_manifests) @@ -329,14 +329,14 @@ set revisions; app.db.get_revision_ids(revisions); - L(FL("checking %d revisions\n") % revisions.size()); + L(FL("checking %d revisions") % revisions.size()); ticker ticks(_("revisions"), "r", revisions.size()/70+1); for (set::const_iterator i = revisions.begin(); - i != revisions.end(); ++i) + i != revisions.end(); ++i) { - L(FL("checking revision %s\n") % *i); + L(FL("checking revision %s") % *i); revision_data data; app.db.get_revision(*i, data); checked_revisions[*i].found = true; @@ -383,13 +383,13 @@ if (found_manifests.find(rev.new_manifest) == found_manifests.end()) checked_revisions[*i].missing_manifests++; - for (edge_map::const_iterator edge = rev.edges.begin(); + for (edge_map::const_iterator edge = rev.edges.begin(); edge != rev.edges.end(); ++edge) { // ignore [] -> [...] revisions // delay checking parents until we've processed all revisions - if (!null_id(edge_old_revision(edge))) + if (!null_id(edge_old_revision(edge))) { checked_revisions[edge_old_revision(edge)].revision_refs++; checked_revisions[*i].parents.insert(edge_old_revision(edge)); @@ -398,14 +398,14 @@ // also check that change_sets applied to old manifests == new // manifests (which might be a merge) } - + ++ticks; } // now check for parent revision existence and problems for (map::iterator - revision = checked_revisions.begin(); + revision = checked_revisions.begin(); revision != checked_revisions.end(); ++revision) { for (set::const_iterator p = revision->second.parents.begin(); @@ -415,20 +415,20 @@ revision->second.missing_revisions++; } } - - L(FL("checked %d revisions after starting with %d\n") + + L(FL("checked %d revisions after starting with %d") % checked_revisions.size() % revisions.size()); } static void -check_ancestry(app_state & app, +check_ancestry(app_state & app, map & checked_revisions) { multimap graph; app.db.get_revision_ancestry(graph); - L(FL("checking %d ancestry edges\n") % graph.size()); + L(FL("checking %d ancestry edges") % graph.size()); ticker ticks(_("ancestry"), "a", graph.size()/70+1); @@ -441,11 +441,11 @@ i != graph.end(); ++i) { // ignore the [] -> [...] edges here too - if (!null_id(i->first)) + if (!null_id(i->first)) { checked_revisions[i->first].ancestry_parent_refs++; - if (!null_id(i->second)) + if (!null_id(i->second)) checked_revisions[i->second].ancestry_child_refs++; } @@ -454,14 +454,14 @@ } static void -check_keys(app_state & app, +check_keys(app_state & app, map & checked_keys) { vector pubkeys; app.db.get_public_keys(pubkeys); - L(FL("checking %d public keys\n") % pubkeys.size()); + L(FL("checking %d public keys") % pubkeys.size()); ticker ticks(_("keys"), "k", 1); @@ -476,7 +476,7 @@ } static void -check_certs(app_state & app, +check_certs(app_state & app, map & checked_revisions, map & checked_keys, size_t & total_certs) @@ -487,7 +487,7 @@ total_certs = certs.size(); - L(FL("checking %d revision certs\n") % certs.size()); + L(FL("checking %d revision certs") % certs.size()); ticker ticks(_("certs"), "c", certs.size()/70+1); @@ -497,12 +497,12 @@ checked_cert checked(*i); checked.found_key = checked_keys[i->inner().key].found; - if (checked.found_key) + if (checked.found_key) { 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, + checked.good_sig = check_signature(app, i->inner().key, + checked_keys[i->inner().key].pub_encoded, signed_text, i->inner().sig); } @@ -514,11 +514,11 @@ } static void -report_files(map const & checked_files, - size_t & missing_files, +report_files(map const & checked_files, + size_t & missing_files, size_t & unreferenced_files) { - for (map::const_iterator + for (map::const_iterator i = checked_files.begin(); i != checked_files.end(); ++i) { checked_file file = i->second; @@ -526,27 +526,27 @@ if (!file.found) { missing_files++; - P(F("file %s missing (%d manifest references)\n") + P(F("file %s missing (%d manifest references)") % i->first % file.roster_refs); } if (file.roster_refs == 0) { unreferenced_files++; - P(F("file %s unreferenced\n") % i->first); + P(F("file %s unreferenced") % i->first); } } } static void -report_rosters(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 (map::const_iterator + for (map::const_iterator i = checked_rosters.begin(); i != checked_rosters.end(); ++i) { checked_roster roster = i->second; @@ -554,34 +554,34 @@ if (roster.revision_refs == 0) { unreferenced_rosters++; - P(F("roster %s unreferenced\n") % i->first); + P(F("roster %s unreferenced") % i->first); } if (roster.missing_files > 0) { incomplete_rosters++; - P(F("roster %s incomplete (%d missing files)\n") + P(F("roster %s incomplete (%d missing files)") % i->first % roster.missing_files); } if (roster.missing_mark_revs > 0) { incomplete_rosters++; - P(F("roster %s incomplete (%d missing revisions)\n") + P(F("roster %s incomplete (%d missing revisions)") % i->first % roster.missing_mark_revs); } if (!roster.parseable) { non_parseable_rosters++; - P(F("roster %s is not parseable (perhaps with unnormalized paths?)\n") + P(F("roster %s is not parseable (perhaps with unnormalized paths?)") % i->first); } if (roster.parseable && !roster.normalized) { non_normalized_rosters++; - P(F("roster %s is not in normalized form\n") + P(F("roster %s is not in normalized form") % i->first); } } @@ -598,7 +598,7 @@ size_t & non_parseable_revisions, size_t & non_normalized_revisions) { - for (map::const_iterator + for (map::const_iterator i = checked_revisions.begin(); i != checked_revisions.end(); ++i) { checked_revision revision = i->second; @@ -606,7 +606,7 @@ if (!revision.found) { missing_revisions++; - P(F("revision %s missing (%d revision references; %d cert references; %d parent references; %d child references; %d roster references)\n") + P(F("revision %s missing (%d revision references; %d cert references; %d parent references; %d child references; %d roster references)") % i->first % revision.revision_refs % revision.cert_refs % revision.ancestry_parent_refs % revision.ancestry_child_refs % revision.marking_refs); } @@ -614,46 +614,46 @@ if (revision.missing_manifests > 0) { incomplete_revisions++; - P(F("revision %s incomplete (%d missing manifests)\n") + P(F("revision %s incomplete (%d missing manifests)") % i->first % revision.missing_manifests); } if (revision.missing_revisions > 0) { incomplete_revisions++; - P(F("revision %s incomplete (%d missing revisions)\n") + P(F("revision %s incomplete (%d missing revisions)") % i->first % revision.missing_revisions); } if (!revision.found_roster_link) { incomplete_revisions++; - P(F("revision %s incomplete (missing roster link)\n") % i->first); + P(F("revision %s incomplete (missing roster link)") % i->first); } if (!revision.found_roster) { incomplete_revisions++; - P(F("revision %s incomplete (missing roster)\n") % i->first); + P(F("revision %s incomplete (missing roster)") % i->first); } if (revision.manifest_mismatch) { manifest_mismatch++; - P(F("revision %s mismatched roster and manifest\n") % i->first); + P(F("revision %s mismatched roster and manifest") % i->first); } if (revision.incomplete_roster) { incomplete_revisions++; - P(F("revision %s incomplete (incomplete roster)\n") % i->first); + P(F("revision %s incomplete (incomplete roster)") % i->first); } if (revision.ancestry_parent_refs != revision.revision_refs) { mismatched_parents++; - P(F("revision %s mismatched parents (%d ancestry parents; %d revision refs)\n") - % i->first + P(F("revision %s mismatched parents (%d ancestry parents; %d revision refs)") + % i->first % revision.ancestry_parent_refs % revision.revision_refs ); } @@ -661,8 +661,8 @@ if (revision.ancestry_child_refs != revision.parents.size()) { mismatched_children++; - P(F("revision %s mismatched children (%d ancestry children; %d parents)\n") - % i->first + P(F("revision %s mismatched children (%d ancestry children; %d parents)") + % i->first % revision.ancestry_child_refs % revision.parents.size() ); } @@ -673,21 +673,21 @@ 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") + P(F("revision %s has bad history (%s)") % i->first % tmp); } if (!revision.parseable) { non_parseable_revisions++; - P(F("revision %s is not parseable (perhaps with unnormalized paths?)\n") + P(F("revision %s is not parseable (perhaps with unnormalized paths?)") % i->first); } if (revision.parseable && !revision.normalized) { non_normalized_revisions++; - P(F("revision %s is not in normalized form\n") + P(F("revision %s is not in normalized form") % i->first); } } @@ -697,21 +697,21 @@ report_keys(map const & checked_keys, size_t & missing_keys) { - for (map::const_iterator + for (map::const_iterator i = checked_keys.begin(); i != checked_keys.end(); ++i) { checked_key key = i->second; if (key.found) { - L(FL("key %s signed %d certs\n") + L(FL("key %s signed %d certs") % i->first % key.sigs); } else { missing_keys++; - P(F("key %s missing (signed %d certs)\n") + P(F("key %s missing (signed %d certs)") % i->first % key.sigs); } @@ -737,23 +737,23 @@ { checked_revision revision = i->second; map cert_counts; - + for (vector::const_iterator checked = revision.checked_certs.begin(); checked != revision.checked_certs.end(); ++checked) { if (!checked->found_key) { unchecked_sigs++; - P(F("revision %s unchecked signature in %s cert from missing key %s\n") - % i->first + P(F("revision %s unchecked signature in %s cert from missing key %s") + % i->first % checked->rcert.inner().name % checked->rcert.inner().key); } else if (!checked->good_sig) { bad_sigs++; - P(F("revision %s bad signature in %s cert from key %s\n") - % i->first + P(F("revision %s bad signature in %s cert from key %s") + % i->first % checked->rcert.inner().name % checked->rcert.inner().key); } @@ -761,13 +761,13 @@ cert_counts[checked->rcert.inner().name]++; } - for (set::const_iterator n = cnames.begin(); + for (set::const_iterator n = cnames.begin(); n != cnames.end(); ++n) { if (revision.found && cert_counts[*n] == 0) { missing_certs++; - P(F("revision %s missing %s cert\n") % i->first % *n); + P(F("revision %s missing %s cert") % i->first % *n); } } @@ -776,7 +776,7 @@ cert_counts[cert_name(date_cert_name)] != cert_counts[cert_name(changelog_cert_name)]) { mismatched_certs++; - P(F("revision %s mismatched certs (%d authors %d dates %d changelogs)\n") + P(F("revision %s mismatched certs (%d authors %d dates %d changelogs)") % i->first % cert_counts[cert_name(author_cert_name)] % cert_counts[cert_name(date_cert_name)] @@ -812,7 +812,7 @@ size_t bad_history = 0; size_t non_parseable_revisions = 0; size_t non_normalized_revisions = 0; - + size_t missing_keys = 0; size_t total_certs = 0; @@ -824,11 +824,11 @@ check_db_integrity_check(app); check_files(app, checked_files); - check_rosters_manifest(app, checked_rosters, checked_revisions, + check_rosters_manifest(app, checked_rosters, checked_revisions, found_manifests, checked_files); check_revisions(app, checked_revisions, checked_rosters, found_manifests); check_rosters_marking(app, checked_rosters, checked_revisions); - check_roster_links(app, checked_revisions, checked_rosters, + check_roster_links(app, checked_revisions, checked_rosters, unreferenced_roster_links, missing_rosters); check_ancestry(app, checked_revisions); @@ -837,14 +837,14 @@ report_files(checked_files, missing_files, unreferenced_files); - report_rosters(checked_rosters, - unreferenced_rosters, + report_rosters(checked_rosters, + unreferenced_rosters, incomplete_rosters, non_parseable_rosters, non_normalized_rosters); - + report_revisions(checked_revisions, - missing_revisions, incomplete_revisions, + missing_revisions, incomplete_revisions, mismatched_parents, mismatched_children, manifest_mismatch, bad_history, non_parseable_revisions, @@ -862,61 +862,61 @@ // -- an entry added to the manual, which describes in detail why the // error occurs and what it means to the user - if (missing_files > 0) - W(F("%d missing files\n") % missing_files); - if (unreferenced_files > 0) - W(F("%d unreferenced files\n") % unreferenced_files); + if (missing_files > 0) + W(F("%d missing files") % missing_files); + if (unreferenced_files > 0) + W(F("%d unreferenced files") % unreferenced_files); - if (unreferenced_rosters > 0) - W(F("%d unreferenced rosters\n") % unreferenced_rosters); + if (unreferenced_rosters > 0) + W(F("%d unreferenced rosters") % unreferenced_rosters); if (incomplete_rosters > 0) - W(F("%d incomplete rosters\n") % incomplete_rosters); + W(F("%d incomplete rosters") % incomplete_rosters); if (non_parseable_rosters > 0) - W(F("%d rosters not parseable (perhaps with invalid paths)\n") + W(F("%d rosters not parseable (perhaps with invalid paths)") % non_parseable_rosters); if (non_normalized_rosters > 0) - W(F("%d rosters not in normalized form\n") % non_normalized_rosters); + W(F("%d rosters not in normalized form") % non_normalized_rosters); if (missing_revisions > 0) - W(F("%d missing revisions\n") % missing_revisions); + W(F("%d missing revisions") % missing_revisions); if (incomplete_revisions > 0) - W(F("%d incomplete revisions\n") % incomplete_revisions); + W(F("%d incomplete revisions") % incomplete_revisions); if (mismatched_parents > 0) - W(F("%d mismatched parents\n") % mismatched_parents); + W(F("%d mismatched parents") % mismatched_parents); if (mismatched_children > 0) - W(F("%d mismatched children\n") % mismatched_children); + W(F("%d mismatched children") % mismatched_children); if (bad_history > 0) - W(F("%d revisions with bad history\n") % bad_history); + W(F("%d revisions with bad history") % bad_history); if (non_parseable_revisions > 0) - W(F("%d revisions not parseable (perhaps with invalid paths)\n") + W(F("%d revisions not parseable (perhaps with invalid paths)") % non_parseable_revisions); if (non_normalized_revisions > 0) - W(F("%d revisions not in normalized form\n") % non_normalized_revisions); + W(F("%d revisions not in normalized form") % non_normalized_revisions); if (unreferenced_roster_links > 0) - W(F("%d unreferenced roster links\n") % unreferenced_roster_links); + W(F("%d unreferenced roster links") % unreferenced_roster_links); if (missing_rosters > 0) - W(F("%d missing rosters\n") % missing_rosters); + W(F("%d missing rosters") % missing_rosters); if (missing_keys > 0) - W(F("%d missing keys\n") % missing_keys); + W(F("%d missing keys") % missing_keys); if (missing_certs > 0) - W(F("%d missing certs\n") % missing_certs); + W(F("%d missing certs") % missing_certs); if (mismatched_certs > 0) - W(F("%d mismatched certs\n") % mismatched_certs); + W(F("%d mismatched certs") % mismatched_certs); if (unchecked_sigs > 0) - W(F("%d unchecked signatures due to missing keys\n") % unchecked_sigs); + W(F("%d unchecked signatures due to missing keys") % unchecked_sigs); if (bad_sigs > 0) - W(F("%d bad signatures\n") % bad_sigs); + W(F("%d bad signatures") % bad_sigs); size_t total = missing_files + unreferenced_files + unreferenced_rosters + incomplete_rosters + non_parseable_rosters + non_normalized_rosters + - missing_revisions + incomplete_revisions + + missing_revisions + incomplete_revisions + non_parseable_revisions + non_normalized_revisions + mismatched_parents + mismatched_children + bad_history + @@ -926,10 +926,10 @@ missing_keys; // unreferenced files and rosters and mismatched certs are not actually // serious errors; odd, but nothing will break. - size_t serious = missing_files + + size_t serious = missing_files + incomplete_rosters + missing_rosters + non_parseable_rosters + non_normalized_rosters + - missing_revisions + incomplete_revisions + + missing_revisions + incomplete_revisions + non_parseable_revisions + non_normalized_revisions + mismatched_parents + mismatched_children + manifest_mismatch + bad_history + @@ -937,17 +937,17 @@ unchecked_sigs + bad_sigs + missing_keys; - P(F("check complete: %d files; %d rosters; %d revisions; %d keys; %d certs\n") + P(F("check complete: %d files; %d rosters; %d revisions; %d keys; %d certs") % checked_files.size() % checked_rosters.size() % checked_revisions.size() % checked_keys.size() % total_certs); - P(F("total problems detected: %d (%d serious)\n") % total % serious); + P(F("total problems detected: %d (%d serious)") % total % serious); if (serious) E(false, F("serious problems detected")); else if (total) - P(F("minor problems detected\n")); + P(F("minor problems detected")); else - P(F("database is good\n")); + P(F("database is good")); } ============================================================ --- database_check.hh 98374bcba5840ad01efdec5f36a0159568e124d7 +++ database_check.hh 7a319e994d382e74c3f6dceee3462a2a6bfe8153 @@ -8,7 +8,7 @@ #include "app_state.hh" -void +void check_db(app_state & app); #endif // header guard ============================================================ --- diff_patch.cc b854d0d4444480e98b9ed8e2aa936d700de1cc22 +++ diff_patch.cc f05f8aa967ed88dae6b96efecdf44c45f288537d @@ -49,7 +49,7 @@ // \----> left // // first you compute the edit list "EDITS(ancestor,left)". -// +// // then you make an offset table "leftpos" which describes positions in // "ancestor" as they map to "left"; that is, for 0 < apos < // ancestor.size(), we have @@ -65,7 +65,7 @@ // // you then go through this edit list applying the edits to left, rather // than ancestor, and using the table leftpos to map the position of each -// edit to an appropriate spot in left. this means you walk a "curr_left" +// edit to an appropriate spot in left. this means you walk a "curr_left" // index through the edits, and for each edit e: // // - if e is a delete (and e.pos is a position in ancestor) @@ -88,7 +88,7 @@ // typedef enum { preserved = 0, deleted = 1, changed = 2 } edit_t; -static char *etab[3] = +static char *etab[3] = { "preserved", "deleted", @@ -97,7 +97,7 @@ struct extent { - extent(size_t p, size_t l, edit_t t) + extent(size_t p, size_t l, edit_t t) : pos(p), len(l), type(t) {} size_t pos; @@ -117,7 +117,7 @@ size_t a_pos = 0, b_pos = 0; - for (vector::const_iterator i = a_b_edits.begin(); + for (vector::const_iterator i = a_b_edits.begin(); i != a_b_edits.end(); ++i) { // L(FL("edit: %d") % *i); @@ -134,7 +134,7 @@ extents.push_back(extent(b_pos++, 1, preserved)); } - // L(FL(" -- delete at A-pos %d (B-pos = %d)\n") % a_deleted % b_pos); + // L(FL(" -- delete at A-pos %d (B-pos = %d)") % a_deleted % b_pos); // skip the deleted line a_pos++; @@ -153,9 +153,9 @@ extents.push_back(extent(b_pos++, 1, preserved)); } - // L(FL(" -- insert at B-pos %d (A-pos = %d) : '%s'\n") + // L(FL(" -- insert at B-pos %d (A-pos = %d) : '%s'") // % b_inserted % a_pos % intern.lookup(b.at(b_inserted))); - + // record that there was an insertion, but a_pos did not move. if ((b_pos == 0 && extents.empty()) || (b_pos == prefix.size())) @@ -187,7 +187,7 @@ for (size_t i = 0; i < a_b_map.size(); ++i) { if (i > 0) - { + { size_t j = i; while (j > 0 && (a_b_map.at(j-1).type == preserved) @@ -206,7 +206,7 @@ // u // v // a ... the a on the RHS here. Hence we can - // q --pres--> q 3 'shift' the entire 'changed' block + // q --pres--> q 3 'shift' the entire 'changed' block // e --chng--> d 4 upwards, leaving a 'preserved' line // g --pres--> g 5 'a'->'a' // @@ -214,7 +214,7 @@ // i // z --pres--> z 0 // o --chng--> o 1 - // a + // a // t // u // v @@ -226,7 +226,7 @@ // Now all the 'changed' extents are normalised to the // earliest possible position. - L(FL("exchanging preserved extent [%d+%d] with changed extent [%d+%d]\n") + L(FL("exchanging preserved extent [%d+%d] with changed extent [%d+%d]") % a_b_map.at(j-1).pos % a_b_map.at(j-1).len % a_b_map.at(j).pos @@ -242,7 +242,7 @@ for (size_t i = 0; i < a_b_map.size(); ++i) { if (i > 0) - { + { size_t j = i; while (j > 0 && a_b_map.at(j).type == changed @@ -253,20 +253,20 @@ // step 1: move a chunk from this insert extent to its // predecessor size_t piece = a_b_map.at(j).len - 1; - // L(FL("moving change piece of len %d from pos %d to pos %d\n") + // L(FL("moving change piece of len %d from pos %d to pos %d") // % piece // % a_b_map.at(j).pos // % a_b_map.at(j-1).pos); a_b_map.at(j).len = 1; a_b_map.at(j).pos += piece; a_b_map.at(j-1).len += piece; - - // step 2: if this extent (now of length 1) has become a "changed" + + // step 2: if this extent (now of length 1) has become a "changed" // extent identical to its previous state, switch it to a "preserved" // extent. if (b.at(a_b_map.at(j).pos) == a.at(j)) { - // L(FL("changing normalized 'changed' extent at %d to 'preserved'\n") + // L(FL("changing normalized 'changed' extent at %d to 'preserved'") // % a_b_map.at(j).pos); a_b_map.at(j).type = preserved; } @@ -292,22 +292,22 @@ // for (; i != a_b_map.end(); ++i, ++j) // { - - // L(FL("trying to merge: [%s %d %d] vs. [%s %d %d] \n") - // % etab[i->type] % i->pos % i->len + + // L(FL("trying to merge: [%s %d %d] vs. [%s %d %d]") + // % etab[i->type] % i->pos % i->len // % etab[j->type] % j->pos % j->len); // } - + // i = a_b_map.begin(); // j = a_c_map.begin(); for (; i != a_b_map.end(); ++i, ++j) { - // L(FL("trying to merge: [%s %d %d] vs. [%s %d %d] \n") - // % etab[i->type] % i->pos % i->len + // L(FL("trying to merge: [%s %d %d] vs. [%s %d %d]") + // % etab[i->type] % i->pos % i->len // % etab[j->type] % j->pos % j->len); - + // mutual, identical preserves / inserts / changes if (((i->type == changed && j->type == changed) || (i->type == preserved && j->type == preserved)) @@ -317,8 +317,8 @@ { if (b.at(i->pos + k) != c.at(j->pos + k)) { - L(FL("conflicting edits: %s %d[%d] '%s' vs. %s %d[%d] '%s'\n") - % etab[i->type] % i->pos % k % in.lookup(b.at(i->pos + k)) + L(FL("conflicting edits: %s %d[%d] '%s' vs. %s %d[%d] '%s'") + % etab[i->type] % i->pos % k % in.lookup(b.at(i->pos + k)) % etab[j->type] % j->pos % k % in.lookup(c.at(j->pos + k))); throw conflict(); } @@ -330,45 +330,45 @@ else if ((i->type == deleted && j->type == deleted) || (i->type == deleted && j->type == preserved) || (i->type == preserved && j->type == deleted)) - { + { // do nothing } - // single-edge insert / changes + // single-edge insert / changes else if (i->type == changed && j->type == preserved) for (size_t k = 0; k < i->len; ++k) merged.push_back(b.at(i->pos + k)); - + else if (i->type == preserved && j->type == changed) for (size_t k = 0; k < j->len; ++k) merged.push_back(c.at(j->pos + k)); - + else { - L(FL("conflicting edits: [%s %d %d] vs. [%s %d %d]\n") - % etab[i->type] % i->pos % i->len + L(FL("conflicting edits: [%s %d %d] vs. [%s %d %d]") + % etab[i->type] % i->pos % i->len % etab[j->type] % j->pos % j->len); - throw conflict(); - } - + throw conflict(); + } + // if (merged.empty()) - // L(FL(" --> EMPTY\n")); + // L(FL(" --> EMPTY")); // else - // L(FL(" --> [%d]: %s\n") % (merged.size() - 1) % in.lookup(merged.back())); + // L(FL(" --> [%d]: %s") % (merged.size() - 1) % in.lookup(merged.back())); } } void merge_via_edit_scripts(vector const & ancestor, - vector const & left, + vector const & left, vector const & right, vector & merged) { - vector anc_interned; - vector left_interned, right_interned; - vector left_edits, right_edits; - vector left_prefix, right_prefix; - vector left_suffix, right_suffix; + vector anc_interned; + vector left_interned, right_interned; + vector left_edits, right_edits; + vector left_prefix, right_prefix; + vector left_suffix, right_suffix; vector left_extents, right_extents; vector merged_interned; interner in; @@ -393,15 +393,15 @@ i != right.end(); ++i) right_interned.push_back(in.intern(*i)); - L(FL("calculating left edit script on %d -> %d lines\n") + L(FL("calculating left edit script on %d -> %d lines") % anc_interned.size() % left_interned.size()); edit_script(anc_interned.begin(), anc_interned.end(), left_interned.begin(), left_interned.end(), min(ancestor.size(), left.size()), left_edits); - - L(FL("calculating right edit script on %d -> %d lines\n") + + L(FL("calculating right edit script on %d -> %d lines") % anc_interned.size() % right_interned.size()); edit_script(anc_interned.begin(), anc_interned.end(), @@ -409,43 +409,43 @@ min(ancestor.size(), right.size()), right_edits); - L(FL("calculating left extents on %d edits\n") % left_edits.size()); - calculate_extents(left_edits, left_interned, - left_prefix, left_extents, left_suffix, + L(FL("calculating left extents on %d edits") % left_edits.size()); + calculate_extents(left_edits, left_interned, + left_prefix, left_extents, left_suffix, anc_interned.size(), in); - L(FL("calculating right extents on %d edits\n") % right_edits.size()); - calculate_extents(right_edits, right_interned, - right_prefix, right_extents, right_suffix, + L(FL("calculating right extents on %d edits") % right_edits.size()); + calculate_extents(right_edits, right_interned, + right_prefix, right_extents, right_suffix, anc_interned.size(), in); - L(FL("normalizing %d right extents\n") % right_extents.size()); + L(FL("normalizing %d right extents") % right_extents.size()); normalize_extents(right_extents, anc_interned, right_interned); - L(FL("normalizing %d left extents\n") % left_extents.size()); + L(FL("normalizing %d left extents") % left_extents.size()); normalize_extents(left_extents, anc_interned, left_interned); if ((!right_prefix.empty()) && (!left_prefix.empty())) { - L(FL("conflicting prefixes\n")); + L(FL("conflicting prefixes")); throw conflict(); } if ((!right_suffix.empty()) && (!left_suffix.empty())) { - L(FL("conflicting suffixes\n")); + L(FL("conflicting suffixes")); throw conflict(); } - L(FL("merging %d left, %d right extents\n") + L(FL("merging %d left, %d right extents") % left_extents.size() % right_extents.size()); copy(left_prefix.begin(), left_prefix.end(), back_inserter(merged_interned)); copy(right_prefix.begin(), right_prefix.end(), back_inserter(merged_interned)); merge_extents(left_extents, right_extents, - left_interned, right_interned, + left_interned, right_interned, in, merged_interned); copy(left_suffix.begin(), left_suffix.end(), back_inserter(merged_interned)); @@ -463,13 +463,13 @@ vector const & right, vector & merged) { - try - { + try + { merge_via_edit_scripts(ancestor, left, right, merged); } catch(conflict &) { - L(FL("conflict detected. no merge.\n")); + L(FL("conflict detected. no merge.")); return false; } return true; @@ -487,27 +487,27 @@ marking_map const & mm) : app(app), mm(mm) { - // FIXME: possibly refactor to run this lazily, as we don't + // FIXME: possibly refactor to run this lazily, as we don't // need to find common ancestors if we're never actually // called on to do content merging. find_common_ancestor_for_merge(left, right, lca, app); } -void -content_merge_database_adaptor::record_merge(file_id const & left_ident, - file_id const & right_ident, +void +content_merge_database_adaptor::record_merge(file_id const & left_ident, + file_id const & right_ident, file_id const & merged_ident, - file_data const & left_data, + file_data const & left_data, file_data const & merged_data) -{ - L(FL("recording successful merge of %s <-> %s into %s\n") +{ + L(FL("recording successful merge of %s <-> %s into %s") % left_ident % right_ident % merged_ident); delta left_delta, right_delta; transaction_guard guard(app.db); - diff(left_data.inner(), merged_data.inner(), left_delta); - diff(left_data.inner(), merged_data.inner(), right_delta); + diff(left_data.inner(), merged_data.inner(), left_delta); + diff(left_data.inner(), merged_data.inner(), right_delta); packet_db_writer dbw(app); dbw.consume_file_delta (left_ident, merged_ident, file_delta(left_delta)); dbw.consume_file_delta (right_ident, merged_ident, file_delta(right_delta)); @@ -524,26 +524,26 @@ if (i != rmap.end()) rout = i->second; else - { + { rout = shared_ptr(new roster_t()); app.db.get_roster(rid, *rout); safe_insert(rmap, make_pair(rid, rout)); } } -void +void content_merge_database_adaptor::get_ancestral_roster(node_id nid, shared_ptr & anc) { // Given a file, if the lca is nonzero and its roster contains the file, // then we use its roster. Otherwise we use the roster at the file's // birth revision, which is the "per-file worst case" lca. - + // Begin by loading any non-empty file lca roster if (!lca.inner()().empty()) load_and_cache_roster(lca, rosters, anc, app); - - // If this roster doesn't contain the file, replace it with + + // If this roster doesn't contain the file, replace it with // the file's birth roster. if (!anc->has_node(nid)) { @@ -553,7 +553,7 @@ } } -void +void content_merge_database_adaptor::get_version(file_path const & path, file_id const & ident, file_data & dat) @@ -566,31 +566,31 @@ // content_merge_workspace_adaptor /////////////////////////////////////////////////////////////////////////// -void -content_merge_workspace_adaptor::record_merge(file_id const & left_id, +void +content_merge_workspace_adaptor::record_merge(file_id const & left_id, file_id const & right_id, file_id const & merged_id, - file_data const & left_data, + file_data const & left_data, file_data const & merged_data) -{ - L(FL("temporarily recording merge of %s <-> %s into %s\n") +{ + L(FL("temporarily recording merge of %s <-> %s into %s") % left_id % right_id % merged_id); I(temporary_store.find(merged_id) == temporary_store.end()); temporary_store.insert(make_pair(merged_id, merged_data)); } -void +void content_merge_workspace_adaptor::get_ancestral_roster(node_id nid, shared_ptr & anc) { - // When doing an update, the base revision is always the ancestor to + // When doing an update, the base revision is always the ancestor to // use for content merging. anc = base; } -void +void content_merge_workspace_adaptor::get_version(file_path const & path, - file_id const & ident, + file_id const & ident, file_data & dat) { if (app.db.file_version_exists(ident)) @@ -616,19 +616,19 @@ // content_merger /////////////////////////////////////////////////////////////////////////// -content_merger::content_merger(app_state & app, +content_merger::content_merger(app_state & app, roster_t const & anc_ros, - roster_t const & left_ros, + roster_t const & left_ros, roster_t const & right_ros, content_merge_adaptor & adaptor) - : app(app), - anc_ros(anc_ros), - left_ros(left_ros), + : app(app), + anc_ros(anc_ros), + left_ros(left_ros), right_ros(right_ros), adaptor(adaptor) {} -string +string content_merger::get_file_encoding(file_path const & path, roster_t const & ros) { @@ -638,7 +638,7 @@ return constants::default_encoding; } -bool +bool content_merger::attribute_manual_merge(file_path const & path, roster_t const & ros) { @@ -649,12 +649,12 @@ return false; // default: enable auto merge } -bool +bool content_merger::try_to_merge_files(file_path const & anc_path, file_path const & left_path, file_path const & right_path, file_path const & merged_path, - file_id const & ancestor_id, + file_id const & ancestor_id, file_id const & left_id, file_id const & right_id, file_id & merged_id) @@ -664,16 +664,16 @@ I(!null_id(ancestor_id)); I(!null_id(left_id)); I(!null_id(right_id)); - - L(FL("trying to merge %s <-> %s (ancestor: %s)\n") + + L(FL("trying to merge %s <-> %s (ancestor: %s)") % left_id % right_id % ancestor_id); if (left_id == right_id) { - L(FL("files are identical\n")); + L(FL("files are identical")); merged_id = left_id; - return true; - } + return true; + } file_data left_data, right_data, ancestor_data; data left_unpacked, ancestor_unpacked, right_unpacked, merged_unpacked; @@ -686,11 +686,11 @@ ancestor_unpacked = ancestor_data.inner(); right_unpacked = right_data.inner(); - if (!attribute_manual_merge(left_path, left_ros) && + if (!attribute_manual_merge(left_path, left_ros) && !attribute_manual_merge(right_path, right_ros)) { // both files mergeable by monotone internal algorithm, try to merge - // note: the ancestor is not considered for manual merging. Forcing the + // note: the ancestor is not considered for manual merging. Forcing the // user to merge manually just because of an ancestor mistakenly marked // manual seems too harsh string left_encoding, anc_encoding, right_encoding; @@ -702,26 +702,26 @@ split_into_lines(left_unpacked(), left_encoding, left_lines); split_into_lines(ancestor_unpacked(), anc_encoding, ancestor_lines); split_into_lines(right_unpacked(), right_encoding, right_lines); - - if (merge3(ancestor_lines, - left_lines, - right_lines, + + if (merge3(ancestor_lines, + left_lines, + right_lines, merged_lines)) { hexenc tmp_id; file_data merge_data; string tmp; - - L(FL("internal 3-way merged ok\n")); + + L(FL("internal 3-way merged ok")); join_lines(merged_lines, tmp); calculate_ident(data(tmp), tmp_id); file_id merged_fid(tmp_id); merge_data = file_data(tmp); - + merged_id = merged_fid; - adaptor.record_merge(left_id, right_id, merged_fid, + adaptor.record_merge(left_id, right_id, merged_fid, left_data, merge_data); - + return true; } } @@ -737,19 +737,19 @@ % merged_path); if (app.lua.hook_merge3(anc_path, left_path, right_path, merged_path, - ancestor_unpacked, left_unpacked, + ancestor_unpacked, left_unpacked, right_unpacked, merged_unpacked)) { hexenc tmp_id; file_data merge_data; - L(FL("lua merge3 hook merged ok\n")); + L(FL("lua merge3 hook merged ok")); calculate_ident(merged_unpacked, tmp_id); file_id merged_fid(tmp_id); merge_data = file_data(merged_unpacked); merged_id = merged_fid; - adaptor.record_merge(left_id, right_id, merged_fid, + adaptor.record_merge(left_id, right_id, merged_fid, left_data, merge_data); return true; } @@ -772,7 +772,7 @@ void walk_hunk_consumer(vector const & lcs, vector const & lines1, - vector const & lines2, + vector const & lines2, hunk_consumer & cons) { @@ -792,7 +792,7 @@ // normal case: files have something in common for (vector::const_iterator i = lcs.begin(); i != lcs.end(); ++i, ++a, ++b) - { + { if (idx(lines1, a) == *i && idx(lines2, b) == *i) continue; @@ -856,7 +856,7 @@ void unidiff_hunk_writer::delete_at(size_t a_pos) { a_len++; - hunk.push_back(string("-") + a[a_pos]); + hunk.push_back(string("-") + a[a_pos]); } void unidiff_hunk_writer::flush_hunk(size_t pos) @@ -866,12 +866,12 @@ // insert trailing context size_t a_pos = a_begin + a_len; for (size_t i = 0; (i < ctx) && (a_pos + i < a.size()); ++i) - { + { hunk.push_back(string(" ") + a[a_pos + i]); a_len++; b_len++; } - + // write hunk to stream if (a_len == 0) ost << "@@ -0,0"; @@ -881,7 +881,7 @@ if (a_len > 1) ost << "," << a_len; } - + if (b_len == 0) ost << " +0,0"; else @@ -891,10 +891,10 @@ ost << "," << b_len; } ost << " @@" << endl; - + copy(hunk.begin(), hunk.end(), ostream_iterator(ost, "\n")); } - + // reset hunk hunk.clear(); skew += b_len - a_len; @@ -933,7 +933,7 @@ { hunk.push_back(string(" ") + a[a_begin + a_len]); a_len++; - b_len++; + b_len++; } } } @@ -963,7 +963,7 @@ void flush_pending_mods(); virtual ~cxtdiff_hunk_writer() {} }; - + cxtdiff_hunk_writer::cxtdiff_hunk_writer(vector const & a, vector const & b, size_t ctx, @@ -979,7 +979,7 @@ inserts.push_back(b_pos); have_insertions = true; } - + void cxtdiff_hunk_writer::delete_at(size_t a_pos) { deletes.push_back(a_pos); @@ -1100,7 +1100,7 @@ from_file.push_back(string(" ") + a[a_begin + a_len]); to_file.push_back(string(" ") + a[a_begin + a_len]); a_len++; - b_len++; + b_len++; } } } @@ -1114,9 +1114,9 @@ ostream & ost, diff_type type) { - vector left_interned; - vector right_interned; - vector lcs; + vector left_interned; + vector right_interned; + vector lcs; interner in; @@ -1187,17 +1187,17 @@ for (size_t i = 0; i < mx; ++i) { cerr << "bad merge: " << i << " [" << prefix << "]\t"; - + if (i < expected.size()) cerr << "[" << expected[i] << "]\t"; else cerr << "[--nil--]\t"; - + if (i < got.size()) cerr << "[" << got[i] << "]\t"; else cerr << "[--nil--]\t"; - + cerr << endl; } } @@ -1216,7 +1216,7 @@ + "{\n" + " say_hello();\n" + "}\n"); - + string dst(string("#include \"hello.h\"\n") + "\n" + "void say_hello()\n" @@ -1234,7 +1234,7 @@ + " printf(\"goodbye\\n\");\n" + "}\n" + "\n"); - + string ud(string("--- hello.c\t0123456789abcdef0123456789abcdef01234567\n") + "+++ hello.c\tabcdef0123456789abcdef0123456789abcdef01\n" + "@@ -9,3 +9,9 @@\n" @@ -1270,7 +1270,7 @@ vector anc, d1, d2, m1, m2, gm; file_randomizer::build_random_fork(anc, d1, d2, gm, - i * 1023, (10 + 2 * i)); + i * 1023, (10 + 2 * i)); BOOST_CHECK(merge3(anc, d1, d2, m1)); if (gm != m1) @@ -1363,7 +1363,7 @@ split_into_lines(confl, cf); split_into_lines(desc2, d2); split_into_lines(good_merge, gm); - + BOOST_CHECK(merge3(anc, d1, d2, m1)); if (gm != m1) dump_incorrect_merge (gm, m1, "merge_addition 1"); ============================================================ --- diff_patch.hh 845e486548ebc492296e0a441557ad6ae96c741f +++ diff_patch.hh bd951a22eea247856e6f5971cadc165a82f56a3a @@ -38,27 +38,27 @@ std::vector const & right, std::vector & merged); -struct +struct content_merge_adaptor { - virtual void record_merge(file_id const & left_ident, - file_id const & right_ident, + virtual void record_merge(file_id const & left_ident, + file_id const & right_ident, file_id const & merged_ident, - file_data const & left_data, + file_data const & left_data, file_data const & merged_data) = 0; virtual void get_ancestral_roster(node_id nid, boost::shared_ptr & anc) = 0; - + virtual void get_version(file_path const & path, - file_id const & ident, + file_id const & ident, file_data & dat) = 0; virtual ~content_merge_adaptor() {} }; struct -content_merge_database_adaptor +content_merge_database_adaptor : public content_merge_adaptor { app_state & app; @@ -69,17 +69,17 @@ revision_id const & left, revision_id const & right, marking_map const & mm); - void record_merge(file_id const & left_ident, - file_id const & right_ident, + void record_merge(file_id const & left_ident, + file_id const & right_ident, file_id const & merged_ident, - file_data const & left_data, + file_data const & left_data, file_data const & merged_data); void get_ancestral_roster(node_id nid, boost::shared_ptr & anc); - + void get_version(file_path const & path, - file_id const & ident, + file_id const & ident, file_data & dat); }; @@ -91,20 +91,20 @@ app_state & app; boost::shared_ptr base; content_merge_workspace_adaptor (app_state & app, - boost::shared_ptr base) - : app(app), base(base) + boost::shared_ptr base) + : app(app), base(base) {} - void record_merge(file_id const & left_ident, - file_id const & right_ident, + void record_merge(file_id const & left_ident, + file_id const & right_ident, file_id const & merged_ident, - file_data const & left_data, + file_data const & left_data, file_data const & merged_data); void get_ancestral_roster(node_id nid, boost::shared_ptr & anc); - + void get_version(file_path const & path, - file_id const & ident, + file_id const & ident, file_data & dat); }; @@ -119,7 +119,7 @@ content_merger(app_state & app, roster_t const & anc_ros, - roster_t const & left_ros, + roster_t const & left_ros, roster_t const & right_ros, content_merge_adaptor & adaptor); @@ -135,7 +135,7 @@ std::string get_file_encoding(file_path const & path, roster_t const & ros); - + bool attribute_manual_merge(file_path const & path, roster_t const & ros); }; ============================================================ --- enumerator.cc e2ebd144f9f66f1dab7a5324c62e2f7d73eb4646 +++ enumerator.cc ec047b5f698ad0fb305210e16361c0008e010da4 @@ -41,7 +41,7 @@ load_graphs(); } -void +void revision_enumerator::load_graphs() { app.db.get_revision_ancestry(graph); @@ -52,7 +52,7 @@ } } -void +void revision_enumerator::get_revision_parents(revision_id const & child, vector & parents) { @@ -69,7 +69,7 @@ } -bool +bool revision_enumerator::all_parents_enumerated(revision_id const & child) { typedef multimap::const_iterator ci; @@ -92,8 +92,8 @@ } void -revision_enumerator::files_for_revision(revision_id const & r, - set & full_files, +revision_enumerator::files_for_revision(revision_id const & r, + set & full_files, set > & del_files) { // when we're sending a merge, we have to be careful if we @@ -119,7 +119,7 @@ { set file_dsts; cset const & cs = edge_changes(i); - + // Queue up all the file-adds for (map::const_iterator fa = cs.files_added.begin(); fa != cs.files_added.end(); ++fa) @@ -127,7 +127,7 @@ file_adds.insert(fa->second); file_dsts.insert(fa->second); } - + // Queue up all the file-deltas for (map >::const_iterator fd = cs.deltas_applied.begin(); @@ -147,7 +147,7 @@ full_files.clear(); size_t num_edges = rs.edges.size(); - for (map::const_iterator i = file_edge_counts.begin(); + for (map::const_iterator i = file_edge_counts.begin(); i != file_edge_counts.end(); i++) { MM(i->first); @@ -182,7 +182,7 @@ } -void +void revision_enumerator::get_revision_certs(revision_id const & rid, vector > & hashes) { @@ -201,8 +201,8 @@ app.db.get_revision_certs(rid, hashes); } } - -void + +void revision_enumerator::step() { while (!done()) @@ -216,13 +216,13 @@ // time around. Cull rather than reprocess. if (enumerated_nodes.find(r) != enumerated_nodes.end()) continue; - + if (!all_parents_enumerated(r)) { revs.push_back(r); continue; } - + if (terminal_nodes.find(r) == terminal_nodes.end()) { typedef multimap::const_iterator ci; @@ -288,8 +288,8 @@ items.push_back(item); } } - - // Queue up some or all of the rev's certs + + // Queue up some or all of the rev's certs vector > hashes; get_revision_certs(r, hashes); for (vector >::const_iterator i = hashes.begin(); @@ -307,28 +307,28 @@ if (!items.empty()) { - L(FL("revision_enumerator::step extracting item\n")); + L(FL("revision_enumerator::step extracting item")); enumerator_item i = items.front(); items.pop_front(); I(!null_id(i.ident_a)); - + switch (i.tag) { case enumerator_item::fdata: cb.note_file_data(file_id(i.ident_a)); break; - + case enumerator_item::fdelta: I(!null_id(i.ident_b)); cb.note_file_delta(file_id(i.ident_a), file_id(i.ident_b)); break; - + case enumerator_item::rev: cb.note_rev(revision_id(i.ident_a)); break; - + case enumerator_item::cert: cb.note_cert(i.ident_a); break; ============================================================ --- enumerator.hh 4f3ce29808f2bf2c0f65701e64ae379e369ab9fb +++ enumerator.hh 03863f83479e729dbcad98faee6140049f9e8768 @@ -36,7 +36,7 @@ virtual ~enumerator_callbacks() {} }; -struct +struct enumerator_item { enum { fdata, fdelta, rev, cert } tag; @@ -72,8 +72,8 @@ app_state & app); void load_graphs(); bool all_parents_enumerated(revision_id const & child); - void files_for_revision(revision_id const & r, - std::set & full_files, + void files_for_revision(revision_id const & r, + std::set & full_files, std::set > & del_files); void step(); bool done(); ============================================================ --- file_io.cc 7c50a2a9534b3e6a0f0f876f785b5a638d419f95 +++ file_io.cc b7b388fa5f4935c5e91038513ca1366b172fe154 @@ -92,21 +92,21 @@ } } -bool -path_exists(any_path const & p) -{ +bool +path_exists(any_path const & p) +{ return get_path_status(p) != path::nonexistent; } -bool -directory_exists(any_path const & p) -{ +bool +directory_exists(any_path const & p) +{ return get_path_status(p) == path::directory; } -bool -file_exists(any_path const & p) -{ +bool +file_exists(any_path const & p) +{ return get_path_status(p) == path::file; } @@ -143,7 +143,7 @@ init_char_is_binary(); } - for (size_t i = 0; i < s.size(); ++i) + for (size_t i = 0; i < s.size(); ++i) { if (char_is_binary[ static_cast(s[i]) ]) return true; @@ -157,9 +157,9 @@ return fs::path(p.as_external(), fs::native); } -void -mkdir_p(any_path const & p) -{ +void +mkdir_p(any_path const & p) +{ try { fs::create_directories(mkdir(p)); @@ -179,9 +179,9 @@ F("could not create directory '%s'\nit is a file") % p); } -void -make_dir_for(any_path const & p) -{ +void +make_dir_for(any_path const & p) +{ fs::path tmp(p.as_external(), fs::native); if (tmp.has_branch_path()) { @@ -208,9 +208,9 @@ } } -void -delete_file(any_path const & p) -{ +void +delete_file(any_path const & p) +{ require_path_is_file(p, F("file to delete '%s' does not exist") % p, F("file to delete, '%s', is not a file but a directory") % p); @@ -233,19 +233,19 @@ do_shallow_deletion_with_sane_error_message(p); } -void -delete_dir_recursive(any_path const & p) -{ +void +delete_dir_recursive(any_path const & p) +{ require_path_is_directory(p, F("directory to delete, '%s', does not exist") % p, F("directory to delete, '%s', is a file") % p); fs::remove_all(mkdir(p)); } -void +void move_file(any_path const & old_path, - any_path const & new_path) -{ + any_path const & new_path) +{ require_path_is_file(old_path, F("rename source file '%s' does not exist") % old_path, F("rename source file '%s' is a directory " @@ -255,10 +255,10 @@ fs::rename(mkdir(old_path), mkdir(new_path)); } -void +void move_dir(any_path const & old_path, - any_path const & new_path) -{ + any_path const & new_path) +{ require_path_is_directory(old_path, F("rename source dir '%s' does not exist") % old_path, F("rename source dir '%s' is a file " @@ -286,7 +286,7 @@ } } -void +void read_data(any_path const & p, data & dat) { require_path_is_file(p, @@ -359,11 +359,11 @@ // but you might want to make this code a bit tighter. -static void +static void write_data_impl(any_path const & p, data const & dat, any_path const & tmp) -{ +{ N(!directory_exists(p), F("file '%s' cannot be overwritten as data; it is a directory") % p); @@ -385,7 +385,7 @@ static void write_data_impl(any_path const & p, data const & dat) -{ +{ // we write, non-atomically, to _MTN/data.tmp. // nb: no mucking around with multiple-writer conditions. we're a // single-user single-threaded program. you get what you paid for. @@ -395,16 +395,16 @@ write_data_impl(p, dat, tmp); } -void +void write_data(file_path const & path, data const & dat) -{ - write_data_impl(path, dat); +{ + write_data_impl(path, dat); } -void +void write_data(bookkeeping_path const & path, data const & dat) -{ - write_data_impl(path, dat); +{ + write_data_impl(path, dat); } void @@ -418,7 +418,7 @@ tree_walker::~tree_walker() {} -static void +static void walk_tree_recursive(fs::path const & absolute, fs::path const & relative, tree_walker & walker) @@ -431,16 +431,16 @@ // the fs::native is necessary here, or it will bomb out on any paths // that look at it funny. (E.g., rcs files with "," in the name.) fs::path rel_entry = relative / fs::path(entry.leaf(), fs::native); - + if (bookkeeping_path::is_bookkeeping_path(rel_entry.normalize().string())) { - L(FL("ignoring book keeping entry %s\n") % rel_entry.string()); + L(FL("ignoring book keeping entry %s") % rel_entry.string()); continue; } - - if (!fs::exists(entry) - || di->string() == "." - || di->string() == "..") + + if (!fs::exists(entry) + || di->string() == "." + || di->string() == "..") { // ignore continue; @@ -448,14 +448,14 @@ else { file_path p; - try + try { // FIXME: BUG: this screws up charsets p = file_path_internal(rel_entry.normalize().string()); } catch (runtime_error const & c) { - W(F("caught runtime error %s constructing file path for %s\n") + W(F("caught runtime error %s constructing file path for %s") % c.what() % rel_entry.string()); continue; } @@ -480,7 +480,7 @@ // from some (safe) sub-entry of cwd -void +void walk_tree(file_path const & path, tree_walker & walker, bool require_existing_path) @@ -490,7 +490,7 @@ walk_tree_recursive(fs::current_path(), fs::path(), walker); return; } - + switch (get_path_status(path)) { case path::nonexistent: @@ -512,7 +512,7 @@ #ifdef BUILD_UNIT_TESTS #include "unit_tests.hh" -void +void add_file_io_tests(test_suite * suite) { I(suite); ============================================================ --- globish.cc 409df5d1f8ff0ad46a144ed6f1344418185d54dc +++ globish.cc febd0cd30ba4ec07bf0012a8f51081b953928132 @@ -51,7 +51,7 @@ regex.clear(); regex.reserve(glob.size() * 2); - L(FL("checked_globish_to_regex: input = '%s'\n") % glob); + L(FL("checked_globish_to_regex: input = '%s'") % glob); if (glob == "") { @@ -61,9 +61,9 @@ for (string::const_iterator i = glob.begin(); i != glob.end(); ++i) { char c = *i; - + N(in_braces < 5, F("braces nested too deep in pattern '%s'") % glob); - + switch(c) { case '*': @@ -97,11 +97,11 @@ break; } } - + N(in_braces == 0, F("run-away brace expression in pattern '%s'") % glob); - L(FL("checked_globish_to_regex: output = '%s'\n") % regex); + L(FL("checked_globish_to_regex: output = '%s'") % regex); } void @@ -143,7 +143,7 @@ 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") + L(FL("matching '%s' against '%s' excluding '%s': %s, %s: %s") % s % r_inc % r_exc % (inc_match ? "included" : "not included") % (exc_match ? "excluded" : "not excluded") ============================================================ --- hash_map.hh 98827ec1d7ba91683c64e731820f434f022fdbe0 +++ hash_map.hh e2f34bc96b7ca591a50dc687cc42e3c84f8507a7 @@ -17,7 +17,7 @@ { // bool operator()(_T const & b, _T const & b) const; }; - + template struct hash { @@ -49,20 +49,20 @@ return __gnu_cxx::__stl_hash_string(s.c_str()); } }; - + template class hash_map : public __gnu_cxx::hash_map<_Key, _Value, hash<_Key>, equal_to<_Key> > {}; - + template class hash_set : public __gnu_cxx::hash_set<_Key, hash<_Key>, equal_to<_Key> > {}; - + template class hash_multimap : public __gnu_cxx::hash_multimap<_Key, _Value, @@ -100,13 +100,13 @@ hash<_Key>, equal_to<_Key> > {}; - + template class hash_set : public std::hash_set<_Key, hash<_Key>, equal_to<_Key> > {}; - + template class hash_multimap : public std::hash_multimap<_Key, _Value, @@ -121,7 +121,7 @@ #include #include -namespace hashmap +namespace hashmap { template<> struct hash ============================================================ --- hmac.cc 668380c352db46c0cefbababed90462db529f486 +++ hmac.cc 472764cfd31f8de5fa089b2ba56f399e52a69c67 @@ -10,7 +10,7 @@ using std::string; chained_hmac::chained_hmac(netsync_session_key const & session_key, bool active) : - hmac_length(constants::sha1_digest_length), + hmac_length(constants::sha1_digest_length), active(active), key(reinterpret_cast(session_key().data()), session_key().size()) { @@ -67,7 +67,7 @@ p.start_msg(); p.write(chain_val); p.write(reinterpret_cast(str.front_pointer(n) + pos), n); - + p.end_msg(); chain_val = p.read_all_as_string(); ============================================================ --- hmac.hh e3082711a437a693ba707ca763e1c2f6755efaba +++ hmac.hh ad2e9fd10edb10a0c65839da6312ca71ce711c24 @@ -13,14 +13,14 @@ public: chained_hmac(netsync_session_key const & session_key, bool active); void set_key(netsync_session_key const & session_key); - std::string process(std::string const & str, size_t pos = 0, + std::string process(std::string const & str, size_t pos = 0, size_t n = std::string::npos); - std::string process(string_queue const & str, size_t pos = 0, + std::string process(string_queue const & str, size_t pos = 0, size_t n = std::string::npos); - + size_t const hmac_length; bool is_active() { return active; } - + private: bool active; Botan::SymmetricKey key; ============================================================ --- inodeprint.cc 62b091111b84a22f6de804b3c9d37716e7a06169 +++ inodeprint.cc adf50d2f722a8a5e13d28c8203162d6d0b7bba14 @@ -26,7 +26,7 @@ // reading inodeprint_maps -void +void read_inodeprint_map(data const & dat, inodeprint_map & ipm) { @@ -55,14 +55,14 @@ // writing inodeprint_maps -ostream & +ostream & operator<<(ostream & out, inodeprint_entry const & e) { return (out << e.second << " " << e.first << "\n"); } -void +void write_inodeprint_map(inodeprint_map const & ipm, data & dat) { ============================================================ --- inodeprint.hh 3db3005b0230aa489265417b80cba28a74dc406e +++ inodeprint.hh 5854a71f0c57d01e06cb736bfb4edc66d34f40b2 @@ -12,8 +12,8 @@ typedef std::pair > inodeprint_entry; -typedef std::map, - std::less, +typedef std::map, + std::less, QA(inodeprint_entry) > inodeprint_map; std::ostream & operator<<(std::ostream & out, inodeprint_entry const & e); @@ -23,7 +23,7 @@ void read_inodeprint_map(data const & dat, inodeprint_map & ipm); -void write_inodeprint_map(inodeprint_map const & ipm, +void write_inodeprint_map(inodeprint_map const & ipm, data & dat); ============================================================ --- interner.hh 70ca14f55628cab86911c21d846931cb64d3319d +++ interner.hh f80a165b21302d7384cac0c7564f06999bbe9c60 @@ -12,8 +12,8 @@ #include "sanity.hh" template -struct -interner +struct +interner { typedef typename hashmap::hash_map hmap; @@ -35,7 +35,7 @@ bool is_new; return intern(s, is_new); } - T intern(std::string const & s, bool & is_new) + T intern(std::string const & s, bool & is_new) { std::pair res; T t = rev.size(); ============================================================ --- key_store.cc dcdebf60e129b121b78cc0f2c53e3c7a19cf69a9 +++ key_store.cc 489c4d61423a5d93788c13358311a6f710cf432f @@ -19,15 +19,15 @@ key_store * ks; keyreader(key_store * k): ks(k) {} - virtual void consume_file_data(file_id const & ident, + virtual void consume_file_data(file_id const & ident, file_data const & dat) {E(false, F("Extraneous data in key store."));} - virtual void consume_file_delta(file_id const & id_old, + virtual void consume_file_delta(file_id const & id_old, file_id const & id_new, file_delta const & del) {E(false, F("Extraneous data in key store."));} - virtual void consume_revision_data(revision_id const & ident, + virtual void consume_revision_data(revision_id const & ident, revision_data const & dat) {E(false, F("Extraneous data in key store."));} virtual void consume_revision_cert(revision const & t) @@ -49,7 +49,7 @@ key_hash_code(ident, kp.pub, hash); ks->hashes.insert(make_pair(hash, ident)); L(FL("successfully read key pair '%s' from key store") % ident); - } + } }; key_store::key_store(app_state * a): have_read(false), app(a) @@ -211,7 +211,7 @@ } void -key_store::put_key_pair(rsa_keypair_id const & ident, +key_store::put_key_pair(rsa_keypair_id const & ident, keypair const & kp) { maybe_read_key_dir(); ============================================================ --- key_store.hh 6821800c3a5f562b7d8aa747e8b232e0b37a9bda +++ key_store.hh 08c0ac89d69b00b55cccad9fde8ee2e30229e1f9 @@ -43,7 +43,7 @@ void get_key_pair(rsa_keypair_id const & ident, keypair & kp); - void put_key_pair(rsa_keypair_id const & ident, + void put_key_pair(rsa_keypair_id const & ident, keypair const & kp); void delete_key(rsa_keypair_id const & ident); ============================================================ --- keys.cc 3d835d4757415bf43f821941e2a37bdbc1c4f2db +++ keys.cc a72e7d7009481fac53ef5086f2f2ccea4b14f5c6 @@ -53,11 +53,11 @@ // there will probably forever be bugs in this file. it's very // hard to get right, portably and securely. sorry about that. -static void +static void do_arc4(SecureVector & sym_key, SecureVector & payload) { - L(FL("running arc4 process on %d bytes of data\n") % payload.size()); + L(FL("running arc4 process on %d bytes of data") % payload.size()); Pipe enc(get_cipher("ARC4", sym_key, Botan::ENCRYPTION)); enc.process_msg(payload); payload = enc.read_all(); @@ -65,7 +65,7 @@ // 'force_from_user' means that we don't use the passphrase cache, and we // don't use the get_passphrase hook. -static void +static void get_passphrase(lua_hooks & lua, rsa_keypair_id const & keyid, string & phrase, @@ -80,7 +80,7 @@ // something. bool persist_phrase = lua.hook_persist_phrase_ok(); static map phrases; - + if (!force_from_user && phrases.find(keyid) != phrases.end()) { phrase = phrases[keyid]; @@ -94,7 +94,7 @@ F("got empty passphrase from get_passphrase() hook")); } else - { + { char pass1[constants::maxpasswd]; char pass2[constants::maxpasswd]; for (int i = 0; i < 3; ++i) @@ -119,15 +119,15 @@ cout << endl; if (strlen(pass1) == 0 || strlen(pass2) == 0) { - P(F("empty passphrases not allowed, try again\n")); - N(i < 2, F("too many failed passphrases\n")); + P(F("empty passphrases not allowed, try again")); + N(i < 2, F("too many failed passphrases")); } else if (strcmp(pass1, pass2) == 0) break; else { - P(F("passphrases do not match, try again\n")); - N(i < 2, F("too many failed passphrases\n")); + P(F("passphrases do not match, try again")); + N(i < 2, F("too many failed passphrases")); } } else @@ -135,7 +135,7 @@ } N(strlen(pass1) != 0, F("no passphrase given")); - try + try { phrase = pass1; @@ -145,7 +145,7 @@ phrases.erase(keyid); safe_insert(phrases, make_pair(keyid, string(pass1))); } - } + } catch (...) { memset(pass1, 0, constants::maxpasswd); @@ -155,21 +155,21 @@ memset(pass1, 0, constants::maxpasswd); memset(pass2, 0, constants::maxpasswd); } -} +} -void +void generate_key_pair(lua_hooks & lua, // to hook for phrase rsa_keypair_id const & id, // to prompting user for phrase keypair & kp_out, string const unit_test_passphrase) { - + string phrase; SecureVector pubkey, privkey; rsa_pub_key raw_pub_key; rsa_priv_key raw_priv_key; - + // generate private key (and encrypt it) RSA_PrivateKey priv(constants::keylen); @@ -180,16 +180,16 @@ Pipe p; p.start_msg(); - Botan::PKCS8::encrypt_key(priv, p, phrase, + Botan::PKCS8::encrypt_key(priv, p, phrase, "PBE-PKCS5v20(SHA-1,TripleDES/CBC)", Botan::RAW_BER); raw_priv_key = rsa_priv_key(p.read_all_as_string()); - + // generate public key Pipe p2; p2.start_msg(); Botan::X509::encode(priv, p2, Botan::RAW_BER); raw_pub_key = rsa_pub_key(p2.read_all_as_string()); - + // if all that worked, we can return our results to caller encode_base64(raw_priv_key, kp_out.priv); encode_base64(raw_pub_key, kp_out.pub); @@ -210,15 +210,15 @@ string phrase; bool force = force_from_user; - L(FL("base64-decoding %d-byte private key\n") % priv().size()); + L(FL("base64-decoding %d-byte private key") % priv().size()); decode_base64(priv, decoded_key); for (int i = 0; i < 3; ++i) { get_passphrase(lua, id, phrase, false, force); - L(FL("have %d-byte encrypted private key\n") % decoded_key().size()); + L(FL("have %d-byte encrypted private key") % decoded_key().size()); shared_ptr pkcs8_key; - try + try { Pipe p; p.process_msg(decoded_key()); @@ -260,21 +260,21 @@ // need to decrypt the old key shared_ptr priv_key; - L(FL("base64-decoding %d-byte old private key\n") % old_priv().size()); + L(FL("base64-decoding %d-byte old private key") % old_priv().size()); decode_base64(old_priv, decoded_key); for (int i = 0; i < 3; ++i) { - decrypted_key.set(reinterpret_cast(decoded_key().data()), + decrypted_key.set(reinterpret_cast(decoded_key().data()), decoded_key().size()); get_passphrase(app.lua, id, phrase, false, force); SecureVector sym_key; sym_key.set(reinterpret_cast(phrase.data()), phrase.size()); do_arc4(sym_key, decrypted_key); - L(FL("building signer from %d-byte decrypted private key\n") % decrypted_key.size()); + L(FL("building signer from %d-byte decrypted private key") % decrypted_key.size()); shared_ptr pkcs8_key; - try + try { Pipe p; p.process_msg(decrypted_key); @@ -300,7 +300,7 @@ // now we can write out the new key Pipe p; p.start_msg(); - Botan::PKCS8::encrypt_key(*priv_key, p, phrase, + Botan::PKCS8::encrypt_key(*priv_key, p, phrase, "PBE-PKCS5v20(SHA-1,TripleDES/CBC)", Botan::RAW_BER); rsa_priv_key raw_priv = rsa_priv_key(p.read_all_as_string()); encode_base64(raw_priv, new_kp.priv); @@ -325,14 +325,14 @@ Pipe p; p.start_msg(); - Botan::PKCS8::encrypt_key(*priv, p, new_phrase, + Botan::PKCS8::encrypt_key(*priv, p, new_phrase, "PBE-PKCS5v20(SHA-1,TripleDES/CBC)", Botan::RAW_BER); rsa_priv_key decoded_key = rsa_priv_key(p.read_all_as_string()); encode_base64(decoded_key, encoded_key); } -void +void make_signature(app_state & app, // to hook for phrase rsa_keypair_id const & id, // to prompting user for phrase base64< rsa_priv_key > const & priv, @@ -358,7 +358,7 @@ { priv_key = get_private_key(app.lua, id, priv); signer = shared_ptr(get_pk_signer(*priv_key, "EMSA3(SHA-1)")); - + /* XXX This is ugly. We need to keep the key around as long * as the signer is around, but the shared_ptr for the key will go * away after we leave this scope. Hence we store a pair of @@ -369,14 +369,14 @@ sig = signer->sign_message(reinterpret_cast(tosign.data()), tosign.size()); sig_string = string(reinterpret_cast(sig.begin()), sig.size()); - - L(FL("produced %d-byte signature\n") % sig_string.size()); + + L(FL("produced %d-byte signature") % sig_string.size()); encode_base64(rsa_sha1_signature(sig_string), signature); } -bool +bool check_signature(app_state &app, - rsa_keypair_id const & id, + rsa_keypair_id const & id, base64 const & pub_encoded, string const & alleged_text, base64 const & signature) @@ -387,7 +387,7 @@ shared_ptr verifier; shared_ptr pub_key; - if (persist_phrase + if (persist_phrase && app.verifiers.find(id) != app.verifiers.end()) verifier = app.verifiers[id].first; @@ -398,7 +398,7 @@ SecureVector pub_block; pub_block.set(reinterpret_cast(pub().data()), pub().size()); - L(FL("building verifier for %d-byte pub key\n") % pub_block.size()); + L(FL("building verifier for %d-byte pub key") % pub_block.size()); shared_ptr x509_key = shared_ptr(Botan::X509::load_key(pub_block)); pub_key = shared_dynamic_cast(x509_key); @@ -407,8 +407,8 @@ verifier = shared_ptr(get_pk_verifier(*pub_key, "EMSA3(SHA-1)")); - /* XXX This is ugly. We need to keep the key around - * as long as the verifier is around, but the shared_ptr will go + /* XXX This is ugly. We need to keep the key around + * as long as the verifier is around, but the shared_ptr will go * away after we leave this scope. Hence we store a pair of * so they both exist. */ if (persist_phrase) @@ -420,7 +420,7 @@ decode_base64(signature, sig_decoded); // check the text+sig against the key - L(FL("checking %d-byte (%d decoded) signature\n") % + L(FL("checking %d-byte (%d decoded) signature") % signature().size() % sig_decoded().size()); bool valid_sig = verifier->verify_message( @@ -472,20 +472,20 @@ plaintext = string(reinterpret_cast(plain.begin()), plain.size()); } -void -read_pubkey(string const & in, +void +read_pubkey(string const & in, rsa_keypair_id & id, base64 & pub) { string tmp_id, tmp_key; size_t pos = 0; extract_variable_length_string(in, tmp_id, pos, "pubkey id"); - extract_variable_length_string(in, tmp_key, pos, "pubkey value"); + extract_variable_length_string(in, tmp_key, pos, "pubkey value"); id = tmp_id; encode_base64(rsa_pub_key(tmp_key), pub); } -void +void write_pubkey(rsa_keypair_id const & id, base64 const & pub, string & out) @@ -497,16 +497,16 @@ } -void +void key_hash_code(rsa_keypair_id const & ident, base64 const & pub, hexenc & out) { data tdat(ident() + ":" + remove_ws(pub())); - calculate_ident(tdat, out); + calculate_ident(tdat, out); } -void +void key_hash_code(rsa_keypair_id const & ident, base64< rsa_priv_key > const & priv, hexenc & out) @@ -517,7 +517,7 @@ // helper to compare if two keys have the same hash // (ie are the same key) -bool +bool keys_match(rsa_keypair_id const & id1, base64 const & key1, rsa_keypair_id const & id2, @@ -529,7 +529,7 @@ return hash1 == hash2; } -bool +bool keys_match(rsa_keypair_id const & id1, base64< rsa_priv_key > const & key1, rsa_keypair_id const & id2, @@ -590,7 +590,7 @@ } -static void +static void signature_round_trip_test() { app_state app; @@ -606,16 +606,16 @@ string plaintext("test string to sign"); base64 sig; make_signature(app, key, kp.priv, plaintext, sig); - + BOOST_CHECKPOINT("checking signature"); BOOST_CHECK(check_signature(app, key, kp.pub, plaintext, sig)); - + string broken_plaintext = plaintext + " ...with a lie"; BOOST_CHECKPOINT("checking non-signature"); BOOST_CHECK(!check_signature(app, key, kp.pub, broken_plaintext, sig)); } -void +void add_key_tests(test_suite * suite) { I(suite); ============================================================ --- keys.hh 8ef7487642f3f7cc3e9bfa80ce88770467edac3d +++ keys.hh 55a0ad2a67a0c6f30b3fc16ac1dd9a904ebd400f @@ -13,7 +13,7 @@ class app_state; // keys.{hh,cc} does all the "delicate" crypto (meaning: that which needs -// to read passphrases and manipulate raw, decrypted private keys). it +// to read passphrases and manipulate raw, decrypted private keys). it // could in theory be in transforms.cc too, but that file's already kinda // big and this stuff "feels" different, imho. @@ -63,7 +63,7 @@ // netsync stuff -void read_pubkey(std::string const & in, +void read_pubkey(std::string const & in, rsa_keypair_id & id, base64 & pub); ============================================================ --- lcs.cc 11c987c3b32ff3c1c860030dc298b5a5547fc2fa +++ lcs.cc 5534a43bd5c14750bf13fde28cfc80b14af0e9fb @@ -1,4 +1,4 @@ -/* +/* this is a pretty direct translation (with only vague understanding, unfortunately) of aubrey jaffer's most recent O(NP) edit-script @@ -16,7 +16,7 @@ computational biology. apparantly it's submitted for publication there too. - --- + --- "differ.scm" O(NP) Sequence Comparison Algorithm. Copyright (C) 2001, 2002, 2003 Aubrey Jaffer @@ -59,7 +59,7 @@ long lo; long hi; static vector vec; - work_vec(long lo, long hi) : + work_vec(long lo, long hi) : lo(lo), hi(hi) { // I(hi >= lo); @@ -68,10 +68,10 @@ vec.assign(len, -1); } - inline long & operator[](long t) + inline long & operator[](long t) { // I(t >= lo && t <= hi); - return vec[t-lo]; + return vec[t-lo]; } }; @@ -79,7 +79,7 @@ template + typename LCS> struct jaffer_edit_calculator { @@ -94,8 +94,8 @@ T base; // underlying representation long start; // current extent long end; // current extent - - subarray(T b, long s, long e) : + + subarray(T b, long s, long e) : base(b), start(s), end(e) {} inline long size() const @@ -105,12 +105,12 @@ else return end - start; } - + inline subarray subset(long s, long e) const { return subarray(base + min(start, end), s, e); } - + inline vt const & operator[](size_t idx) const { if (end < start) @@ -118,15 +118,15 @@ else return *(base + (start + idx)); } - }; + }; - static long run(work_vec & fp, long k, + static long run(work_vec & fp, long k, subarray const & a, long m, subarray const & b, long n, cost_vec & CC, long p) { long cost = k + 2*p; - + // do the run long y = max(fp[k-1]+1, fp[k+1]); long x = y - k; @@ -135,13 +135,13 @@ I(x >= 0); while (true) - { + { // record costs along the way long xcst = m - x; if (y < static_cast(CC.size()) && xcst >= 0) { - CC[y] = min(xcst + cost, CC[y]); - } + CC[y] = min(xcst + cost, CC[y]); + } if (x < m && y < n && a[x] == b[y]) { ++x; ++y; @@ -155,7 +155,7 @@ } // 'compare' here is the core myers, manber and miller algorithm. - static long compare(cost_vec & costs, + static long compare(cost_vec & costs, subarray const & a, long m, subarray const & b, long n, long p_lim, @@ -193,11 +193,11 @@ return delta + 2*p; } - + static long divide_and_conquer(subarray const & a, long start_a, long end_a, subarray const & b, long start_b, long end_b, edit_vec & edits, - unsigned long edx, + unsigned long edx, long polarity, long p_lim) { @@ -214,15 +214,15 @@ I(end_a <= a.size()); I(end_b >= 0); I(end_b <= b.size()); - + cost_vec cc(len_b + 1, len_a + len_b); cost_vec rr(len_b + 1, len_a + len_b); - compare (cc, + compare (cc, a.subset(start_a, mid_a), (mid_a - start_a), b.subset(start_b, end_b), len_b, min(p_lim, len_a)); - compare (rr, + compare (rr, a.subset(end_a, mid_a), (end_a - mid_a), b.subset(end_b, start_b), len_b, min(p_lim, len_a)); @@ -233,22 +233,22 @@ long cost_c = diff_to_et (a, start_a, mid_a, b, start_b, start_b + b_split, - edits, edx, polarity, + edits, edx, polarity, (est_c - (b_split - (mid_a - start_a))) / 2); I(cost_c == est_c); - + long cost_r = diff_to_et (a, mid_a, end_a, b, start_b + b_split, end_b, edits, est_c + edx, polarity, (est_r - ((len_b - b_split) - (end_a - mid_a))) / 2); I(cost_r == est_r); - + return est_r + est_c; } - - static long mid_split(long m, long n, + + static long mid_split(long m, long n, cost_vec const & rr, cost_vec const & cc, long cost) @@ -259,16 +259,16 @@ { I (rdx >= 0); - if (cost == (cc[rdx] + rr[n-rdx])) + if (cost == (cc[rdx] + rr[n-rdx])) return rdx; if (cost == (cc[cdx] + rr[n-cdx])) - return cdx; + return cdx; --rdx; ++cdx; } } - - + + static void order_edits(edit_vec const & edits, long sign, edit_vec & nedits) @@ -276,13 +276,13 @@ nedits.clear(); nedits.resize(edits.size()); long cost = edits.size(); - + if (cost == 0) { nedits = edits; return; } - + edit_vec sedits = edits; sort(sedits.begin(), sedits.end()); @@ -290,25 +290,25 @@ for (idx0 = 0; idx0 < cost && sedits[idx0] < 0; ++idx0); long len_a = max(0L, -sedits[0]); long len_b = sedits[cost-1]; - + long ddx = idx0 - 1; long idx = idx0; long ndx = 0; long adx = 0; long bdx = 0; - + while (bdx < len_b || adx < len_a) { long del = (ddx < 0) ? 0 : sedits[ddx]; long ins = (idx >= cost) ? 0 : sedits[idx]; - + if (del < 0 && adx >= (-1 - del) && ins > 0 && bdx >= (-1 + ins)) { nedits[ndx] = del; nedits[ndx+1] = ins; - --ddx; ++idx; ndx += 2; ++adx; ++bdx; + --ddx; ++idx; ndx += 2; ++adx; ++bdx; } else if (del < 0 && adx >= (-1 - del)) { @@ -326,7 +326,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, @@ -348,28 +348,28 @@ I(end_a - start_a >= p_lim); long bsx, bdx, asx, adx; - + for (bdx = end_b - 1, adx = end_a - 1; - (start_b <= bdx) && (start_a <= adx) && (a[adx] == b[bdx]); + (start_b <= bdx) && (start_a <= adx) && (a[adx] == b[bdx]); --bdx, --adx); - + for (bsx = start_b, asx = start_a; (bsx < bdx) && (asx < adx) && (a[asx] == b[bsx]); ++bsx, ++asx); - + // we've trimmed; now call diff_to_ez. - + long delta = (bdx - bsx) - (adx - asx); if (delta < 0) - return diff_to_ez (b, bsx, bdx+1, + return diff_to_ez (b, bsx, bdx+1, a, asx, adx+1, edits, edx, -polarity, delta + p_lim); else return diff_to_ez (a, asx, adx+1, - b, bsx, bdx+1, - edits, edx, polarity, p_lim); + b, bsx, bdx+1, + edits, edx, polarity, p_lim); } - + static long diff_to_ez(subarray const & a, long start_a, long end_a, subarray const & b, long start_b, long end_b, vector & edits, @@ -398,26 +398,26 @@ // A == B, no edits if (len_a == len_b) return 0; - + long adx = start_a; long bdx = start_b; long edx0 = edx1; - + while (true) - { + { if (bdx >= end_b) return len_b - len_a; - + if (adx >= end_a) { - for (long idx = bdx, edx = edx0; - idx < end_b; + for (long idx = bdx, edx = edx0; + idx < end_b; ++idx, ++edx) edits[edx] = polarity * (idx+1); - - return len_b - len_a; + + return len_b - len_a; } - + if (a[adx] == b[bdx]) { ++adx; ++bdx; @@ -429,22 +429,22 @@ } } } - + // easy case #2: delete all A, insert all B - else if (len_a <= p_lim) + else if (len_a <= p_lim) { I(len_a == p_lim); long edx0 = edx1; for (long idx = start_a; idx < end_a; ++idx, ++edx0) edits[edx0] = polarity * (-1 - idx); - + for (long jdx = start_b; jdx < end_b; ++jdx, ++edx0) edits[edx0] = polarity * (jdx + 1); - + return len_a + len_b; } - + // hard case: recurse on subproblems else { @@ -453,7 +453,7 @@ edits, edx1, polarity, p_lim); } } - + static void diff_to_edits(subarray const & a, long m, subarray const & b, long n, vector & edits, @@ -465,13 +465,13 @@ edits.clear(); edits.resize(edit_distance, 0); - long cost = diff_to_et(a, 0, m, - b, 0, n, + long cost = diff_to_et(a, 0, m, + b, 0, n, edits, 0, 1, (edit_distance - (n-m)) / 2); I(cost == edit_distance); } - - static void edits_to_lcs (vector const & edits, + + static void edits_to_lcs (vector const & edits, subarray const a, long m, long n, LCS output) { @@ -481,7 +481,7 @@ while (true) { long edit = (edx < static_cast(edits.size())) ? edits[edx] : 0; - + if (adx >= m) break; else if (edit > 0) @@ -566,7 +566,7 @@ } -void +void longest_common_subsequence(vector::const_iterator begin_a, vector::const_iterator end_a, vector::const_iterator begin_b, @@ -579,7 +579,7 @@ p_lim, lcs); } -void +void edit_script(vector::const_iterator begin_a, vector::const_iterator end_a, vector::const_iterator begin_b, @@ -588,8 +588,8 @@ vector & edits_out) { vector lcs; - _edit_script(begin_a, end_a, - begin_b, end_b, + _edit_script(begin_a, end_a, + begin_b, end_b, p_lim, edits_out, back_inserter(lcs)); } ============================================================ --- lcs.hh 8fd9c138a9fb9baa870ebdf56723bb5ef189a081 +++ lcs.hh dfdece3a1525237aa7ac5996a76cf0d64671e59f @@ -10,7 +10,7 @@ #include #include "quick_alloc.hh" -void +void longest_common_subsequence(std::vector::const_iterator begin_a, std::vector::const_iterator end_a, std::vector::const_iterator begin_b, @@ -18,7 +18,7 @@ long p_lim, std::back_insert_iterator< std::vector > lcs); -void +void edit_script(std::vector::const_iterator begin_a, std::vector::const_iterator end_a, std::vector::const_iterator begin_b, ============================================================ --- legacy.cc cb7eb7d67ccf5f3b3d762c3889a90f1e17509222 +++ legacy.cc fef9d94af73fe443c3ec75ae2a47c01ab826377f @@ -13,7 +13,7 @@ namespace legacy { - namespace + namespace { namespace syms { @@ -28,9 +28,9 @@ basic_io::input_source src(dat(), ".mt-attrs"); basic_io::tokenizer tok(src); basic_io::parser parser(tok); - + string file, name, value; - + attr.clear(); while (parser.symp(syms::file)) @@ -38,8 +38,8 @@ parser.sym(); parser.str(file); file_path fp = file_path_internal(file); - - while (parser.symp() && + + while (parser.symp() && !parser.symp(syms::file)) { parser.sym(name); @@ -49,7 +49,7 @@ } } - namespace + namespace { namespace syms { @@ -66,7 +66,7 @@ symbol const rename_dir("rename_dir"); } } - + // cf. revision.cc:parse_edge and change_set.cc:parse_change_set and // change_set.cc:parse_path_rearrangement in the pre-roster code. static void @@ -118,7 +118,7 @@ } // cf. revision.cc:parse_revision in the pre-roster code. - void + void get_manifest_and_renames_for_rev(app_state & app, revision_id const & ident, manifest_id & mid, @@ -139,7 +139,7 @@ } // cf. manifest.cc:read_manifest_map in the pre-roster code. - void + void read_manifest_map(manifest_data const & mdat, manifest_map & man) { @@ -166,5 +166,5 @@ } return; } - + } ============================================================ --- legacy.hh 4759323523ca05da97a2d525c629b3b0e446a674 +++ legacy.hh ca42f4646c6f80ec2bf9f8d332efa8aebdd92f85 @@ -21,7 +21,7 @@ // parser for old .mt-attrs file format typedef std::map > dot_mt_attrs_map; - void + void read_dot_mt_attrs(data const & dat, dot_mt_attrs_map & attr); /////// @@ -36,7 +36,7 @@ typedef std::map > renames_map; - void + void get_manifest_and_renames_for_rev(app_state & app, revision_id const & ident, manifest_id & mid, @@ -44,7 +44,7 @@ /////// // parsing old-style manifests, for 'rosterify' and 'changesetify' commands - typedef std::map > manifest_map; void read_manifest_map(manifest_data const & mdat, manifest_map & man); ============================================================ --- localized_file_io.cc a224f91ef63f02d73e12173351f918b30c526075 +++ localized_file_io.cc 8d36617800f80f983c2e9be3724555b6c9eea95d @@ -33,23 +33,23 @@ return true; } -void -read_localized_data(file_path const & path, - data & dat, +void +read_localized_data(file_path const & path, + data & dat, lua_hooks & lua) { string db_linesep, ext_linesep; string db_charset, ext_charset; - - bool do_lineconv = (lua.hook_get_linesep_conv(path, db_linesep, ext_linesep) + + bool do_lineconv = (lua.hook_get_linesep_conv(path, db_linesep, ext_linesep) && db_linesep != ext_linesep); - bool do_charconv = (lua.hook_get_charset_conv(path, db_charset, ext_charset) + bool do_charconv = (lua.hook_get_charset_conv(path, db_charset, ext_charset) && db_charset != ext_charset); data tdat; read_data(path, tdat); - + string tmp1, tmp2; tmp2 = tdat(); if (do_charconv) { @@ -63,20 +63,20 @@ dat = tmp2; } -void -write_localized_data(file_path const & path, - data const & dat, +void +write_localized_data(file_path const & path, + data const & dat, lua_hooks & lua) { string db_linesep, ext_linesep; string db_charset, ext_charset; - - bool do_lineconv = (lua.hook_get_linesep_conv(path, db_linesep, ext_linesep) + + bool do_lineconv = (lua.hook_get_linesep_conv(path, db_linesep, ext_linesep) && db_linesep != ext_linesep); - bool do_charconv = (lua.hook_get_charset_conv(path, db_charset, ext_charset) + bool do_charconv = (lua.hook_get_charset_conv(path, db_charset, ext_charset) && db_charset != ext_charset); - + string tmp1, tmp2; tmp2 = dat(); if (do_lineconv) { @@ -91,7 +91,7 @@ write_data(path, data(tmp2)); } -void +void calculate_ident(file_path const & file, hexenc & ident, lua_hooks & lua) @@ -99,10 +99,10 @@ string db_linesep, ext_linesep; string db_charset, ext_charset; - bool do_lineconv = (lua.hook_get_linesep_conv(file, db_linesep, ext_linesep) + bool do_lineconv = (lua.hook_get_linesep_conv(file, db_linesep, ext_linesep) && db_linesep != ext_linesep); - bool do_charconv = (lua.hook_get_charset_conv(file, db_charset, ext_charset) + bool do_charconv = (lua.hook_get_charset_conv(file, db_charset, ext_charset) && db_charset != ext_charset); if (do_charconv || do_lineconv) ============================================================ --- localized_file_io.hh 9cdb8ca069e30a6dbf3e02d53337b4e2407e6bdd +++ localized_file_io.hh 92af84cfbe868c3cefbaf45bb479cc5f465e405a @@ -9,16 +9,16 @@ class lua_hooks; -void read_localized_data(file_path const & path, - data & dat, +void read_localized_data(file_path const & path, + data & dat, lua_hooks & lua); bool ident_existing_file(file_path const & p, file_id & ident, lua_hooks & lua); void calculate_ident(file_path const & file, - hexenc & ident, + hexenc & ident, lua_hooks & lua); -void write_localized_data(file_path const & path, - data const & dat, +void write_localized_data(file_path const & path, + data const & dat, lua_hooks & lua); #endif ============================================================ --- lua.cc 510492e0a3d30022cff1fcf325ddf6de32a899f4 +++ lua.cc e08614b229eb4cddd3a9820ea729d5cb33d58489 @@ -58,19 +58,19 @@ out += string(lua_tostring(st, i), lua_strlen(st, i)); out += '\''; break; - + case LUA_TBOOLEAN: /* booleans */ out += (lua_toboolean(st, i) ? "true" : "false"); break; - + case LUA_TNUMBER: /* numbers */ out += (FL("%g") % lua_tonumber(st, i)).str(); break; - + default: /* other values */ out += std::string(lua_typename(st, t)); break; - + } out += " "; /* put a separator */ } @@ -78,7 +78,7 @@ } -Lua::Lua(lua_State * s) : +Lua::Lua(lua_State * s) : st(s), failed(false) {} @@ -90,16 +90,16 @@ void Lua::fail(string const & reason) { - L(FL("lua failure: %s; stack = %s\n") % reason % dump_stack(st)); + L(FL("lua failure: %s; stack = %s") % reason % dump_stack(st)); failed = true; } bool -Lua::ok() +Lua::ok() { - if (failed) + if (failed) L(FL("Lua::ok(): failed")); - return !failed; + return !failed; } void @@ -107,7 +107,7 @@ { I(lua_isstring(st, -1)); string err = string(lua_tostring(st, -1), lua_strlen(st, -1)); - W(i18n_format("%s\n") % err); + W(i18n_format("%s") % err); L(FL("lua stack: %s") % dump_stack(st)); lua_pop(st, 1); failed = true; @@ -116,71 +116,71 @@ // getters Lua & -Lua::get(int idx) -{ +Lua::get(int idx) +{ if (failed) return *this; - if (!lua_istable (st, idx)) - { + if (!lua_istable (st, idx)) + { fail("istable() in get"); - return *this; + return *this; } - if (lua_gettop (st) < 1) - { + if (lua_gettop (st) < 1) + { fail("stack top > 0 in get"); - return *this; + return *this; } - lua_gettable(st, idx); - return *this; + lua_gettable(st, idx); + return *this; } Lua & -Lua::get_fn(int idx) -{ +Lua::get_fn(int idx) +{ if (failed) return *this; get(idx); - if (!lua_isfunction (st, -1)) + if (!lua_isfunction (st, -1)) fail("isfunction() in get_fn"); - return *this; + return *this; } Lua & -Lua::get_tab(int idx) -{ +Lua::get_tab(int idx) +{ if (failed) return *this; get(idx); - if (!lua_istable (st, -1)) + if (!lua_istable (st, -1)) fail("istable() in get_tab"); - return *this; + return *this; } Lua & -Lua::get_str(int idx) -{ +Lua::get_str(int idx) +{ if (failed) return *this; get(idx); - if (!lua_isstring (st, -1)) + if (!lua_isstring (st, -1)) fail("isstring() in get_str"); - return *this; + return *this; } Lua & -Lua::get_num(int idx) -{ +Lua::get_num(int idx) +{ if (failed) return *this; get(idx); - if (!lua_isnumber (st, -1)) + if (!lua_isnumber (st, -1)) fail("isnumber() in get_num"); - return *this; + return *this; } Lua & -Lua::get_bool(int idx) -{ +Lua::get_bool(int idx) +{ if (failed) return *this; get(idx); - if (!lua_isboolean (st, -1)) + if (!lua_isboolean (st, -1)) fail("isboolean() in get_bool"); - return *this; + return *this; } // extractors @@ -189,8 +189,8 @@ Lua::extract_str_nolog(string & str) { if (failed) return *this; - if (!lua_isstring (st, -1)) - { + if (!lua_isstring (st, -1)) + { fail("isstring() in extract_str"); return *this; } @@ -218,8 +218,8 @@ Lua::extract_int(int & i) { if (failed) return *this; - if (!lua_isnumber (st, -1)) - { + if (!lua_isnumber (st, -1)) + { fail("isnumber() in extract_int"); return *this; } @@ -232,8 +232,8 @@ Lua::extract_double(double & i) { if (failed) return *this; - if (!lua_isnumber (st, -1)) - { + if (!lua_isnumber (st, -1)) + { fail("isnumber() in extract_double"); return *this; } @@ -247,8 +247,8 @@ Lua::extract_bool(bool & i) { if (failed) return *this; - if (!lua_isboolean (st, -1)) - { + if (!lua_isboolean (st, -1)) + { fail("isboolean() in extract_bool"); return *this; } @@ -264,22 +264,22 @@ Lua::begin() { if (failed) return *this; - if (!lua_istable(st, -1)) - { + if (!lua_istable(st, -1)) + { fail("istable() in begin"); return *this; } I(lua_checkstack (st, 1)); - lua_pushnil(st); + lua_pushnil(st); return *this; } bool -Lua::next() +Lua::next() { if (failed) return false; - if (!lua_istable(st, -2)) - { + if (!lua_istable(st, -2)) + { fail("istable() in next"); return false; } @@ -295,98 +295,98 @@ // pushers Lua & -Lua::push_str(string const & str) -{ +Lua::push_str(string const & str) +{ if (failed) return *this; I(lua_checkstack (st, 1)); - lua_pushlstring(st, str.c_str(), str.size()); - return *this; + lua_pushlstring(st, str.c_str(), str.size()); + return *this; } Lua & -Lua::push_int(int num) -{ +Lua::push_int(int num) +{ if (failed) return *this; I(lua_checkstack (st, 1)); - lua_pushnumber(st, num); - return *this; + lua_pushnumber(st, num); + return *this; } Lua & -Lua::push_int(double num) -{ +Lua::push_int(double num) +{ if (failed) return *this; I(lua_checkstack (st, 1)); - lua_pushnumber(st, num); - return *this; + lua_pushnumber(st, num); + return *this; } Lua & -Lua::push_bool(bool b) -{ +Lua::push_bool(bool b) +{ if (failed) return *this; I(lua_checkstack (st, 1)); - lua_pushboolean(st, b); - return *this; + lua_pushboolean(st, b); + return *this; } Lua & -Lua::push_nil() -{ +Lua::push_nil() +{ if (failed) return *this; I(lua_checkstack (st, 1)); - lua_pushnil(st); - return *this; + lua_pushnil(st); + return *this; } Lua & -Lua::push_table() -{ +Lua::push_table() +{ if (failed) return *this; I(lua_checkstack (st, 1)); - lua_newtable(st); - return *this; + lua_newtable(st); + return *this; } Lua & -Lua::set_table(int idx) -{ +Lua::set_table(int idx) +{ if (failed) return *this; I(lua_checkstack (st, 1)); - lua_settable(st, idx); - return *this; + lua_settable(st, idx); + return *this; } Lua & -Lua::call(int in, int out) -{ +Lua::call(int in, int out) +{ if (failed) return *this; I(lua_checkstack (st, out)); if (lua_pcall(st, in, out, 0) != 0) - { + { report_error(); - } - return *this; + } + return *this; } Lua & -Lua::pop(int count) -{ +Lua::pop(int count) +{ if (failed) return *this; - if (lua_gettop (st) < count) - { + if (lua_gettop (st) < count) + { fail("stack top is not >= count in pop"); - return *this; + return *this; } - lua_pop(st, count); - return *this; + lua_pop(st, count); + return *this; } Lua & Lua::func(string const & fname) { L(FL("loading lua hook %s") % fname); - if (!failed) + if (!failed) { if (missing_functions.find(fname) != missing_functions.end()) failed = true; @@ -434,30 +434,30 @@ extern "C" { - static int - monotone_mkstemp_for_lua(lua_State *L) + static int + monotone_mkstemp_for_lua(lua_State *L) { int fd = -1; FILE **pf = NULL; char const *filename = luaL_checkstring (L, -1); string dup(filename); - + fd = monotone_mkstemp(dup); - + if (fd == -1) return 0; - + // this magic constructs a lua object which the lua io library // will enjoy working with pf = static_cast(lua_newuserdata(L, sizeof(FILE *))); - *pf = fdopen(fd, "r+"); + *pf = fdopen(fd, "r+"); lua_pushstring(L, "FILE*"); lua_rawget(L, LUA_REGISTRYINDEX); - lua_setmetatable(L, -2); - + lua_setmetatable(L, -2); + lua_pushstring(L, dup.c_str()); - - if (*pf == NULL) + + if (*pf == NULL) { lua_pushnil(L); lua_pushfstring(L, "%s", strerror(errno)); @@ -552,7 +552,7 @@ N(path, F("%s called with an invalid parameter") % "guess_binary"); ifstream file(path, ios_base::binary); - if (!file) + if (!file) { lua_pushnil(L); return 1; @@ -564,7 +564,7 @@ { I(file.gcount() <= static_cast(sizeof tmpbuf)); buf.assign(tmpbuf, file.gcount()); - if (guess_binary(buf)) + if (guess_binary(buf)) { lua_pushboolean(L, true); return 1; @@ -573,13 +573,13 @@ lua_pushboolean(L, false); return 1; } - + static int monotone_include_for_lua(lua_State *L) { const char *path = luaL_checkstring(L, -1); N(path, F("%s called with an invalid parameter") % "Include"); - + bool res =Lua(L) .loadfile(string(path, lua_strlen(L, -1))) .call(0,1) @@ -588,7 +588,7 @@ lua_pushboolean(L, res); return 1; } - + static int monotone_includedir_for_lua(lua_State *L) { @@ -619,7 +619,7 @@ N(res, F("lua error while loading rcfile '%s'") % i->string()); } - lua_pushboolean(L, true); + lua_pushboolean(L, true); return 1; } @@ -741,22 +741,22 @@ } } -bool +bool run_string(lua_State * st, string const &str, string const & identity) { I(st); - return + return Lua(st) .loadstring(str, identity) .call(0,1) .ok(); } -bool +bool run_file(lua_State * st, string const &filename) { I(st); - return + return Lua(st) .loadfile(filename) .call(0,1) ============================================================ --- lua.hh 54e0054144207e223df17764f6da0e6134cb6a02 +++ lua.hh 6b805dfc204b315a49e7be86ad8f3ca8519ffdaa @@ -11,7 +11,7 @@ // transaction are ignored. it cleans the lua stack up when it is // destructed, so no need to pop values when you're done. -struct +struct Lua { lua_State * st; ============================================================ --- lua_hooks.cc a61adade16562803f2118f96bdd2d5b2b8c391bd +++ lua_hooks.cc f6958169c7ac3b2cba99da60c075dfd9f8f766d4 @@ -79,7 +79,7 @@ lua_hooks::lua_hooks() { - st = lua_open (); + st = lua_open (); I(st); lua_atpanic (st, &panic_thrower); @@ -96,9 +96,9 @@ // Disable any functions we don't want. This is easiest // to do just by running a lua string. - if (!run_string(st, + if (!run_string(st, "os.execute = nil " - "io.popen = nil ", + "io.popen = nil ", string(""))) throw oops("lua error while disabling existing functions"); } @@ -121,7 +121,7 @@ #ifdef BUILD_UNIT_TESTS -void +void lua_hooks::add_test_hooks() { if (!run_string(st, test_hooks_constant, string(""))) @@ -129,14 +129,14 @@ } #endif -void +void lua_hooks::add_std_hooks() { if (!run_string(st, std_hooks_constant, string(""))) throw oops("lua error while setting up standard hooks"); } -void +void lua_hooks::default_rcfilename(system_path & file) { map::iterator i = map_of_lua_to_app.find(st); @@ -144,7 +144,7 @@ file = i->second->get_confdir() / "monotonerc"; } -void +void lua_hooks::workspace_rcfilename(bookkeeping_path & file) { file = bookkeeping_root / "monotonerc"; @@ -179,28 +179,28 @@ } } data dat; - L(FL("opening rcfile '%s'\n") % rc); + L(FL("opening rcfile '%s'") % rc); read_data_for_command_line(rc, dat); N(run_string(st, dat(), rc().c_str()), F("lua error while loading rcfile '%s'") % rc); - L(FL("'%s' is ok\n") % rc); + L(FL("'%s' is ok") % rc); } -void +void lua_hooks::load_rcfile(any_path const & rc, bool required) { - I(st); + I(st); if (path_exists(rc)) { - L(FL("opening rcfile '%s'\n") % rc); + L(FL("opening rcfile '%s'") % rc); N(run_file(st, rc.as_external()), F("lua error while loading '%s'") % rc); - L(FL("'%s' is ok\n") % rc); + L(FL("'%s' is ok") % rc); } else { N(!required, F("rcfile '%s' does not exist") % rc); - L(FL("skipping nonexistent rcfile '%s'\n") % rc); + L(FL("skipping nonexistent rcfile '%s'") % rc); } } @@ -209,7 +209,7 @@ // nb: if you're hooking lua to return your passphrase, you don't care if we // keep a couple extra temporaries of your passphrase around. -bool +bool lua_hooks::hook_get_passphrase(rsa_keypair_id const & k, string & phrase) { return Lua(st) @@ -220,7 +220,7 @@ .ok(); } -bool +bool lua_hooks::hook_persist_phrase_ok() { bool persist_ok = false; @@ -232,8 +232,8 @@ return executed_ok && persist_ok; } -bool -lua_hooks::hook_expand_selector(string const & sel, +bool +lua_hooks::hook_expand_selector(string const & sel, string & exp) { return Lua(st) @@ -244,8 +244,8 @@ .ok(); } -bool -lua_hooks::hook_expand_date(string const & sel, +bool +lua_hooks::hook_expand_date(string const & sel, string & exp) { exp.clear(); @@ -258,8 +258,8 @@ return res && exp.size(); } -bool -lua_hooks::hook_get_branch_key(cert_value const & branchname, +bool +lua_hooks::hook_get_branch_key(cert_value const & branchname, rsa_keypair_id & k) { string key; @@ -274,8 +274,8 @@ return ok; } -bool -lua_hooks::hook_get_author(cert_value const & branchname, +bool +lua_hooks::hook_get_author(cert_value const & branchname, string & author) { return Lua(st) @@ -286,7 +286,7 @@ .ok(); } -bool +bool lua_hooks::hook_edit_comment(string const & commentary, string const & user_log_message, string & result) @@ -300,7 +300,7 @@ .ok(); } -bool +bool lua_hooks::hook_ignore_file(file_path const & p) { bool ignore_it = false; @@ -313,7 +313,7 @@ return exec_ok && ignore_it; } -bool +bool lua_hooks::hook_ignore_branch(string const & branch) { bool ignore_it = false; @@ -334,7 +334,7 @@ cert_value const & val) { ll.push_table(); - + int k = 1; for (set::const_iterator v = signers.begin(); v != signers.end(); ++v) @@ -353,22 +353,22 @@ .call(4, 1) .extract_bool(ok) .ok(); - + return exec_ok && ok; } -bool +bool lua_hooks::hook_get_revision_cert_trust(set const & signers, hexenc const & id, cert_name const & name, cert_value const & val) { Lua ll(st); - ll.func("get_revision_cert_trust"); + ll.func("get_revision_cert_trust"); return shared_trust_function_body(ll, signers, id, name, val); } -bool +bool lua_hooks::hook_get_manifest_cert_trust(set const & signers, hexenc const & id, cert_name const & name, @@ -379,7 +379,7 @@ return shared_trust_function_body(ll, signers, id, name, val); } -bool +bool lua_hooks::hook_accept_testresult_change(map const & old_results, map const & new_results) { @@ -412,19 +412,19 @@ .extract_bool(ok) .ok(); - return exec_ok && ok; + return exec_ok && ok; } -bool +bool lua_hooks::hook_merge3(file_path const & anc_path, file_path const & left_path, file_path const & right_path, file_path const & merged_path, - data const & ancestor, - data const & left, - data const & right, + data const & ancestor, + data const & left, + data const & right, data & result) { string res; @@ -498,7 +498,7 @@ { ll.push_table(); - if (!u.scheme.empty()) + if (!u.scheme.empty()) { ll.push_str("scheme"); ll.push_str(u.scheme); @@ -548,7 +548,7 @@ } } -bool +bool lua_hooks::hook_get_netsync_connect_command(uri const & u, std::string const & include_pattern, std::string const & exclude_pattern, @@ -587,7 +587,7 @@ ll.call(2,1); ll.begin(); - + argv.clear(); while(ll.next()) { @@ -599,7 +599,7 @@ } -bool +bool lua_hooks::hook_use_transport_auth(uri const & u) { bool use_auth = true; @@ -614,8 +614,8 @@ } -bool -lua_hooks::hook_get_netsync_read_permitted(string const & branch, +bool +lua_hooks::hook_get_netsync_read_permitted(string const & branch, rsa_keypair_id const & identity) { bool permitted = false, exec_ok = false; @@ -632,7 +632,7 @@ } // Anonymous no-key version -bool +bool lua_hooks::hook_get_netsync_read_permitted(string const & branch) { bool permitted = false, exec_ok = false; @@ -648,7 +648,7 @@ return exec_ok && permitted; } -bool +bool lua_hooks::hook_get_netsync_write_permitted(rsa_keypair_id const & identity) { bool permitted = false, exec_ok = false; @@ -660,10 +660,10 @@ .extract_bool(permitted) .ok(); - return exec_ok && permitted; + return exec_ok && permitted; } -bool +bool lua_hooks::hook_init_attributes(file_path const & filename, map & attrs) { @@ -672,7 +672,7 @@ ll .push_str("attr_init_functions") .get_tab(); - + L(FL("calling attr_init_function for %s") % filename); ll.begin(); while (ll.next()) @@ -702,9 +702,9 @@ return ll.pop().ok(); } -bool -lua_hooks::hook_apply_attribute(string const & attr, - file_path const & filename, +bool +lua_hooks::hook_apply_attribute(string const & attr, + file_path const & filename, string const & value) { return Lua(st) @@ -719,7 +719,7 @@ } -bool +bool lua_hooks::hook_get_system_linesep(string & linesep) { return Lua(st) @@ -729,9 +729,9 @@ .ok(); } -bool -lua_hooks::hook_get_charset_conv(file_path const & p, - string & db, +bool +lua_hooks::hook_get_charset_conv(file_path const & p, + string & db, string & ext) { Lua ll(st); @@ -740,7 +740,7 @@ .push_str(p.as_external()) .call(1,1) .begin(); - + ll.next(); ll.extract_str(db).pop(); @@ -749,9 +749,9 @@ return ll.ok(); } -bool -lua_hooks::hook_get_linesep_conv(file_path const & p, - string & db, +bool +lua_hooks::hook_get_linesep_conv(file_path const & p, + string & db, string & ext) { Lua ll(st); @@ -760,7 +760,7 @@ .push_str(p.as_external()) .call(1,1) .begin(); - + ll.next(); ll.extract_str(db).pop(); @@ -788,7 +788,7 @@ .ok(); } -bool +bool lua_hooks::hook_note_commit(revision_id const & new_id, revision_data const & rdat, map const & certs) @@ -808,12 +808,12 @@ ll.push_str(i->second()); ll.set_table(); } - + ll.call(3, 0); return ll.ok(); } -bool +bool lua_hooks::hook_note_netsync_start(string nonce) { Lua ll(st); @@ -824,7 +824,7 @@ .ok(); } -bool +bool lua_hooks::hook_note_netsync_revision_received(revision_id const & new_id, revision_data const & rdat, set > > cdat; int n=0; @@ -898,7 +898,7 @@ return ll.ok(); } -bool +bool lua_hooks::hook_note_netsync_end(string nonce) { Lua ll(st); ============================================================ --- lua_hooks.hh 4808b67b1e1cf6250e423ffd16d2153cba51ca78 +++ lua_hooks.hh 5e33a2a94befbcd2969d80363fdfc8a09994565b @@ -45,7 +45,7 @@ bool hook_get_author(cert_value const & branchname, std::string & author); bool hook_edit_comment(std::string const & commentary, std::string const & user_log_message, - std::string & result); + std::string & result); bool hook_persist_phrase_ok(); bool hook_get_revision_cert_trust(std::set const & signers, hexenc const & id, @@ -65,8 +65,8 @@ bool debug, std::vector & argv); bool hook_use_transport_auth(uri const & u); - - bool hook_get_netsync_read_permitted(std::string const & branch, + + bool hook_get_netsync_read_permitted(std::string const & branch, rsa_keypair_id const & identity); // anonymous no-key version bool hook_get_netsync_read_permitted(std::string const & branch); @@ -79,9 +79,9 @@ file_path const & left_path, file_path const & right_path, file_path const & merged_path, - data const & ancestor, - data const & left, - data const & right, + data const & ancestor, + data const & left, + data const & right, data & result); bool hook_external_diff(file_path const & path, @@ -99,15 +99,15 @@ // attribute hooks bool hook_init_attributes(file_path const & filename, std::map & attrs); - bool hook_apply_attribute(std::string const & attr, - file_path const & filename, + bool hook_apply_attribute(std::string const & attr, + file_path const & filename, std::string const & value); // conversion hooks bool hook_get_system_linesep(std::string & linesep); - bool hook_get_charset_conv(file_path const & p, + bool hook_get_charset_conv(file_path const & p, std::string & db, std::string & ext); - bool hook_get_linesep_conv(file_path const & p, + bool hook_get_linesep_conv(file_path const & p, std::string & db, std::string & ext); // validation hooks ============================================================ --- main.cc 1b50bf9eefcb967254582b38a5a886f8ad09eea6 +++ main.cc 14ebc50eeeaf3248b88c1a79d45586ecb2e22f2d @@ -1,9 +1,9 @@ // This file is derived from execution_monitor.cpp, a part of boost. -// +// // the error reporting mechanisms in that file were irritating to our -// users, so we've just copied and modified the code, cleaning up -// parts of it in the process. +// users, so we've just copied and modified the code, cleaning up +// parts of it in the process. // // it is somewhat likely that you actually want to look in monotone.cc for // cpp_main(), which is the function which does more interesting stuff. all @@ -35,7 +35,7 @@ #include #include #include -#include +#include #if !defined(__MWERKS__) #define MS_CRT_DEBUG_HOOK #include @@ -43,11 +43,11 @@ #elif (defined(__BORLANDC__) && defined(_Windows)) #define MS_STRUCTURED_EXCEPTION_HANDLING -#include // Borland 5.5.1 has its own way of doing things. +#include // Borland 5.5.1 has its own way of doing things. -#elif (defined(__GNUC__) && defined(__MINGW32__)) +#elif (defined(__GNUC__) && defined(__MINGW32__)) #define MS_STRUCTURED_EXCEPTION_HANDLING -#include +#include #elif defined(__unix) || defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) #define UNIX_STYLE_SIGNAL_HANDLING @@ -62,7 +62,7 @@ using std::string; // A rough outline of what this file does: -// +// // runs main() // - sets up a try block to catch the_one_true_exception // - calls main_with_many_flavours_of_exception @@ -74,10 +74,10 @@ // * sets up a unix sigjump_buf if appropriate // * calls cpp_main -extern int +extern int cpp_main(int argc, char ** argv); -static const size_t +static const size_t REPORT_ERROR_BUFFER_SIZE = 512; #ifdef BOOST_NO_STDC_NAMESPACE @@ -97,7 +97,7 @@ }; char the_one_true_exception::buf[REPORT_ERROR_BUFFER_SIZE]; -static void +static void report_error(char const *msg1, char const *msg2 = "") { throw the_one_true_exception(msg1, msg2); @@ -105,7 +105,7 @@ //////////////////////////////////////////////// -// windows style structured exception handling +// windows style structured exception handling // (and assertions, which get their own support) //////////////////////////////////////////////// @@ -118,11 +118,11 @@ case _CRT_ASSERT: report_error(userMessage); return 1; - + case _CRT_ERROR: report_error(userMessage); return 1; - + default: return 0; } @@ -132,11 +132,11 @@ #if defined(MS_STRUCTURED_EXCEPTION_HANDLING) #if !defined(__BORLANDC__) && !defined(__MINGW32__) struct -ms_se_exception +ms_se_exception { unsigned int exception_id; - explicit ms_se_exception(unsigned int n) - : exception_id(n) + explicit ms_se_exception(unsigned int n) + : exception_id(n) {} }; @@ -149,16 +149,16 @@ static void report_ms_se_error(unsigned int id) { - switch (id) + switch (id) { case EXCEPTION_ACCESS_VIOLATION: report_error("memory access violation"); break; - + case EXCEPTION_ILLEGAL_INSTRUCTION: report_error("illegal instruction"); break; - + case EXCEPTION_PRIV_INSTRUCTION: report_error("privilaged instruction"); break; @@ -174,7 +174,7 @@ case EXCEPTION_DATATYPE_MISALIGNMENT: report_error("data misalignment"); break; - + case EXCEPTION_INT_DIVIDE_BY_ZERO: report_error("integer divide by zero"); break; @@ -194,7 +194,7 @@ case EXCEPTION_FLT_STACK_CHECK: report_error("floating point stack check"); break; - + case EXCEPTION_FLT_DENORMAL_OPERAND: case EXCEPTION_FLT_INEXACT_RESULT: case EXCEPTION_FLT_INVALID_OPERATION: @@ -202,7 +202,7 @@ case EXCEPTION_FLT_UNDERFLOW: report_error("floating point error"); break; - + default: report_error("unrecognized exception or signal"); } @@ -211,14 +211,14 @@ #if (defined(__BORLANDC__) && defined(_Windows)) // this works for Borland but not other Win32 compilers (which trap too many cases) -static int +static int main_with_signal_handlers(int argc, char **argv) { int result; - __try - { - result = cpp_main(argc, argv); - } + __try + { + result = cpp_main(argc, argv); + } __except (1) { throw ms_se_exception(GetExceptionCode()); @@ -227,7 +227,7 @@ } #else -static int +static int main_with_signal_handlers(int argc, char **argv) { return cpp_main(argc, argv); @@ -236,12 +236,12 @@ ///////////////////////////// -// unix style signal handling +// unix style signal handling ///////////////////////////// #elif defined(UNIX_STYLE_SIGNAL_HANDLING) struct -unix_signal_exception +unix_signal_exception { char const * error_message; explicit unix_signal_exception(char const * em) @@ -251,16 +251,16 @@ static sigjmp_buf jump_buf; -extern "C" +extern "C" { - static void + static void unix_style_signal_handler(int sig) { siglongjmp(jump_buf, sig); - } + } } -static int +static int main_with_signal_handlers(int argc, char **argv) { typedef struct sigaction* sigaction_ptr; @@ -278,7 +278,7 @@ all_signals_action.sa_flags = 0; all_signals_action.sa_handler = &unix_style_signal_handler; sigemptyset(&all_signals_action.sa_mask); - + ignore_signals_action.sa_flags = 0; ignore_signals_action.sa_handler = SIG_IGN; sigemptyset(&ignore_signals_action.sa_mask); @@ -299,15 +299,15 @@ volatile int sigtype = sigsetjmp(jump_buf, 1); - if(sigtype == 0) + if(sigtype == 0) { result = cpp_main(argc, argv); } - - else + + else { trapped_signal = true; - switch(sigtype) + switch(sigtype) { case SIGTRAP: em = "signal: SIGTRAP (perhaps integer divide by zero)"; @@ -334,7 +334,7 @@ em = "signal: unrecognized signal"; } } - + sigaction(SIGFPE , &old_SIGFPE_action , sigaction_ptr()); sigaction(SIGTRAP, &old_SIGTRAP_action, sigaction_ptr()); sigaction(SIGSEGV, &old_SIGSEGV_action, sigaction_ptr()); @@ -349,8 +349,8 @@ close_all_databases(); return 1; } - - if(trapped_signal) + + if(trapped_signal) throw unix_signal_exception(em); return result; @@ -358,136 +358,136 @@ #endif -static int +static int main_with_many_flavours_of_exception(int argc, char **argv) { - + #if defined(MS_STRUCTURED_EXCEPTION_HANDLING) && !defined(__BORLANDC__) && !defined(__MINGW32__) _set_se_translator(ms_se_trans_func); #endif - + #if defined(MS_CRT_DEBUG_HOOK) _CrtSetReportHook(&assert_reporting_function); #endif - try + try { return main_with_signal_handlers(argc, argv); } catch (char const * ex) - { - report_error("C string: ", ex); + { + report_error("C string: ", ex); } catch (string const & ex) - { - report_error("string: ", ex.c_str()); + { + report_error("string: ", ex.c_str()); } - + catch( std::bad_alloc const & ex ) - { - report_error("std::bad_alloc: ", ex.what()); + { + report_error("std::bad_alloc: ", ex.what()); } - + #if !defined(__BORLANDC__) || __BORLANDC__ > 0x0551 catch (std::bad_cast const & ex) - { - report_error("std::bad_cast: ", ex.what()); + { + report_error("std::bad_cast: ", ex.what()); } catch (std::bad_typeid const & ex) - { - report_error("std::bad_typeid: ", ex.what()); + { + report_error("std::bad_typeid: ", ex.what()); } #else catch(std::bad_cast const & ex) - { - report_error("std::bad_cast"); + { + report_error("std::bad_cast"); } catch( std::bad_typeid const & ex) - { - report_error("std::bad_typeid"); + { + report_error("std::bad_typeid"); } #endif - + catch(std::bad_exception const & ex) - { - report_error("std::bad_exception: ", ex.what()); + { + report_error("std::bad_exception: ", ex.what()); } catch( std::domain_error const& ex ) - { - report_error("std::domain_error: ", ex.what()); + { + report_error("std::domain_error: ", ex.what()); } catch( std::invalid_argument const& ex ) - { - report_error("std::invalid_argument: ", ex.what()); + { + report_error("std::invalid_argument: ", ex.what()); } catch( std::length_error const& ex ) - { - report_error("std::length_error: ", ex.what()); + { + report_error("std::length_error: ", ex.what()); } catch( std::out_of_range const& ex ) - { - report_error("std::out_of_range: ", ex.what()); + { + report_error("std::out_of_range: ", ex.what()); } catch( std::range_error const& ex ) - { - report_error("std::range_error: ", ex.what()); + { + report_error("std::range_error: ", ex.what()); } catch( std::overflow_error const& ex ) - { - report_error("std::overflow_error: ", ex.what()); + { + report_error("std::overflow_error: ", ex.what()); } catch( std::underflow_error const& ex ) - { - report_error("std::underflow_error: ", ex.what()); + { + report_error("std::underflow_error: ", ex.what()); } catch( std::logic_error const& ex ) - { - report_error("std::logic_error: ", ex.what()); + { + report_error("std::logic_error: ", ex.what()); } catch( std::runtime_error const& ex ) - { - report_error("std::runtime_error: ", ex.what()); + { + report_error("std::runtime_error: ", ex.what()); } catch( std::exception const& ex ) - { - report_error("std::exception: ", ex.what()); + { + report_error("std::exception: ", ex.what()); } #if defined(MS_STRUCTURED_EXCEPTION_HANDLING) && !defined(__BORLANDC__) && !defined(__MINGW32__) catch(ms_se_exception const & ex) - { - report_ms_se_error(ex.exception_id); + { + report_ms_se_error(ex.exception_id); } #elif defined(UNIX_STYLE_SIGNAL_HANDLING) catch(unix_signal_exception const & ex) - { - report_error(ex.error_message); + { + report_error(ex.error_message); } #endif catch( ... ) - { - report_error("exception of unknown type" ); + { + report_error("exception of unknown type" ); } return 0; } -int +int main(int argc, char **argv) { try ============================================================ --- merge.cc cc6860bdc2e1ba18713800ef24ceb08c605abab0 +++ merge.cc cb10f705835971e69ada0c322e42ab635f8388cb @@ -40,9 +40,9 @@ void resolve_merge_conflicts(revision_id const & left_rid, revision_id const & right_rid, - roster_t const & left_roster, + roster_t const & left_roster, roster_t const & right_roster, - marking_map const & left_marking_map, + marking_map const & left_marking_map, marking_map const & right_marking_map, roster_merge_result & result, content_merge_adaptor & adaptor, @@ -68,7 +68,7 @@ if (!result.file_content_conflicts.empty()) { - L(FL("examining content conflicts\n")); + L(FL("examining content conflicts")); vector residual_conflicts; for (size_t i = 0; i < result.file_content_conflicts.size(); ++i) @@ -87,17 +87,17 @@ get_file_details (*roster_for_file_lca, conflict.nid, anc_id, anc_path); get_file_details (left_roster, conflict.nid, left_id, left_path); get_file_details (right_roster, conflict.nid, right_id, right_path); - + file_id merged_id; - - content_merger cm(app, *roster_for_file_lca, - left_roster, right_roster, + + content_merger cm(app, *roster_for_file_lca, + left_roster, right_roster, adaptor); if (cm.try_to_merge_files(anc_path, left_path, right_path, right_path, anc_id, left_id, right_id, merged_id)) { - L(FL("resolved content conflict %d / %d\n") + L(FL("resolved content conflict %d / %d") % (i+1) % result.file_content_conflicts.size()); file_t f = downcast_to_file_t(result.roster.get_node(conflict.nid)); f->content = merged_id; @@ -105,7 +105,7 @@ else residual_conflicts.push_back(conflict); } - result.file_content_conflicts = residual_conflicts; + result.file_content_conflicts = residual_conflicts; } } @@ -133,9 +133,9 @@ // { // data tmp; // write_roster_and_marking(left_roster, left_marking_map, tmp); -// P(F("merge left roster: [[[\n%s\n]]]\n") % tmp); +// P(F("merge left roster: [[[\n%s\n]]]") % tmp); // write_roster_and_marking(right_roster, right_marking_map, tmp); -// P(F("merge right roster: [[[\n%s\n]]]\n") % tmp); +// P(F("merge right roster: [[[\n%s\n]]]") % tmp); // } roster_merge(left_roster, left_marking_map, left_uncommon_ancestors, @@ -168,23 +168,23 @@ merged_roster.check_sane(); revision_set merged_rev; - + calculate_ident(merged_roster, merged_rev.new_manifest); - + shared_ptr left_to_merged(new cset); make_cset(left_roster, merged_roster, *left_to_merged); safe_insert(merged_rev.edges, make_pair(left_rid, left_to_merged)); - + shared_ptr right_to_merged(new cset); make_cset(right_roster, merged_roster, *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); calculate_ident(merged_data, merged_rid); { transaction_guard guard(app.db); - + app.db.put_revision(merged_rid, merged_rev); packet_db_writer dbw(app); if (app.date_set) ============================================================ --- merge.hh ba5196326f988aa8d857e7aa3b138ff17afbe06b +++ merge.hh 87e2852d5ba1ef5e8c0d615b70688223a1cb095c @@ -24,9 +24,9 @@ void resolve_merge_conflicts(revision_id const & left_rid, revision_id const & right_rid, - roster_t const & left_roster, + roster_t const & left_roster, roster_t const & right_roster, - marking_map const & left_marking_map, + marking_map const & left_marking_map, marking_map const & right_marking_map, roster_merge_result & result, content_merge_adaptor & adaptor, ============================================================ --- merkle_tree.cc 7011e2dbceb1d2e78db31c8c4570d443b383c639 +++ merkle_tree.cc 888e9121fb11a391bc924b2da6fa186353f24cd3 @@ -37,7 +37,7 @@ rawpref = prefix(s); } -void +void netcmd_item_type_to_string(netcmd_item_type t, string & typestr) { typestr.clear(); @@ -67,11 +67,11 @@ // and we have to send them over the wire, we use a raw variant here // for compactness. -string +string raw_sha1(string const & in) { Botan::SHA_160 hash; - hash.update(reinterpret_cast(in.data()), + hash.update(reinterpret_cast(in.data()), static_cast(in.size())); char digest[constants::sha1_digest_length]; hash.final(reinterpret_cast(digest)); @@ -80,14 +80,14 @@ } -merkle_node::merkle_node() : level(0), pref(0), - total_num_leaves(0), +merkle_node::merkle_node() : level(0), pref(0), + total_num_leaves(0), bitmap(constants::merkle_bitmap_length_in_bits), slots(constants::merkle_num_slots), - type(revision_item) + type(revision_item) {} -bool +bool merkle_node::operator==(merkle_node const & other) const { return (level == other.level @@ -98,7 +98,7 @@ && type == other.type); } -void +void merkle_node::check_invariants() const { I(this->pref.size() == prefix_length_in_bits(this->level)); @@ -107,14 +107,14 @@ I(this->bitmap.size() == constants::merkle_bitmap_length_in_bits); } -void +void merkle_node::get_raw_prefix(prefix & pref) const { check_invariants(); bitset_to_prefix(this->pref, pref); } -void +void merkle_node::get_hex_prefix(hexenc & hpref) const { prefix pref; @@ -122,7 +122,7 @@ encode_hexenc(pref, hpref); } -void +void merkle_node::get_raw_slot(size_t slot, id & i) const { I(get_slot_state(slot) != empty_state); @@ -130,7 +130,7 @@ i = idx(this->slots, slot); } -void +void merkle_node::get_hex_slot(size_t slot, hexenc & val) const { id i; @@ -138,14 +138,14 @@ encode_hexenc(i, val); } -void +void merkle_node::set_raw_slot(size_t slot, id const & val) { check_invariants(); idx(this->slots, slot) = val; } -void +void merkle_node::set_hex_slot(size_t slot, hexenc const & val) { id i; @@ -153,8 +153,8 @@ set_raw_slot(slot, i); } -void -merkle_node::extended_prefix(size_t slot, +void +merkle_node::extended_prefix(size_t slot, dynamic_bitset & extended) const { // remember, in a dynamic_bitset, bit size()-1 is most significant @@ -165,8 +165,8 @@ extended.push_back(static_cast((slot >> i) & 1)); } -void -merkle_node::extended_raw_prefix(size_t slot, +void +merkle_node::extended_raw_prefix(size_t slot, prefix & extended) const { dynamic_bitset ext; @@ -174,8 +174,8 @@ bitset_to_prefix(ext, extended); } -void -merkle_node::extended_hex_prefix(size_t slot, +void +merkle_node::extended_hex_prefix(size_t slot, hexenc & extended) const { prefix pref; @@ -183,7 +183,7 @@ encode_hexenc(pref, extended); } -slot_state +slot_state merkle_node::get_slot_state(size_t n) const { check_invariants(); @@ -199,10 +199,10 @@ else { return empty_state; - } + } } -void +void merkle_node::set_slot_state(size_t n, slot_state st) { check_invariants(); @@ -214,16 +214,16 @@ bitmap.set(2*n); if (st == subtree_state) bitmap.set(2*n+1); -} +} -size_t +size_t prefix_length_in_bits(size_t level) { return level * constants::merkle_fanout_bits; } -size_t +size_t prefix_length_in_bytes(size_t level) { // level is the number of levels in tree this prefix has. @@ -236,9 +236,9 @@ return (num_bits / 8) + 1; } -void +void write_node(merkle_node const & in, string & outbuf) -{ +{ ostringstream oss; oss.put(static_cast(in.type)); I(in.pref.size() == in.level * constants::merkle_fanout_bits); @@ -271,26 +271,26 @@ outbuf.append(hash); outbuf.append(oss.str()); } - -void + +void read_node(string const & inbuf, size_t & pos, merkle_node & out) { - string hash = extract_substring(inbuf, pos, - constants::merkle_hash_length_in_bytes, + string hash = extract_substring(inbuf, pos, + constants::merkle_hash_length_in_bytes, "node hash"); size_t begin_pos = pos; out.type = static_cast(extract_datum_lsb(inbuf, pos, "node type")); out.level = extract_datum_uleb128(inbuf, pos, "node level"); if (out.level >= constants::merkle_num_tree_levels) - throw bad_decode(F("node level is %d, exceeds maximum %d") + throw bad_decode(F("node level is %d, exceeds maximum %d") % widen(out.level) % widen(constants::merkle_num_tree_levels)); size_t prefixsz = prefix_length_in_bytes(out.level); - require_bytes(inbuf, pos, prefixsz, "node prefix"); + require_bytes(inbuf, pos, prefixsz, "node prefix"); out.pref.resize(prefix_length_in_bits(out.level)); - from_block_range(inbuf.begin() + pos, + from_block_range(inbuf.begin() + pos, inbuf.begin() + pos + prefixsz, out.pref); pos += prefixsz; @@ -299,7 +299,7 @@ require_bytes(inbuf, pos, constants::merkle_bitmap_length_in_bytes, "bitmap"); out.bitmap.resize(constants::merkle_bitmap_length_in_bits); - from_block_range(inbuf.begin() + pos, + from_block_range(inbuf.begin() + pos, inbuf.begin() + pos + constants::merkle_bitmap_length_in_bytes, out.bitmap); pos += constants::merkle_bitmap_length_in_bytes; @@ -308,25 +308,25 @@ { if (out.get_slot_state(slot) != empty_state) { - string slot_val = extract_substring(inbuf, pos, - constants::merkle_hash_length_in_bytes, + string slot_val = extract_substring(inbuf, pos, + constants::merkle_hash_length_in_bytes, "slot value"); out.set_raw_slot(slot, slot_val); } } - + string checkhash = raw_sha1(inbuf.substr(begin_pos, pos - begin_pos)); out.check_invariants(); if (hash != checkhash) - throw bad_decode(F("mismatched node hash value %s, expected %s") + throw bad_decode(F("mismatched node hash value %s, expected %s") % xform(checkhash) % xform(hash)); } -// returns the first hashsz bytes of the serialized node, which is +// returns the first hashsz bytes of the serialized node, which is // the hash of its contents. -static id +static id hash_merkle_node(merkle_node const & node) { string out; @@ -335,10 +335,10 @@ return id(out.substr(0, constants::merkle_hash_length_in_bytes)); } -void -pick_slot_and_prefix_for_value(id const & val, - size_t level, - size_t & slotnum, +void +pick_slot_and_prefix_for_value(id const & val, + size_t level, + size_t & slotnum, dynamic_bitset & pref) { pref.resize(val().size() * 8); @@ -360,13 +360,13 @@ id recalculate_merkle_codes(merkle_table & tab, - prefix const & pref, + prefix const & pref, size_t level) { - merkle_table::const_iterator i = tab.find(make_pair(pref, level)); + merkle_table::const_iterator i = tab.find(make_pair(pref, level)); I(i != tab.end()); merkle_ptr node = i->second; - + for (size_t slotnum = 0; slotnum < constants::merkle_num_slots; ++slotnum) { slot_state st = node->get_slot_state(slotnum); @@ -383,7 +383,7 @@ } } } - + return hash_merkle_node(*node); } @@ -407,7 +407,7 @@ case empty_state: break; - case leaf_state: + case leaf_state: node->get_raw_slot(slot, item); items.insert(item); break; @@ -464,7 +464,7 @@ size_t level) { I(constants::merkle_hash_length_in_bytes == leaf().size()); - I(constants::merkle_fanout_bits * (level + 1) + I(constants::merkle_fanout_bits * (level + 1) <= constants::merkle_hash_length_in_bits); size_t slotnum; @@ -473,7 +473,7 @@ prefix rawpref; bitset_to_prefix(pref, rawpref); - + merkle_table::const_iterator i = tab.find(make_pair(rawpref, level)); merkle_ptr node; @@ -499,7 +499,7 @@ insert_into_merkle_tree(tab, type, leaf, level+1); id empty_subtree_hash; node->set_raw_slot(slotnum, empty_subtree_hash); - node->set_slot_state(slotnum, subtree_state); + node->set_slot_state(slotnum, subtree_state); } } break; ============================================================ --- merkle_tree.hh af2fed86c559da7f86f0d9a0f6189ab385ee8c08 +++ merkle_tree.hh 21726c0cadb872365e5b32361d87d5c450a4e019 @@ -37,7 +37,7 @@ typedef enum { file_item = 2, - key_item = 3, + key_item = 3, revision_item = 4, cert_item = 5, epoch_item = 6 @@ -55,7 +55,7 @@ slot_state; struct merkle_node -{ +{ size_t level; boost::dynamic_bitset pref; size_t total_num_leaves; @@ -133,7 +133,7 @@ merkle_ptr & mp); -void +void pick_slot_and_prefix_for_value(id const & val, size_t level, size_t & slotnum, @@ -149,7 +149,7 @@ // Insert an item into a tree. -void +void insert_into_merkle_tree(merkle_table & tab, netcmd_item_type type, id const & leaf, @@ -170,9 +170,9 @@ // insert_into_merkle_tree, and before using tree (but you can batch up // multiple calls to insert_into_merkle_tree and then only call this once). -id +id recalculate_merkle_codes(merkle_table & tab, - prefix const & pref, + prefix const & pref, size_t level); - + #endif // __MERKLE_TREE_HH__ ============================================================ --- mkstemp.cc 84c177af02e8c9cde94a596461bdc5d837512fd4 +++ mkstemp.cc cbcbd1d3b07c4207bb3e474397a0b07a95f2f0d6 @@ -50,7 +50,7 @@ #ifdef _MSC_VER fd = _open(tmp.c_str(), _O_RDWR | _O_CREAT | _O_EXCL | _O_BINARY, 0600); #else - fd = open(tmp.c_str(), O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0600); + fd = open(tmp.c_str(), O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0600); #endif if (fd >= 0) { @@ -59,7 +59,7 @@ } else if (errno != EEXIST) break; - } + } return -1; } ============================================================ --- monotone.cc 47ee3ca3d15e6e3a261fdaace69671e05f7cba01 +++ monotone.cc 33fac939423bd5f1f6286e2fddd4b546df8067bf @@ -142,17 +142,17 @@ // in other words, this program should *never* unexpectedly terminate // without dumping some diagnostics. -void -dumper() +void +dumper() { if (!global_sanity.clean_shutdown) global_sanity.dump_buffer(); - + Botan::Init::deinitialize(); } -struct +struct utf8_argv { int argc; @@ -175,7 +175,7 @@ } } - ~utf8_argv() + ~utf8_argv() { if (argv != NULL) { @@ -183,7 +183,7 @@ if (argv[i] != NULL) free(argv[i]); free(argv); - } + } } }; @@ -249,7 +249,7 @@ return string(); } -int +int cpp_main(int argc, char ** argv) { int ret = 0; @@ -282,11 +282,11 @@ cmdline_string = cmdline_ss.str(); } MM(cmdline_string); - L(FL("command line: %s\n") % cmdline_string); + L(FL("command line: %s") % cmdline_string); 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); + L(FL("set locale: LC_ALL=%s") % locale_string); string full_version_string; get_full_version(full_version_string); @@ -295,7 +295,7 @@ // Set up secure memory allocation etc Botan::Init::initialize(); Botan::set_default_allocator("malloc"); - + // decode all argv values into a UTF-8 array save_initial_path(); @@ -310,7 +310,7 @@ // prepare for arg parsing - cleanup_ptr + cleanup_ptr ctx(poptGetContext(NULL, argc, (char const **) uv.argv, options, 0), &my_poptFreeContext); @@ -496,7 +496,7 @@ case OPT_EXTERNAL_DIFF: app.set_diff_format(external_diff); break; - + case OPT_EXTERNAL_DIFF_ARGS: app.set_diff_args(utf8(string(argstr))); break; @@ -519,7 +519,7 @@ 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) { @@ -527,7 +527,7 @@ 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 != string::npos)) @@ -538,7 +538,7 @@ port_part = ""; addr_part = (squareb == string::npos ? arg.substr(1, arg.size()) : arg.substr(1, squareb-1)); } - else + else { addr_part = arg; port_part = ""; @@ -614,7 +614,7 @@ app.allow_workspace(); - // main options processed, now invoke the + // main options processed, now invoke the // sub-command w/ remaining args if (cmd.empty()) @@ -651,25 +651,25 @@ if (command_options.find(o->val) != command_options.end()) { o->argInfo &= ~POPT_ARGFLAG_DOC_HIDDEN; - L(FL("Removed 'hidden' from option # %d\n") % o->argInfo); + L(FL("Removed 'hidden' from option # %d") % o->argInfo); count++; } else { o->argInfo |= POPT_ARGFLAG_DOC_HIDDEN; - L(FL("Added 'hidden' to option # %d\n") % o->argInfo); + L(FL("Added 'hidden' to option # %d") % o->argInfo); } } free((void *)options[0].descrip); options[0].descrip = NULL; if (count != 0) { ostringstream sstr; - sstr << F("Options specific to '%s %s':") + sstr << F("Options specific to '%s %s':") % prog_name % u.which; options[0].descrip = strdup(sstr.str().c_str()); options[0].argInfo |= POPT_ARGFLAG_DOC_HIDDEN; - L(FL("Added 'hidden' to option # %d\n") % options[0].argInfo); + L(FL("Added 'hidden' to option # %d") % options[0].argInfo); } poptPrintHelp(ctx(), stdout, 0); ============================================================ --- mt_version.cc 936a7e6ad5c7ef202f0bdbc0f0bfc7ebc380ff27 +++ mt_version.cc 672188a1ba9293f6cc3fa56411521403022b1644 @@ -5,7 +5,7 @@ // This is split off into its own file to minimize recompilation time; it is // the only .cc file that depends on the revision/full_revision header files, -// which change constantly. +// which change constantly. #include "config.h" ============================================================ --- netcmd.cc bd6ee0d97bdb27879e1d8342d6bc64899a6971e7 +++ netcmd.cc f344ffb3dcd799f0b4ec4c6796dbc5db9f1a64e7 @@ -17,8 +17,8 @@ using std::string; -static netcmd_item_type -read_netcmd_item_type(string const & in, +static netcmd_item_type +read_netcmd_item_type(string const & in, size_t & pos, string const & name) { @@ -26,17 +26,17 @@ switch (tmp) { case static_cast(revision_item): - return revision_item; + return revision_item; case static_cast(file_item): return file_item; case static_cast(cert_item): return cert_item; case static_cast(key_item): - return key_item; + return key_item; case static_cast(epoch_item): - return epoch_item; + return epoch_item; default: - throw bad_decode(F("unknown item type 0x%x for '%s'") + throw bad_decode(F("unknown item type 0x%x for '%s'") % static_cast(tmp) % name); } } @@ -45,15 +45,15 @@ cmd_code(error_cmd) {} -size_t netcmd::encoded_size() +size_t netcmd::encoded_size() { string tmp; insert_datum_uleb128(payload.size(), tmp); return 1 + 1 + tmp.size() + payload.size() + 4; } -bool -netcmd::operator==(netcmd const & other) const +bool +netcmd::operator==(netcmd const & other) const { return version == other.version && cmd_code == other.cmd_code && @@ -61,7 +61,7 @@ } // note: usher_reply_cmd does not get included in the hmac. -void +void netcmd::write(string & out, chained_hmac & hmac) const { size_t oldlen = out.size(); @@ -78,7 +78,7 @@ } // note: usher_cmd does not get included in the hmac. -bool +bool netcmd::read(string_queue & inbuf, chained_hmac & hmac) { size_t pos = 0; @@ -126,11 +126,11 @@ if (!try_extract_datum_uleb128(inbuf, pos, "netcmd payload length", payload_len)) return false; - + // they might have given us a bogus size if (payload_len > constants::netcmd_payload_limit) throw bad_decode(F("oversized payload of '%d' bytes") % payload_len); - + // there might not be enough data yet in the input buffer unsigned int minsize; if (hmac.is_active() && cmd_code != usher_cmd) @@ -152,21 +152,21 @@ I(hmac.hmac_length == constants::netsync_hmac_value_length_in_bytes); digest = hmac.process(inbuf, 0, pos + payload_len); } - + payload = extract_substring(inbuf, pos, payload_len, "netcmd payload"); - + if (hmac.is_active() && cmd_code != usher_cmd) { // they might have given us bogus data - cmd_digest = extract_substring(inbuf, pos, + cmd_digest = extract_substring(inbuf, pos, constants::netsync_hmac_value_length_in_bytes, "netcmd HMAC"); } inbuf.pop_front(pos); - if (hmac.is_active() - && cmd_code != usher_cmd + if (hmac.is_active() + && cmd_code != usher_cmd && cmd_digest != digest) { throw bad_decode(F("bad HMAC checksum (got %s, wanted %s)\n" @@ -175,14 +175,14 @@ % encode_hexenc(digest)); } - return true; + return true; } //////////////////////////////////////////// // payload reader/writer functions follow // //////////////////////////////////////////// -void +void netcmd::read_error_cmd(string & errmsg) const { size_t pos = 0; @@ -191,7 +191,7 @@ assert_end_of_buffer(payload, pos, "error netcmd payload"); } -void +void netcmd::write_error_cmd(string const & errmsg) { cmd_code = error_cmd; @@ -200,7 +200,7 @@ } -void +void netcmd::read_hello_cmd(rsa_keypair_id & server_keyname, rsa_pub_key & server_key, id & nonce) const @@ -215,12 +215,12 @@ "hello netcmd, server key"); server_key = rsa_pub_key(sk_str); nonce = id(extract_substring(payload, pos, - constants::merkle_hash_length_in_bytes, + constants::merkle_hash_length_in_bytes, "hello netcmd, nonce")); assert_end_of_buffer(payload, pos, "hello netcmd payload"); } -void +void netcmd::write_hello_cmd(rsa_keypair_id const & server_keyname, rsa_pub_key const & server_key, id const & nonce) @@ -234,7 +234,7 @@ } -void +void netcmd::read_bye_cmd(u8 & phase) const { size_t pos = 0; @@ -244,7 +244,7 @@ } -void +void netcmd::write_bye_cmd(u8 phase) { cmd_code = bye_cmd; @@ -294,12 +294,12 @@ insert_variable_length_string(hmac_key_encrypted(), payload); } -void -netcmd::read_auth_cmd(protocol_role & role, +void +netcmd::read_auth_cmd(protocol_role & role, utf8 & include_pattern, utf8 & exclude_pattern, - id & client, - id & nonce1, + id & client, + id & nonce1, rsa_oaep_sha_data & hmac_key_encrypted, string & signature) const { @@ -321,10 +321,10 @@ "auth(hmac) netcmd, exclude_pattern"); exclude_pattern = utf8(pattern_string); client = id(extract_substring(payload, pos, - constants::merkle_hash_length_in_bytes, + constants::merkle_hash_length_in_bytes, "auth(hmac) netcmd, client identifier")); nonce1 = id(extract_substring(payload, pos, - constants::merkle_hash_length_in_bytes, + constants::merkle_hash_length_in_bytes, "auth(hmac) netcmd, nonce1")); string hmac_key; extract_variable_length_string(payload, hmac_key, pos, @@ -362,7 +362,7 @@ size_t pos = 0; assert_end_of_buffer(payload, pos, "confirm netcmd payload"); } - + void netcmd::write_confirm_cmd() { @@ -370,7 +370,7 @@ payload.clear(); } -void +void netcmd::read_refine_cmd(refinement_type & ty, merkle_node & node) const { // syntax is: @@ -383,7 +383,7 @@ assert_end_of_buffer(payload, pos, "refine cmd"); } -void +void netcmd::write_refine_cmd(refinement_type ty, merkle_node const & node) { cmd_code = refine_cmd; @@ -392,18 +392,18 @@ write_node(node, payload); } -void +void netcmd::read_done_cmd(netcmd_item_type & type, size_t & n_items) const { size_t pos = 0; - // syntax is: + // syntax is: type = read_netcmd_item_type(payload, pos, "done netcmd, item type"); n_items = extract_datum_uleb128(payload, pos, "done netcmd, item-to-send count"); assert_end_of_buffer(payload, pos, "done netcmd payload"); } -void +void netcmd::write_done_cmd(netcmd_item_type type, size_t n_items) { @@ -413,17 +413,17 @@ insert_datum_uleb128(n_items, payload); } -void +void netcmd::read_data_cmd(netcmd_item_type & type, id & item, string & dat) const { size_t pos = 0; - // syntax is: + // syntax is: // type = read_netcmd_item_type(payload, pos, "data netcmd, item type"); item = id(extract_substring(payload, pos, - constants::merkle_hash_length_in_bytes, + constants::merkle_hash_length_in_bytes, "data netcmd, item identifier")); dat.clear(); @@ -441,7 +441,7 @@ assert_end_of_buffer(payload, pos, "data netcmd payload"); } -void +void netcmd::write_data_cmd(netcmd_item_type type, id const & item, string const & dat) @@ -459,25 +459,25 @@ } else { - payload += static_cast(0); // compressed flag + payload += static_cast(0); // compressed flag insert_variable_length_string(dat, payload); } } -void +void netcmd::read_delta_cmd(netcmd_item_type & type, id & base, id & ident, delta & del) const { size_t pos = 0; // syntax is: - // + // type = read_netcmd_item_type(payload, pos, "delta netcmd, item type"); base = id(extract_substring(payload, pos, - constants::merkle_hash_length_in_bytes, + constants::merkle_hash_length_in_bytes, "delta netcmd, base identifier")); ident = id(extract_substring(payload, pos, - constants::merkle_hash_length_in_bytes, + constants::merkle_hash_length_in_bytes, "delta netcmd, ident identifier")); u8 compressed_p = extract_datum_lsb(payload, pos, "delta netcmd, compression flag"); @@ -496,9 +496,9 @@ assert_end_of_buffer(payload, pos, "delta netcmd payload"); } -void +void netcmd::write_delta_cmd(netcmd_item_type & type, - id const & base, id const & ident, + id const & base, id const & ident, delta const & del) { cmd_code = delta_cmd; @@ -519,14 +519,14 @@ } else { - payload += static_cast(0); // compressed flag + payload += static_cast(0); // compressed flag tmp = del(); } I(tmp.size() <= constants::netcmd_payload_limit); insert_variable_length_string(tmp, payload); } -void +void netcmd::read_usher_cmd(utf8 & greeting) const { size_t pos = 0; @@ -536,7 +536,7 @@ assert_end_of_buffer(payload, pos, "error netcmd payload"); } -void +void netcmd::write_usher_reply_cmd(utf8 const & server, utf8 const & pattern) { cmd_code = usher_reply_cmd; @@ -611,16 +611,16 @@ BOOST_CHECK(in_cmd == out_cmd); } -void +void test_netcmd_functions() { - - try + + try { // error_cmd { - L(FL("checking i/o round trip on error_cmd\n")); + L(FL("checking i/o round trip on error_cmd")); netcmd out_cmd, in_cmd; string out_errmsg("your shoelaces are untied"), in_errmsg; string buf; @@ -628,12 +628,12 @@ do_netcmd_roundtrip(out_cmd, in_cmd, buf); in_cmd.read_error_cmd(in_errmsg); BOOST_CHECK(in_errmsg == out_errmsg); - L(FL("errmsg_cmd test done, buffer was %d bytes\n") % buf.size()); + L(FL("errmsg_cmd test done, buffer was %d bytes") % buf.size()); } - + // hello_cmd { - L(FL("checking i/o round trip on hello_cmd\n")); + L(FL("checking i/o round trip on hello_cmd")); netcmd out_cmd, in_cmd; string buf; rsa_keypair_id out_server_keyname("address@hidden"), in_server_keyname; @@ -645,12 +645,12 @@ BOOST_CHECK(in_server_keyname == out_server_keyname); BOOST_CHECK(in_server_key == out_server_key); BOOST_CHECK(in_nonce == out_nonce); - L(FL("hello_cmd test done, buffer was %d bytes\n") % buf.size()); + L(FL("hello_cmd test done, buffer was %d bytes") % buf.size()); } // bye_cmd { - L(FL("checking i/o round trip on bye_cmd\n")); + L(FL("checking i/o round trip on bye_cmd")); netcmd out_cmd, in_cmd; u8 out_phase(1), in_phase; string buf; @@ -659,12 +659,12 @@ do_netcmd_roundtrip(out_cmd, in_cmd, buf); in_cmd.read_bye_cmd(in_phase); BOOST_CHECK(in_phase == out_phase); - L(FL("bye_cmd test done, buffer was %d bytes\n") % buf.size()); + L(FL("bye_cmd test done, buffer was %d bytes") % buf.size()); } // anonymous_cmd { - L(FL("checking i/o round trip on anonymous_cmd\n")); + L(FL("checking i/o round trip on anonymous_cmd")); netcmd out_cmd, in_cmd; protocol_role out_role = source_and_sink_role, in_role; string buf; @@ -681,16 +681,16 @@ BOOST_CHECK(in_include_pattern == out_include_pattern); BOOST_CHECK(in_exclude_pattern == out_exclude_pattern); BOOST_CHECK(in_role == out_role); - L(FL("anonymous_cmd test done, buffer was %d bytes\n") % buf.size()); + L(FL("anonymous_cmd test done, buffer was %d bytes") % buf.size()); } // auth_cmd { - L(FL("checking i/o round trip on auth_cmd\n")); + L(FL("checking i/o round trip on auth_cmd")); netcmd out_cmd, in_cmd; protocol_role out_role = source_and_sink_role, in_role; string buf; - id out_client(raw_sha1("happy client day")), out_nonce1(raw_sha1("nonce me amadeus")), + id out_client(raw_sha1("happy client day")), out_nonce1(raw_sha1("nonce me amadeus")), in_client, in_nonce1; // total cheat, since we don't actually verify that rsa_oaep_sha_data // is sensible anywhere here... @@ -711,23 +711,23 @@ BOOST_CHECK(in_role == out_role); BOOST_CHECK(in_include_pattern == out_include_pattern); BOOST_CHECK(in_exclude_pattern == out_exclude_pattern); - L(FL("auth_cmd test done, buffer was %d bytes\n") % buf.size()); + L(FL("auth_cmd test done, buffer was %d bytes") % buf.size()); } // confirm_cmd { - L(FL("checking i/o round trip on confirm_cmd\n")); + L(FL("checking i/o round trip on confirm_cmd")); netcmd out_cmd, in_cmd; string buf; out_cmd.write_confirm_cmd(); do_netcmd_roundtrip(out_cmd, in_cmd, buf); in_cmd.read_confirm_cmd(); - L(FL("confirm_cmd test done, buffer was %d bytes\n") % buf.size()); + L(FL("confirm_cmd test done, buffer was %d bytes") % buf.size()); } // refine_cmd { - L(FL("checking i/o round trip on refine_cmd\n")); + L(FL("checking i/o round trip on refine_cmd")); netcmd out_cmd, in_cmd; string buf; refinement_type out_ty (refinement_query), in_ty(refinement_response); @@ -747,12 +747,12 @@ in_cmd.read_refine_cmd(in_ty, in_node); BOOST_CHECK(in_ty == out_ty); BOOST_CHECK(in_node == out_node); - L(FL("refine_cmd test done, buffer was %d bytes\n") % buf.size()); + L(FL("refine_cmd test done, buffer was %d bytes") % buf.size()); } // done_cmd { - L(FL("checking i/o round trip on done_cmd\n")); + L(FL("checking i/o round trip on done_cmd")); netcmd out_cmd, in_cmd; size_t out_n_items(12), in_n_items(0); netcmd_item_type out_type(key_item), in_type(revision_item); @@ -763,12 +763,12 @@ in_cmd.read_done_cmd(in_type, in_n_items); BOOST_CHECK(in_n_items == out_n_items); BOOST_CHECK(in_type == out_type); - L(FL("done_cmd test done, buffer was %d bytes\n") % buf.size()); + L(FL("done_cmd test done, buffer was %d bytes") % buf.size()); } // data_cmd { - L(FL("checking i/o round trip on data_cmd\n")); + L(FL("checking i/o round trip on data_cmd")); netcmd out_cmd, in_cmd; netcmd_item_type out_type(file_item), in_type(key_item); id out_id(raw_sha1("tuna is not yummy")), in_id; @@ -779,12 +779,12 @@ in_cmd.read_data_cmd(in_type, in_id, in_dat); BOOST_CHECK(in_id == out_id); BOOST_CHECK(in_dat == out_dat); - L(FL("data_cmd test done, buffer was %d bytes\n") % buf.size()); + L(FL("data_cmd test done, buffer was %d bytes") % buf.size()); } // delta_cmd { - L(FL("checking i/o round trip on delta_cmd\n")); + L(FL("checking i/o round trip on delta_cmd")); netcmd out_cmd, in_cmd; netcmd_item_type out_type(file_item), in_type(key_item); id out_head(raw_sha1("your seat cusion can be reused")), in_head; @@ -799,18 +799,18 @@ BOOST_CHECK(in_head == out_head); BOOST_CHECK(in_base == out_base); BOOST_CHECK(in_delta == out_delta); - L(FL("delta_cmd test done, buffer was %d bytes\n") % buf.size()); + L(FL("delta_cmd test done, buffer was %d bytes") % buf.size()); } } catch (bad_decode & d) { - L(FL("bad decode exception: '%s'\n") % d.what); + L(FL("bad decode exception: '%s'") % d.what); throw; } } -void +void add_netcmd_tests(test_suite * suite) { suite->add(BOOST_TEST_CASE(&test_netcmd_functions)); ============================================================ --- netcmd.hh e290b45f5acb01bfe181832d4750275e05b2f98f +++ netcmd.hh 06cdc51d8a9a6eb0b38cc17b810ededb0121d5e1 @@ -15,10 +15,10 @@ #include "hmac.hh" #include "string_queue.hh" -typedef enum - { - source_role = 1, - sink_role = 2, +typedef enum + { + source_role = 1, + sink_role = 2, source_and_sink_role = 3 } protocol_role; @@ -30,8 +30,8 @@ } refinement_type; -typedef enum - { +typedef enum + { // general commands error_cmd = 0, bye_cmd = 1, @@ -41,11 +41,11 @@ anonymous_cmd = 3, auth_cmd = 4, confirm_cmd = 5, - + // refinement commands refine_cmd = 6, done_cmd = 7, - + // transmission commands data_cmd = 8, delta_cmd = 9, @@ -109,23 +109,23 @@ utf8 & include_pattern, utf8 & exclude_pattern, rsa_oaep_sha_data & hmac_key_encrypted) const; - void write_anonymous_cmd(protocol_role role, + void write_anonymous_cmd(protocol_role role, utf8 const & include_pattern, utf8 const & exclude_pattern, rsa_oaep_sha_data const & hmac_key_encrypted); - void read_auth_cmd(protocol_role & role, + void read_auth_cmd(protocol_role & role, utf8 & include_pattern, utf8 & exclude_pattern, - id & client, - id & nonce1, + id & client, + id & nonce1, rsa_oaep_sha_data & hmac_key_encrypted, std::string & signature) const; - void write_auth_cmd(protocol_role role, - utf8 const & include_pattern, - utf8 const & exclude_pattern, + void write_auth_cmd(protocol_role role, + utf8 const & include_pattern, + utf8 const & exclude_pattern, id const & client, - id const & nonce1, + id const & nonce1, rsa_oaep_sha_data const & hmac_key_encrypted, std::string const & signature); @@ -146,10 +146,10 @@ std::string const & dat); void read_delta_cmd(netcmd_item_type & type, - id & base, id & ident, + id & base, id & ident, delta & del) const; void write_delta_cmd(netcmd_item_type & type, - id const & base, id const & ident, + id const & base, id const & ident, delta const & del); void read_usher_cmd(utf8 & greeting) const; ============================================================ --- netio.hh 3177bc0e70e1d2333e7ffeee004b01f2d114ccfb +++ netio.hh e37bb9cfb163aac2a2ac4e63a29f233bab47c9c0 @@ -20,10 +20,10 @@ std::string what; }; -inline void -require_bytes(std::string const & str, - size_t pos, - size_t len, +inline void +require_bytes(std::string const & str, + size_t pos, + size_t len, std::string const & name) { // if you've gone past the end of the buffer, there's a logic error, @@ -34,14 +34,14 @@ if (len == 0) return; if (str.size() < pos + len) - throw bad_decode(F("need %d bytes to decode %s at %d, only have %d") + throw bad_decode(F("need %d bytes to decode %s at %d, only have %d") % len % name % pos % (str.size() - pos)); } -inline void -require_bytes(string_queue const & str, - size_t pos, - size_t len, +inline void +require_bytes(string_queue const & str, + size_t pos, + size_t len, std::string const & name) { // if you've gone past the end of the buffer, there's a logic error, @@ -52,13 +52,13 @@ if (len == 0) return; if (str.size() < pos + len) - throw bad_decode(F("need %d bytes to decode %s at %d, only have %d") + throw bad_decode(F("need %d bytes to decode %s at %d, only have %d") % len % name % pos % (str.size() - pos)); } template -inline bool -try_extract_datum_uleb128(std::string const & in, +inline bool +try_extract_datum_uleb128(std::string const & in, size_t & pos, std::string const & name, T & out) @@ -73,14 +73,14 @@ return false; T curr = widen(in[pos]); ++pos; - out |= ((static_cast(curr) + out |= ((static_cast(curr) & static_cast(0x7f)) << shift); bool finished = ! static_cast(static_cast(curr) & static_cast(0x80)); if (finished) break; else if (maxbytes == 1) - throw bad_decode(F("uleb128 decode for '%s' into %d-byte datum overflowed") + throw bad_decode(F("uleb128 decode for '%s' into %d-byte datum overflowed") % name % maxbytes); else { @@ -92,8 +92,8 @@ } template -inline bool -try_extract_datum_uleb128(string_queue const & in, +inline bool +try_extract_datum_uleb128(string_queue const & in, size_t & pos, std::string const & name, T & out) @@ -108,14 +108,14 @@ return false; T curr = widen(in[pos]); ++pos; - out |= ((static_cast(curr) + out |= ((static_cast(curr) & static_cast(0x7f)) << shift); bool finished = ! static_cast(static_cast(curr) & static_cast(0x80)); if (finished) break; else if (maxbytes == 1) - throw bad_decode(F("uleb128 decode for '%s' into %d-byte datum overflowed") + throw bad_decode(F("uleb128 decode for '%s' into %d-byte datum overflowed") % name % maxbytes); else { @@ -127,8 +127,8 @@ } template -inline T -extract_datum_uleb128(std::string const & in, +inline T +extract_datum_uleb128(std::string const & in, size_t & pos, std::string const & name) { @@ -142,7 +142,7 @@ } template -inline void +inline void insert_datum_uleb128(T in, std::string & out) { BOOST_STATIC_ASSERT(std::numeric_limits::is_signed == false); @@ -167,7 +167,7 @@ } template -inline void +inline void insert_datum_uleb128(T in, string_queue & out) { BOOST_STATIC_ASSERT(std::numeric_limits::is_signed == false); @@ -192,9 +192,9 @@ } template -inline T -extract_datum_lsb(std::string const & in, - size_t & pos, +inline T +extract_datum_lsb(std::string const & in, + size_t & pos, std::string const & name) { size_t nbytes = sizeof(T); @@ -213,9 +213,9 @@ } template -inline T -extract_datum_lsb(string_queue const & in, - size_t & pos, +inline T +extract_datum_lsb(string_queue const & in, + size_t & pos, std::string const & name) { size_t nbytes = sizeof(T); @@ -234,7 +234,7 @@ } template -inline void +inline void insert_datum_lsb(T in, std::string & out) { size_t const nbytes = sizeof(T); @@ -248,7 +248,7 @@ } template -inline void +inline void insert_datum_lsb(T in, string_queue & out) { size_t const nbytes = sizeof(T); @@ -261,7 +261,7 @@ out.append(std::string(tmp, tmp+nbytes)); } -inline void +inline void extract_variable_length_string(std::string const & buf, std::string & out, size_t & pos, @@ -278,7 +278,7 @@ pos += len; } -inline void +inline void insert_variable_length_string(std::string const & in, std::string & buf) { @@ -287,7 +287,7 @@ buf.append(in); } -inline void +inline void insert_variable_length_string(std::string const & in, string_queue & buf) { @@ -297,9 +297,9 @@ } inline std::string -extract_substring(std::string const & buf, +extract_substring(std::string const & buf, size_t & pos, - size_t len, + size_t len, std::string const & name) { require_bytes(buf, pos, len, name); @@ -309,9 +309,9 @@ } inline std::string -extract_substring(string_queue const & buf, +extract_substring(string_queue const & buf, size_t & pos, - size_t len, + size_t len, std::string const & name) { require_bytes(buf, pos, len, name); @@ -320,13 +320,13 @@ return tmp; } -inline void -assert_end_of_buffer(std::string const & str, - size_t pos, +inline void +assert_end_of_buffer(std::string const & str, + size_t pos, std::string const & name) { if (str.size() != pos) - throw bad_decode(F("expected %s to end at %d, have %d bytes") + throw bad_decode(F("expected %s to end at %d, have %d bytes") % name % pos % str.size()); } ============================================================ --- netsync.cc 790c8fceb436ee65f0ade641aefe3a60d10893d9 +++ netsync.cc a65ecca750cb7342ee8ab24f152ea92ff208eba0 @@ -104,7 +104,7 @@ // - empty // - leaf // - subtree -// +// // In addition, each leaf contains a hash code which identifies an element // of the set being synchronized. Each subtree slot contains a hash code of // the node immediately beneath it in the merkle tree. Empty slots contain @@ -121,7 +121,7 @@ // 20 bytes - hash of the remaining bytes in the node // 1 byte - type of this node (manifest, file, key, mcert, fcert) // 1-N bytes - level of this node in the tree (0 == "root", uleb128) -// 0-20 bytes - the prefix of this node, 4 bits * level, +// 0-20 bytes - the prefix of this node, 4 bits * level, // rounded up to a byte // 1-N bytes - number of leaves under this node (uleb128) // 4 bytes - slot-state bitmap of the node @@ -190,7 +190,7 @@ // // For more details on the refinement process, see refiner.cc. // -// +// // Transmission // ------------ // @@ -247,10 +247,10 @@ using boost::shared_ptr; using boost::lexical_cast; -static inline void +static inline void require(bool check, string const & context) { - if (!check) + if (!check) throw bad_decode(F("check of '%s' failed") % context); } @@ -260,7 +260,7 @@ netsync_error(string const & s): msg(s) {} }; -struct +struct session: public refiner_callbacks, public enumerator_callbacks @@ -273,11 +273,11 @@ app_state & app; string peer_id; - shared_ptr str; + shared_ptr str; - string_queue inbuf; + string_queue inbuf; // deque of pair - deque< pair > outbuf; + deque< pair > outbuf; // the total data stored in outbuf - this is // used as a valve to stop too much data // backing up @@ -301,7 +301,7 @@ auto_ptr cert_out_ticker; auto_ptr revision_in_ticker; auto_ptr revision_out_ticker; - + vector written_revisions; vector written_keys; vector written_certs; @@ -309,13 +309,13 @@ id saved_nonce; packet_db_writer dbw; - enum - { + enum + { working_state, shutdown_state, confirmed_state } - protocol_state; + protocol_state; bool encountered_error; bool set_totals; @@ -347,7 +347,7 @@ shared_ptr sock); virtual ~session(); - + void rev_written_callback(revision_id rid); void key_written_callback(rsa_keypair_id kid); void cert_written_callback(cert const & c); @@ -383,29 +383,29 @@ void queue_error_cmd(string const & errmsg); void queue_done_cmd(netcmd_item_type type, size_t n_items); void queue_hello_cmd(rsa_keypair_id const & key_name, - base64 const & pub_encoded, + base64 const & pub_encoded, id const & nonce); - void queue_anonymous_cmd(protocol_role role, - utf8 const & include_pattern, - utf8 const & exclude_pattern, + void queue_anonymous_cmd(protocol_role role, + utf8 const & include_pattern, + utf8 const & exclude_pattern, id const & nonce2, base64 server_key_encoded); - void queue_auth_cmd(protocol_role role, - utf8 const & include_pattern, - utf8 const & exclude_pattern, - id const & client, - id const & nonce1, - id const & nonce2, + void queue_auth_cmd(protocol_role role, + utf8 const & include_pattern, + utf8 const & exclude_pattern, + id const & client, + id const & nonce1, + id const & nonce2, string const & signature, base64 server_key_encoded); void queue_confirm_cmd(); void queue_refine_cmd(refinement_type ty, merkle_node const & node); - void queue_data_cmd(netcmd_item_type type, + void queue_data_cmd(netcmd_item_type type, id const & item, string const & dat); - void queue_delta_cmd(netcmd_item_type type, - id const & base, - id const & ident, + void queue_delta_cmd(netcmd_item_type type, + id const & base, + id const & ident, delta const & del); // Incoming dispatch-called methods. @@ -414,23 +414,23 @@ rsa_pub_key const & server_key, id const & nonce); bool process_bye_cmd(u8 phase, transaction_guard & guard); - bool process_anonymous_cmd(protocol_role role, + bool process_anonymous_cmd(protocol_role role, utf8 const & their_include_pattern, utf8 const & their_exclude_pattern); - bool process_auth_cmd(protocol_role role, - utf8 const & their_include_pattern, - utf8 const & their_exclude_pattern, - id const & client, - id const & nonce1, + bool process_auth_cmd(protocol_role role, + utf8 const & their_include_pattern, + utf8 const & their_exclude_pattern, + id const & client, + id const & nonce1, string const & signature); bool process_refine_cmd(refinement_type ty, merkle_node const & node); bool process_done_cmd(netcmd_item_type type, size_t n_items); bool process_data_cmd(netcmd_item_type type, - id const & item, + id const & item, string const & dat); bool process_delta_cmd(netcmd_item_type type, - id const & base, - id const & ident, + id const & base, + id const & ident, delta const & del); bool process_usher_cmd(utf8 const & msg); @@ -441,7 +441,7 @@ // Various helpers. void assume_corresponding_role(protocol_role their_role); void respond_to_confirm_cmd(); - bool data_exists(netcmd_item_type type, + bool data_exists(netcmd_item_type type, id const & item); void load_data(netcmd_item_type type, id const & item, @@ -455,14 +455,14 @@ bool process(transaction_guard & guard); }; - + session::session(protocol_role role, protocol_voice voice, utf8 const & our_include_pattern, utf8 const & our_exclude_pattern, app_state & app, string const & peer, - shared_ptr sock) : + shared_ptr sock) : role(role), voice(voice), our_include_pattern(our_include_pattern), @@ -531,7 +531,7 @@ } // if (role == sink_role || role == source_and_sink_role) - if (!written_keys.empty() + if (!written_keys.empty() || !written_revisions.empty() || !written_certs.empty()) { @@ -578,7 +578,7 @@ } } -bool +bool session::process_this_rev(revision_id const & rev) { id item; @@ -587,7 +587,7 @@ != rev_refiner.items_to_send.end()); } -bool +bool session::queue_this_cert(hexenc const & c) { id item; @@ -596,13 +596,13 @@ != cert_refiner.items_to_send.end()); } -bool +bool session::queue_this_file(hexenc const & f) { return file_items_sent.find(f) == file_items_sent.end(); } -void +void session::note_file_data(file_id const & f) { if (role == sink_role) @@ -615,7 +615,7 @@ file_items_sent.insert(f); } -void +void session::note_file_delta(file_id const & src, file_id const & dst) { if (role == sink_role) @@ -623,13 +623,13 @@ file_delta fdel; id fid1, fid2; decode_hexenc(src.inner(), fid1); - decode_hexenc(dst.inner(), fid2); + decode_hexenc(dst.inner(), fid2); app.db.get_arbitrary_file_delta(src, dst, fdel); queue_delta_cmd(file_item, fid1, fid2, fdel.inner()); file_items_sent.insert(dst); } -void +void session::note_rev(revision_id const & rev) { if (role == sink_role) @@ -643,7 +643,7 @@ queue_data_cmd(revision_item, item, tmp()); } -void +void session::note_cert(hexenc const & c) { if (role == sink_role) @@ -673,7 +673,7 @@ written_certs.push_back(c); } -id +id session::mk_nonce() { I(this->saved_nonce().size() == 0); @@ -685,7 +685,7 @@ return this->saved_nonce; } -void +void session::mark_recent_io() { last_io_time = ::time(NULL); @@ -744,7 +744,7 @@ } } -bool +bool session::done_all_refinements() { bool all = rev_refiner.done @@ -765,15 +765,15 @@ if (revision_in_ticker.get()) revision_in_ticker->set_total(rev_refiner.items_to_receive); - + set_totals = true; } - return all; + return all; } -bool +bool session::received_all_items() { if (role == source_role) @@ -785,19 +785,19 @@ return all; } -bool +bool session::finished_working() { - bool all = done_all_refinements() + bool all = done_all_refinements() && received_all_items() && queued_all_items() && rev_enumerator.done(); return all; } -bool +bool session::queued_all_items() -{ +{ if (role == sink_role) return true; bool all = rev_refiner.items_to_send.empty() @@ -907,7 +907,7 @@ } } -void +void session::write_netcmd_and_try_flush(netcmd const & cmd) { if (!encountered_error) @@ -918,7 +918,7 @@ outbuf_size += buf.size(); } else - L(FL("dropping outgoing netcmd (because we're in error unwind mode)\n")); + L(FL("dropping outgoing netcmd (because we're in error unwind mode)")); // FIXME: this helps keep the protocol pipeline full but it seems to // interfere with initial and final sequences. careful with it. // write_some(); @@ -936,7 +936,7 @@ throw netsync_error(errmsg); } -Netxx::Probe::ready_type +Netxx::Probe::ready_type session::which_events() const { // Only ask to read if we're not armed. @@ -953,10 +953,10 @@ return Netxx::Probe::ready_write | Netxx::Probe::ready_read | Netxx::Probe::ready_oobd; else return Netxx::Probe::ready_write | Netxx::Probe::ready_oobd; - } + } } -bool +bool session::read_some() { I(inbuf.size() < constants::netcmd_maxsz); @@ -964,10 +964,10 @@ Netxx::signed_size_type count = str->read(tmp, sizeof(tmp)); if (count > 0) { - L(FL("read %d bytes from fd %d (peer %s)\n") % count % str->get_socketfd() % peer_id); + L(FL("read %d bytes from fd %d (peer %s)") % count % str->get_socketfd() % peer_id); if (encountered_error) { - L(FL("in error unwind mode, so throwing them into the bit bucket\n")); + L(FL("in error unwind mode, so throwing them into the bit bucket")); return true; } inbuf.append(tmp,count); @@ -980,12 +980,12 @@ return false; } -bool +bool session::write_some() { - I(!outbuf.empty()); + 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, + Netxx::signed_size_type count = str->write(outbuf.front().first.data() + outbuf.front().second, min(writelen, constants::bufsz)); if (count > 0) @@ -999,7 +999,7 @@ { outbuf.front().second += count; } - L(FL("wrote %d bytes to fd %d (peer %s)\n") + L(FL("wrote %d bytes to fd %d (peer %s)") % count % str->get_socketfd() % peer_id); mark_recent_io(); if (byte_out_ticker.get() != NULL) @@ -1007,7 +1007,7 @@ if (encountered_error && outbuf.empty()) { // we've flushed our error message, so it's time to get out. - L(FL("finished flushing output queue in error unwind mode, disconnecting\n")); + L(FL("finished flushing output queue in error unwind mode, disconnecting")); return false; } return true; @@ -1018,42 +1018,42 @@ // senders -void +void session::queue_error_cmd(string const & errmsg) { - L(FL("queueing 'error' command\n")); + L(FL("queueing 'error' command")); netcmd cmd; cmd.write_error_cmd(errmsg); write_netcmd_and_try_flush(cmd); } -void -session::queue_bye_cmd(u8 phase) +void +session::queue_bye_cmd(u8 phase) { - L(FL("queueing 'bye' command, phase %d\n") + L(FL("queueing 'bye' command, phase %d") % static_cast(phase)); netcmd cmd; cmd.write_bye_cmd(phase); write_netcmd_and_try_flush(cmd); } -void +void session::queue_done_cmd(netcmd_item_type type, - size_t n_items) + size_t n_items) { string typestr; netcmd_item_type_to_string(type, typestr); - L(FL("queueing 'done' command for %s (%d items)\n") + L(FL("queueing 'done' command for %s (%d items)") % typestr % n_items); netcmd cmd; cmd.write_done_cmd(type, n_items); write_netcmd_and_try_flush(cmd); } -void +void session::queue_hello_cmd(rsa_keypair_id const & key_name, - base64 const & pub_encoded, - id const & nonce) + base64 const & pub_encoded, + id const & nonce) { rsa_pub_key pub; if (app.use_transport_auth) @@ -1062,10 +1062,10 @@ write_netcmd_and_try_flush(cmd); } -void -session::queue_anonymous_cmd(protocol_role role, - utf8 const & include_pattern, - utf8 const & exclude_pattern, +void +session::queue_anonymous_cmd(protocol_role role, + utf8 const & include_pattern, + utf8 const & exclude_pattern, id const & nonce2, base64 server_key_encoded) { @@ -1080,13 +1080,13 @@ set_session_key(nonce2()); } -void -session::queue_auth_cmd(protocol_role role, - utf8 const & include_pattern, - utf8 const & exclude_pattern, - id const & client, - id const & nonce1, - id const & nonce2, +void +session::queue_auth_cmd(protocol_role role, + utf8 const & include_pattern, + utf8 const & exclude_pattern, + id const & client, + id const & nonce1, + id const & nonce2, string const & signature, base64 server_key_encoded) { @@ -1109,14 +1109,14 @@ write_netcmd_and_try_flush(cmd); } -void +void session::queue_refine_cmd(refinement_type ty, merkle_node const & node) { string typestr; hexenc hpref; node.get_hex_prefix(hpref); netcmd_item_type_to_string(node.type, typestr); - L(FL("queueing refinement %s of %s node '%s', level %d\n") + L(FL("queueing refinement %s of %s node '%s', level %d") % (ty == refinement_query ? "query" : "response") % typestr % hpref % static_cast(node.level)); netcmd cmd; @@ -1124,9 +1124,9 @@ write_netcmd_and_try_flush(cmd); } -void +void session::queue_data_cmd(netcmd_item_type type, - id const & item, + id const & item, string const & dat) { string typestr; @@ -1136,19 +1136,19 @@ if (role == sink_role) { - L(FL("not queueing %s data for '%s' as we are in pure sink role\n") + L(FL("not queueing %s data for '%s' as we are in pure sink role") % typestr % hid); return; } - L(FL("queueing %d bytes of data for %s item '%s'\n") + L(FL("queueing %d bytes of data for %s item '%s'") % dat.size() % typestr % hid); netcmd cmd; // TODO: This pair of functions will make two copies of a large // file, the first in cmd.write_data_cmd, and the second in // write_netcmd_and_try_flush when the data is copied from the - // cmd.payload variable to the string buffer for output. This + // cmd.payload variable to the string buffer for output. This // double copy should be collapsed out, it may be better to use // a string_queue for output as well as input, as that will reduce // the amount of mallocs that happen when the string queue is large @@ -1160,8 +1160,8 @@ void session::queue_delta_cmd(netcmd_item_type type, - id const & base, - id const & ident, + id const & base, + id const & ident, delta const & del) { I(type == file_item); @@ -1175,12 +1175,12 @@ if (role == sink_role) { - L(FL("not queueing %s delta '%s' -> '%s' as we are in pure sink role\n") + L(FL("not queueing %s delta '%s' -> '%s' as we are in pure sink role") % typestr % base_hid % ident_hid); return; } - L(FL("queueing %s delta '%s' -> '%s'\n") + L(FL("queueing %s delta '%s' -> '%s'") % typestr % base_hid % ident_hid); netcmd cmd; cmd.write_delta_cmd(type, base, ident, del); @@ -1191,8 +1191,8 @@ // processors -bool -session::process_error_cmd(string const & errmsg) +bool +session::process_error_cmd(string const & errmsg) { throw bad_decode(F("received network error: %s") % errmsg); } @@ -1206,10 +1206,10 @@ static const var_domain known_servers_domain = var_domain("known-servers"); -bool +bool session::process_hello_cmd(rsa_keypair_id const & their_keyname, rsa_pub_key const & their_key, - id const & nonce) + id const & nonce) { I(this->remote_peer_key_hash().size() == 0); I(this->saved_nonce().size() == 0); @@ -1221,7 +1221,7 @@ hexenc their_key_hash; encode_base64(their_key, their_key_encoded); key_hash_code(their_keyname, their_key_encoded, their_key_hash); - L(FL("server key has name %s, hash %s\n") % their_keyname % their_key_hash); + L(FL("server key has name %s, hash %s") % their_keyname % their_key_hash); var_key their_key_key(known_servers_domain, var_name(peer_id)); if (app.db.var_exists(their_key_key)) { @@ -1236,7 +1236,7 @@ "it is also possible that the server key has just been changed\n" "remote host sent key %s\n" "I expected %s\n" - "'%s unset %s %s' overrides this check\n") + "'%s unset %s %s' overrides this check") % their_key_hash % expected_key_hash % app.prog_name % their_key_key.first % their_key_key.second); E(false, F("server key changed")); @@ -1251,19 +1251,19 @@ } if (!app.db.public_key_exists(their_key_hash)) { - W(F("saving public key for %s to database\n") % their_keyname); + W(F("saving public key for %s to database") % their_keyname); app.db.put_key(their_keyname, their_key_encoded); } { hexenc hnonce; encode_hexenc(nonce, hnonce); - L(FL("received 'hello' netcmd from server '%s' with nonce '%s'\n") + L(FL("received 'hello' netcmd from server '%s' with nonce '%s'") % their_key_hash % hnonce); } I(app.db.public_key_exists(their_key_hash)); - - // save their identity + + // save their identity id their_key_hash_decoded; decode_hexenc(their_key_hash, their_key_hash_decoded); this->remote_peer_key_hash = their_key_hash_decoded; @@ -1283,8 +1283,8 @@ rebuild_merkle_trees(app, ok_branches); setup_client_tickers(); - - if (app.use_transport_auth && + + if (app.use_transport_auth && app.signing_key() != "") { // get our key pair @@ -1296,13 +1296,13 @@ id our_key_hash_raw; key_hash_code(app.signing_key, our_kp.pub, our_key_hash); decode_hexenc(our_key_hash, our_key_hash_raw); - + // make a signature base64 sig; rsa_sha1_signature sig_raw; make_signature(app, app.signing_key, our_kp.priv, nonce(), sig); decode_base64(sig, sig_raw); - + // make a new nonce of our own and send off the 'auth' queue_auth_cmd(this->role, our_include_pattern, our_exclude_pattern, our_key_hash_raw, nonce, mk_nonce(), sig_raw(), @@ -1313,12 +1313,12 @@ queue_anonymous_cmd(this->role, our_include_pattern, our_exclude_pattern, mk_nonce(), their_key_encoded); } - + return true; } -bool -session::process_anonymous_cmd(protocol_role their_role, +bool +session::process_anonymous_cmd(protocol_role their_role, utf8 const & their_include_pattern, utf8 const & their_exclude_pattern) { @@ -1335,8 +1335,8 @@ // // Client must be a sink and server must be a source (anonymous - // read-only), unless transport auth is disabled. - // + // read-only), unless transport auth is disabled. + // // If running in no-transport-auth mode, we operate anonymously and // permit adoption of any role. @@ -1344,14 +1344,14 @@ { if (their_role != sink_role) { - W(F("rejected attempt at anonymous connection for write\n")); + W(F("rejected attempt at anonymous connection for write")); this->saved_nonce = id(""); return false; } - + if (this->role == sink_role) { - W(F("rejected attempt at anonymous connection while running as sink\n")); + W(F("rejected attempt at anonymous connection while running as sink")); this->saved_nonce = id(""); return false; } @@ -1382,13 +1382,13 @@ if (app.use_transport_auth) { - P(F("allowed anonymous read permission for '%s' excluding '%s'\n") + P(F("allowed anonymous read permission for '%s' excluding '%s'") % their_include_pattern % their_exclude_pattern); this->role = source_role; } else { - P(F("allowed anonymous read/write permission for '%s' excluding '%s'\n") + P(F("allowed anonymous read/write permission for '%s' excluding '%s'") % their_include_pattern % their_exclude_pattern); assume_corresponding_role(their_role); } @@ -1410,15 +1410,15 @@ I(this->role != source_role); this->role = sink_role; break; - + case source_and_sink_role: I(this->role == source_and_sink_role); break; - + case sink_role: I(this->role != sink_role); this->role = source_role; - break; + break; } } @@ -1432,18 +1432,18 @@ { I(this->remote_peer_key_hash().size() == 0); I(this->saved_nonce().size() == constants::merkle_hash_length_in_bytes); - + hexenc their_key_hash; encode_hexenc(client, their_key_hash); set ok_branches; vector branchnames; get_branches(app, branchnames); globish_matcher their_matcher(their_include_pattern, their_exclude_pattern); - + // Check that they replied with the nonce we asked for. if (!(nonce1 == this->saved_nonce)) { - W(F("detected replay attack in auth netcmd\n")); + W(F("detected replay attack in auth netcmd")); this->saved_nonce = id(""); return false; } @@ -1465,12 +1465,12 @@ // have the private key that goes with it. if (!app.keys.try_ensure_in_db(their_key_hash)) { - W(F("remote public key hash '%s' is unknown\n") % their_key_hash); + W(F("remote public key hash '%s' is unknown") % their_key_hash); this->saved_nonce = id(""); return false; } } - + // Get their public key. rsa_keypair_id their_id; base64 their_key; @@ -1482,7 +1482,7 @@ { if (this->role != source_role && this->role != source_and_sink_role) { - W(F("denied '%s' read permission for '%s' excluding '%s' while running as pure sink\n") + W(F("denied '%s' read permission for '%s' excluding '%s' while running as pure sink") % their_id % their_include_pattern % their_exclude_pattern); this->saved_nonce = id(""); return false; @@ -1502,7 +1502,7 @@ } else if (!app.lua.hook_get_netsync_read_permitted(*i, their_id)) { - W(F("denied '%s' read permission for '%s' excluding '%s' because of branch '%s'\n") + W(F("denied '%s' read permission for '%s' excluding '%s' because of branch '%s'") % their_id % their_include_pattern % their_exclude_pattern % *i); error((F("access to branch '%s' denied by server") % *i).str()); @@ -1515,7 +1515,7 @@ // If we're source_and_sink_role, continue even with no branches readable // eg. serve --db=empty.db - P(F("allowed '%s' read permission for '%s' excluding '%s'\n") + P(F("allowed '%s' read permission for '%s' excluding '%s'") % their_id % their_include_pattern % their_exclude_pattern); // Client as source, server as sink (writing). @@ -1524,7 +1524,7 @@ { if (this->role != sink_role && this->role != source_and_sink_role) { - W(F("denied '%s' write permission for '%s' excluding '%s' while running as pure source\n") + W(F("denied '%s' write permission for '%s' excluding '%s' while running as pure source") % their_id % their_include_pattern % their_exclude_pattern); this->saved_nonce = id(""); return false; @@ -1532,13 +1532,13 @@ if (!app.lua.hook_get_netsync_write_permitted(their_id)) { - W(F("denied '%s' write permission for '%s' excluding '%s'\n") + W(F("denied '%s' write permission for '%s' excluding '%s'") % their_id % their_include_pattern % their_exclude_pattern); this->saved_nonce = id(""); return false; } - P(F("allowed '%s' write permission for '%s' excluding '%s'\n") + P(F("allowed '%s' write permission for '%s' excluding '%s'") % their_id % their_include_pattern % their_exclude_pattern); } @@ -1553,7 +1553,7 @@ if (check_signature(app, their_id, their_key, nonce1(), sig)) { // Get our private key and sign back. - L(FL("client signature OK, accepting authentication\n")); + L(FL("client signature OK, accepting authentication")); this->authenticated = true; this->remote_peer_key_name = their_id; @@ -1562,8 +1562,8 @@ } else { - W(F("bad client signature\n")); - } + W(F("bad client signature")); + } return false; } @@ -1572,27 +1572,27 @@ { string typestr; netcmd_item_type_to_string(node.type, typestr); - L(FL("processing refine cmd for %s node at level %d\n") + L(FL("processing refine cmd for %s node at level %d") % typestr % node.level); switch (node.type) - { + { case file_item: - W(F("Unexpected 'refine' command on non-refined item type\n")); + W(F("Unexpected 'refine' command on non-refined item type")); break; - + case key_item: key_refiner.process_refinement_command(ty, node); break; - + case revision_item: rev_refiner.process_refinement_command(ty, node); break; - + case cert_item: cert_refiner.process_refinement_command(ty, node); break; - + case epoch_item: epoch_refiner.process_refinement_command(ty, node); break; @@ -1600,8 +1600,8 @@ return true; } -bool -session::process_bye_cmd(u8 phase, +bool +session::process_bye_cmd(u8 phase, transaction_guard & guard) { @@ -1615,16 +1615,16 @@ // 0. [refinement, data, deltas, etc.] // client: C_SHUTDOWN // (client checkpoints here) -// 1. client -> "bye 0" +// 1. client -> "bye 0" // 2. "bye 0" -> server // server: S_SHUTDOWN // (server checkpoints here) -// 3. "bye 1" <- server -// 4. client <- "bye 1" +// 3. "bye 1" <- server +// 4. client <- "bye 1" // client: C_CONFIRMED -// 5. client -> "bye 2" +// 5. client -> "bye 2" // 6. "bye 2" -> server -// server: S_CONFIRMED +// server: S_CONFIRMED // 7. [server drops connection] // // @@ -1641,7 +1641,7 @@ switch (phase) { case 0: - if (voice == server_voice && + if (voice == server_voice && protocol_state == working_state) { protocol_state = shutdown_state; @@ -1653,7 +1653,7 @@ break; case 1: - if (voice == client_voice && + if (voice == client_voice && protocol_state == shutdown_state) { protocol_state = confirmed_state; @@ -1664,7 +1664,7 @@ break; case 2: - if (voice == server_voice && + if (voice == server_voice && protocol_state == shutdown_state) { protocol_state = confirmed_state; @@ -1681,32 +1681,32 @@ return true; } -bool +bool session::process_done_cmd(netcmd_item_type type, size_t n_items) { string typestr; netcmd_item_type_to_string(type, typestr); L(FL("received 'done' command for %s (%s items)") % typestr % n_items); switch (type) - { + { case file_item: - W(F("Unexpected 'done' command on non-refined item type\n")); + W(F("Unexpected 'done' command on non-refined item type")); break; - + case key_item: key_refiner.process_done_command(n_items); if (key_refiner.done && role != sink_role) send_all_data(key_item, key_refiner.items_to_send); break; - + case revision_item: rev_refiner.process_done_command(n_items); break; - + case cert_item: cert_refiner.process_done_command(n_items); break; - + case epoch_item: epoch_refiner.process_done_command(n_items); if (epoch_refiner.done) @@ -1725,8 +1725,8 @@ epoch_refiner.begin_refinement(); } -bool -session::data_exists(netcmd_item_type type, +bool +session::data_exists(netcmd_item_type type, id const & item) { hexenc hitem; @@ -1734,26 +1734,26 @@ switch (type) { case key_item: - return key_refiner.local_item_exists(item) + return key_refiner.local_item_exists(item) || app.db.public_key_exists(hitem); case file_item: return app.db.file_version_exists(file_id(hitem)); case revision_item: - return rev_refiner.local_item_exists(item) + return rev_refiner.local_item_exists(item) || app.db.revision_exists(revision_id(hitem)); case cert_item: - return cert_refiner.local_item_exists(item) + return cert_refiner.local_item_exists(item) || app.db.revision_cert_exists(hitem); case epoch_item: - return epoch_refiner.local_item_exists(item) + return epoch_refiner.local_item_exists(item) || app.db.epoch_exists(epoch_id(hitem)); } return false; } -void -session::load_data(netcmd_item_type type, - id const & item, +void +session::load_data(netcmd_item_type type, + id const & item, string & out) { string typestr; @@ -1780,7 +1780,7 @@ rsa_keypair_id keyid; base64 pub_encoded; app.db.get_pubkey(hitem, keyid, pub_encoded); - L(FL("public key '%s' is also called '%s'\n") % hitem % keyid); + L(FL("public key '%s' is also called '%s'") % hitem % keyid); write_pubkey(keyid, pub_encoded, out); } break; @@ -1793,7 +1793,7 @@ out = mdat.inner()(); } break; - + case file_item: { file_data fdat; @@ -1814,11 +1814,11 @@ } } -bool +bool session::process_data_cmd(netcmd_item_type type, - id const & item, + id const & item, string const & dat) -{ +{ hexenc hitem; encode_hexenc(item, hitem); @@ -1828,7 +1828,7 @@ note_item_arrived(type, item); if (data_exists(type, item)) { - L(FL("%s '%s' already exists in our database\n") % typestr % hitem); + L(FL("%s '%s' already exists in our database") % typestr % hitem); return true; } @@ -1839,19 +1839,19 @@ cert_value branch; epoch_data epoch; read_epoch(dat, branch, epoch); - L(FL("received epoch %s for branch %s\n") % epoch % branch); + L(FL("received epoch %s for branch %s") % epoch % branch); map epochs; app.db.get_epochs(epochs); map::const_iterator i; i = epochs.find(branch); if (i == epochs.end()) { - L(FL("branch %s has no epoch; setting epoch to %s\n") % branch % epoch); + L(FL("branch %s has no epoch; setting epoch to %s") % branch % epoch); app.db.set_epoch(branch, epoch); } else { - L(FL("branch %s already has an epoch; checking\n") % branch); + L(FL("branch %s already has an epoch; checking") % branch); // If we get here, then we know that the epoch must be // different, because if it were the same then the // if (epoch_exists()) branch up above would have been taken. @@ -1859,7 +1859,7 @@ // hashing or something, which is very dangerous, so play it // safe... I(!(i->second == epoch)); - + // It is safe to call 'error' here, because if we get here, // then the current netcmd packet cannot possibly have // written anything to the database. @@ -1872,7 +1872,7 @@ } maybe_note_epochs_finished(); break; - + case key_item: { rsa_keypair_id keyid; @@ -1882,7 +1882,7 @@ key_hash_code(keyid, pub, tmp); if (! (tmp == hitem)) throw bad_decode(F("hash check failed for public key '%s' (%s);" - " wanted '%s' got '%s'") + " wanted '%s' got '%s'") % hitem % keyid % hitem % tmp); this->dbw.consume_public_key(keyid, pub); } @@ -1902,14 +1902,14 @@ case revision_item: { - L(FL("received revision '%s'\n") % hitem); + L(FL("received revision '%s'") % hitem); this->dbw.consume_revision_data(revision_id(hitem), revision_data(dat)); } break; - + case file_item: { - L(FL("received file '%s'\n") % hitem); + L(FL("received file '%s'") % hitem); this->dbw.consume_file_data(file_id(hitem), file_data(dat)); } break; @@ -1917,10 +1917,10 @@ return true; } -bool +bool session::process_delta_cmd(netcmd_item_type type, - id const & base, - id const & ident, + id const & base, + id const & ident, delta const & del) { string typestr; @@ -1938,14 +1938,14 @@ case file_item: { file_id src_file(hbase), dst_file(hident); - this->dbw.consume_file_delta(src_file, + this->dbw.consume_file_delta(src_file, dst_file, file_delta(del)); } break; - + default: - L(FL("ignoring delta received for item type %s\n") % typestr); + L(FL("ignoring delta received for item type %s") % typestr); break; } return true; @@ -1978,9 +1978,9 @@ // Use temporary; passed arg will be invalidated during iteration. set tmp = items; - for (set::const_iterator i = tmp.begin(); + for (set::const_iterator i = tmp.begin(); i != tmp.end(); ++i) - { + { hexenc hitem; encode_hexenc(*i, hitem); @@ -1993,11 +1993,11 @@ } } -bool +bool session::dispatch_payload(netcmd const & cmd, transaction_guard & guard) { - + switch (cmd.get_cmd_code()) { @@ -2034,7 +2034,7 @@ require(! authenticated, "anonymous netcmd received when not authenticated"); require(voice == server_voice, "anonymous netcmd received in server voice"); require(role == source_role || - role == source_and_sink_role, + role == source_and_sink_role, "anonymous netcmd received in source or source/sink role"); { protocol_role role; @@ -2124,7 +2124,7 @@ case data_cmd: require(authenticated, "data netcmd received when not authenticated"); require(role == sink_role || - role == source_and_sink_role, + role == source_and_sink_role, "data netcmd received in source or source/sink role"); { netcmd_item_type type; @@ -2138,7 +2138,7 @@ case delta_cmd: require(authenticated, "delta netcmd received when not authenticated"); require(role == sink_role || - role == source_and_sink_role, + role == source_and_sink_role, "delta netcmd received in source or source/sink role"); { netcmd_item_type type; @@ -2147,7 +2147,7 @@ cmd.read_delta_cmd(type, base, ident, del); return process_delta_cmd(type, base, ident, del); } - break; + break; case usher_cmd: { @@ -2165,7 +2165,7 @@ } // This kicks off the whole cascade starting from "hello". -void +void session::begin_service() { keypair kp; @@ -2174,7 +2174,7 @@ queue_hello_cmd(app.signing_key, kp.pub, mk_nonce()); } -void +void session::maybe_step() { while (done_all_refinements() @@ -2185,7 +2185,7 @@ } } -void +void session::maybe_say_goodbye(transaction_guard & guard) { if (voice == client_voice @@ -2198,14 +2198,14 @@ } } -bool +bool session::arm() { if (!armed) { // Don't pack the buffer unnecessarily. if (outbuf_size > constants::bufsz * 10) - return false; + return false; if (cmd.read(inbuf, read_hmac)) { @@ -2213,19 +2213,19 @@ } } return armed; -} +} bool session::process(transaction_guard & guard) { if (encountered_error) return true; - try + try { if (!arm()) return true; - + armed = false; - L(FL("processing %d byte input buffer from peer %s\n") + L(FL("processing %d byte input buffer from peer %s") % inbuf.size() % peer_id); size_t sz = cmd.encoded_size(); @@ -2236,21 +2236,21 @@ "after netcmd dispatch\n") % peer_id); guard.maybe_checkpoint(sz); - + if (!ret) - L(FL("finishing processing with '%d' packet") + L(FL("finishing processing with '%d' packet") % cmd.get_cmd_code()); return ret; } catch (bad_decode & bd) { - W(F("protocol error while processing peer %s: '%s'\n") + W(F("protocol error while processing peer %s: '%s'") % peer_id % bd.what); return false; } catch (netsync_error & err) { - W(F("error: %s\n") % err.msg); + W(F("error: %s") % err.msg); queue_error_cmd(err.msg); encountered_error = true; return true; // Don't terminate until we've send the error_cmd. @@ -2258,7 +2258,7 @@ } -static shared_ptr +static shared_ptr build_stream_to_server(app_state & app, utf8 const & include_pattern, utf8 const & exclude_pattern, @@ -2269,8 +2269,8 @@ shared_ptr server; uri u; vector argv; - if (parse_uri(address(), u) - && app.lua.hook_get_netsync_connect_command(u, + if (parse_uri(address(), u) + && app.lua.hook_get_netsync_connect_command(u, include_pattern(), exclude_pattern(), global_sanity.debug, @@ -2282,23 +2282,23 @@ app.use_transport_auth = app.lua.hook_use_transport_auth(u); return shared_ptr (new Netxx::PipeStream(cmd, argv)); - + } - else - { + else + { #ifdef USE_IPV6 bool use_ipv6=true; #else bool use_ipv6=false; #endif - Netxx::Address addr(address().c_str(), + Netxx::Address addr(address().c_str(), default_port, use_ipv6); return shared_ptr (new Netxx::Stream(addr, timeout)); - } + } } -static void +static void call_server(protocol_role role, utf8 const & include_pattern, utf8 const & exclude_pattern, @@ -2314,13 +2314,13 @@ // FIXME: split into labels and convert to ace here. - P(F("connecting to %s\n") % address()); + P(F("connecting to %s") % address()); - shared_ptr server - = build_stream_to_server(app, + shared_ptr server + = build_stream_to_server(app, include_pattern, exclude_pattern, - address, default_port, + address, default_port, timeout); @@ -2329,21 +2329,21 @@ Netxx::SockOpt socket_options(server->get_socketfd(), false); socket_options.set_non_blocking(); - session sess(role, client_voice, - include_pattern, + session sess(role, client_voice, + include_pattern, exclude_pattern, app, address(), server); while (true) - { + { bool armed = false; - try + try { armed = sess.arm(); } catch (bad_decode & bd) { - E(false, F("protocol error while processing peer %s: '%s'\n") + E(false, F("protocol error while processing peer %s: '%s'") % sess.peer_id % bd.what); } @@ -2355,11 +2355,11 @@ Netxx::Probe::result_type res = probe.ready(armed ? instant : timeout); Netxx::Probe::ready_type event = res.second; Netxx::socket_type fd = res.first; - - if (fd == -1 && !armed) + + if (fd == -1 && !armed) { E(false, (F("timed out waiting for I/O with " - "peer %s, disconnecting\n") + "peer %s, disconnecting\n") % sess.peer_id)); } @@ -2367,7 +2367,7 @@ if (event & Netxx::Probe::ready_read) all_io_clean = all_io_clean && sess.read_some(); - + if (event & Netxx::Probe::ready_write) all_io_clean = all_io_clean && sess.write_some(); @@ -2376,13 +2376,13 @@ { // Commit whatever work we managed to accomplish anyways. guard.commit(); - + // We failed during processing. This should only happen in // client voice when we have a decode exception, or received an // error from our server (which is translated to a decode // exception). We call these cases E() errors. E(false, F("processing failure while talking to " - "peer %s, disconnecting\n") + "peer %s, disconnecting\n") % sess.peer_id); return; } @@ -2395,22 +2395,22 @@ // We had an I/O error. We must decide if this represents a // user-reported error or a clean disconnect. See protocol // state diagram in session::process_bye_cmd. - + if (sess.protocol_state == session::confirmed_state) - { - P(F("successful exchange with %s\n") + { + P(F("successful exchange with %s") % sess.peer_id); return; } else if (sess.encountered_error) { - P(F("peer %s disconnected after we informed them of error\n") + P(F("peer %s disconnected after we informed them of error") % sess.peer_id); return; } else E(false, (F("I/O failure while talking to " - "peer %s, disconnecting\n") + "peer %s, disconnecting\n") % sess.peer_id)); } } @@ -2422,13 +2422,13 @@ { // This is a bit of a hack. Initially all "file descriptors" in // netsync were full duplex, so we could get away with indexing - // sessions by their file descriptor. + // sessions by their file descriptor. // // When using pipes in unix, it's no longer true: a session gets // entered in the session map under its read pipe fd *and* its write // pipe fd. When we're in such a situation the socket fd is "-1" and // we downcast to a PipeStream and use its read+write fds. - // + // // When using pipes in windows, we use a full duplex pipe (named // pipe) so the socket-like abstraction holds. @@ -2441,9 +2441,9 @@ { sessions.erase(fd); } - else + else { - shared_ptr pipe = + shared_ptr pipe = boost::dynamic_pointer_cast(sess->str); I(static_cast(pipe)); I(pipe->get_writefd() != -1); @@ -2453,32 +2453,32 @@ } } -static void +static void arm_sessions_and_calculate_probe(Netxx::PipeCompatibleProbe & probe, map > & sessions, set & armed_sessions) { set arm_failed; - for (map >::const_iterator i = sessions.begin(); i != sessions.end(); ++i) { i->second->maybe_step(); - try + try { if (i->second->arm()) { - L(FL("fd %d is armed\n") % i->first); + L(FL("fd %d is armed") % i->first); armed_sessions.insert(i->first); } probe.add(*i->second->str, i->second->which_events()); } catch (bad_decode & bd) { - W(F("protocol error while processing peer %s: '%s', marking as bad\n") + W(F("protocol error while processing peer %s: '%s', marking as bad") % i->second->peer_id % bd.what); arm_failed.insert(i->first); - } + } } for (set::const_iterator i = arm_failed.begin(); i != arm_failed.end(); ++i) @@ -2497,25 +2497,25 @@ map > & sessions, app_state & app) { - L(FL("accepting new connection on %s : %s\n") + L(FL("accepting new connection on %s : %s") % (addr.get_name()?addr.get_name():"") % lexical_cast(addr.get_port())); Netxx::Peer client = server.accept_connection(); - - if (!client) + + if (!client) { - L(FL("accept() returned a dead client\n")); + L(FL("accept() returned a dead client")); } else { - P(F("accepted new client connection from %s : %s\n") + P(F("accepted new client connection from %s : %s") % client.get_address() % lexical_cast(client.get_port())); // 'false' here means not to revert changes when the SockOpt // goes out of scope. Netxx::SockOpt socket_options(client.get_socketfd(), false); socket_options.set_non_blocking(); - - shared_ptr str = + + shared_ptr str = shared_ptr (new Netxx::Stream(client.get_socketfd(), timeout)); @@ -2528,7 +2528,7 @@ } } -static void +static void handle_read_available(Netxx::socket_type fd, shared_ptr sess, map > & sessions, @@ -2544,7 +2544,7 @@ } catch (bad_decode & bd) { - W(F("protocol error while processing peer %s: '%s', disconnecting\n") + W(F("protocol error while processing peer %s: '%s', disconnecting") % sess->peer_id % bd.what); drop_session_associated_with_fd(sessions, fd); live_p = false; @@ -2555,18 +2555,18 @@ switch (sess->protocol_state) { case session::working_state: - P(F("peer %s read failed in working state (error)\n") + P(F("peer %s read failed in working state (error)") % sess->peer_id); break; case session::shutdown_state: P(F("peer %s read failed in shutdown state " - "(possibly client misreported error)\n") + "(possibly client misreported error)\n") % sess->peer_id); break; case session::confirmed_state: - P(F("peer %s read failed in confirmed state (success)\n") + P(F("peer %s read failed in confirmed state (success)") % sess->peer_id); break; } @@ -2576,7 +2576,7 @@ } -static void +static void handle_write_available(Netxx::socket_type fd, shared_ptr sess, map > & sessions, @@ -2587,18 +2587,18 @@ switch (sess->protocol_state) { case session::working_state: - P(F("peer %s write failed in working state (error)\n") + P(F("peer %s write failed in working state (error)") % sess->peer_id); break; case session::shutdown_state: P(F("peer %s write failed in shutdown state " - "(possibly client misreported error)\n") + "(possibly client misreported error)\n") % sess->peer_id); break; case session::confirmed_state: - P(F("peer %s write failed in confirmed state (success)\n") + P(F("peer %s write failed in confirmed state (success)") % sess->peer_id); break; } @@ -2625,7 +2625,7 @@ shared_ptr sess = j->second; if (!sess->process(guard)) { - P(F("peer %s processing finished, disconnecting\n") + P(F("peer %s processing finished, disconnecting") % sess->peer_id); drop_session_associated_with_fd(sessions, *i); } @@ -2641,13 +2641,13 @@ // or who have exchanged all items and flushed their output buffers. set dead_clients; time_t now = ::time(NULL); - for (map >::const_iterator + for (map >::const_iterator i = sessions.begin(); i != sessions.end(); ++i) { - if (static_cast(i->second->last_io_time + timeout_seconds) + if (static_cast(i->second->last_io_time + timeout_seconds) < static_cast(now)) { - P(F("fd %d (peer %s) has been idle too long, disconnecting\n") + P(F("fd %d (peer %s) has been idle too long, disconnecting") % i->first % i->second->peer_id); dead_clients.insert(i->first); } @@ -2659,7 +2659,7 @@ } } -static void +static void serve_connections(protocol_role role, utf8 const & include_pattern, utf8 const & exclude_pattern, @@ -2669,11 +2669,11 @@ unsigned long timeout_seconds, unsigned long session_limit) { - Netxx::PipeCompatibleProbe probe; + Netxx::PipeCompatibleProbe probe; - Netxx::Timeout - forever, - timeout(static_cast(timeout_seconds)), + Netxx::Timeout + forever, + timeout(static_cast(timeout_seconds)), instant(0,1); if (!app.bind_port().empty()) @@ -2715,13 +2715,13 @@ try_again=false; const char *name = addr.get_name(); - P(F("beginning service on %s : %s\n") + P(F("beginning service on %s : %s") % (name != NULL ? name : _("")) % lexical_cast(addr.get_port())); - + map > sessions; set armed_sessions; - + shared_ptr guard; while (true) @@ -2737,7 +2737,7 @@ arm_sessions_and_calculate_probe(probe, sessions, armed_sessions); - L(FL("i/o probe with %d armed\n") % armed_sessions.size()); + L(FL("i/o probe with %d armed") % armed_sessions.size()); Netxx::socket_type fd; Netxx::Timeout how_long; if (sessions.empty()) @@ -2757,20 +2757,20 @@ guard = shared_ptr(new transaction_guard(app.db)); I(guard); - + if (fd == -1) { if (armed_sessions.empty()) - L(FL("timed out waiting for I/O (listening on %s : %s)\n") + L(FL("timed out waiting for I/O (listening on %s : %s)") % addr.get_name() % lexical_cast(addr.get_port())); } - + // we either got a new connection else if (fd == server) handle_new_connection(addr, server, timeout, role, include_pattern, exclude_pattern, sessions, app); - + // or an existing session woke up else { @@ -2778,7 +2778,7 @@ i = sessions.find(fd); if (i == sessions.end()) { - L(FL("got woken up for action on unknown fd %d\n") % fd); + L(FL("got woken up for action on unknown fd %d") % fd); } else { @@ -2789,13 +2789,13 @@ if (event & Netxx::Probe::ready_read) handle_read_available(fd, sess, sessions, armed_sessions, live_p); - + if (live_p && (event & Netxx::Probe::ready_write)) handle_write_available(fd, sess, sessions, live_p); - + if (live_p && (event & Netxx::Probe::ready_oobd)) { - P(F("got OOB from peer %s, disconnecting\n") + P(F("got OOB from peer %s, disconnecting") % sess->peer_id); drop_session_associated_with_fd(sessions, fd); } @@ -2844,30 +2844,30 @@ while(try_again); } -static void +static void serve_single_connection(shared_ptr sess, unsigned long timeout_seconds) { - Netxx::PipeCompatibleProbe probe; - - Netxx::Timeout - forever, - timeout(static_cast(timeout_seconds)), + Netxx::PipeCompatibleProbe probe; + + Netxx::Timeout + forever, + timeout(static_cast(timeout_seconds)), instant(0,1); - - P(F("beginning service on %s\n") % sess->peer_id); - + + P(F("beginning service on %s") % sess->peer_id); + sess->begin_service(); - + transaction_guard guard(sess->app.db); map > sessions; set armed_sessions; - - if (sess->str->get_socketfd() == -1) + + if (sess->str->get_socketfd() == -1) { // Unix pipes are non-duplex, have two filedescriptors - shared_ptr pipe = + shared_ptr pipe = boost::dynamic_pointer_cast(sess->str); I(pipe); sessions[pipe->get_writefd()]=sess; @@ -2875,27 +2875,27 @@ } else sessions[sess->str->get_socketfd()]=sess; - + while (!sessions.empty()) { probe.clear(); armed_sessions.clear(); - + arm_sessions_and_calculate_probe(probe, sessions, armed_sessions); - - L(FL("i/o probe with %d armed\n") % armed_sessions.size()); - Netxx::Probe::result_type res = probe.ready((armed_sessions.empty() ? timeout + + L(FL("i/o probe with %d armed") % armed_sessions.size()); + Netxx::Probe::result_type res = probe.ready((armed_sessions.empty() ? timeout : instant)); Netxx::Probe::ready_type event = res.second; Netxx::socket_type fd = res.first; - + if (fd == -1) { - if (armed_sessions.empty()) - L(FL("timed out waiting for I/O (listening on %s)\n") + if (armed_sessions.empty()) + L(FL("timed out waiting for I/O (listening on %s)") % sess->peer_id); } - + // an existing session woke up else { @@ -2903,7 +2903,7 @@ i = sessions.find(fd); if (i == sessions.end()) { - L(FL("got woken up for action on unknown fd %d\n") % fd); + L(FL("got woken up for action on unknown fd %d") % fd); } else { @@ -2912,13 +2912,13 @@ if (event & Netxx::Probe::ready_read) handle_read_available(fd, sess, sessions, armed_sessions, live_p); - + if (live_p && (event & Netxx::Probe::ready_write)) handle_write_available(fd, sess, sessions, live_p); - + if (live_p && (event & Netxx::Probe::ready_oobd)) { - P(F("got some OOB data on fd %d (peer %s), disconnecting\n") + P(F("got some OOB data on fd %d (peer %s), disconnecting") % fd % sess->peer_id); drop_session_associated_with_fd(sessions, fd); } @@ -2931,11 +2931,11 @@ void -insert_with_parents(revision_id rev, - refiner & ref, +insert_with_parents(revision_id rev, + refiner & ref, revision_enumerator & rev_enumerator, set & revs, - app_state & app, + app_state & app, ticker & revisions_ticker) { deque work; @@ -2963,11 +2963,11 @@ } } -void +void session::rebuild_merkle_trees(app_state & app, set const & branchnames) { - P(F("finding items to synchronize:\n")); + P(F("finding items to synchronize:")); for (set::const_iterator i = branchnames.begin(); i != branchnames.end(); ++i) L(FL("including branch %s") % *i); @@ -2981,7 +2981,7 @@ set revision_ids; set inserted_keys; - + { // Get our branches vector names; @@ -2999,7 +2999,7 @@ j != certs.end(); j++) { revision_id rid(j->inner().ident); - insert_with_parents(rid, rev_refiner, rev_enumerator, + insert_with_parents(rid, rev_refiner, rev_enumerator, revision_ids, app, revisions_ticker); // Granch certs go in here, others later on. hexenc tmp; @@ -3014,11 +3014,11 @@ } } } - + { map epochs; app.db.get_epochs(epochs); - + epoch_data epoch_zero(string(constants::epochlen, '0')); for (set::const_iterator i = branchnames.begin(); i != branchnames.end(); ++i) @@ -3030,7 +3030,7 @@ // Set to zero any epoch which is not yet set. if (j == epochs.end()) { - L(FL("setting epoch on %s to zero\n") % branch); + L(FL("setting epoch on %s to zero") % branch); epochs.insert(make_pair(branch, epoch_zero)); app.db.set_epoch(branch, epoch_zero); } @@ -3045,11 +3045,11 @@ epoch_refiner.note_local_item(epoch_item); } } - + { typedef vector< pair, pair > > cert_idx; - + cert_idx idx; app.db.get_revision_cert_nobranch_index(idx); @@ -3063,10 +3063,10 @@ rsa_keypair_id const & key = i->second.second; rev_enumerator.note_cert(ident, hash); - + if (revision_ids.find(ident) == revision_ids.end()) continue; - + id item; decode_hexenc(hash, item); cert_refiner.note_local_item(item); @@ -3077,8 +3077,8 @@ } // Add any keys specified on the command line. - for (vector::const_iterator key - = app.keys_to_push.begin(); + for (vector::const_iterator key + = app.keys_to_push.begin(); key != app.keys_to_push.end(); ++key) { if (inserted_keys.find(*key) == inserted_keys.end()) @@ -3104,7 +3104,7 @@ app.db.get_key(*key, pub_encoded); hexenc keyhash; key_hash_code(*key, pub_encoded, keyhash); - L(FL("noting key '%s' = '%s' to send\n") % *key % keyhash); + L(FL("noting key '%s' = '%s' to send") % *key % keyhash); id key_item; decode_hexenc(keyhash, key_item); key_refiner.note_local_item(key_item); @@ -3118,10 +3118,10 @@ epoch_refiner.reindex_local_items(); } -void -run_netsync_protocol(protocol_voice voice, - protocol_role role, - utf8 const & addr, +void +run_netsync_protocol(protocol_voice voice, + protocol_role role, + utf8 const & addr, utf8 const & include_pattern, utf8 const & exclude_pattern, app_state & app) @@ -3138,38 +3138,38 @@ "%s\n") % exclude_pattern()); } - try + try { if (voice == server_voice) { if (app.bind_stdio) - { + { shared_ptr str(new Netxx::PipeStream(0,1)); - shared_ptr sess(new session(role, server_voice, + shared_ptr sess(new session(role, server_voice, include_pattern, exclude_pattern, app, "stdio", str)); serve_single_connection(sess,constants::netsync_timeout_seconds); } else serve_connections(role, include_pattern, exclude_pattern, app, - addr, static_cast(constants::netsync_default_port), - static_cast(constants::netsync_timeout_seconds), + addr, static_cast(constants::netsync_default_port), + static_cast(constants::netsync_timeout_seconds), static_cast(constants::netsync_connection_limit)); } - else + else { I(voice == client_voice); call_server(role, include_pattern, exclude_pattern, app, - addr, static_cast(constants::netsync_default_port), + addr, static_cast(constants::netsync_default_port), static_cast(constants::netsync_timeout_seconds)); } } catch (Netxx::NetworkException & e) - { + { throw informative_failure((F("network error: %s") % e.what()).str()); } catch (Netxx::Exception & e) - { + { throw oops((F("network error: %s") % e.what()).str());; } } ============================================================ --- netsync.hh 276fdfd34e38b36adc1a45d012792fd43db07a2c +++ netsync.hh 7307b7f9d4053a98d543ff7068d2767689dcc249 @@ -19,9 +19,9 @@ } protocol_voice; -void run_netsync_protocol(protocol_voice voice, - protocol_role role, - utf8 const & addr, +void run_netsync_protocol(protocol_voice voice, + protocol_role role, + utf8 const & addr, utf8 const & include_pattern, utf8 const & exclude_pattern, app_state & app); ============================================================ --- netxx_pipe.cc bf56e7d54b7cd63656f6ec741a848d4df3e86bf8 +++ netxx_pipe.cc 6af839b4682d91c62c38d6393d83bb9f04f65177 @@ -14,7 +14,7 @@ #include #include #include -#else +#else #include #include #include @@ -22,7 +22,7 @@ #endif Netxx::PipeStream::PipeStream(int _readfd, int _writefd) - : + : #ifdef WIN32 child(INVALID_HANDLE_VALUE), bytes_available(0), @@ -36,13 +36,13 @@ #ifdef WIN32 if (_setmode(_readfd, _O_BINARY) == -1) L(FL("failed to set input file descriptor to binary")); - + if (_setmode(_writefd, _O_BINARY) == -1) L(FL("failed to set output file descriptor to binary")); named_pipe = (HANDLE)_get_osfhandle(_readfd); - E(named_pipe != INVALID_HANDLE_VALUE, + E(named_pipe != INVALID_HANDLE_VALUE, F("pipe handle is invalid")); // Create infrastructure for overlapping I/O @@ -90,11 +90,11 @@ } else if (!result) - { + { // fd1[1] for writing, fd2[0] for reading close(fd1[0]); close(fd2[1]); - if (dup2(fd2[0], 0) != 0 || + if (dup2(fd2[0], 0) != 0 || dup2(fd1[1], 1) != 1) { perror("dup2"); @@ -105,7 +105,7 @@ } else - { + { // fd1[0] for reading, fd2[1] for writing close(fd1[1]); close(fd2[0]); @@ -116,7 +116,7 @@ #endif #ifdef WIN32 -static std::string +static std::string err_msg() { char buf[1024]; @@ -128,9 +128,9 @@ #endif -Netxx::PipeStream::PipeStream (const std::string & cmd, +Netxx::PipeStream::PipeStream (const std::string & cmd, const std::vector & args) - : + : #ifdef WIN32 child(INVALID_HANDLE_VALUE), bytes_available(0), @@ -161,42 +161,42 @@ // pipes and overlapped i/o. There is no other way, alas. static unsigned long serial = 0; - std::string pipename = (F("\\\\.\\pipe\\netxx_pipe_%ld_%d") - % GetCurrentProcessId() + std::string pipename = (F("\\\\.\\pipe\\netxx_pipe_%ld_%d") + % GetCurrentProcessId() % (++serial)).str(); // Create the parent's handle to the named pipe. - named_pipe = CreateNamedPipe(pipename.c_str(), + named_pipe = CreateNamedPipe(pipename.c_str(), PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, - PIPE_TYPE_BYTE | PIPE_WAIT, + PIPE_TYPE_BYTE | PIPE_WAIT, 1, - sizeof(readbuf), sizeof(readbuf), - 1000, + sizeof(readbuf), + 1000, 0); E(named_pipe != INVALID_HANDLE_VALUE, - F("CreateNamedPipe(%s,...) call failed: %s") + F("CreateNamedPipe(%s,...) call failed: %s") % pipename % err_msg()); // Open the child's handle to the named pipe. - + SECURITY_ATTRIBUTES inherit; memset(&inherit,0,sizeof inherit); inherit.nLength=sizeof inherit; inherit.bInheritHandle = TRUE; - HANDLE hpipe = CreateFile(pipename.c_str(), - GENERIC_READ|GENERIC_WRITE, 0, + HANDLE hpipe = CreateFile(pipename.c_str(), + GENERIC_READ|GENERIC_WRITE, 0, &inherit, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED,0); E(hpipe != INVALID_HANDLE_VALUE, - F("CreateFile(%s,...) call failed: %s") + F("CreateFile(%s,...) call failed: %s") % pipename % err_msg()); - + // Set up the child with the pipes as stdin/stdout and inheriting stderr. PROCESS_INFORMATION piProcInfo; @@ -212,7 +212,7 @@ siStartInfo.dwFlags |= STARTF_USESTDHANDLES; std::string cmdline = munge_argv_into_cmdline(newargv); - L(FL("Subprocess command line: '%s'\n") % cmdline); + L(FL("Subprocess command line: '%s'") % cmdline); BOOL started = CreateProcess(NULL, // Application name const_cast(cmdline.c_str()), @@ -224,7 +224,7 @@ NULL, // Current directory &siStartInfo, &piProcInfo); - E(started, + E(started, F("CreateProcess(%s,...) call failed: %s") % cmdline % err_msg()); @@ -253,16 +253,16 @@ fcntl(readfd, F_SETFL, fcntl(readfd, F_GETFL) | O_NONBLOCK); #endif - // P(F("mtn %d: set up i/o channels\n") + // P(F("mtn %d: set up i/o channels") // % GetCurrentProcessId()); } // Non blocking read. -Netxx::signed_size_type +Netxx::signed_size_type Netxx::PipeStream::read (void *buffer, size_type length) { -#ifdef WIN32 +#ifdef WIN32 if (length > bytes_available) length = bytes_available; @@ -281,20 +281,20 @@ #endif } -Netxx::signed_size_type +Netxx::signed_size_type Netxx::PipeStream::write(const void *buffer, size_type length) { #ifdef WIN32 DWORD written = 0; BOOL ok = WriteFile(named_pipe, buffer, length, &written, NULL); - E(ok, F("WriteFile call failed: %s") % err_msg()); + E(ok, F("WriteFile call failed: %s") % err_msg()); #else size_t written = ::write(writefd, buffer, length); #endif return written; } -void +void Netxx::PipeStream::close (void) { @@ -335,7 +335,7 @@ #endif } -const Netxx::ProbeInfo* +const Netxx::ProbeInfo* Netxx::PipeStream::get_probe_info (void) const { return 0; @@ -355,13 +355,13 @@ } } -Netxx::Probe::result_type +Netxx::Probe::result_type Netxx::PipeCompatibleProbe::ready(const Timeout &timeout, ready_type rt) { if (!is_pipe) return Probe::ready(timeout, rt); - // L(F("mtn %d: checking for i/o ready state\n") % GetCurrentProcessId()); + // L(F("mtn %d: checking for i/o ready state") % GetCurrentProcessId()); if (rt == ready_none) rt = ready_t; // remembered from add @@ -376,9 +376,9 @@ if (pipe->bytes_available == 0) { // Issue an async request to fill our buffer. - BOOL ok = ReadFile(pipe->named_pipe, pipe->readbuf, + BOOL ok = ReadFile(pipe->named_pipe, pipe->readbuf, sizeof(pipe->readbuf), NULL, &pipe->overlap); - E(ok || GetLastError() == ERROR_IO_PENDING, + E(ok || GetLastError() == ERROR_IO_PENDING, F("ReadFile call failed: %s") % err_msg()); pipe->read_in_progress = true; } @@ -389,10 +389,10 @@ // Attempt to wait for the completion of the read-in-progress. - int milliseconds = ((timeout.get_sec() * 1000) + int milliseconds = ((timeout.get_sec() * 1000) + (timeout.get_usec() / 1000)); - L(FL("WaitForSingleObject(,%d)\n") % milliseconds); + L(FL("WaitForSingleObject(,%d)") % milliseconds); DWORD wstatus = WAIT_FAILED; @@ -408,31 +408,31 @@ handles[0] = pipe->overlap.hEvent; handles[1] = pipe->child; - wstatus = WaitForMultipleObjects(2, - handles, - FALSE, + wstatus = WaitForMultipleObjects(2, + handles, + FALSE, milliseconds); - E(wstatus != WAIT_FAILED, + E(wstatus != WAIT_FAILED, F("WaitForMultipleObjects call failed: %s") % err_msg()); if (wstatus == WAIT_OBJECT_0 + 1) return std::make_pair(pipe->get_socketfd(), ready_oobd); } else - { - wstatus = WaitForSingleObject(pipe->overlap.hEvent, + { + wstatus = WaitForSingleObject(pipe->overlap.hEvent, milliseconds); - E(wstatus != WAIT_FAILED, + E(wstatus != WAIT_FAILED, F("WaitForSingleObject call failed: %s") % err_msg()); } - + if (wstatus == WAIT_TIMEOUT) return std::make_pair(-1, ready_none); - - BOOL ok = GetOverlappedResult(pipe->named_pipe, - &pipe->overlap, - &pipe->bytes_available, + + BOOL ok = GetOverlappedResult(pipe->named_pipe, + &pipe->overlap, + &pipe->bytes_available, FALSE); if (ok) @@ -444,21 +444,21 @@ { // We did not complete our read. E(GetLastError() == ERROR_IO_INCOMPLETE, - F("GetOverlappedResult call failed: %s") + F("GetOverlappedResult call failed: %s") % err_msg()); } } - + if (pipe->bytes_available != 0) { return std::make_pair(pipe->get_socketfd(), ready_read); } } - + return std::make_pair(pipe->get_socketfd(), ready_none); } -void +void Netxx::PipeCompatibleProbe::add(PipeStream &ps, ready_type rt) { assert(!is_pipe); @@ -468,9 +468,9 @@ ready_t = rt; } -void +void Netxx::PipeCompatibleProbe::add(const StreamBase &sb, ready_type rt) - { + { // FIXME: This is an unfortunate way of performing a downcast. // Perhaps we should twiddle the caller-visible API. try @@ -484,7 +484,7 @@ } } -void +void Netxx::PipeCompatibleProbe::add(const StreamServer &ss, ready_type rt) { assert(!is_pipe); @@ -525,7 +525,7 @@ static void simple_pipe_test() -{ try +{ try { Netxx::PipeStream pipe("cat",std::vector()); @@ -572,12 +572,12 @@ pipe.close(); - } -catch (informative_failure &e) + } +catch (informative_failure &e) // for some reason boost does not provide // enough information - { - W(F("Failure %s\n") % e.what); + { + W(F("Failure %s") % e.what); throw; } } ============================================================ --- netxx_pipe.hh 720992e155fa3f850ed0c46aaa1d224e25c95efe +++ netxx_pipe.hh 54d564cba3c9ca9952c6d739f2b3e5d279b7ed5c @@ -12,27 +12,27 @@ # include #endif -/* +/* What is this all for? - + If you want to transparently handle a pipe and a socket on unix and windows you have to abstract some difficulties: - + - sockets have a single filedescriptor for reading and writing pipes usually come in pairs (one for reading and one for writing) - + - process creation is different on unix and windows - + => so Netxx::PipeStream is a Netxx::StreamBase which abstracts two pipes to and from an external command - + - windows can select on a socket but not on a pipe - + => so Netxx::PipeCompatibleProbe is a Netxx::Probe like class which _can_ handle pipes on windows (emulating select is difficult at best!) - (on unix Probe and PipeCompatibleProbe are nearly identical: with pipes + (on unix Probe and PipeCompatibleProbe are nearly identical: with pipes you should not select for both read and write on the same descriptor) - + */ namespace Netxx @@ -42,7 +42,7 @@ class PipeStream : public StreamBase { -#ifdef WIN32 +#ifdef WIN32 HANDLE named_pipe; HANDLE child; char readbuf[1024]; @@ -58,11 +58,11 @@ public: // do we need Timeout for symmetry with Stream? - explicit PipeStream (int readfd, int writefd); + explicit PipeStream (int readfd, int writefd); explicit PipeStream (const std::string &cmd, const std::vector &args); virtual ~PipeStream() { close(); } virtual signed_size_type read (void *buffer, size_type length); - virtual signed_size_type write (const void *buffer, size_type length); + virtual signed_size_type write (const void *buffer, size_type length); virtual void close (void); virtual socket_type get_socketfd (void) const; virtual const ProbeInfo* get_probe_info (void) const; @@ -89,7 +89,7 @@ // This probe can either handle _one_ PipeStream or several network // Streams so if !is_pipe this acts like a Probe. class PipeCompatibleProbe : public Probe - { + { bool is_pipe; // only meaningful if is_pipe is true PipeStream *pipe; ============================================================ --- packet.cc dfdefb2d2808183cd0312752b2ee1f840bace11c +++ packet.cc cfef3e3f3868a9c41f6cce65f0a3325515de73df @@ -63,20 +63,20 @@ } -packet_db_writer::packet_db_writer(app_state & app) +packet_db_writer::packet_db_writer(app_state & app) : app(app) {} -packet_db_writer::~packet_db_writer() +packet_db_writer::~packet_db_writer() {} -void -packet_db_writer::consume_file_data(file_id const & ident, +void +packet_db_writer::consume_file_data(file_id const & ident, file_data const & dat) { if (app.db.file_version_exists(ident)) { - L(FL("file version '%s' already exists in db\n") % ident); + L(FL("file version '%s' already exists in db") % ident); return; } @@ -85,8 +85,8 @@ guard.commit(); } -void -packet_db_writer::consume_file_delta(file_id const & old_id, +void +packet_db_writer::consume_file_delta(file_id const & old_id, file_id const & new_id, file_delta const & del) { @@ -94,7 +94,7 @@ if (app.db.file_version_exists(new_id)) { - L(FL("file version '%s' already exists in db\n") % new_id); + L(FL("file version '%s' already exists in db") % new_id); return; } @@ -111,45 +111,45 @@ } void -packet_db_writer::consume_revision_data(revision_id const & ident, +packet_db_writer::consume_revision_data(revision_id const & ident, revision_data const & dat) { MM(ident); transaction_guard guard(app.db); if (app.db.revision_exists(ident)) { - L(FL("revision '%s' already exists in db\n") % ident); + L(FL("revision '%s' already exists in db") % ident); return; } revision_set rev; MM(rev); read_revision_set(dat, rev); - - for (edge_map::const_iterator i = rev.edges.begin(); + + for (edge_map::const_iterator i = rev.edges.begin(); i != rev.edges.end(); ++i) { - if (!edge_old_revision(i).inner()().empty() + if (!edge_old_revision(i).inner()().empty() && !app.db.revision_exists(edge_old_revision(i))) { - W(F("missing prerequisite revision '%s'\n") % edge_old_revision(i)); - W(F("dropping revision '%s'\n") % ident); + W(F("missing prerequisite revision '%s'") % edge_old_revision(i)); + W(F("dropping revision '%s'") % ident); return; } - - for (map::const_iterator a - = edge_changes(i).files_added.begin(); - a != edge_changes(i).files_added.end(); ++a) + + for (map::const_iterator a + = edge_changes(i).files_added.begin(); + a != edge_changes(i).files_added.end(); ++a) { if (! app.db.file_version_exists(a->second)) { - W(F("missing prerequisite file '%s'\n") % a->second); - W(F("dropping revision '%s'\n") % ident); + W(F("missing prerequisite file '%s'") % a->second); + W(F("dropping revision '%s'") % ident); return; - } + } } - for (map >::const_iterator d + for (map >::const_iterator d = edge_changes(i).deltas_applied.begin(); d != edge_changes(i).deltas_applied.end(); ++d) { @@ -158,57 +158,57 @@ if (! app.db.file_version_exists(delta_entry_src(d))) { - W(F("missing prerequisite file pre-delta '%s'\n") + W(F("missing prerequisite file pre-delta '%s'") % delta_entry_src(d)); - W(F("dropping revision '%s'\n") % ident); + W(F("dropping revision '%s'") % ident); return; - } - + } + if (! app.db.file_version_exists(delta_entry_dst(d))) { - W(F("missing prerequisite file post-delta '%s'\n") + W(F("missing prerequisite file post-delta '%s'") % delta_entry_dst(d)); - W(F("dropping revision '%s'\n") % ident); + W(F("dropping revision '%s'") % ident); return; } - } + } } app.db.put_revision(ident, dat); - if (on_revision_written) + if (on_revision_written) on_revision_written(ident); guard.commit(); } -void +void packet_db_writer::consume_revision_cert(revision const & t) { transaction_guard guard(app.db); if (app.db.revision_cert_exists(t)) { - L(FL("revision cert on '%s' already exists in db\n") + L(FL("revision cert on '%s' already exists in db") % t.inner().ident); return; } - + if (!app.db.revision_exists(revision_id(t.inner().ident))) { - W(F("cert revision '%s' does not exist in db\n") + W(F("cert revision '%s' does not exist in db") % t.inner().ident); - W(F("dropping cert\n")); + W(F("dropping cert")); return; } app.db.put_revision_cert(t); - if (on_cert_written) + if (on_cert_written) on_cert_written(t.inner()); guard.commit(); } -void +void packet_db_writer::consume_public_key(rsa_keypair_id const & ident, base64< rsa_pub_key > const & k) { @@ -219,20 +219,20 @@ base64 tmp; app.db.get_key(ident, tmp); if (!keys_match(ident, tmp, ident, k)) - W(F("key '%s' is not equal to key '%s' in database\n") % ident % ident); - L(FL("skipping existing public key %s\n") % ident); + W(F("key '%s' is not equal to key '%s' in database") % ident % ident); + L(FL("skipping existing public key %s") % ident); return; } - L(FL("putting public key %s\n") % ident); + L(FL("putting public key %s") % ident); app.db.put_key(ident, k); - if (on_pubkey_written) + if (on_pubkey_written) on_pubkey_written(ident); guard.commit(); } -void +void packet_db_writer::consume_key_pair(rsa_keypair_id const & ident, keypair const & kp) { @@ -240,12 +240,12 @@ if (app.keys.key_pair_exists(ident)) { - L(FL("skipping existing key pair %s\n") % ident); + L(FL("skipping existing key pair %s") % ident); return; } app.keys.put_key_pair(ident, kp); - if (on_keypair_written) + if (on_keypair_written) on_keypair_written(ident); guard.commit(); @@ -255,42 +255,42 @@ packet_writer::packet_writer(ostream & o) : ost(o) {} -void -packet_writer::consume_file_data(file_id const & ident, +void +packet_writer::consume_file_data(file_id const & ident, file_data const & dat) { base64 > packed; pack(dat.inner(), packed); - ost << "[fdata " << ident.inner()() << "]" << endl + ost << "[fdata " << ident.inner()() << "]" << endl << trim_ws(packed()) << endl << "[end]" << endl; } -void -packet_writer::consume_file_delta(file_id const & old_id, +void +packet_writer::consume_file_delta(file_id const & old_id, file_id const & new_id, file_delta const & del) { base64 > packed; pack(del.inner(), packed); - ost << "[fdelta " << old_id.inner()() << endl - << " " << new_id.inner()() << "]" << endl + ost << "[fdelta " << old_id.inner()() << endl + << " " << new_id.inner()() << "]" << endl << trim_ws(packed()) << endl << "[end]" << endl; } -void -packet_writer::consume_revision_data(revision_id const & ident, +void +packet_writer::consume_revision_data(revision_id const & ident, revision_data const & dat) { base64 > packed; pack(dat.inner(), packed); - ost << "[rdata " << ident.inner()() << "]" << endl + ost << "[rdata " << ident.inner()() << "]" << endl << trim_ws(packed()) << endl << "[end]" << endl; } -void +void packet_writer::consume_revision_cert(revision const & t) { ost << "[rcert " << t.inner().ident() << endl @@ -301,7 +301,7 @@ << "[end]" << endl; } -void +void packet_writer::consume_public_key(rsa_keypair_id const & ident, base64< rsa_pub_key > const & k) { @@ -310,7 +310,7 @@ << "[end]" << endl; } -void +void packet_writer::consume_key_pair(rsa_keypair_id const & ident, keypair const & kp) { @@ -322,7 +322,7 @@ // -- remainder just deals with the regexes for reading packets off streams -struct +struct feed_packet_consumer { app_state & app; @@ -348,7 +348,7 @@ bool operator()(match_results const & res) const { if (res.size() != 4) - throw oops("matched impossible packet with " + throw oops("matched impossible packet with " + lexical_cast(res.size()) + " matching parts: " + string(res[0].first, res[0].second)); I(res[1].matched); @@ -366,10 +366,10 @@ data contents; unpack(body_packed, contents); if (type == "rdata") - cons.consume_revision_data(revision_id(hexenc(args)), + cons.consume_revision_data(revision_id(hexenc(args)), revision_data(contents)); else if (type == "fdata") - cons.consume_file_data(file_id(hexenc(args)), + cons.consume_file_data(file_id(hexenc(args)), file_data(contents)); else throw oops("matched impossible data packet with head '" + type + "'"); @@ -385,8 +385,8 @@ base64 > body_packed(trim_ws(body)); delta contents; unpack(body_packed, contents); - cons.consume_file_delta(file_id(hexenc(src_id)), - file_id(hexenc(dst_id)), + cons.consume_file_delta(file_id(hexenc(src_id)), + file_id(hexenc(dst_id)), file_delta(contents)); } else if (type == "rcert") @@ -408,7 +408,7 @@ rsa_keypair_id(keyid), base64(canonical_base64(contents))); cons.consume_revision_cert(revision(t)); - } + } else if (type == "pubkey") { L(FL("read pubkey data packet")); @@ -451,7 +451,7 @@ } }; -static size_t +static size_t extract_packets(string const & s, packet_consumer & cons, app_state & app) { string const head("\\[([a-z]+)[[:space:]]+([^\\[\\]]+)\\]"); @@ -465,7 +465,7 @@ } -size_t +size_t read_packets(istream & in, packet_consumer & cons, app_state & app) { string accum, tmp; @@ -476,7 +476,7 @@ while(in) { in.read(buf, bufsz); - accum.append(buf, in.gcount()); + accum.append(buf, in.gcount()); string::size_type endpos = string::npos; endpos = accum.rfind(end); if (endpos != string::npos) @@ -501,7 +501,7 @@ using std::istringstream; using std::ostringstream; -static void +static void packet_roundabout_test() { string tmp; @@ -516,7 +516,7 @@ calculate_ident(fdata, fid); pw.consume_file_data(fid, fdata); - // an fdelta packet + // an fdelta packet file_data fdata2(data("this is some file data which is not the same as the first one")); file_id fid2; calculate_ident(fdata2, fid2); @@ -543,10 +543,10 @@ base64 val; encode_base64(cert_value("peaches"), val); base64 sig; - encode_base64(rsa_sha1_signature("blah blah there is no way this is a valid signature"), sig); + encode_base64(rsa_sha1_signature("blah blah there is no way this is a valid signature"), sig); // should be a type violation to use a file id here instead of a revision // id, but no-one checks... - cert c(fid.inner(), cert_name("smell"), val, + cert c(fid.inner(), cert_name("smell"), val, rsa_keypair_id("address@hidden"), sig); pw.consume_revision_cert(revision(c)); @@ -557,9 +557,9 @@ // a keypair packet encode_base64(rsa_priv_key("this is not a real rsa key either!"), kp.priv); - + pw.consume_key_pair(rsa_keypair_id("address@hidden"), kp); - + tmp = oss.str(); } @@ -572,7 +572,7 @@ { // now spin around sending and receiving this a few times ostringstream oss; - packet_writer pw(oss); + packet_writer pw(oss); istringstream iss(tmp); read_packets(iss, pw, aaa); BOOST_CHECK(oss.str() == tmp); @@ -580,7 +580,7 @@ } } -void +void add_packet_tests(test_suite * suite) { I(suite); ============================================================ --- packet.hh 97e6723f3b4974aa36826b5391b2018870ad4eb3 +++ packet.hh 287d928c5429c8c9d1c16a9fb4588eb9ec87001b @@ -18,7 +18,7 @@ // the idea here is that monotone can produce and consume "packet streams", // where each packet is *informative* rather than transactional. that is to // say, they contain no information which needs to be replied to or processed -// in any particular manner during some communication session. +// in any particular manner during some communication session. // // unlike nearly every other part of this program, the packet stream // interface is really *stream* oriented. the idea being that, while you @@ -28,7 +28,7 @@ // // packet streams are ascii text, formatted for comfortable viewing on a // terminal or inclusion in an email / netnews post. they can be edited with -// vi, filtered with grep, and concatenated with cat. +// vi, filtered with grep, and concatenated with cat. // // there are currently 8 types of packets, though this can grow without hurting // anyone's feelings. if there's a backwards compatibility problem, just introduce @@ -51,23 +51,23 @@ const & x); virtual void set_on_keypair_written(boost::function1 const & x); - + virtual ~packet_consumer() {} - virtual void consume_file_data(file_id const & ident, + virtual void consume_file_data(file_id const & ident, file_data const & dat) = 0; - virtual void consume_file_delta(file_id const & id_old, + virtual void consume_file_delta(file_id const & id_old, file_id const & id_new, file_delta const & del) = 0; - virtual void consume_revision_data(revision_id const & ident, + virtual void consume_revision_data(revision_id const & ident, revision_data const & dat) = 0; - virtual void consume_revision_cert(revision const & t) = 0; + virtual void consume_revision_cert(revision const & t) = 0; virtual void consume_public_key(rsa_keypair_id const & ident, - base64< rsa_pub_key > const & k) = 0; + base64< rsa_pub_key > const & k) = 0; virtual void consume_key_pair(rsa_keypair_id const & ident, - keypair const & kp) = 0; + keypair const & kp) = 0; }; // this writer writes packets into a stream @@ -77,13 +77,13 @@ std::ostream & ost; explicit packet_writer(std::ostream & o); virtual ~packet_writer() {} - virtual void consume_file_data(file_id const & ident, + virtual void consume_file_data(file_id const & ident, file_data const & dat); - virtual void consume_file_delta(file_id const & id_old, + virtual void consume_file_delta(file_id const & id_old, file_id const & id_new, file_delta const & del); - - virtual void consume_revision_data(revision_id const & ident, + + virtual void consume_revision_data(revision_id const & ident, revision_data const & dat); virtual void consume_revision_cert(revision const & t); @@ -101,13 +101,13 @@ public: packet_db_writer(app_state & app); virtual ~packet_db_writer(); - virtual void consume_file_data(file_id const & ident, + virtual void consume_file_data(file_id const & ident, file_data const & dat); - virtual void consume_file_delta(file_id const & id_old, + virtual void consume_file_delta(file_id const & id_old, file_id const & id_new, file_delta const & del); - - virtual void consume_revision_data(revision_id const & ident, + + virtual void consume_revision_data(revision_id const & ident, revision_data const & dat); virtual void consume_revision_cert(revision const & t); ============================================================ --- parallel_iter.hh a00fa825f37d7c08c98cdc99a45d7304c4e64fd2 +++ parallel_iter.hh 686f6f5be905ac6b2b4b45eac9e3ce217096ce94 @@ -40,7 +40,7 @@ namespace parallel { typedef enum { in_left, in_right, in_both, invalid } state_t; - + template class iter { @@ -98,7 +98,7 @@ } return !finished_; } - + state_t state() const { return state_; @@ -110,7 +110,7 @@ I(state_ == in_left || state_ == in_both); return *left_; } - + typename M::key_type const & left_key() { ============================================================ --- paths.cc cef87a9f72cc5011f93bb8bfa7d9ac6f6d0eeadd +++ paths.cc 48db23c7a770cf3743c971b3fd31431356e8b186 @@ -263,9 +263,9 @@ case external: if (!initial_rel_path.initialized) { - // we are not in a workspace; treat this as an internal - // path, and set the access_tracker() into a very uninitialised - // state so that we will hit an exception if we do eventually + // we are not in a workspace; treat this as an internal + // path, and set the access_tracker() into a very uninitialised + // state so that we will hit an exception if we do eventually // enter a workspace initial_rel_path.may_not_initialize(); data = path; @@ -322,13 +322,13 @@ // This function takes a vector of path components and joins them into a // single file_path. This is the inverse to file_path::split. It takes a // vector of the form: -// +// // ["", p[0], p[1], ..., p[n]] -// +// // and constructs the path: -// +// // p[0]/p[1]/.../p[n] -// +// file_path::file_path(split_path const & sp) { split_path::const_iterator i = sp.begin(); @@ -391,7 +391,7 @@ for (split_path::const_iterator i = sp.begin(); i != sp.end(); ++i) { - if (null_name(*i)) + if (null_name(*i)) oss << "."; else oss << "/" << *i; @@ -564,13 +564,13 @@ split_path & dirname, path_component & basename) { I(!sp.empty()); - // L(FL("dirname_basename('%s' [%d components],...)\n") % file_path(sp) % sp.size()); + // L(FL("dirname_basename('%s' [%d components],...)") % file_path(sp) % sp.size()); dirname = sp; dirname.pop_back(); basename = sp.back(); if (dirname.empty()) { - // L(FL("basename %d vs. null component %d\n") % basename % the_null_component); + // L(FL("basename %d vs. null component %d") % basename % the_null_component); I(null_name(basename)); } } @@ -579,7 +579,7 @@ // workspace (and path root) handling /////////////////////////////////////////////////////////////////////////// -system_path +system_path current_root_path() { return system_path(fs::initial_path().root_path().string()); @@ -600,7 +600,7 @@ fs::path::iterator ri = root.begin(); fs::path::iterator ci = current.begin(); - while (ri != root.end() && ci != current.end() && *ri == *ci) + while (ri != root.end() && ci != current.end() && *ri == *ci) { ++ri; ++ci; @@ -611,12 +611,12 @@ if (ri != root.end()) { W(F("current directory '%s' is not below root '%s'") - % current.string() + % current.string() % root.string()); return false; } - L(FL("searching for '%s' directory with root '%s'\n") + L(FL("searching for '%s' directory with root '%s'") % bookdir.string() % root.string()); @@ -625,32 +625,32 @@ && current.has_leaf() && !fs::exists(check)) { - L(FL("'%s' not found in '%s' with '%s' removed\n") + L(FL("'%s' not found in '%s' with '%s' removed") % bookdir.string() % current.string() % removed.string()); removed = fs::path(current.leaf(), fs::native) / removed; current = current.branch_path(); check = current / bookdir; } - L(FL("search for '%s' ended at '%s' with '%s' removed\n") + L(FL("search for '%s' ended at '%s' with '%s' removed") % bookdir.string() % current.string() % removed.string()); if (!fs::exists(check)) { - L(FL("'%s' does not exist\n") % check.string()); + L(FL("'%s' does not exist") % check.string()); return false; } if (!fs::is_directory(check)) { - L(FL("'%s' is not a directory\n") % check.string()); + L(FL("'%s' is not a directory") % check.string()); return false; } // check for _MTN/. and _MTN/.. to see if mt dir is readable if (!fs::exists(check / ".") || !fs::exists(check / "..")) { - L(FL("problems with '%s' (missing '.' or '..')\n") % check.string()); + L(FL("problems with '%s' (missing '.' or '..')") % check.string()); return false; } @@ -749,7 +749,7 @@ "_MTNfoo/bar", "foo:bar", 0 }; - + for (int i = 0; i < 2; ++i) { initial_rel_path.unset(); @@ -796,7 +796,7 @@ i = split_test.begin() + 1; i != split_test.end(); ++i) BOOST_CHECK(!null_name(*i)); } - + static void test_file_path_external_null_prefix() { initial_rel_path.unset(); @@ -835,7 +835,7 @@ L(FL("test_file_path_external_null_prefix: trying baddie: %s") % *c); BOOST_CHECK_THROW(file_path_external(utf8(*c)), informative_failure); } - + check_fp_normalizes_to("a", "a"); check_fp_normalizes_to("foo", "foo"); check_fp_normalizes_to("foo/bar", "foo/bar"); @@ -916,7 +916,7 @@ L(FL("test_file_path_external_prefix_a_b: trying baddie: %s") % *c); BOOST_CHECK_THROW(file_path_external(utf8(*c)), informative_failure); } - + check_fp_normalizes_to("foo", "a/b/foo"); check_fp_normalizes_to("a", "a/b/a"); check_fp_normalizes_to("foo/bar", "a/b/foo/bar"); @@ -1077,7 +1077,7 @@ } 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"); check_bk_normalizes_to("foo/bar", "_MTN/foo/bar"); ============================================================ --- paths.hh b97148599d5823bd41c4be253a363dbaf64e2411 +++ paths.hh e084737c12b8cbff745ff1ea5b49092360edad43 @@ -31,7 +31,7 @@ // system_path(file_path_internal("foo")) // is not, in general, the same as // system_path("foo") -// +// // -- file_path // this is a path representing a versioned file. it is always // a fully normalized relative path, that does not escape the project @@ -45,10 +45,10 @@ // to the project root. // file_path_external: use this for strings that come from the user. // these strings are normalized before being checked, and if there is -// a problem trigger N() invariants rather than I() invariants. if in -// a workspace, such strings are interpreted as being -// _relative to the user's original directory_. -// if not in a workspace, strings are treated as referring to some +// a problem trigger N() invariants rather than I() invariants. if in +// a workspace, such strings are interpreted as being +// _relative to the user's original directory_. +// if not in a workspace, strings are treated as referring to some // database object directly. // file_path's also provide optimized splitting and joining // functionality. @@ -63,7 +63,7 @@ // 'bookkeeping_root', which points to the _MTN directory. Thus to // construct a path pointing to _MTN/options, use: // bookkeeping_root / "options" -// +// // All path types should always be constructed from utf8-encoded strings. // // All path types provide an "operator /" which allows one to construct new @@ -150,7 +150,7 @@ file_path() {} // join a file_path out of pieces file_path(split_path const & sp); - + // this currently doesn't do any normalization or anything. file_path operator /(std::string const & to_append) const; @@ -243,7 +243,7 @@ void save_initial_path(); -system_path +system_path current_root_path(); // returns true if workspace found, in which case cwd has been changed @@ -259,7 +259,7 @@ typedef std::set path_set; // equivalent to file_path_internal(path).split(sp) but more efficient. -void +void internal_string_to_split_path(std::string const & path, split_path & sp); #endif ============================================================ --- po/it.po a548b1b52dc1b491a42cb4aa38355868a116512d +++ po/it.po ee2152af52bae06b3db4e103b4082b18bf9f255b @@ -1,9 +1,9 @@ msgid "" msgstr "" "Project-Id-Version: monotone\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2006-05-27 12:06+0200\n" -"PO-Revision-Date: 2006-06-02 15:26+0100\n" +"POT-Creation-Date: 2006-06-02 15:19+0200\n" +"PO-Revision-Date: 2006-06-03 10:26+0100\n" "Last-Translator: Lapo Luchini \n" "Language-Team: Lapo Luchini \n" "MIME-Version: 1.0\n" @@ -78,22 +78,22 @@ #: cert.cc:77 #, c-format -msgid "ignoring bad signature by '%s' on '%s'\n" -msgstr "ignoro la firma invalida di ‘%s’ su ‘%s’\n" +msgid "ignoring bad signature by '%s' on '%s'" +msgstr "ignoro la firma invalida di ‘%s’ su ‘%s’" #: cert.cc:85 #, c-format -msgid "ignoring unknown signature by '%s' on '%s'\n" -msgstr "ignoro la firma sconosciuta di ‘%s’ su ‘%s’\n" +msgid "ignoring unknown signature by '%s' on '%s'" +msgstr "ignoro la firma sconosciuta di ‘%s’ su ‘%s’" #: cert.cc:148 #, c-format -msgid "trust function disliked %d signers of %s cert on manifest %s\n" +msgid "trust function disliked %d signers of %s cert on manifest %s" msgstr "" #: cert.cc:201 #, c-format -msgid "trust function disliked %d signers of %s cert on revision %s\n" +msgid "trust function disliked %d signers of %s cert on revision %s" msgstr "" #: cert.cc:290 @@ -453,8 +453,8 @@ #: cmd_files.cc:158 #: cmd_files.cc:160 #, c-format -msgid "no file '%s' found in revision '%s'\n" -msgstr "nessun file ‘%s’ trovato nella revisione ‘%s’\n" +msgid "no file '%s' found in revision '%s'" +msgstr "nessun file ‘%s’ trovato nella revisione ‘%s’" #: cmd.hh:75 #, c-format @@ -515,13 +515,13 @@ #: cmd_key_cert.cc:56 #, c-format -msgid "dropping public key '%s' from database\n" -msgstr "sto cancellando la chiave pubblica ‘%s’ dal database\n" +msgid "dropping public key '%s' from database" +msgstr "sto cancellando la chiave pubblica ‘%s’ dal database" #: cmd_key_cert.cc:66 #, c-format -msgid "dropping key pair '%s' from keystore\n" -msgstr "cancello la coppia di chiavi ‘%s’ dal portachiavi\n" +msgid "dropping key pair '%s' from keystore" +msgstr "cancello la coppia di chiavi ‘%s’ dal portachiavi" #: cmd_key_cert.cc:73 #, c-format @@ -544,8 +544,8 @@ #: cmd_key_cert.cc:97 #, c-format -msgid "passphrase changed\n" -msgstr "passphrase cambiata\n" +msgid "passphrase changed" +msgstr "passphrase cambiata" #: cmd_key_cert.cc:100 msgid "REVISION CERTNAME [CERTVAL]" @@ -684,18 +684,18 @@ #: cmd_list.cc:212 #, c-format -msgid "no keys found\n" -msgstr "nessuna chiave trovata\n" +msgid "no keys found" +msgstr "nessuna chiave trovata" #: cmd_list.cc:214 #, c-format -msgid "no keys found matching '%s'\n" -msgstr "nessuna chiave corrispondente a ‘%s’ trovata\n" +msgid "no keys found matching '%s'" +msgstr "nessuna chiave corrispondente a ‘%s’ trovata" #: cmd_list.cc:258 #, c-format -msgid "no epoch for branch %s\n" -msgstr "nessuna epoca trovata per il ramo ‘%s’\n" +msgid "no epoch for branch %s" +msgstr "nessuna epoca trovata per il ramo ‘%s’" #: cmd_list.cc:437 msgid "" @@ -789,13 +789,14 @@ #: cmd_merging.cc:119 #, c-format -msgid "already up to date at %s\n" -msgstr "già aggiornato a ‘%s’\n" +msgid "already up to date at %s" +msgstr "già aggiornato a ‘%s’" +# TODO: qui "update" è senza apici #: cmd_merging.cc:127 #, c-format -msgid "selected update target %s\n" -msgstr "selezionata revisione ‘%s’ per l'update\n" +msgid "selected update target %s" +msgstr "selezionata revisione ‘%s’ per l'update" #: cmd_merging.cc:151 #, c-format @@ -834,8 +835,8 @@ #: cmd_merging.cc:276 #, c-format -msgid "updated to base revision %s\n" -msgstr "aggiorno alla revisione base ‘%s’\n" +msgid "updated to base revision %s" +msgstr "aggiorno alla revisione base ‘%s’" #: cmd_merging.cc:286 #: cmd_merging.cc:339 @@ -862,24 +863,25 @@ #: cmd_merging.cc:388 #: cmd_merging.cc:391 #: cmd_merging.cc:591 +#: cmd_ws_commit.cc:401 #, c-format -msgid "branch '%s' is empty\n" -msgstr "il ramo ‘%s’ è vuoto\n" +msgid "branch '%s' is empty" +msgstr "il ramo ‘%s’ è vuoto" #: cmd_merging.cc:302 #, c-format -msgid "branch '%s' is already merged\n" -msgstr "il ramo ‘%s’ è già unito\n" +msgid "branch '%s' is already merged" +msgstr "il ramo ‘%s’ è già unito" #: cmd_merging.cc:310 #, c-format -msgid "starting with revision 1 / %d\n" -msgstr "inizio con la revisione 1 / %d\n" +msgid "starting with revision 1 / %d" +msgstr "inizio con la revisione 1 / %d" #: cmd_merging.cc:314 #, c-format -msgid "merging with revision %d / %d\n" -msgstr "‘merge’ con la revisione %d / %d\n" +msgid "merging with revision %d / %d" +msgstr "‘merge’ con la revisione %d / %d" #: cmd_merging.cc:315 #: cmd_merging.cc:316 @@ -887,20 +889,20 @@ #: cmd_merging.cc:523 #: cmd_merging.cc:524 #, c-format -msgid "[source] %s\n" -msgstr "[sorgente] %s\n" +msgid "[source] %s" +msgstr "[sorgente] %s" #: cmd_merging.cc:333 #: cmd_merging.cc:496 #: cmd_merging.cc:542 #, c-format -msgid "[merged] %s\n" -msgstr "[unione] %s\n" +msgid "[merged] %s" +msgstr "[unione] %s" #: cmd_merging.cc:336 #, c-format -msgid "note: your workspaces have not been updated\n" -msgstr "nota: lo spazio di lavoro non è stato aggiornato\n" +msgid "note: your workspaces have not been updated" +msgstr "nota: lo spazio di lavoro non è stato aggiornato" #: cmd_merging.cc:339 msgid "SOURCE-BRANCH DEST-BRANCH" @@ -921,33 +923,33 @@ #: cmd_merging.cc:389 #: cmd_merging.cc:392 #, c-format -msgid "branch '%s' is not merged\n" -msgstr "il ramo ‘%s’ è separato\n" +msgid "branch '%s' is not merged" +msgstr "il ramo ‘%s’ è separato" #: cmd_merging.cc:397 #, c-format -msgid "propagating %s -> %s\n" -msgstr "propago ‘%s’ → ‘%s’\n" +msgid "propagating %s -> %s" +msgstr "propago ‘%s’ → ‘%s’" #: cmd_merging.cc:399 #, c-format -msgid "[target] %s\n" -msgstr "[obiettivo] %s\n" +msgid "[target] %s" +msgstr "[obiettivo] %s" #: cmd_merging.cc:404 #, c-format -msgid "branch '%s' is up-to-date with respect to branch '%s'\n" -msgstr "il ramo ‘%s’ è aggiornato rispetto al ramo ‘%s’\n" +msgid "branch '%s' is up-to-date with respect to branch '%s'" +msgstr "il ramo ‘%s’ è aggiornato rispetto al ramo ‘%s’" #: cmd_merging.cc:406 #, c-format -msgid "no action taken\n" -msgstr "nessuna azione svolta\n" +msgid "no action taken" +msgstr "nessuna azione svolta" #: cmd_merging.cc:410 #, c-format -msgid "no merge necessary; putting %s in branch '%s'\n" -msgstr "‘merge’ non necessario; metto ‘%s’ nel ramo ‘%s’\n" +msgid "no merge necessary; putting %s in branch '%s'" +msgstr "‘merge’ non necessario; metto ‘%s’ nel ramo ‘%s’" #: cmd_merging.cc:446 #, c-format @@ -1023,13 +1025,13 @@ #: cmd_merging.cc:593 #, c-format -msgid "branch '%s' is currently merged:\n" -msgstr "il ramo ‘%s’ è attualmente unito:\n" +msgid "branch '%s' is currently merged:" +msgstr "il ramo ‘%s’ è attualmente unito:" #: cmd_merging.cc:595 #, c-format -msgid "branch '%s' is currently unmerged:\n" -msgstr "il ramo ‘%s’ è attualmente separato:\n" +msgid "branch '%s' is currently unmerged:" +msgstr "il ramo ‘%s’ è attualmente separato:" #: cmd_merging.cc:602 msgid "REVID" @@ -1041,8 +1043,8 @@ #: cmd_netsync.cc:40 #, c-format -msgid "setting default server to %s\n" -msgstr "imposto il server di default a ‘%s’\n" +msgid "setting default server to %s" +msgstr "imposto il server di default a ‘%s’" #: cmd_netsync.cc:46 #, c-format @@ -1062,13 +1064,13 @@ #: cmd_netsync.cc:67 #, c-format -msgid "setting default branch include pattern to '%s'\n" -msgstr "imposto il pattern di default di inclusione rami a ‘%s’\n" +msgid "setting default branch include pattern to '%s'" +msgstr "imposto il pattern di default di inclusione rami a ‘%s’" #: cmd_netsync.cc:73 #, c-format -msgid "setting default branch exclude pattern to '%s'\n" -msgstr "imposto il pattern di default di esclusione rami a ‘%s’\n" +msgid "setting default branch exclude pattern to '%s'" +msgstr "imposto il pattern di default di esclusione rami a ‘%s’" #: cmd_netsync.cc:81 #, c-format @@ -1098,8 +1100,8 @@ #: cmd_netsync.cc:120 #, c-format -msgid "doing anonymous pull; use -kKEYNAME if you need authentication\n" -msgstr "eseguo ‘pull’ anonimo; utilizza ‘-k NOMECHIAVE’ se necessiti di autenticazione\n" +msgid "doing anonymous pull; use -kKEYNAME if you need authentication" +msgstr "eseguo ‘pull’ anonimo; utilizza ‘-k NOMECHIAVE’ se necessiti di autenticazione" #: cmd_netsync.cc:127 msgid "sync branches matching PATTERN with netsync server at ADDRESS" @@ -1322,11 +1324,6 @@ msgid "checkout directory '%s' already exists" msgstr "la directory ‘%s’ esiste già, non può essere utilizzata per il ‘checkout’" -#: cmd_ws_commit.cc:401 -#, c-format -msgid "branch '%s' is empty" -msgstr "il ramo ‘%s’ è vuoto" - #: cmd_ws_commit.cc:404 #, c-format msgid "branch %s has multiple heads:" @@ -1344,8 +1341,8 @@ #: cmd_ws_commit.cc:435 #, c-format -msgid "revision %s is not a member of branch %s\n" -msgstr "la revisione ‘%s’ non fa parte del ramo ‘%s’\n" +msgid "revision %s is not a member of branch %s" +msgstr "la revisione ‘%s’ non fa parte del ramo ‘%s’" #: cmd_ws_commit.cc:469 #, c-format @@ -1389,13 +1386,13 @@ #: cmd_ws_commit.cc:612 #, c-format -msgid "no changes to commit\n" -msgstr "nessuna modifica che necessita di commit\n" +msgid "no changes to commit" +msgstr "nessuna modifica che necessita di commit" #: cmd_ws_commit.cc:626 #, c-format -msgid "beginning commit on branch '%s'\n" -msgstr "inizio il commit sul ramo ‘%s’\n" +msgid "beginning commit on branch '%s'" +msgstr "inizio il commit sul ramo ‘%s’" #: cmd_ws_commit.cc:635 #, c-format @@ -1415,13 +1412,13 @@ #: cmd_ws_commit.cc:666 #, c-format -msgid "log message rejected: %s\n" -msgstr "messaggio di log respinto: %s\n" +msgid "log message rejected: %s" +msgstr "messaggio di log respinto: %s" #: cmd_ws_commit.cc:674 #, c-format -msgid "revision %s already in database\n" -msgstr "la revisione ‘%s’ è già nel database\n" +msgid "revision %s already in database" +msgstr "la revisione ‘%s’ è già nel database" #: cmd_ws_commit.cc:712 #: cmd_ws_commit.cc:739 @@ -1436,8 +1433,8 @@ #: cmd_ws_commit.cc:765 #, c-format -msgid "committed revision %s\n" -msgstr "eseguito ‘commit’ della revisione %s\n" +msgid "committed revision %s" +msgstr "eseguito ‘commit’ della revisione %s" #: cmd_ws_commit.cc:771 #, c-format @@ -1466,7 +1463,6 @@ msgstr "aggiorna la cache degli inodeprint" #: commands.cc:111 -#: commands.cc:220 #, c-format msgid "unknown command '%s'\n" msgstr "comando ‘%s’ sconosciuto\n" @@ -1480,6 +1476,11 @@ msgid "commands:" msgstr "comandi:" +#: commands.cc:220 +#, c-format +msgid "unknown command '%s'" +msgstr "comando ‘%s’ sconosciuto" + #: commands.cc:241 msgid "command [ARGS...]" msgstr "comando [ARGOMENTI…]" @@ -1490,8 +1491,8 @@ #: commands.cc:372 #, c-format -msgid "expanding selection '%s'\n" -msgstr "espando la selezione ‘%s’\n" +msgid "expanding selection '%s'" +msgstr "espando la selezione ‘%s’" #: commands.cc:380 #, c-format @@ -1500,8 +1501,8 @@ #: commands.cc:386 #, c-format -msgid "expanded to '%s'\n" -msgstr "espanso in ‘%s’\n" +msgid "expanded to '%s'" +msgstr "espanso in ‘%s’" #: commands.cc:403 #, c-format @@ -1564,233 +1565,235 @@ #: database_check.cc:529 #, c-format -msgid "file %s missing (%d manifest references)\n" +msgid "file %s missing (%d manifest references)" msgstr "" #: database_check.cc:536 #, c-format -msgid "file %s unreferenced\n" -msgstr "file ‘%s’ senza referenze\n" +msgid "file %s unreferenced" +msgstr "file ‘%s’ senza referenze" #: database_check.cc:557 #, c-format -msgid "roster %s unreferenced\n" -msgstr "roster ‘%s’ senza referenze\n" +msgid "roster %s unreferenced" +msgstr "roster ‘%s’ senza referenze" #: database_check.cc:563 #, c-format -msgid "roster %s incomplete (%d missing files)\n" -msgstr "roster ‘%s’ incompleto (‘%d’ file mancanti)\n" +msgid "roster %s incomplete (%d missing files)" +msgstr "roster ‘%s’ incompleto (%d file mancanti)" #: database_check.cc:570 #, c-format -msgid "roster %s incomplete (%d missing revisions)\n" -msgstr "roster ‘%s’ incompleto (‘%d’ revisioni mancanti)\n" +msgid "roster %s incomplete (%d missing revisions)" +msgstr "roster ‘%s’ incompleto (%d revisioni mancanti)" +# TODO: togliere il ? in inglese #: database_check.cc:577 #, c-format -msgid "roster %s is not parseable (perhaps with unnormalized paths?)\n" -msgstr "roster ‘%s’ non leggibile (forse a causa di percorsi non normalizzati?)\n" +msgid "roster %s is not parseable (perhaps with unnormalized paths?)" +msgstr "roster ‘%s’ non comprensibile (forse a causa di percorsi non normalizzati)" #: database_check.cc:584 #, c-format -msgid "roster %s is not in normalized form\n" -msgstr "il roster ‘%s’ non è in forma normalizzata\n" +msgid "roster %s is not in normalized form" +msgstr "il roster ‘%s’ non è in forma normalizzata" #: database_check.cc:609 #, c-format -msgid "revision %s missing (%d revision references; %d cert references; %d parent references; %d child references; %d roster references)\n" +msgid "revision %s missing (%d revision references; %d cert references; %d parent references; %d child references; %d roster references)" msgstr "" #: database_check.cc:617 #, c-format -msgid "revision %s incomplete (%d missing manifests)\n" -msgstr "la revisione ‘%s’ è incompleta (mancano %d manifesti)\n" +msgid "revision %s incomplete (%d missing manifests)" +msgstr "la revisione ‘%s’ è incompleta (mancano %d manifesti)" #: database_check.cc:624 #, c-format -msgid "revision %s incomplete (%d missing revisions)\n" -msgstr "la revisione ‘%s’ è incompleta (mancano %d revisioni)\n" +msgid "revision %s incomplete (%d missing revisions)" +msgstr "la revisione ‘%s’ è incompleta (mancano %d revisioni)" #: database_check.cc:631 #, c-format -msgid "revision %s incomplete (missing roster link)\n" -msgstr "" +msgid "revision %s incomplete (missing roster link)" +msgstr "la revisione ‘%s’ è incompleta (manca il link al roster)" #: database_check.cc:637 #, c-format -msgid "revision %s incomplete (missing roster)\n" -msgstr "la revisione ‘%s’ è incompleta (roster mancante)\n" +msgid "revision %s incomplete (missing roster)" +msgstr "la revisione ‘%s’ è incompleta (manca il roster)" #: database_check.cc:643 #, c-format -msgid "revision %s mismatched roster and manifest\n" +msgid "revision %s mismatched roster and manifest" msgstr "" #: database_check.cc:649 #, c-format -msgid "revision %s incomplete (incomplete roster)\n" -msgstr "la revisione ‘%s’ è incompleta (roster incompleto)\n" +msgid "revision %s incomplete (incomplete roster)" +msgstr "la revisione ‘%s’ è incompleta (roster incompleto)" #: database_check.cc:655 #, c-format -msgid "revision %s mismatched parents (%d ancestry parents; %d revision refs)\n" +msgid "revision %s mismatched parents (%d ancestry parents; %d revision refs)" msgstr "" #: database_check.cc:664 #, c-format -msgid "revision %s mismatched children (%d ancestry children; %d parents)\n" +msgid "revision %s mismatched children (%d ancestry children; %d parents)" msgstr "" #: database_check.cc:676 #, c-format -msgid "revision %s has bad history (%s)\n" -msgstr "la revisione ‘%s’ ha una storia non valida (%s)\n" +msgid "revision %s has bad history (%s)" +msgstr "la revisione ‘%s’ ha una storia non valida (%s)" +# TODO: togliere il ? in inglese #: database_check.cc:683 #, c-format -msgid "revision %s is not parseable (perhaps with unnormalized paths?)\n" -msgstr "revisione ‘%s’ non leggibile (perhaps with unnormalized paths?)\n" +msgid "revision %s is not parseable (perhaps with unnormalized paths?)" +msgstr "revisione ‘%s’ non comprensibile (forse a causa di percorsi non normalizzati)" #: database_check.cc:690 #, c-format -msgid "revision %s is not in normalized form\n" -msgstr "la revisione ‘%s’ non in forma normalizzata\n" +msgid "revision %s is not in normalized form" +msgstr "la revisione ‘%s’ non in forma normalizzata" #: database_check.cc:714 #, c-format -msgid "key %s missing (signed %d certs)\n" -msgstr "chiave ‘%s’ mancante (firma %d certificati)\n" +msgid "key %s missing (signed %d certs)" +msgstr "chiave ‘%s’ mancante (firma %d certificati)" #: database_check.cc:747 #, c-format -msgid "revision %s unchecked signature in %s cert from missing key %s\n" +msgid "revision %s unchecked signature in %s cert from missing key %s" msgstr "" #: database_check.cc:755 #, c-format -msgid "revision %s bad signature in %s cert from key %s\n" +msgid "revision %s bad signature in %s cert from key %s" msgstr "" #: database_check.cc:770 #, c-format -msgid "revision %s missing %s cert\n" -msgstr "alla revisione ‘%s’ manca il certificato ‘%s’\n" +msgid "revision %s missing %s cert" +msgstr "alla revisione ‘%s’ manca il certificato ‘%s’" #: database_check.cc:779 #, c-format -msgid "revision %s mismatched certs (%d authors %d dates %d changelogs)\n" +msgid "revision %s mismatched certs (%d authors %d dates %d changelogs)" msgstr "" #: database_check.cc:866 #, c-format -msgid "%d missing files\n" -msgstr "%d file mancanti\n" +msgid "%d missing files" +msgstr "%d file mancanti" #: database_check.cc:868 #, c-format -msgid "%d unreferenced files\n" -msgstr "%d file non utilizzati\n" +msgid "%d unreferenced files" +msgstr "" #: database_check.cc:871 #, c-format -msgid "%d unreferenced rosters\n" -msgstr "%d roster non utilizzati\n" +msgid "%d unreferenced rosters" +msgstr "" #: database_check.cc:873 #, c-format -msgid "%d incomplete rosters\n" -msgstr "%d roster incompleti\n" +msgid "%d incomplete rosters" +msgstr "%d roster incompleti" #: database_check.cc:875 #, c-format -msgid "%d rosters not parseable (perhaps with invalid paths)\n" -msgstr "%d roster non leggibili (forse con percorsi invalidi)\n" +msgid "%d rosters not parseable (perhaps with invalid paths)" +msgstr "%d roster non comprensibili (forse con percorsi invalidi)" #: database_check.cc:878 #, c-format -msgid "%d rosters not in normalized form\n" -msgstr "%d roster non in forma normalizzata\n" +msgid "%d rosters not in normalized form" +msgstr "%d roster non in forma normalizzata" #: database_check.cc:881 #, c-format -msgid "%d missing revisions\n" -msgstr "%d revisioni mancanti\n" +msgid "%d missing revisions" +msgstr "%d revisioni mancanti" #: database_check.cc:883 #, c-format -msgid "%d incomplete revisions\n" -msgstr "%d revisioni incomplete\n" +msgid "%d incomplete revisions" +msgstr "%d revisioni incomplete" #: database_check.cc:885 #, c-format -msgid "%d mismatched parents\n" -msgstr "%d genitori non abbinati\n" +msgid "%d mismatched parents" +msgstr "%d genitori non abbinati" #: database_check.cc:887 #, c-format -msgid "%d mismatched children\n" -msgstr "%d figli non abbinati\n" +msgid "%d mismatched children" +msgstr "%d figli non abbinati" #: database_check.cc:889 #, c-format -msgid "%d revisions with bad history\n" -msgstr "%d revisioni con storia non valida\n" +msgid "%d revisions with bad history" +msgstr "%d revisioni con storia non valida" #: database_check.cc:891 #, c-format -msgid "%d revisions not parseable (perhaps with invalid paths)\n" -msgstr "%d revisioni non leggibili (forse con percorsi invalidi)\n" +msgid "%d revisions not parseable (perhaps with invalid paths)" +msgstr "%d revisioni non leggibili (forse con percorsi invalidi)" #: database_check.cc:894 #, c-format -msgid "%d revisions not in normalized form\n" -msgstr "%d revisioni non in forma normalizzata\n" +msgid "%d revisions not in normalized form" +msgstr "%d revisioni non in forma normalizzata" #: database_check.cc:898 #, c-format -msgid "%d unreferenced roster links\n" -msgstr "" +msgid "%d unreferenced roster links" +msgstr "%d roster non utilizzati" #: database_check.cc:901 #, c-format -msgid "%d missing rosters\n" -msgstr "%d roster mancanti\n" +msgid "%d missing rosters" +msgstr "%d roster mancanti" #: database_check.cc:905 #, c-format -msgid "%d missing keys\n" -msgstr "%d chiavi mancanti\n" +msgid "%d missing keys" +msgstr "%d chiavi mancanti" #: database_check.cc:908 #, c-format -msgid "%d missing certs\n" -msgstr "%d certificati mancanti\n" +msgid "%d missing certs" +msgstr "%d certificati mancanti" #: database_check.cc:910 #, c-format -msgid "%d mismatched certs\n" -msgstr "%d certificati non corrispondenti\n" +msgid "%d mismatched certs" +msgstr "%d certificati non corrispondenti" #: database_check.cc:912 #, c-format -msgid "%d unchecked signatures due to missing keys\n" -msgstr "%d firme non controllate per mancanza delle chiavi\n" +msgid "%d unchecked signatures due to missing keys" +msgstr "%d firme non controllate per mancanza delle chiavi" #: database_check.cc:914 #, c-format -msgid "%d bad signatures\n" -msgstr "%d firme non valide\n" +msgid "%d bad signatures" +msgstr "%d firme non valide" #: database_check.cc:940 #, c-format -msgid "check complete: %d files; %d rosters; %d revisions; %d keys; %d certs\n" -msgstr "controllo completo: %d file; %d roster; %d revisioni; %d chiavi; %d certificati\n" +msgid "check complete: %d files; %d rosters; %d revisions; %d keys; %d certs" +msgstr "controllo completo: %d file; %d roster; %d revisioni; %d chiavi; %d certificati" #: database_check.cc:946 #, c-format -msgid "total problems detected: %d (%d serious)\n" -msgstr "numero totale di problemi individuati: %d (di cui %d gravi)\n" +msgid "total problems detected: %d (%d serious)" +msgstr "numero totale di problemi individuati: %d (di cui %d gravi)" #: database_check.cc:948 #, c-format @@ -1799,13 +1802,13 @@ #: database_check.cc:950 #, c-format -msgid "minor problems detected\n" -msgstr "individuato un problema minore\n" +msgid "minor problems detected" +msgstr "individuato un problema minore" #: database_check.cc:952 #, c-format -msgid "database is good\n" -msgstr "il database non ha problemi\n" +msgid "database is good" +msgstr "il database non ha problemi" #: database.cc:158 #, c-format @@ -1951,8 +1954,8 @@ #: database.cc:771 #, c-format -msgid "null result in query: %s\n" -msgstr "risultato nullo nella query: %s\n" +msgid "null result in query: %s" +msgstr "risultato nullo nella query: %s" #: database.cc:789 #, c-format @@ -2150,7 +2153,7 @@ #: file_io.cc:458 #, c-format -msgid "caught runtime error %s constructing file path for %s\n" +msgid "caught runtime error %s constructing file path for %s" msgstr "" #: file_io.cc:497 @@ -2175,19 +2178,19 @@ #: keys.cc:122 #, c-format -msgid "empty passphrases not allowed, try again\n" -msgstr "le passphrase non può essere vuota, riprova\n" +msgid "empty passphrases not allowed, try again" +msgstr "le passphrase non può essere vuota, riprova" #: keys.cc:123 #: keys.cc:130 #, c-format -msgid "too many failed passphrases\n" -msgstr "troppe passphrase errate\n" +msgid "too many failed passphrases" +msgstr "troppe passphrase errate" #: keys.cc:129 #, c-format -msgid "passphrases do not match, try again\n" -msgstr "le passphrase non corrispondono, riprova\n" +msgid "passphrases do not match, try again" +msgstr "le passphrase non corrispondono, riprova" #: keys.cc:136 #, c-format @@ -2605,7 +2608,7 @@ "it is also possible that the server key has just been changed\n" "remote host sent key %s\n" "I expected %s\n" -"'%s unset %s %s' overrides this check\n" +"'%s unset %s %s' overrides this check" msgstr "" "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n" "@ ATTENZIONE: L'IDENTIFICAZIONE DEL SERVER È CAMBIATA @\n" @@ -2614,7 +2617,7 @@ "è anche possibile che la chiave del server sia stata semplicemente cambiata\n" "l'host remoto ha inviato la chiave ‘%s’\n" "mi aspettavo la chiave ‘%s’\n" -"‘%s unset %s %s’ per forzare questo controllo\n" +"‘%s unset %s %s’ per forzare questo controllo" #: netsync.cc:1242 #, c-format @@ -2631,18 +2634,18 @@ #: netsync.cc:1254 #, c-format -msgid "saving public key for %s to database\n" -msgstr "salvo la chiave pubblica per ‘%s’ nel database\n" +msgid "saving public key for %s to database" +msgstr "salvo la chiave pubblica per ‘%s’ nel database" #: netsync.cc:1347 #, c-format -msgid "rejected attempt at anonymous connection for write\n" -msgstr "rifiutato un tentativo di connessione anonima in scrittura\n" +msgid "rejected attempt at anonymous connection for write" +msgstr "rifiutato un tentativo di connessione anonima in scrittura" #: netsync.cc:1354 #, c-format -msgid "rejected attempt at anonymous connection while running as sink\n" -msgstr "rifiutato un tentativo di connessione anonima funzionando come pozzo\n" +msgid "rejected attempt at anonymous connection while running as sink" +msgstr "rifiutato un tentativo di connessione anonima funzionando come pozzo" #: netsync.cc:1370 #: netsync.cc:1499 @@ -2657,33 +2660,33 @@ #: netsync.cc:1385 #, c-format -msgid "allowed anonymous read permission for '%s' excluding '%s'\n" -msgstr "concessi permessi di lettura anonima a ‘%s’ con esclusione di ‘%s’\n" +msgid "allowed anonymous read permission for '%s' excluding '%s'" +msgstr "concessi permessi di lettura anonima a ‘%s’ con esclusione di ‘%s’" #: netsync.cc:1391 #, c-format -msgid "allowed anonymous read/write permission for '%s' excluding '%s'\n" -msgstr "concessi permessi di lettura/scrittura anonime a ‘%s’ con esclusione di ‘%s’\n" +msgid "allowed anonymous read/write permission for '%s' excluding '%s'" +msgstr "concessi permessi di lettura/scrittura anonime a ‘%s’ con esclusione di ‘%s’" #: netsync.cc:1446 #, c-format -msgid "detected replay attack in auth netcmd\n" -msgstr "individuato attacco replay nell'autenticazione netcmd\n" +msgid "detected replay attack in auth netcmd" +msgstr "individuato attacco replay nell'autenticazione netcmd" #: netsync.cc:1468 #, c-format -msgid "remote public key hash '%s' is unknown\n" -msgstr "l'hash ‘%s’ della chiave pubblica remota è sconosciuto\n" +msgid "remote public key hash '%s' is unknown" +msgstr "l'hash ‘%s’ della chiave pubblica remota è sconosciuto" #: netsync.cc:1485 #, c-format -msgid "denied '%s' read permission for '%s' excluding '%s' while running as pure sink\n" -msgstr "" +msgid "denied '%s' read permission for '%s' excluding '%s' while running as pure sink" +msgstr "negato a ‘%s’ il permesso di lettura a ‘%s’ con esclusione di ‘%s’ nel ruolo di pozzo" #: netsync.cc:1505 #, c-format -msgid "denied '%s' read permission for '%s' excluding '%s' because of branch '%s'\n" -msgstr "" +msgid "denied '%s' read permission for '%s' excluding '%s' because of branch '%s'" +msgstr "negato a ‘%s’ il permesso di lettura a ‘%s’ con esclusione di ‘%s’ a causa del ramo ‘%s’" #: netsync.cc:1508 #, c-format @@ -2692,32 +2695,32 @@ #: netsync.cc:1518 #, c-format -msgid "allowed '%s' read permission for '%s' excluding '%s'\n" -msgstr "concessi a ‘%s’ permessi di lettura per ‘%s’ con esclusione di ‘%s’\n" +msgid "allowed '%s' read permission for '%s' excluding '%s'" +msgstr "concessi a ‘%s’ permessi di lettura per ‘%s’ con esclusione di ‘%s’" #: netsync.cc:1527 #, c-format -msgid "denied '%s' write permission for '%s' excluding '%s' while running as pure source\n" -msgstr "" +msgid "denied '%s' write permission for '%s' excluding '%s' while running as pure source" +msgstr "negato a ‘%s’ il permesso di scrittura a ‘%s’ con esclusione di ‘%s’ nel ruolo di sorgente" #: netsync.cc:1535 #, c-format -msgid "denied '%s' write permission for '%s' excluding '%s'\n" -msgstr "negati a ‘%s’ permessi di scrittura per ‘%s’ con esclusione di ‘%s’\n" +msgid "denied '%s' write permission for '%s' excluding '%s'" +msgstr "negati a ‘%s’ permessi di scrittura per ‘%s’ con esclusione di ‘%s’" #: netsync.cc:1541 #, c-format -msgid "allowed '%s' write permission for '%s' excluding '%s'\n" -msgstr "concessi a ‘%s’ permessi di scrittura per ‘%s’ con esclusione di ‘%s’\n" +msgid "allowed '%s' write permission for '%s' excluding '%s'" +msgstr "concessi a ‘%s’ permessi di scrittura per ‘%s’ con esclusione di ‘%s’" #: netsync.cc:1565 #, c-format -msgid "bad client signature\n" -msgstr "firma del client non valida\n" +msgid "bad client signature" +msgstr "firma del client non valida" #: netsync.cc:1581 #, c-format -msgid "Unexpected 'refine' command on non-refined item type\n" +msgid "Unexpected 'refine' command on non-refined item type" msgstr "" #: netsync.cc:1678 @@ -2727,7 +2730,7 @@ #: netsync.cc:1693 #, c-format -msgid "Unexpected 'done' command on non-refined item type\n" +msgid "Unexpected 'done' command on non-refined item type" msgstr "" #: netsync.cc:1765 @@ -2778,18 +2781,18 @@ #: netsync.cc:2247 #: netsync.cc:2346 #, c-format -msgid "protocol error while processing peer %s: '%s'\n" +msgid "protocol error while processing peer %s: '%s'" msgstr "" #: netsync.cc:2253 #, c-format -msgid "error: %s\n" -msgstr "errore: %s\n" +msgid "error: %s" +msgstr "errore: %s" #: netsync.cc:2317 #, c-format -msgid "connecting to %s\n" -msgstr "connessione a ‘%s’\n" +msgid "connecting to %s" +msgstr "connessione a ‘%s’" #: netsync.cc:2361 #, c-format @@ -2803,12 +2806,12 @@ #: netsync.cc:2401 #, c-format -msgid "successful exchange with %s\n" -msgstr "scambio con ‘%s’ avvenuto con successo\n" +msgid "successful exchange with %s" +msgstr "scambio con ‘%s’ avvenuto con successo" #: netsync.cc:2407 #, c-format -msgid "peer %s disconnected after we informed them of error\n" +msgid "peer %s disconnected after we informed them of error" msgstr "" #: netsync.cc:2412 @@ -2818,22 +2821,22 @@ #: netsync.cc:2478 #, c-format -msgid "protocol error while processing peer %s: '%s', marking as bad\n" +msgid "protocol error while processing peer %s: '%s', marking as bad" msgstr "" #: netsync.cc:2510 #, c-format -msgid "accepted new client connection from %s : %s\n" +msgid "accepted new client connection from %s : %s" msgstr "" #: netsync.cc:2547 #, c-format -msgid "protocol error while processing peer %s: '%s', disconnecting\n" +msgid "protocol error while processing peer %s: '%s', disconnecting" msgstr "" #: netsync.cc:2558 #, c-format -msgid "peer %s read failed in working state (error)\n" +msgid "peer %s read failed in working state (error)" msgstr "" #: netsync.cc:2563 @@ -2843,12 +2846,12 @@ #: netsync.cc:2569 #, c-format -msgid "peer %s read failed in confirmed state (success)\n" +msgid "peer %s read failed in confirmed state (success)" msgstr "" #: netsync.cc:2590 #, c-format -msgid "peer %s write failed in working state (error)\n" +msgid "peer %s write failed in working state (error)" msgstr "" #: netsync.cc:2595 @@ -2858,23 +2861,23 @@ #: netsync.cc:2601 #, c-format -msgid "peer %s write failed in confirmed state (success)\n" +msgid "peer %s write failed in confirmed state (success)" msgstr "" #: netsync.cc:2628 #, c-format -msgid "peer %s processing finished, disconnecting\n" -msgstr "il peer ‘%s’ ha finito, mi scollego\n" +msgid "peer %s processing finished, disconnecting" +msgstr "il peer ‘%s’ ha finito, mi scollego" #: netsync.cc:2650 #, c-format -msgid "fd %d (peer %s) has been idle too long, disconnecting\n" +msgid "fd %d (peer %s) has been idle too long, disconnecting" msgstr "" #: netsync.cc:2718 #, c-format -msgid "beginning service on %s : %s\n" -msgstr "attivo il servizio su %s : %s\n" +msgid "beginning service on %s : %s" +msgstr "attivo il servizio su %s : %s" #: netsync.cc:2719 msgid "" @@ -2887,24 +2890,24 @@ #: netsync.cc:2798 #, c-format -msgid "got OOB from peer %s, disconnecting\n" -msgstr "ricevuti dati OOB dal peer ‘%s’, mi scollego\n" +msgid "got OOB from peer %s, disconnecting" +msgstr "ricevuti dati OOB dal peer ‘%s’, mi scollego" #: netsync.cc:2858 #, c-format -msgid "beginning service on %s\n" -msgstr "attivo il servizio su %s\n" +msgid "beginning service on %s" +msgstr "attivo il servizio su %s" # TODO: peer? #: netsync.cc:2921 #, c-format -msgid "got some OOB data on fd %d (peer %s), disconnecting\n" -msgstr "ricevuti dati OOB su fd %d (peer ‘%s’), mi scollego\n" +msgid "got some OOB data on fd %d (peer %s), disconnecting" +msgstr "ricevuti dati OOB su fd %d (peer ‘%s’), mi scollego" #: netsync.cc:2970 #, c-format -msgid "finding items to synchronize:\n" -msgstr "cerco elementi da sincronizzare:\n" +msgid "finding items to synchronize:" +msgstr "cerco elementi da sincronizzare:" #: netsync.cc:2978 msgid "certificates" @@ -2947,47 +2950,48 @@ #: packet.cc:135 #, c-format -msgid "missing prerequisite revision '%s'\n" -msgstr "manca un requisito: la revisione ‘%s’\n" +msgid "missing prerequisite revision '%s'" +msgstr "manca un requisito: la revisione ‘%s’" #: packet.cc:136 #: packet.cc:147 #: packet.cc:163 #: packet.cc:171 #, c-format -msgid "dropping revision '%s'\n" -msgstr "elimino la revisione ‘%s’\n" +msgid "dropping revision '%s'" +msgstr "elimino la revisione ‘%s’" #: packet.cc:146 #, c-format -msgid "missing prerequisite file '%s'\n" -msgstr "manca un requisito: il file ‘%s’\n" +msgid "missing prerequisite file '%s'" +msgstr "manca un requisito: il file ‘%s’" +# TODO: sarà del file o del pre-delta la %s? #: packet.cc:161 #, c-format -msgid "missing prerequisite file pre-delta '%s'\n" -msgstr "" +msgid "missing prerequisite file pre-delta '%s'" +msgstr "manca un requisito: la pre-delta del file ‘%s’" #: packet.cc:169 #, c-format -msgid "missing prerequisite file post-delta '%s'\n" -msgstr "" +msgid "missing prerequisite file post-delta '%s'" +msgstr "manca un requisito: la post-delta del file ‘%s’" # TODO: specificare "il certificato della"? #: packet.cc:197 #, c-format -msgid "cert revision '%s' does not exist in db\n" -msgstr "la revisione ‘%s’ non è presente in database\n" +msgid "cert revision '%s' does not exist in db" +msgstr "la revisione ‘%s’ non è presente in database" #: packet.cc:199 #, c-format -msgid "dropping cert\n" -msgstr "cancella certificato\n" +msgid "dropping cert" +msgstr "cancella certificato" #: packet.cc:222 #, c-format -msgid "key '%s' is not equal to key '%s' in database\n" -msgstr "la chiave ‘%s’ non è uguale alla chiave ‘%s’ nel database\n" +msgid "key '%s' is not equal to key '%s' in database" +msgstr "la chiave ‘%s’ non è uguale alla chiave ‘%s’ nel database" #: packet.cc:346 #, c-format @@ -3016,18 +3020,18 @@ #: rcs_import.cc:715 #, c-format -msgid "parsing RCS file %s\n" -msgstr "analizzo il file RCS ‘%s’\n" +msgid "parsing RCS file %s" +msgstr "analizzo il file RCS ‘%s’" #: rcs_import.cc:718 #, c-format -msgid "parsed RCS file %s OK\n" -msgstr "file RCS ‘%s’ analizzato correttamente\n" +msgid "parsed RCS file %s OK" +msgstr "file RCS ‘%s’ analizzato correttamente" #: rcs_import.cc:907 #, c-format -msgid "error reading RCS file %s: %s\n" -msgstr "errore leggendo file RCS ‘%s’: %s\n" +msgid "error reading RCS file %s: %s" +msgstr "errore leggendo file RCS ‘%s’: %s" #: rcs_import.cc:1204 #, c-format @@ -3054,23 +3058,23 @@ #: revision.cc:727 #, c-format -msgid "scanning for bogus merge edges\n" +msgid "scanning for bogus merge edges" msgstr "" #: revision.cc:769 #, c-format -msgid "optimizing out redundant edge %d -> %d\n" +msgid "optimizing out redundant edge %d -> %d" msgstr "" #: revision.cc:778 #, c-format -msgid "failed to eliminate edge %d -> %d\n" +msgid "failed to eliminate edge %d -> %d" msgstr "" #: revision.cc:789 #, c-format -msgid "rebuilding %d nodes\n" -msgstr "ricostruisco %d nodi\n" +msgid "rebuilding %d nodes" +msgstr "ricostruisco %d nodi" #: revision.cc:994 #, c-format @@ -3103,13 +3107,13 @@ #: revision.cc:1420 #, c-format -msgid "converting existing revision graph to new roster-style revisions\n" +msgid "converting existing revision graph to new roster-style revisions" msgstr "" #: revision.cc:1475 #, c-format -msgid "rebuilding revision graph from manifest certs\n" -msgstr "ricostruisco il grafo delle revisioni dai certificati di manifesto\n" +msgid "rebuilding revision graph from manifest certs" +msgstr "ricostruisco il grafo delle revisioni dai certificati di manifesto" #: revision.cc:1578 #, c-format @@ -3204,8 +3208,8 @@ #: schema_migration.cc:311 #, c-format -msgid "no migration performed; database schema already up-to-date at %s\n" -msgstr "nessuna migrazione effettuata: lo schema del database era già aggiornato a ‘%s’\n" +msgid "no migration performed; database schema already up-to-date at %s" +msgstr "nessuna migrazione effettuata: lo schema del database era già aggiornato a ‘%s’" #: schema_migration.cc:861 #, c-format @@ -3270,7 +3274,7 @@ #: update.cc:69 #, c-format -msgid "failed to decode boolean testresult cert value '%s'\n" +msgid "failed to decode boolean testresult cert value '%s'" msgstr "" #: update.cc:163 ============================================================ --- quick_alloc.hh 597049a62d0a2e6af7df0b19f4945ec7d6458727 +++ quick_alloc.hh 2df81e1736db37f310079c13ac4ef7dd98d42980 @@ -1,10 +1,10 @@ #ifndef __QUICK_ALLOC__ #define __QUICK_ALLOC__ #if defined(__GNUC__) && __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4) # define QA(T) std::__allocator< T, std::__single_client_alloc > # define QA_SUPPORTED -#else +#else # define QA(T) std::allocator< T > #endif ============================================================ --- randomfile.hh b1f6e5652eaa4a22cef5061e97930ad6ecb0ade7 +++ randomfile.hh 00d68b5949086027d0005fa67a4a433802fb9990 @@ -17,9 +17,9 @@ std::vector lines; std::string prefix; - void seed(int seed = 0xf00feed) - { - srand (seed); + void seed(int seed = 0xf00feed) + { + srand (seed); } size_t random_index(bool last_line_ok = true) @@ -101,7 +101,7 @@ std::vector & merged, int seed, int n_hunks = 10) - { + { file_randomizer fr; fr.seed(seed); ============================================================ --- rcs_file.cc e6ecf0169b282a6f96e278227893eef9ca10680e +++ rcs_file.cc 7e9f91d6c2d5dd3012ad17ea84b7545e28fc48f4 @@ -37,14 +37,14 @@ using std::string; #ifdef HAVE_MMAP -struct +struct file_handle { string const & filename; off_t length; int fd; - file_handle(string const & fn) : - filename(fn), + file_handle(string const & fn) : + filename(fn), length(0), fd(-1) { @@ -56,7 +56,7 @@ if (fd == -1) throw oops("open of " + filename + " failed"); } - ~file_handle() + ~file_handle() { if (close(fd) == -1) throw oops("close of " + filename + " failed"); @@ -87,9 +87,9 @@ ++pos; return good(); } - file_source(string const & fn, - int f, - off_t len) : + file_source(string const & fn, + int f, + off_t len) : filename(fn), fd(f), length(len), @@ -97,7 +97,7 @@ mapping(NULL) { mapping = mmap(0, length, PROT_READ, MAP_PRIVATE, fd, 0); - if (mapping == MAP_FAILED) + if (mapping == MAP_FAILED) throw oops("mmap of " + filename + " failed"); } ~file_source() @@ -107,14 +107,14 @@ } }; #elif defined(WIN32) -struct +struct file_handle { string const & filename; off_t length; HANDLE fd; - file_handle(string const & fn) : - filename(fn), + file_handle(string const & fn) : + filename(fn), length(0), fd(NULL) { @@ -123,14 +123,14 @@ throw oops("stat of " + filename + " failed"); length = st.st_size; fd = CreateFile(fn.c_str(), - GENERIC_READ, + GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (fd == NULL) throw oops("open of " + filename + " failed"); } - ~file_handle() + ~file_handle() { if (CloseHandle(fd)==0) throw oops("close of " + filename + " failed"); @@ -192,15 +192,15 @@ typedef istream file_source; #endif -typedef enum +typedef enum { TOK_STRING, TOK_SYMBOL, TOK_NUM, TOK_SEMI, TOK_COLON, - TOK_NONE - } + TOK_NONE + } token_type; static inline void @@ -215,17 +215,17 @@ ++col; } -static token_type +static token_type get_token(file_source & ist, string & str, - size_t & line, + size_t & line, size_t & col) { bool saw_idchar = false; int i = ist.peek(); char c; str.clear(); - + // eat leading whitespace while (true) { @@ -241,11 +241,11 @@ switch (i) { case ';': - ist.get(c); + ist.get(c); ++col; - return TOK_SEMI; + return TOK_SEMI; break; - + case ':': ist.get(c); ++col; @@ -274,9 +274,9 @@ break; default: - while (ist.good() - && i != ';' - && i != ':' + while (ist.good() + && i != ';' + && i != ':' && !isspace(i)) { ist.get(c); @@ -288,7 +288,7 @@ } break; } - + if (str.empty()) return TOK_NONE; else if (saw_idchar) @@ -307,10 +307,10 @@ size_t line, col; parser(file_source & s, - rcs_file & r) + rcs_file & r) : ist(s), r(r), line(1), col(1) {} - + string tt2str(token_type tt) { switch (tt) @@ -360,10 +360,10 @@ void sym() { eat(TOK_SYMBOL); } void num(string & v) { v = token; eat(TOK_NUM); } void num() { eat(TOK_NUM); } - void semi() { eat(TOK_SEMI); } + void semi() { eat(TOK_SEMI); } void colon() { eat(TOK_COLON); } void expect(string const & expected) - { + { string tmp; if (!symp(expected)) throw oops((F("parse failure %d:%d: expecting word '%s'\n") @@ -379,7 +379,7 @@ || ttype == TOK_COLON); } void word() - { + { if (!wordp()) throw oops((F("parse failure %d:%d: expecting word\n") % line % col).str()); @@ -401,26 +401,26 @@ expect("head"); num(r.admin.head); semi(); if (symp("branch")) { sym(r.admin.branch); if (nump()) num(); semi(); } expect("access"); while(symp()) { sym(); } semi(); - expect("symbols"); + expect("symbols"); // "man rcsfile" lies: there are real files in the wild which use // num tokens as the key value in a symbols entry. for example // "3.1:1.1.0.2" is a real sym:num specification, despite "3.1" // being a num itself, not a sym. - while(symp() || nump()) - { + while(symp() || nump()) + { string stmp, ntmp; if (symp()) { - sym(stmp); colon(); num(ntmp); + sym(stmp); colon(); num(ntmp); } else { - num(stmp); colon(); num(ntmp); + num(stmp); colon(); num(ntmp); } r.admin.symbols.insert(make_pair(ntmp, stmp)); - } + } semi(); expect("locks"); while(symp()) { sym(); colon(); num(); } semi(); if (symp("strict")) { sym(); semi(); } @@ -430,7 +430,7 @@ } void parse_deltas() - { + { while (nump()) { rcs_delta d; @@ -438,12 +438,12 @@ expect("date"); num(d.date); semi(); expect("author"); sym(d.author); semi(); expect("state"); if (symp()) sym(d.state); semi(); - expect("branches"); - while(nump()) - { - string tmp; - num(tmp); - d.branches.push_back(tmp); + expect("branches"); + while(nump()) + { + string tmp; + num(tmp); + d.branches.push_back(tmp); } semi(); expect("next"); if (nump()) num(d.next); semi(); @@ -463,7 +463,7 @@ { rcs_deltatext d; num(d.num); - expect("log"); str(d.log); + expect("log"); str(d.log); parse_newphrases("text"); expect("text"); str(d.text); r.push_deltatext(d); ============================================================ --- rcs_file.hh be175e779bb2c3dfb0a22a72013d1c25523cbe2d +++ rcs_file.hh 7cf27d862430efb640e00330ab59226d4feb6538 @@ -35,20 +35,20 @@ std::string text; }; -struct rcs_file +struct rcs_file { rcs_admin admin; std::map > deltas; std::map > deltatexts; - void push_delta(rcs_delta const & d) - { + void push_delta(rcs_delta const & d) + { boost::shared_ptr dp(new rcs_delta(d)); - deltas.insert(make_pair(dp->num,dp)); + deltas.insert(make_pair(dp->num,dp)); } - void push_deltatext(rcs_deltatext const & dt) - { + void push_deltatext(rcs_deltatext const & dt) + { boost::shared_ptr dp(new rcs_deltatext(dt)); - deltatexts.insert(make_pair(dp->num, dp)); + deltatexts.insert(make_pair(dp->num, dp)); } }; ============================================================ --- rcs_import.cc 45f1588e753d5220aa502425e5c32500f3069d7c +++ rcs_import.cc 7f7c2ab405b7b8d5758d74713c510fc567191c0f @@ -70,7 +70,7 @@ struct cvs_commit { - cvs_commit(rcs_file const & r, + cvs_commit(rcs_file const & r, string const & rcs_version, file_id const & ident, cvs_history & cvs); @@ -83,8 +83,8 @@ cvs_version version; cvs_path path; vector tags; - - bool operator<(cvs_commit const & other) const + + bool operator<(cvs_commit const & other) const { return time < other.time; } @@ -99,7 +99,7 @@ time_t first_commit; map live_at_beginning; - vector lineage; + vector lineage; cvs_branch() : has_a_branchpoint(false), @@ -107,7 +107,7 @@ last_branchpoint(0), first_commit(0) { - } + } void note_commit(time_t now) { @@ -132,7 +132,7 @@ time_t beginning() const { - I(has_a_branchpoint || has_a_commit); + I(has_a_branchpoint || has_a_commit); if (has_a_commit) { I(first_commit != 0); @@ -144,8 +144,8 @@ return last_branchpoint; } } - - void append_commit(cvs_commit const & c) + + void append_commit(cvs_commit const & c) { I(c.time != 0); note_commit(c.time); @@ -153,7 +153,7 @@ } }; -struct +struct cvs_history { @@ -164,11 +164,11 @@ interner path_interner; interner tag_interner; - // assume admin has foo:X.Y.0.N in it, then + // assume admin has foo:X.Y.0.N in it, then // this multimap contains entries of the form // X.Y -> foo multimap branchpoints; - + // and this map contains entries of the form // X.Y.N.1 -> foo map branch_first_entries; @@ -189,11 +189,11 @@ file_path curr_file; cvs_path curr_file_interned; - + string base_branch; ticker n_versions; - ticker n_tree_branches; + ticker n_tree_branches; cvs_history(); void set_filename(string const & file, @@ -234,31 +234,31 @@ } -cvs_commit::cvs_commit(rcs_file const & r, +cvs_commit::cvs_commit(rcs_file const & r, string const & rcs_version, file_id const & ident, cvs_history & cvs) { - map >::const_iterator delta = + map >::const_iterator delta = r.deltas.find(rcs_version); I(delta != r.deltas.end()); - - map >::const_iterator deltatext = + + map >::const_iterator deltatext = r.deltatexts.find(rcs_version); I(deltatext != r.deltatexts.end()); - + struct tm t; // We need to initialize t to all zeros, because strptime has a habit of // leaving bits of the data structure alone, letting garbage sneak into // our output. memset(&t, 0, sizeof(t)); char const * dp = delta->second->date.c_str(); - L(FL("Calculating time of %s\n") % dp); + L(FL("Calculating time of %s") % dp); #ifdef HAVE_STRPTIME if (strptime(dp, "%y.%m.%d.%H.%M.%S", &t) == NULL) I(strptime(dp, "%Y.%m.%d.%H.%M.%S", &t) != NULL); #else - I(sscanf(dp, "%d.%d.%d.%d.%d.%d", &(t.tm_year), &(t.tm_mon), + I(sscanf(dp, "%d.%d.%d.%d.%d.%d", &(t.tm_year), &(t.tm_mon), &(t.tm_mday), &(t.tm_hour), &(t.tm_min), &(t.tm_sec))==6); t.tm_mon--; // Apparently some RCS files have 2 digit years, others four; tm always @@ -267,9 +267,9 @@ t.tm_year-=1900; #endif time = mktime(&t); - L(FL("= %i\n") % time); + L(FL("= %i") % time); - is_synthetic_branch_root = is_sbr(delta->second, + is_synthetic_branch_root = is_sbr(delta->second, deltatext->second); alive = delta->second->state != "dead"; @@ -282,12 +282,12 @@ version = cvs.file_version_interner.intern(ident.inner()()); typedef multimap::const_iterator ity; - pair range = r.admin.symbols.equal_range(rcs_version); + pair range = r.admin.symbols.equal_range(rcs_version); for (ity i = range.first; i != range.second; ++i) { if (i->first == rcs_version) { - L(FL("version %s -> tag %s\n") % rcs_version % i->second); + L(FL("version %s -> tag %s") % rcs_version % i->second); tags.push_back(cvs.tag_interner.intern(i->second)); } } @@ -299,7 +299,7 @@ struct piece; -struct +struct piece_store { vector< shared_ptr > texts; @@ -311,12 +311,12 @@ }; // FIXME: kludge, I was lazy and did not make this -// a properly scoped variable. +// a properly scoped variable. static piece_store global_pieces; -struct +struct piece { piece(string::size_type p, string::size_type l, unsigned long id) : @@ -331,7 +331,7 @@ }; -void +void piece_store::build_string(vector const & pieces, string & out) { @@ -342,12 +342,12 @@ out.append(texts.at(i->string_id)->text, i->pos, i->len); } -void +void piece_store::index_deltatext(shared_ptr const & dt, vector & pieces) { pieces.clear(); - pieces.reserve(dt->text.size() / 30); + pieces.reserve(dt->text.size() / 30); texts.push_back(dt); unsigned long id = texts.size() - 1; string::size_type begin = 0; @@ -368,7 +368,7 @@ } -static void +static void process_one_hunk(vector< piece > const & source, vector< piece > & dest, vector< piece >::const_iterator & i, @@ -378,7 +378,7 @@ assert(directive.size() > 1); ++i; - try + try { char code; int pos, len; @@ -396,7 +396,7 @@ dest.push_back(*i++); } else if (code == 'd') - { + { // 'dx y' means "copy from source to dest until cursor == x-1, // then increment cursor by y, ignoring those y lines" while (cursor < (pos - 1)) @@ -404,22 +404,22 @@ I(cursor == pos - 1); cursor += len; } - else + else throw oops("unknown directive '" + directive + "'"); - } + } catch (out_of_range &) { - throw oops("out_of_range while processing " + directive - + " with source.size() == " + throw oops("out_of_range while processing " + directive + + " with source.size() == " + lexical_cast(source.size()) + " and cursor == " + lexical_cast(cursor)); - } + } } static void construct_version(vector< piece > const & source_lines, - string const & dest_version, + string const & dest_version, vector< piece > & dest_lines, rcs_file const & r) { @@ -428,15 +428,15 @@ I(r.deltas.find(dest_version) != r.deltas.end()); shared_ptr delta = r.deltas.find(dest_version)->second; - + I(r.deltatexts.find(dest_version) != r.deltatexts.end()); shared_ptr deltatext = r.deltatexts.find(dest_version)->second; - + vector deltalines; global_pieces.index_deltatext(deltatext, deltalines); - + int cursor = 0; - for (vector::const_iterator i = deltalines.begin(); + for (vector::const_iterator i = deltalines.begin(); i != deltalines.end(); ) process_one_hunk(source_lines, dest_lines, i, cursor); while (cursor < static_cast(source_lines.size())) @@ -446,7 +446,7 @@ // FIXME: should these be someplace else? using 'friend' to reach into the // DB is stupid, but it's also stupid to put raw edge insert methods on the // DB itself. or is it? hmm.. encapsulation vs. usage guidance.. -void +void rcs_put_raw_file_edge(hexenc const & old_id, hexenc const & new_id, delta const & del, @@ -454,7 +454,7 @@ { if (old_id == new_id) { - L(FL("skipping identity file edge\n")); + L(FL("skipping identity file edge")); return; } @@ -462,7 +462,7 @@ { // we already have a way to get to this old version, // no need to insert another reconstruction path - L(FL("existing path to %s found, skipping\n") % old_id); + L(FL("existing path to %s found, skipping") % old_id); } else { @@ -499,14 +499,14 @@ /* - + please read this exhaustingly long comment and understand it before mucking with the branch inference logic. we are processing a file version. a branch might begin here. if the current version is X.Y, then there is a branch B starting here iff there is a symbol in the admin section called X.Y.0.Z, -where Z is the branch number (or if there is a private branch +where Z is the branch number (or if there is a private branch called X.Y.Z, which is either an import branch or some private RCS cruft). @@ -551,30 +551,30 @@ history. each branchpoint symbol mentioned in the administrative section of a file is considered the root of a new lineage. - + */ -static void -process_branch(string const & begin_version, +static void +process_branch(string const & begin_version, vector< piece > const & begin_lines, data const & begin_data, hexenc const & begin_id, - rcs_file const & r, + rcs_file const & r, database & db, cvs_history & cvs) { string curr_version = begin_version; scoped_ptr< vector< piece > > next_lines(new vector); - scoped_ptr< vector< piece > > curr_lines(new vector + scoped_ptr< vector< piece > > curr_lines(new vector (begin_lines.begin(), - begin_lines.end())); + begin_lines.end())); data curr_data(begin_data), next_data; hexenc curr_id(begin_id), next_id; - + while(! (r.deltas.find(curr_version) == r.deltas.end())) { - L(FL("version %s has %d lines\n") % curr_version % curr_lines->size()); + L(FL("version %s has %d lines") % curr_version % curr_lines->size()); cvs_commit curr_commit(r, curr_version, curr_id, cvs); if (!curr_commit.is_synthetic_branch_root) @@ -582,18 +582,18 @@ cvs.stk.top()->append_commit(curr_commit); ++cvs.n_versions; } - + string next_version = r.deltas.find(curr_version)->second->next; if (! next_version.empty()) - { - L(FL("following RCS edge %s -> %s\n") % curr_version % next_version); + { + L(FL("following RCS edge %s -> %s") % curr_version % next_version); construct_version(*curr_lines, next_version, *next_lines, r); - L(FL("constructed RCS version %s, inserting into database\n") % + L(FL("constructed RCS version %s, inserting into database") % next_version); - insert_into_db(curr_data, curr_id, + insert_into_db(curr_data, curr_id, *next_lines, next_data, next_id, db); } @@ -601,12 +601,12 @@ // we're at a branchpoint typedef multimap::const_iterator ity; pair range = cvs.branchpoints.equal_range(curr_version); - if (range.first != cvs.branchpoints.end() + if (range.first != cvs.branchpoints.end() && range.first->first == curr_version) { for (ity i = range.first; i != range.second; ++i) { - cvs.push_branch(i->second, false); + cvs.push_branch(i->second, false); shared_ptr b = cvs.stk.top(); if (curr_commit.alive) b->live_at_beginning[cvs.curr_file_interned] = curr_commit.version; @@ -614,8 +614,8 @@ cvs.pop_branch(); } } - + // recursively follow any branch commits coming from the branchpoint shared_ptr curr_delta = r.deltas.find(curr_version)->second; for(vector::const_iterator i = curr_delta->branches.begin(); @@ -627,27 +627,27 @@ vector< piece > branch_lines; bool priv = false; map::const_iterator be = cvs.branch_first_entries.find(*i); - + if (be != cvs.branch_first_entries.end()) branch = be->second; else priv = true; - - L(FL("following RCS branch %s = '%s'\n") % (*i) % branch); - - construct_version(*curr_lines, *i, branch_lines, r); - insert_into_db(curr_data, curr_id, + + L(FL("following RCS branch %s = '%s'") % (*i) % branch); + + construct_version(*curr_lines, *i, branch_lines, r); + insert_into_db(curr_data, curr_id, branch_lines, branch_data, branch_id, db); - + cvs.push_branch(branch, priv); process_branch(*i, branch_lines, branch_data, branch_id, r, db, cvs); cvs.pop_branch(); - - L(FL("finished RCS branch %s = '%s'\n") % (*i) % branch); + + L(FL("finished RCS branch %s = '%s'") % (*i) % branch); } - + if (!r.deltas.find(curr_version)->second->next.empty()) - { + { // advance curr_data = next_data; curr_id = next_id; @@ -656,24 +656,24 @@ next_lines->clear(); } else break; - } -} + } +} -static void +static void import_rcs_file_with_cvs(string const & filename, database & db, cvs_history & cvs) { rcs_file r; - L(FL("parsing RCS file %s\n") % filename); + L(FL("parsing RCS file %s") % filename); parse_rcs_file(filename, r); - L(FL("parsed RCS file %s OK\n") % filename); + L(FL("parsed RCS file %s OK") % filename); { - vector< piece > head_lines; + vector< piece > head_lines; I(r.deltatexts.find(r.admin.head) != r.deltatexts.end()); I(r.deltas.find(r.admin.head) != r.deltas.end()); - hexenc id; + hexenc id; data dat(r.deltatexts.find(r.admin.head)->second->text); calculate_ident(dat, id); file_id fid = id; @@ -683,17 +683,17 @@ if (! db.file_version_exists (fid)) { - db.put_file(fid, dat); + db.put_file(fid, dat); } - + { // create the head state in case it is a loner // cvs_key k; // shared_ptr s; - // L(FL("noting head version %s : %s\n") % cvs.curr_file % r.admin.head); + // L(FL("noting head version %s : %s") % cvs.curr_file % r.admin.head); // cvs.find_key_and_state (r, r.admin.head, k, s); } - + global_pieces.reset(); global_pieces.index_deltatext(r.deltatexts.find(r.admin.head)->second, head_lines); process_branch(r.admin.head, head_lines, dat, id, r, db, cvs); @@ -704,7 +704,7 @@ } -void +void test_parse_rcs_file(system_path const & filename, database & db) { cvs_history cvs; @@ -712,10 +712,10 @@ I(! filename.empty()); assert_path_is_file(filename); - P(F("parsing RCS file %s\n") % filename); + P(F("parsing RCS file %s") % filename); rcs_file r; parse_rcs_file(filename.as_external(), r); - P(F("parsed RCS file %s OK\n") % filename); + P(F("parsed RCS file %s OK") % filename); } @@ -751,11 +751,11 @@ { } -void +void cvs_history::set_filename(string const & file, - file_id const & ident) + file_id const & ident) { - L(FL("importing file '%s'\n") % file); + L(FL("importing file '%s'") % file); I(file.size() > 2); I(file.substr(file.size() - 2) == string(",v")); string ss = file; @@ -775,7 +775,7 @@ branchpoints.clear(); branch_first_entries.clear(); - for (multimap::const_iterator i = + for (multimap::const_iterator i = r.admin.symbols.begin(); i != r.admin.symbols.end(); ++i) { string const & num = i->first; @@ -787,24 +787,24 @@ vector first_entry_components; vector branchpoint_components; - if (components.size() > 2 && + if (components.size() > 2 && (components.size() % 2 == 1)) { // this is a "vendor" branch - // + // // such as "1.1.1", where "1.1" is the branchpoint and // "1.1.1.1" will be the first commit on it. - + first_entry_components = components; first_entry_components.push_back("1"); branchpoint_components = components; - branchpoint_components.erase(branchpoint_components.end() - 1, + branchpoint_components.erase(branchpoint_components.end() - 1, branchpoint_components.end()); - } + } - else if (components.size() > 2 && + else if (components.size() > 2 && (components.size() % 2 == 0) && components[components.size() - 2] == string("0")) { @@ -814,11 +814,11 @@ // "1.3.2.1" first_entry_components = components; - first_entry_components[first_entry_components.size() - 2] - = first_entry_components[first_entry_components.size() - 1]; - first_entry_components[first_entry_components.size() - 1] + first_entry_components[first_entry_components.size() - 2] + = first_entry_components[first_entry_components.size() - 1]; + first_entry_components[first_entry_components.size() - 1] = string("1"); - + branchpoint_components = components; branchpoint_components.erase(branchpoint_components.end() - 2, branchpoint_components.end()); @@ -826,26 +826,26 @@ string first_entry_version; join_version(first_entry_components, first_entry_version); - - L(FL("first version in branch %s would be %s\n") + + L(FL("first version in branch %s would be %s") % sym % first_entry_version); branch_first_entries.insert(make_pair(first_entry_version, sym)); string branchpoint_version; join_version(branchpoint_components, branchpoint_version); - - L(FL("file branchpoint for %s at %s\n") % sym % branchpoint_version); + + L(FL("file branchpoint for %s at %s") % sym % branchpoint_version); branchpoints.insert(make_pair(branchpoint_version, sym)); } } -void +void cvs_history::push_branch(string const & branch_name, bool private_branch) { shared_ptr branch; - + string bname = base_branch + "." + branch_name; I(stk.size() > 0); @@ -857,7 +857,7 @@ return; } else - { + { map >::const_iterator b = branches.find(bname); if (b == branches.end()) { @@ -867,14 +867,14 @@ } else branch = b->second; - + stk.push(branch); bstk.push(branch_interner.intern(bname)); } } -void -cvs_history::pop_branch() +void +cvs_history::pop_branch() { I(stk.size() > 1); stk.pop(); @@ -882,21 +882,21 @@ } -class -cvs_tree_walker +class +cvs_tree_walker : public tree_walker { cvs_history & cvs; database & db; public: - cvs_tree_walker(cvs_history & c, database & d) : - cvs(c), db(d) + cvs_tree_walker(cvs_history & c, database & d) : + cvs(c), db(d) { } virtual void visit_file(file_path const & path) { string file = path.as_external(); - if (file.substr(file.size() - 2) == string(",v")) + if (file.substr(file.size() - 2) == string(",v")) { try { @@ -904,11 +904,11 @@ } catch (oops const & o) { - W(F("error reading RCS file %s: %s\n") % file % o.what()); + W(F("error reading RCS file %s: %s") % file % o.what()); } } else - L(FL("skipping non-RCS file %s\n") % file); + L(FL("skipping non-RCS file %s") % file); } virtual ~cvs_tree_walker() {} }; @@ -951,12 +951,12 @@ // commit associated with rev #3 quickly updated and committed at // 0013, finishing off at 0014. // -// - can rev #1 accept it? no. because CVS calcualted the version it +// - can rev #1 accept it? no. because CVS calcualted the version it // expected to see in bar.txt before calling up the server, when // committing rev #1. the version it expected to see was the version // in bar.txt *before* time 0012; that is, before rev #2 had any affect -// on bar.txt. when it contacted the server, the commit associated -// with rev #1 would have aborted if it had seen any other number. +// on bar.txt. when it contacted the server, the commit associated +// with rev #1 would have aborted if it had seen any other number. // so rev #1 could not start before an edit to bar.txt and then // include its own edit to bar.txt. // @@ -965,7 +965,7 @@ // wrong changelog/author) it starts a new revision. // // as we scan forwards, if we hit timestamps which lie beyond rev #n's -// window, we flush rev #n. +// window, we flush rev #n. // // if there are multiple coincident and legal revs to direct a // commit to (all with the same author/changelog), we direct the @@ -980,9 +980,9 @@ cvs_changelog changelog; set tags; - cvs_cluster(time_t t, + cvs_cluster(time_t t, cvs_author a, - cvs_changelog c) + cvs_changelog c) : first_time(t), author(a), changelog(c) @@ -1018,7 +1018,7 @@ struct prepared_revision { - prepared_revision(revision_id i, + prepared_revision(revision_id i, shared_ptr r, cvs_cluster const & c); revision_id rid; @@ -1049,7 +1049,7 @@ void store_revisions(); }; -typedef shared_ptr +typedef shared_ptr cluster_ptr; struct @@ -1065,8 +1065,8 @@ typedef set cluster_set; -void -import_branch(cvs_history & cvs, +void +import_branch(cvs_history & cvs, app_state & app, string const & branchname, shared_ptr const & branch, @@ -1081,15 +1081,15 @@ for (vector::const_iterator i = branch->lineage.begin(); i != branch->lineage.end(); ++i) - { + { commits_remaining--; - L(FL("examining next commit [t:%d] [p:%s] [a:%s] [c:%s]\n") - % i->time + L(FL("examining next commit [t:%d] [p:%s] [a:%s] [c:%s]") + % i->time % cvs.path_interner.lookup(i->path) % cvs.author_interner.lookup(i->author) % cvs.changelog_interner.lookup(i->changelog)); - + // step 2: expire all clusters from the beginning of the set which // have passed the window size while (!clusters.empty()) @@ -1097,14 +1097,14 @@ cluster_set::iterator j = clusters.begin(); if ((*j)->first_time + constants::cvs_window < i->time) { - L(FL("expiring cluster\n")); + L(FL("expiring cluster")); cons.consume_cluster(**j); clusters.erase(j); } else break; } - + // step 3: find the last still-live cluster to have touched this // file time_t time_of_last_cluster_touching_this_file = 0; @@ -1112,26 +1112,26 @@ unsigned clu = 0; for (cluster_set::const_iterator j = clusters.begin(); j != clusters.end(); ++j) - { - L(FL("examining cluster %d to see if it touched %d\n") + { + L(FL("examining cluster %d to see if it touched %d") % clu++ % i->path); - + cvs_cluster::entry_map::const_iterator k = (*j)->entries.find(i->path); if ((k != (*j)->entries.end()) && (k->second.time > time_of_last_cluster_touching_this_file)) { - L(FL("found cluster touching %d: [t:%d] [a:%d] [c:%d]\n") + L(FL("found cluster touching %d: [t:%d] [a:%d] [c:%d]") % i->path - % (*j)->first_time + % (*j)->first_time % (*j)->author % (*j)->changelog); time_of_last_cluster_touching_this_file = (*j)->first_time; } } - L(FL("last modification time is %d\n") + L(FL("last modification time is %d") % time_of_last_cluster_touching_this_file); - + // step 4: find a cluster which starts on or after the // last_modify_time, which doesn't modify the file in question, // and which contains the same author and changelog as our @@ -1144,67 +1144,67 @@ && ((*j)->author == i->author) && ((*j)->changelog == i->changelog) && ((*j)->entries.find(i->path) == (*j)->entries.end())) - { - L(FL("picked existing cluster [t:%d] [a:%d] [c:%d]\n") - % (*j)->first_time + { + L(FL("picked existing cluster [t:%d] [a:%d] [c:%d]") + % (*j)->first_time % (*j)->author % (*j)->changelog); target = (*j); } } - + // if we're still not finding an active cluster, - // this is probably the first commit in it. make + // this is probably the first commit in it. make // a new one. if (!target) { - L(FL("building new cluster [t:%d] [a:%d] [c:%d]\n") - % i->time + L(FL("building new cluster [t:%d] [a:%d] [c:%d]") + % i->time % i->author % i->changelog); - target = cluster_ptr(new cvs_cluster(i->time, - i->author, + target = cluster_ptr(new cvs_cluster(i->time, + i->author, i->changelog)); clusters.insert(target); } - + I(target); - target->entries.insert(make_pair(i->path, - cvs_cluster::entry(i->alive, + target->entries.insert(make_pair(i->path, + cvs_cluster::entry(i->alive, i->version, i->time))); for (vector::const_iterator j = i->tags.begin(); j != i->tags.end(); ++j) { - target->tags.insert(*j); + target->tags.insert(*j); } } // now we are done this lineage; flush all remaining clusters - L(FL("finished branch commits, writing all pending clusters\n")); + L(FL("finished branch commits, writing all pending clusters")); while (!clusters.empty()) { cons.consume_cluster(**clusters.begin()); clusters.erase(clusters.begin()); } - L(FL("finished writing pending clusters\n")); + L(FL("finished writing pending clusters")); cons.store_revisions(); } -void -import_cvs_repo(system_path const & cvsroot, +void +import_cvs_repo(system_path const & cvsroot, app_state & app) { N(!directory_exists(cvsroot / "CVSROOT"), F("%s appears to be a CVS repository root directory\n" "try importing a module instead, with 'cvs_import %s/") % cvsroot % cvsroot); - + { // early short-circuit to avoid failure after lots of work rsa_keypair_id key; @@ -1243,17 +1243,17 @@ map >::const_iterator i = cvs.branches.begin(); string branchname = i->first; shared_ptr branch = i->second; - L(FL("branch %s has %d entries\n") % branchname % branch->lineage.size()); + L(FL("branch %s has %d entries") % branchname % branch->lineage.size()); import_branch(cvs, app, branchname, branch, n_revs); // free up some memory - cvs.branches.erase(branchname); + cvs.branches.erase(branchname); guard.commit(); } { transaction_guard guard(app.db); - L(FL("trunk has %d entries\n") % cvs.trunk->lineage.size()); + L(FL("trunk has %d entries") % cvs.trunk->lineage.size()); import_branch(cvs, app, cvs.base_branch, cvs.trunk, n_revs); guard.commit(); } @@ -1283,8 +1283,8 @@ string const & branchname, cvs_branch const & branch, ticker & n_revs) - : cvs(cvs), - app(app), + : cvs(cvs), + app(app), branchname(branchname), branch(branch), n_revisions(n_revs), @@ -1292,26 +1292,26 @@ { if (!branch.live_at_beginning.empty()) { - cvs_author synthetic_author = + cvs_author synthetic_author = cvs.author_interner.intern("cvs_import"); - - cvs_changelog synthetic_cl = - cvs.changelog_interner.intern("beginning of branch " + + cvs_changelog synthetic_cl = + cvs.changelog_interner.intern("beginning of branch " + branchname); - + time_t synthetic_time = branch.beginning(); - cvs_cluster initial_cluster(synthetic_time, - synthetic_author, + cvs_cluster initial_cluster(synthetic_time, + synthetic_author, synthetic_cl); - - L(FL("initial cluster on branch %s has %d live entries\n") % + + L(FL("initial cluster on branch %s has %d live entries") % branchname % branch.live_at_beginning.size()); for (map::const_iterator i = branch.live_at_beginning.begin(); i != branch.live_at_beginning.end(); ++i) { cvs_cluster::entry e(true, i->second, synthetic_time); - L(FL("initial cluster contains %s at %s\n") % + L(FL("initial cluster contains %s at %s") % cvs.path_interner.lookup(i->first) % cvs.file_version_interner.lookup(i->second)); initial_cluster.entries.insert(make_pair(i->first, e)); @@ -1319,14 +1319,14 @@ consume_cluster(initial_cluster); } } - -cluster_consumer::prepared_revision::prepared_revision(revision_id i, + +cluster_consumer::prepared_revision::prepared_revision(revision_id i, shared_ptr r, cvs_cluster const & c) - : rid(i), - rev(r), - time(c.first_time), - author(c.author), + : rid(i), + rev(r), + time(c.first_time), + author(c.author), changelog(c.changelog) { for (set::const_iterator i = c.tags.begin(); @@ -1337,7 +1337,7 @@ } -void +void cluster_consumer::store_revisions() { for (vector::const_iterator i = preps.begin(); @@ -1354,7 +1354,7 @@ } } -void +void cluster_consumer::store_auxiliary_certs(prepared_revision const & p) { packet_db_writer dbw(app); @@ -1362,7 +1362,7 @@ for (vector::const_iterator i = p.tags.begin(); i != p.tags.end(); ++i) { - map >::const_iterator j + map >::const_iterator j = cvs.resolved_tags.find(*i); if (j != cvs.resolved_tags.end()) @@ -1380,13 +1380,13 @@ } } - cert_revision_in_branch(p.rid, cert_value(branchname), app, dbw); - cert_revision_author(p.rid, cvs.author_interner.lookup(p.author), app, dbw); + cert_revision_in_branch(p.rid, cert_value(branchname), app, dbw); + cert_revision_author(p.rid, cvs.author_interner.lookup(p.author), app, dbw); cert_revision_changelog(p.rid, cvs.changelog_interner.lookup(p.changelog), app, dbw); cert_revision_date_time(p.rid, p.time, app, dbw); } -void +void cluster_consumer::add_missing_parents(split_path const & sp, cset & cs) { split_path tmp(sp); @@ -1422,14 +1422,14 @@ if (e == live_files.end()) { add_missing_parents(sp, cs); - L(FL("adding entry state '%s' on '%s'\n") % fid % pth); + L(FL("adding entry state '%s' on '%s'") % fid % pth); safe_insert(cs.files_added, make_pair(sp, fid)); live_files[i->first] = i->second.version; } else if (e->second != i->second.version) { file_id old_fid(cvs.file_version_interner.lookup(e->second)); - L(FL("applying state delta on '%s' : '%s' -> '%s'\n") + L(FL("applying state delta on '%s' : '%s' -> '%s'") % pth % old_fid % fid); safe_insert(cs.deltas_applied, make_pair(sp, make_pair(old_fid, fid))); @@ -1441,7 +1441,7 @@ map::const_iterator e = live_files.find(i->first); if (e != live_files.end()) { - L(FL("deleting entry state '%s' on '%s'\n") % fid % pth); + L(FL("deleting entry state '%s' on '%s'") % fid % pth); safe_insert(cs.nodes_deleted, sp); live_files.erase(i->first); } ============================================================ --- refiner.cc f2f64fe6722f3501ce1fea2d85516818070151e2 +++ refiner.cc e286ca0e353379af8a9b3ebf4c0fbf8fd6679e9e @@ -47,13 +47,13 @@ // the client sends a done command, stating how many items it will be // sending. // -// When the server receives a done command, it echoes it back stating how -// many items *it* is going to send. +// When the server receives a done command, it echoes it back stating how +// many items *it* is going to send. // // When either side receives a done command, it transitions to // streaming send mode, sending all the items it's calculated. -void +void refiner::note_local_item(id const & item) { local_items.insert(item); @@ -66,11 +66,11 @@ recalculate_merkle_codes(table, prefix(""), 0); } -void +void refiner::load_merkle_node(size_t level, prefix const & pref, merkle_ptr & node) { - merkle_table::const_iterator j = table.find(make_pair(pref, level)); + merkle_table::const_iterator j = table.find(make_pair(pref, level)); I(j != table.end()); node = j->second; } @@ -83,7 +83,7 @@ return (j != table.end()); } -void +void refiner::calculate_items_to_send() { if (calculated_items_to_send) @@ -98,8 +98,8 @@ string typestr; netcmd_item_type_to_string(type, typestr); - - L(FL("determined %d %s items to send") % items_to_send.size() % typestr); + + L(FL("determined %d %s items to send") % items_to_send.size() % typestr); calculated_items_to_send = true; } @@ -123,8 +123,8 @@ collect_items_in_subtree(table, pref, our_node.level+1, peer_items); } -refiner::refiner(netcmd_item_type type, protocol_voice voice, refiner_callbacks & cb) - : type(type), voice (voice), cb(cb), +refiner::refiner(netcmd_item_type type, protocol_voice voice, refiner_callbacks & cb) + : type(type), voice (voice), cb(cb), sent_initial_query(false), queries_in_flight(0), calculated_items_to_send(false), @@ -148,20 +148,20 @@ { hexenc hslotval; their_node.get_hex_slot(slot, hslotval); - + hexenc hpref; their_node.get_hex_prefix(hpref); - + string typestr; netcmd_item_type_to_string(their_node.type, typestr); - - L(FL("peer has %s '%s' at slot %d (in node '%s', level %d)\n") + + L(FL("peer has %s '%s' at slot %d (in node '%s', level %d)") % typestr % hslotval % slot % hpref % their_node.level); } } -void +void refiner::begin_refinement() { merkle_ptr root; @@ -174,7 +174,7 @@ L(FL("Beginning %s refinement.") % typestr); } -void +void refiner::process_done_command(size_t n_items) { string typestr; @@ -193,8 +193,8 @@ } -void -refiner::process_refinement_command(refinement_type ty, +void +refiner::process_refinement_command(refinement_type ty, merkle_node const & their_node) { prefix pref; @@ -202,13 +202,13 @@ their_node.get_raw_prefix(pref); their_node.get_hex_prefix(hpref); string typestr; - + netcmd_item_type_to_string(their_node.type, typestr); size_t lev = static_cast(their_node.level); - - L(FL("received refinement %s netcmd on %s node '%s', level %d") + + L(FL("received refinement %s netcmd on %s node '%s', level %d") % (ty == refinement_query ? "query" : "response") % typestr % hpref % lev); - + merkle_ptr our_node; if (merkle_node_exists(their_node.level, pref)) @@ -243,7 +243,7 @@ } } } - + // Compare any subtrees, if we both have subtrees. if (our_node->get_slot_state(slot) == subtree_state && their_node.get_slot_state(slot) == subtree_state) @@ -251,11 +251,11 @@ id our_slotval, their_slotval; their_node.get_raw_slot(slot, their_slotval); our_node->get_raw_slot(slot, our_slotval); - + // Always note when you share a subtree. if (their_slotval == our_slotval) note_subtree_shared_with_peer(*our_node, slot); - + // Send subqueries when you have a different subtree // and you're answering a query message. else if (ty == refinement_query) @@ -267,7 +267,7 @@ // have any of the *other* parts of my subtree, so it's ok if I // eventually wind up sending the subtree-minus-their-leaf. } - + if (ty == refinement_response) { E((queries_in_flight > 0), ============================================================ --- refiner.hh 785a738e8476f63f8f8b0c5ecfee085dbd764ade +++ refiner.hh cb3b7386d2d3c0836382814daebb8ff4074cf04e @@ -18,10 +18,10 @@ // refiner for every merkle trie you wish to refine, and pass it a // reference to a refiner_callbacks object, such as the netsync session // object. Refinement proceeds in stages. -// +// // 1. Add local items. // -// 2. Call reindex_local_items to index the merkle table. +// 2. Call reindex_local_items to index the merkle table. // // 3. Call begin_refinement, and process the queue_refine_cmd callback // this will generate. @@ -35,7 +35,7 @@ struct refiner_callbacks { - virtual void queue_refine_cmd(refinement_type ty, + virtual void queue_refine_cmd(refinement_type ty, merkle_node const & our_node) = 0; virtual void queue_done_cmd(netcmd_item_type ty, size_t n_items) = 0; @@ -78,16 +78,16 @@ void begin_refinement(); void process_done_command(size_t n_items); void process_refinement_command(refinement_type ty, merkle_node const & their_node); - bool local_item_exists(id const & ident) - { - return local_items.find(ident) != local_items.end(); + bool local_item_exists(id const & ident) + { + return local_items.find(ident) != local_items.end(); } // These are populated as the 'done' packets arrive. bool done; std::set items_to_send; - size_t items_to_receive; + size_t items_to_receive; }; ============================================================ --- restrictions.cc d7c60923a328aefb9a8429ecb6654586ce31a3f9 +++ restrictions.cc 7419cd1cb2303f5a839b67594d6de2943a57309c @@ -36,15 +36,15 @@ } static void -add_paths(map & path_map, - path_set const & paths, +add_paths(map & path_map, + path_set const & paths, path_state const state) { for (path_set::const_iterator i = paths.begin(); i != paths.end(); ++i) { map::iterator p = path_map.find(*i); if (p != path_map.end()) - N(p->second == state, + N(p->second == state, F("conflicting include/exclude on path '%s'") % *i); else path_map.insert(make_pair(*i, state)); @@ -52,22 +52,22 @@ } static void -add_nodes(map & node_map, +add_nodes(map & node_map, roster_t const & roster, - path_set const & paths, - path_set & known, + path_set const & paths, + path_set & known, path_state const state) { for (path_set::const_iterator i = paths.begin(); i != paths.end(); ++i) { - if (roster.has_node(*i)) + if (roster.has_node(*i)) { known.insert(*i); node_id nid = roster.get_node(*i)->self; - + map::iterator n = node_map.find(nid); if (n != node_map.end()) - N(n->second == state, + N(n->second == state, F("conflicting include/exclude on path '%s'") % *i); else node_map.insert(make_pair(nid, state)); @@ -102,7 +102,7 @@ { int bad = 0; - for (path_set::const_iterator i = included_paths.begin(); + for (path_set::const_iterator i = included_paths.begin(); i != included_paths.end(); ++i) { // ignored paths are allowed into the restriction but are not considered @@ -118,7 +118,7 @@ } } - for (path_set::const_iterator i = excluded_paths.begin(); + for (path_set::const_iterator i = excluded_paths.begin(); i != excluded_paths.end(); ++i) { if (known_paths.find(*i) == known_paths.end()) @@ -127,7 +127,7 @@ W(F("unknown path excluded %s") % *i); } } - + N(bad == 0, F("%d unknown paths") % bad); } @@ -143,9 +143,9 @@ split_path sp; roster.get_name(nid, sp); - + // empty restriction includes everything - if (empty()) + if (empty()) { L(FL("empty include of nid %d path '%s'") % nid % file_path(sp)); return true; @@ -159,13 +159,13 @@ // somewhat more reasonable here to use depth=0 to mean "exactly this // directory" and depth=1 to mean "this directory and its immediate children" - while (!null_node(current) && (app.depth == -1 || depth <= app.depth + 1)) + while (!null_node(current) && (app.depth == -1 || depth <= app.depth + 1)) { map::const_iterator r = node_map.find(current); - if (r != node_map.end()) + if (r != node_map.end()) { - switch (r->second) + switch (r->second) { case included: L(FL("explicit include of nid %d path '%s'") % current % file_path(sp)); @@ -184,12 +184,12 @@ if (included_paths.empty()) { - L(FL("default include of nid %d path '%s'\n") % nid % file_path(sp)); + L(FL("default include of nid %d path '%s'") % nid % file_path(sp)); return true; } else { - L(FL("default exclude of nid %d path '%s'\n") % nid % file_path(sp)); + L(FL("default exclude of nid %d path '%s'") % nid % file_path(sp)); return false; } } @@ -198,7 +198,7 @@ restriction::includes(split_path const & sp) const { // empty restriction includes everything - if (empty()) + if (empty()) { L(FL("empty include of path '%s'") % file_path(sp)); return true; @@ -218,7 +218,7 @@ if (r != path_map.end()) { - switch (r->second) + switch (r->second) { case included: L(FL("explicit include of path '%s'") % file_path(sp)); @@ -236,12 +236,12 @@ if (included_paths.empty()) { - L(FL("default include of path '%s'\n") % file_path(sp)); + L(FL("default include of path '%s'") % file_path(sp)); return true; } else { - L(FL("default exclude of path '%s'\n") % file_path(sp)); + L(FL("default exclude of path '%s'") % file_path(sp)); return false; } } @@ -327,7 +327,7 @@ file_id fid_yyf(string("d000000000000000000000000000000000000000")); file_id fid_yyg(string("e000000000000000000000000000000000000000")); -static void setup(roster_t & roster) +static void setup(roster_t & roster) { temp_node_id_source nis; @@ -404,7 +404,7 @@ roster.attach_node(nid_yyg, sp_yyg); } -static void +static void test_empty_restriction() { roster_t roster; @@ -412,7 +412,7 @@ app_state app; restriction mask(app); - + BOOST_CHECK(mask.empty()); // check restricted nodes @@ -466,7 +466,7 @@ BOOST_CHECK(mask.includes(sp_yyg)); } -static void +static void test_simple_include() { roster_t roster; @@ -532,7 +532,7 @@ BOOST_CHECK( mask.includes(sp_yyg)); } -static void +static void test_simple_exclude() { roster_t roster; @@ -598,7 +598,7 @@ BOOST_CHECK(!mask.includes(sp_yyg)); } -static void +static void test_include_exclude() { roster_t roster; @@ -666,7 +666,7 @@ BOOST_CHECK(!mask.includes(sp_yyg)); } -static void +static void test_exclude_include() { roster_t roster; @@ -737,7 +737,7 @@ BOOST_CHECK( mask.includes(sp_yyg)); } -static void +static void test_invalid_paths() { roster_t roster; @@ -763,7 +763,7 @@ app_state app; // FIXME: depth == 0 currently means directory + immediate children - // this should be changed to mean just the named directory but for + // this should be changed to mean just the named directory but for // compatibility with old restrictions this behaviour has been preserved app.set_depth(0); restriction mask(includes, excludes, roster, app); @@ -833,7 +833,7 @@ app_state app; // FIXME: depth == 1 currently means directory + children + grand children - // this should be changed to mean directory + immediate children but for + // this should be changed to mean directory + immediate children but for // compatibility with old restrictions this behaviour has been preserved app.set_depth(1); restriction mask(includes, excludes, roster, app); ============================================================ --- restrictions.hh 797c6f69647ff3a63870f7870b88353840cf9200 +++ restrictions.hh 2559135fa63540e2fe96c33eb01cf846bcb8519e @@ -56,7 +56,7 @@ restriction(std::vector const & includes, std::vector const & excludes, - roster_t const & roster, + roster_t const & roster, app_state & a) : app(a) { @@ -64,7 +64,7 @@ map_nodes(roster); validate(); } - + restriction(std::vector const & includes, std::vector const & excludes, roster_t const & roster1, ============================================================ --- revision.cc 8b358213321192d8a1f65992915ed1b20dd2cbbe +++ revision.cc 201081607e581bf1fcf2416486399d2840189617 @@ -91,10 +91,10 @@ // (done in put_revision, for instance) covers this case automatically. } -bool +bool revision_set::is_merge_node() const -{ - return edges.size() > 1; +{ + return edges.size() > 1; } bool @@ -119,7 +119,7 @@ edges = other.edges; } -revision_set const & +revision_set const & revision_set::operator=(revision_set const & other) { other.check_sane(); @@ -155,10 +155,10 @@ typedef dynamic_bitset<> bitmap; typedef shared_ptr shared_bitmap; -static void +static void calculate_ancestors_from_graph(interner & intern, revision_id const & init, - multimap const & graph, + multimap const & graph, map< ctx, shared_bitmap > & ancestors, shared_bitmap & total_union); @@ -188,7 +188,7 @@ inverse_graph.insert(make_pair(i->second, i->first)); } - + while (leaves.size() != 1) { isect->clear(); @@ -205,8 +205,8 @@ else { curr_leaf_ancestors = shared_bitmap(new bitmap()); - calculate_ancestors_from_graph(intern, revision_id(intern.lookup(curr_leaf)), - inverse_graph, ancestors, + calculate_ancestors_from_graph(intern, revision_id(intern.lookup(curr_leaf)), + inverse_graph, ancestors, curr_leaf_ancestors); } if (isect->size() > curr_leaf_ancestors->size()) @@ -220,16 +220,16 @@ else (*isect) &= (*curr_leaf_ancestors); } - + // 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 + // 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). set new_leaves; for (ctx i = 0; i < isect->size(); ++i) { if (isect->test(i)) { - calculate_ancestors_from_graph(intern, revision_id(intern.lookup(i)), + calculate_ancestors_from_graph(intern, revision_id(intern.lookup(i)), inverse_graph, ancestors, isect_ancs); } } @@ -286,7 +286,7 @@ } } } - return false; + return false; } bool @@ -294,7 +294,7 @@ revision_id const & descendent_id, app_state & app) { - L(FL("checking whether %s is an ancestor of %s\n") % ancestor_id % descendent_id); + L(FL("checking whether %s is an ancestor of %s") % ancestor_id % descendent_id); multimap graph; app.db.get_revision_ancestry(graph); @@ -302,7 +302,7 @@ } -static void +static void add_bitset_to_union(shared_bitmap src, shared_bitmap dst) { @@ -314,10 +314,10 @@ } -static void +static void calculate_ancestors_from_graph(interner & intern, revision_id const & init, - multimap const & graph, + multimap const & graph, map< ctx, shared_bitmap > & ancestors, shared_bitmap & total_union) { @@ -406,7 +406,7 @@ { // now stick them in our ordering (if wanted) and remove them from the // graph, calculating the new roots as we go - L(FL("new root: %s\n") % (roots.front())); + L(FL("new root: %s") % (roots.front())); if (revisions.find(roots.front()) != revisions.end()) sorted.push_back(roots.front()); for(gi i = graph.lower_bound(roots.front()); @@ -421,7 +421,7 @@ for (set::const_iterator i = leaves.begin(); i != leaves.end(); ++i) { - L(FL("new leaf: %s\n") % (*i)); + L(FL("new leaf: %s") % (*i)); if (revisions.find(*i) != revisions.end()) sorted.push_back(*i); } @@ -448,7 +448,7 @@ for (set::const_iterator i = revisions.begin(); i != revisions.end(); ++i) - { + { calculate_ancestors_from_graph(intern, *i, inverse_graph, ancestors, u); } @@ -461,7 +461,7 @@ if (!has_ancestor_in_set) tmp.insert(*i); } - + revisions = tmp; } @@ -491,7 +491,7 @@ for (set::const_iterator i = bs.begin(); i != bs.end(); ++i) - { + { calculate_ancestors_from_graph(intern, *i, inverse_graph, ancestors, u); ctx c = intern.intern(i->inner()()); if (u->size() <= c) @@ -510,7 +510,7 @@ au->resize(max(au->size(), u->size())); u->resize(max(au->size(), u->size())); - + *au -= *u; for (unsigned int i = 0; i != au->size(); ++i) @@ -539,19 +539,19 @@ 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), - old_roster, - new_roster, + select_nodes_modified_by_cset(edge_changes(i), + old_roster, + new_roster, edge_nodes_modified); - copy(edge_nodes_modified.begin(), edge_nodes_modified.end(), + copy(edge_nodes_modified.begin(), edge_nodes_modified.end(), inserter(nodes_modified, nodes_modified.begin())); } } void -make_revision_set(revision_id const & old_rev_id, +make_revision_set(revision_id const & old_rev_id, roster_t const & old_roster, roster_t const & new_roster, revision_set & rev) @@ -560,10 +560,10 @@ rev.edges.clear(); make_cset(old_roster, new_roster, *cs); - + calculate_ident(new_roster, rev.new_manifest); - L(FL("new manifest_id is %s\n") % rev.new_manifest); - + L(FL("new manifest_id is %s") % rev.new_manifest); + safe_insert(rev.edges, make_pair(old_rev_id, cs)); } @@ -571,7 +571,7 @@ // Stuff related to rebuilding the revision graph. Unfortunately this is a // real enough error case that we need support code for it. -typedef map, shared_ptr > > +typedef map, shared_ptr > > parent_roster_map; template <> void @@ -597,16 +597,16 @@ struct anc_graph { - anc_graph(bool existing, app_state & a) : + anc_graph(bool existing, app_state & a) : existing_graph(existing), - app(a), - max_node(0), + app(a), + max_node(0), n_nodes("nodes", "n", 1), n_certs_in("certs in", "c", 1), n_revs_out("revs out", "r", 1), n_certs_out("certs out", "C", 1) {} - + bool existing_graph; app_state & app; u64 max_node; @@ -630,14 +630,14 @@ multimap > certs; multimap ancestry; set branches; - - void add_node_ancestry(u64 child, u64 parent); + + void add_node_ancestry(u64 child, u64 parent); void write_certs(); void kluge_for_bogus_merge_edges(); void rebuild_ancestry(); void get_node_manifest(u64 node, manifest_id & man); u64 add_node_for_old_manifest(manifest_id const & man); - u64 add_node_for_oldstyle_revision(revision_id const & rev); + u64 add_node_for_oldstyle_revision(revision_id const & rev); void construct_revisions_from_ancestry(); void fixup_node_identities(parent_roster_map const & parent_rosters, roster_t & child_roster, @@ -647,7 +647,7 @@ void anc_graph::add_node_ancestry(u64 child, u64 parent) { - L(FL("noting ancestry from child %d -> parent %d\n") % child % parent); + L(FL("noting ancestry from child %d -> parent %d") % child % parent); ancestry.insert(make_pair(child, parent)); } @@ -662,7 +662,7 @@ { { // regenerate epochs on all branches to random states - + for (set::const_iterator i = branches.begin(); i != branches.end(); ++i) { char buf[constants::epochlen_bytes]; @@ -670,21 +670,21 @@ hexenc 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); + L(FL("setting epoch for %s to %s") % *i % new_epoch); app.db.set_epoch(cert_value(*i), new_epoch); } } typedef multimap >::const_iterator ci; - + for (map::const_iterator i = node_to_new_rev.begin(); i != node_to_new_rev.end(); ++i) { revision_id rev(i->second); pair range = certs.equal_range(i->first); - + for (ci j = range.first; j != range.second; ++j) { cert_name name(j->second.first); @@ -698,8 +698,8 @@ ++n_certs_out; app.db.put_revision_cert(rcert); } - } - } + } + } } void @@ -724,7 +724,7 @@ // dropped by a previous kluge ("3-ancestor") so we have removed that // code. - P(F("scanning for bogus merge edges\n")); + P(F("scanning for bogus merge edges")); multimap parent_to_child_map; for (multimap::const_iterator i = ancestry.begin(); @@ -743,7 +743,7 @@ { if (j->first == i->first) { - L(FL("considering old merge edge %s\n") % + L(FL("considering old merge edge %s") % safe_get(node_to_old_rev, i->first)); u64 parent1 = i->second; u64 parent2 = j->second; @@ -755,7 +755,7 @@ } } - for (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; @@ -766,16 +766,16 @@ { if (j->second == parent) { - P(F("optimizing out redundant edge %d -> %d\n") + P(F("optimizing out redundant edge %d -> %d") % parent % child); ancestry.erase(j); killed = true; break; } } - + if (!killed) - W(F("failed to eliminate edge %d -> %d\n") + W(F("failed to eliminate edge %d -> %d") % parent % child); } } @@ -786,11 +786,11 @@ { kluge_for_bogus_merge_edges(); - P(F("rebuilding %d nodes\n") % max_node); + P(F("rebuilding %d nodes") % max_node); { transaction_guard guard(app.db); if (existing_graph) - app.db.delete_existing_revs_and_certs(); + app.db.delete_existing_revs_and_certs(); construct_revisions_from_ancestry(); write_certs(); if (existing_graph) @@ -799,7 +799,7 @@ } } -u64 +u64 anc_graph::add_node_for_old_manifest(manifest_id const & man) { I(!existing_graph); @@ -808,22 +808,22 @@ { node = max_node++; ++n_nodes; - L(FL("node %d = manifest %s\n") % node % man); + L(FL("node %d = manifest %s") % node % man); old_man_to_node.insert(make_pair(man, node)); node_to_old_man.insert(make_pair(node, man)); - + // load certs vector< manifest > mcerts; app.db.get_manifest_certs(man, mcerts); - erase_bogus_certs(mcerts, app); + erase_bogus_certs(mcerts, app); 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); + L(FL("loaded '%s' manifest cert for node %s") % i->inner().name % node); cert_value tv; decode_base64(i->inner().value, tv); ++n_certs_in; - certs.insert(make_pair(node, + certs.insert(make_pair(node, make_pair(i->inner().name, tv))); } } @@ -843,12 +843,12 @@ { node = max_node++; ++n_nodes; - + manifest_id man; legacy::renames_map renames; legacy::get_manifest_and_renames_for_rev(app, rev, man, renames); - - L(FL("node %d = revision %s = manifest %s\n") % node % rev % man); + + L(FL("node %d = revision %s = manifest %s") % node % rev % man); 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)); @@ -857,18 +857,18 @@ // load certs vector< revision > rcerts; app.db.get_revision_certs(rev, rcerts); - erase_bogus_certs(rcerts, app); + erase_bogus_certs(rcerts, app); 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); + L(FL("loaded '%s' revision cert for node %s") % i->inner().name % node); cert_value tv; decode_base64(i->inner().value, tv); ++n_certs_in; - certs.insert(make_pair(node, + certs.insert(make_pair(node, make_pair(i->inner().name, tv))); - if (i->inner().name == branch_cert_name) + if (i->inner().name == branch_cert_name) branches.insert(tv()); } } @@ -897,17 +897,17 @@ // node's birth revision is _not_ an ancestor of the revision. // "Dead" means, the node does not exist in the revision's tree, and the // node's birth revision _is_ an ancestor of the revision. - - // L(FL("testing liveliness of node %d, born in rev %d\n") % nid % birth_rev); + + // L(FL("testing liveliness of node %d, born in rev %d") % nid % birth_rev); for (parent_roster_map::const_iterator r = parent_rosters.begin(); r != parent_rosters.end(); ++r) { shared_ptr parent = r->second.first; - // L(FL("node %d %s in parent roster %d\n") + // L(FL("node %d %s in parent roster %d") // % nid - // % (parent->has_node(n->first) ? "exists" : "does not exist" ) + // % (parent->has_node(n->first) ? "exists" : "does not exist" ) // % r->first); - + if (!parent->has_node(nid)) { deque work; @@ -917,13 +917,13 @@ { u64 curr = work.front(); work.pop_front(); - // L(FL("examining ancestor %d of parent roster %d, looking for anc=%d\n") + // L(FL("examining ancestor %d of parent roster %d, looking for anc=%d") // % curr % r->first % birth_rev); - + if (seen.find(curr) != seen.end()) continue; seen.insert(curr); - + if (curr == birth_rev) { // L(FL("node is dead in %d") % r->first); @@ -939,7 +939,7 @@ } } } - } + } // L(FL("node is alive in all parents, returning true")); return true; } @@ -981,8 +981,8 @@ } static void -insert_into_roster(roster_t & child_roster, - temp_node_id_source & nis, +insert_into_roster(roster_t & child_roster, + temp_node_id_source & nis, file_path const & pth, file_id const & fid) { @@ -1012,7 +1012,7 @@ } if (child_roster.has_node(sp)) - { + { node_t n = child_roster.get_node(sp); E(is_file_t(n), F("Path %s cannot be added, as there is a directory in the way\n") % sp); @@ -1046,7 +1046,7 @@ 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(); + for (parent_roster_map::const_iterator i = parent_rosters.begin(); i != parent_rosters.end(); ++i) { shared_ptr parent_roster = i->second.first; @@ -1080,7 +1080,7 @@ if (not_dead_yet(n, birth_rev, parent_rosters, ancestry)) { - for (parent_roster_map::const_iterator j = parent_rosters.begin(); + for (parent_roster_map::const_iterator j = parent_rosters.begin(); j != parent_rosters.end(); ++j) { shared_ptr parent_roster = j->second.first; @@ -1111,19 +1111,19 @@ { child_roster.replace_node_id(cn->self, n); break; - } + } } } } } } -struct +struct current_rev_debugger { u64 node; anc_graph const & agraph; - current_rev_debugger(u64 n, anc_graph const & ag) + current_rev_debugger(u64 n, anc_graph const & ag) : node(n), agraph(ag) { } @@ -1145,7 +1145,7 @@ } -void +void anc_graph::construct_revisions_from_ancestry() { // This is an incredibly cheesy, and also reasonably simple sorting @@ -1177,7 +1177,7 @@ { all.insert(i->first); } - + set_difference(all.begin(), all.end(), children.begin(), children.end(), back_inserter(work)); @@ -1185,7 +1185,7 @@ while (!work.empty()) { - + u64 child = work.front(); current_rev_debugger dbg(child, *this); @@ -1213,10 +1213,10 @@ parents.insert(parent); } - if (parents_all_done + if (parents_all_done && (node_to_new_rev.find(child) == node_to_new_rev.end())) - { - L(FL("processing node %d\n") % child); + { + L(FL("processing node %d") % child); manifest_id old_child_mid; legacy::manifest_map old_child_man; @@ -1229,12 +1229,12 @@ // Load all the parent rosters into a temporary roster map parent_roster_map parent_rosters; MM(parent_rosters); - + for (ci i = parent_range.first; parents_all_done && i != parent_range.second; ++i) { if (i->first != child) continue; - u64 parent = i->second; + u64 parent = i->second; if (parent_rosters.find(parent) == parent_rosters.end()) { shared_ptr ros = shared_ptr(new roster_t()); @@ -1272,7 +1272,7 @@ else insert_into_roster(child_roster, nis, i->first, i->second); } - + // migrate attributes out of .mt-attrs { legacy::manifest_map::const_iterator i = old_child_man.find(attr_path); @@ -1336,7 +1336,7 @@ shared_ptr parent_roster = i->second.first; shared_ptr cs = shared_ptr(new cset()); MM(*cs); - make_cset(*parent_roster, child_roster, *cs); + make_cset(*parent_roster, child_roster, *cs); safe_insert(rev.edges, make_pair(parent_rid, cs)); } @@ -1351,9 +1351,9 @@ shared_ptr parent_roster = shared_ptr(new roster_t()); shared_ptr cs = shared_ptr(new cset()); MM(*cs); - make_cset(*parent_roster, child_roster, *cs); + make_cset(*parent_roster, child_roster, *cs); safe_insert(rev.edges, make_pair (parent_rid, cs)); - + } // Finally, put all this excitement into the database and save @@ -1365,8 +1365,8 @@ new_rev_to_node.insert(make_pair(new_rid, child)); /* - P(F("------------------------------------------------\n")); - P(F("made revision %s with %d edges, manifest id = %s\n") + P(F("------------------------------------------------")); + P(F("made revision %s with %d edges, manifest id = %s") % new_rid % rev.edges.size() % rev.new_manifest); { @@ -1374,29 +1374,29 @@ data dtmp; dump(dbg, rtmp); write_revision_set(rev, dtmp); - P(F("%s\n") % rtmp); - P(F("%s\n") % dtmp); + P(F("%s") % rtmp); + P(F("%s") % dtmp); } - P(F("------------------------------------------------\n")); + P(F("------------------------------------------------")); */ if (!app.db.revision_exists (new_rid)) { - L(FL("mapped node %d to revision %s\n") % child % new_rid); + L(FL("mapped node %d to revision %s") % child % new_rid); app.db.put_revision(new_rid, rev); ++n_revs_out; } else { - L(FL("skipping already existing revision %s\n") % new_rid); + L(FL("skipping already existing revision %s") % new_rid); } - + // Mark this child as done, hooray! safe_insert(done, child); // Extend the work queue with all the children of this child pair grandchild_range = parent_to_child_map.equal_range(child); - for (ci i = grandchild_range.first; + for (ci i = grandchild_range.first; i != grandchild_range.second; ++i) { if (i->first != child) @@ -1408,7 +1408,7 @@ } } -void +void build_roster_style_revs_from_manifest_style_revs(app_state & app) { app.db.ensure_open_for_format_changes(); @@ -1417,7 +1417,7 @@ global_sanity.set_relaxed(true); anc_graph graph(true, app); - P(F("converting existing revision graph to new roster-style revisions\n")); + P(F("converting existing revision graph to new roster-style revisions")); multimap existing_graph; { @@ -1464,7 +1464,7 @@ } -void +void build_changesets_from_manifest_ancestry(app_state & app) { app.db.ensure_open_for_format_changes(); @@ -1472,7 +1472,7 @@ anc_graph graph(false, app); - P(F("rebuilding revision graph from manifest certs\n")); + P(F("rebuilding revision graph from manifest certs")); { // early short-circuit to avoid failure after lots of work @@ -1498,13 +1498,13 @@ u64 child_node = graph.add_node_for_old_manifest(child); graph.add_node_ancestry(child_node, parent_node); } - + graph.rebuild_ancestry(); } // i/o stuff -namespace +namespace { namespace syms { @@ -1514,28 +1514,28 @@ } } -void +void print_edge(basic_io::printer & printer, edge_entry const & e) -{ +{ basic_io::stanza st; st.push_hex_pair(syms::old_revision, edge_old_revision(e).inner()); printer.print_stanza(st); - print_cset(printer, edge_changes(e)); + print_cset(printer, edge_changes(e)); } -void +void print_revision(basic_io::printer & printer, revision_set const & rev) { rev.check_sane(); - basic_io::stanza format_stanza; + basic_io::stanza format_stanza; format_stanza.push_str_pair(syms::format_version, "1"); printer.print_stanza(format_stanza); - basic_io::stanza manifest_stanza; + basic_io::stanza manifest_stanza; manifest_stanza.push_hex_pair(syms::new_manifest, rev.new_manifest.inner()); printer.print_stanza(manifest_stanza); @@ -1545,7 +1545,7 @@ } -void +void parse_edge(basic_io::parser & parser, edge_map & es) { @@ -1554,18 +1554,18 @@ manifest_id old_man; revision_id old_rev; string tmp; - + parser.esym(syms::old_revision); parser.hex(tmp); old_rev = revision_id(tmp); - + parse_cset(parser, *cs); es.insert(make_pair(old_rev, cs)); } -void +void parse_revision(basic_io::parser & parser, revision_set & rev) { @@ -1587,7 +1587,7 @@ rev.check_sane(); } -void +void read_revision_set(data const & dat, revision_set & rev) { @@ -1600,7 +1600,7 @@ rev.check_sane(); } -void +void read_revision_set(revision_data const & dat, revision_set & rev) { @@ -1681,7 +1681,7 @@ I(foo_bar == find_new_path_for(renames, foo_baz)); } -void +void add_revision_tests(test_suite * suite) { I(suite); ============================================================ --- revision.hh f31cef31d418dc6585a24fc61267b9ff47b0cdf5 +++ revision.hh e765cc1218de6df527126268ea5aa8569812e4a0 @@ -47,7 +47,7 @@ typedef edge_map::value_type edge_entry; -struct +struct revision_set { void check_sane() const; @@ -62,38 +62,38 @@ edge_map edges; }; -inline revision_id const & -edge_old_revision(edge_entry const & e) -{ - return e.first; +inline revision_id const & +edge_old_revision(edge_entry const & e) +{ + return e.first; } -inline revision_id const & -edge_old_revision(edge_map::const_iterator i) -{ - return i->first; +inline revision_id const & +edge_old_revision(edge_map::const_iterator i) +{ + return i->first; } -inline cset const & -edge_changes(edge_entry const & e) -{ - return *(e.second); +inline cset const & +edge_changes(edge_entry const & e) +{ + return *(e.second); } -inline cset const & -edge_changes(edge_map::const_iterator i) -{ - return *(i->second); +inline cset const & +edge_changes(edge_map::const_iterator i) +{ + return *(i->second); } template <> void dump(revision_set const & rev, std::string & out); -void +void read_revision_set(data const & dat, revision_set & rev); -void +void read_revision_set(revision_data const & dat, revision_set & rev); @@ -135,7 +135,7 @@ app_state & app); -// FIXME: can probably optimize this passing a lookaside cache of the active +// FIXME: can probably optimize this passing a lookaside cache of the active // frontier set of shared_ptrs, while traversing history. void select_nodes_modified_by_rev(revision_id const & rid, @@ -145,13 +145,13 @@ app_state & app); void -make_revision_set(revision_id const & old_rev_id, +make_revision_set(revision_id const & old_rev_id, roster_t const & old_roster, roster_t const & new_roster, revision_set & rev); /* -void +void calculate_composite_cset(revision_id const & ancestor, revision_id const & child, app_state & app, @@ -165,29 +165,29 @@ */ -void +void build_changesets_from_manifest_ancestry(app_state & app); -void +void build_roster_style_revs_from_manifest_style_revs(app_state & app); // basic_io access to printers and parsers namespace basic_io { struct printer; struct parser; } -void +void print_revision(basic_io::printer & printer, revision_set const & rev); -void +void parse_revision(basic_io::parser & parser, revision_set & rev); -void +void print_edge(basic_io::printer & printer, edge_entry const & e); -void +void parse_edge(basic_io::parser & parser, edge_map & es); ============================================================ --- roster.cc fde433622561c188f726b4b591388c070cc1e391 +++ roster.cc 2bf3101b93e77a6c51c1267d799220a69a2f5a9d @@ -107,7 +107,7 @@ out = oss.str(); } -namespace +namespace { // // We have a few concepts of "nullness" here: @@ -117,7 +117,7 @@ // is detached. // // - the_null_component is a path_component. It is the *name* of the root - // node. Its string representation is "", the empty string. + // node. Its string representation is "", the empty string. // // - The split_path corresponding to the_null_node is [], the empty vector. // @@ -132,7 +132,7 @@ // We do this in order to support the notion of moving the root directory // around, or applying attributes to the root directory (though we will // not support moving the root at this time, since we haven't worked out - // all the UI implications yet). + // all the UI implications yet). // @@ -146,7 +146,7 @@ node::node(node_id i) - : self(i), + : self(i), parent(the_null_node), name(the_null_component) { @@ -155,7 +155,7 @@ node::node() : self(the_null_node), - parent(the_null_node), + parent(the_null_node), name(the_null_component) { } @@ -179,14 +179,14 @@ return children.find(pc) != children.end(); } -node_t +node_t dir_node::get_child(path_component const & pc) const { return safe_get(children, pc); } - -void + +void dir_node::attach_child(path_component const & pc, node_t child) { I(null_node(child->parent)); @@ -197,7 +197,7 @@ } -node_t +node_t dir_node::detach_child(path_component const & pc) { node_t n = get_child(pc); @@ -314,14 +314,14 @@ struct dfs_iter { - + dir_t root; bool return_root; stack< pair > stk; split_path dirname; - dfs_iter(dir_t r) + dfs_iter(dir_t r) : root(r), return_root(root) { if (root && !root->children.empty()) @@ -398,12 +398,12 @@ inline bool -shallow_equal(node_t a, node_t b, +shallow_equal(node_t a, node_t b, bool shallow_compare_dir_children) { if (a->self != b->self) return false; - + if (a->parent != b->parent) return false; @@ -421,7 +421,7 @@ file_t fa = downcast_to_file_t(a); file_t fb = downcast_to_file_t(b); if (!(fa->content == fb->content)) - return false; + return false; } else { @@ -432,11 +432,11 @@ { if (da->children.size() != db->children.size()) return false; - - dir_map::const_iterator + + dir_map::const_iterator i = da->children.begin(), - j = db->children.begin(); - + j = db->children.begin(); + while (i != da->children.end() && j != db->children.end()) { if (i->first != j->first) @@ -456,10 +456,10 @@ // FIXME_ROSTERS: why does this do two loops? why does it pass 'true' to // shallow_equal? // -- njs -bool +bool roster_t::operator==(roster_t const & other) const { - node_map::const_iterator i = nodes.begin(), j = other.nodes.begin(); + node_map::const_iterator i = nodes.begin(), j = other.nodes.begin(); while (i != nodes.end() && j != other.nodes.end()) { if (i->first != j->first) @@ -507,7 +507,7 @@ return root_dir; } - dir_t d = root_dir; + dir_t d = root_dir; for (split_path::const_iterator i = dirname.begin()+1; i != dirname.end(); ++i) d = downcast_to_dir_t(d->get_child(*i)); return d->get_child(basename); @@ -541,8 +541,8 @@ // If we have no root, we *definitely* don't have a non-root path if (!has_root()) return false; - - dir_t d = root_dir; + + dir_t d = root_dir; for (split_path::const_iterator i = dirname.begin()+1; i != dirname.end(); ++i) { if (d->children.find(*i) == d->children.end()) @@ -576,7 +576,7 @@ } -void +void roster_t::replace_node_id(node_id from, node_id to) { I(!null_node(from)); @@ -585,7 +585,7 @@ safe_erase(nodes, from); safe_insert(nodes, make_pair(to, n)); n->self = to; - + if (is_dir_t(n)) { dir_t d = downcast_to_dir_t(n); @@ -708,7 +708,7 @@ roster_t::attach_node(node_id nid, node_id parent, path_component name) { node_t n = get_node(nid); - + I(!null_node(n->self)); // ensure the node is already detached (as best one can) I(null_node(n->parent)); @@ -735,7 +735,7 @@ parent_n->attach_child(name, n); I(i == old_locations.end() || i->second != make_pair(n->parent, n->name)); } - + if (i != old_locations.end()) old_locations.erase(i); } @@ -846,7 +846,7 @@ } I(has_root()); - size_t maxdepth = nodes.size(); + size_t maxdepth = nodes.size(); for (dfs_iter i(root_dir); !i.finished(); ++i) { I(*i == get_node((*i)->self)); @@ -893,11 +893,11 @@ } -temp_node_id_source::temp_node_id_source() - : curr(first_temp_node) +temp_node_id_source::temp_node_id_source() + : curr(first_temp_node) {} -node_id +node_id temp_node_id_source::next() { node_id n = curr++; @@ -909,39 +909,39 @@ : r(r), nis(nis) {} -node_id +node_id editable_roster_base::detach_node(split_path const & src) { - // L(FL("detach_node('%s')") % file_path(src)); + // L(FL("detach_node('%s')") % file_path(src)); return r.detach_node(src); } -void +void editable_roster_base::drop_detached_node(node_id nid) { - // L(FL("drop_detached_node(%d)") % nid); + // L(FL("drop_detached_node(%d)") % nid); r.drop_detached_node(nid); } -node_id +node_id editable_roster_base::create_dir_node() { - // L(FL("create_dir_node()\n")); + // L(FL("create_dir_node()")); node_id n = r.create_dir_node(nis); - // L(FL("create_dir_node() -> %d\n") % n); + // L(FL("create_dir_node() -> %d") % n); return n; } -node_id +node_id editable_roster_base::create_file_node(file_id const & content) { - // L(FL("create_file_node('%s')\n") % content); + // L(FL("create_file_node('%s')") % content); node_id n = r.create_file_node(content, nis); - // L(FL("create_file_node('%s') -> %d\n") % content % n); + // L(FL("create_file_node('%s') -> %d") % content % n); return n; } -void +void editable_roster_base::attach_node(node_id nid, split_path const & dst) { // L(FL("attach_node(%d, '%s')") % nid % file_path(dst)); @@ -950,16 +950,16 @@ r.attach_node(nid, dst); } -void -editable_roster_base::apply_delta(split_path const & pth, - file_id const & old_id, +void +editable_roster_base::apply_delta(split_path const & pth, + file_id const & old_id, file_id const & new_id) { // L(FL("clear_attr('%s', '%s', '%s')") % file_path(pth) % old_id % new_id); r.apply_delta(pth, old_id, new_id); } -void +void editable_roster_base::clear_attr(split_path const & pth, attr_key const & name) { @@ -967,7 +967,7 @@ r.clear_attr(pth, name); } -void +void editable_roster_base::set_attr(split_path const & pth, attr_key const & name, attr_value const & val) @@ -981,9 +981,9 @@ { } -namespace +namespace { - struct true_node_id_source + struct true_node_id_source : public node_id_source { true_node_id_source(app_state & app) : app(app) {} @@ -997,7 +997,7 @@ }; - class editable_roster_for_merge + class editable_roster_for_merge : public editable_roster_base { public: @@ -1206,7 +1206,7 @@ set & new_marks) { I(new_marks.empty()); - + // let's not depend on T::operator!= being defined, only on T::operator== // being defined. bool diff_from_left = !(new_val == left_val); @@ -1376,13 +1376,13 @@ mark_unmerged_scalar(safe_get(left_marking.attrs, key), li->second, new_rid, i->second, new_marks); - + else if (li == ln->attrs.end() && ri != rn->attrs.end()) // only the right side has seen this attr before mark_unmerged_scalar(safe_get(right_marking.attrs, key), ri->second, new_rid, i->second, new_marks); - + else // both sides have seen this attr before mark_merged_scalar(safe_get(left_marking.attrs, key), @@ -1419,7 +1419,7 @@ marking_map const & right_markings, set const & right_uncommon_ancestors, revision_id const & new_rid, - roster_t const & merge, + roster_t const & merge, marking_map & new_markings) { for (node_map::const_iterator i = merge.all_nodes().begin(); @@ -1472,10 +1472,10 @@ safe_insert(new_markings, make_pair(i->first, new_marking)); } - } - - - class editable_roster_for_nonmerge + } + + + class editable_roster_for_nonmerge : public editable_roster_base { public: @@ -1555,12 +1555,12 @@ marking->second.attrs.insert(make_pair(name, set())); am = marking->second.attrs.find(name); } - + I(am != marking->second.attrs.end()); am->second.clear(); am->second.insert(rid); } - + private: revision_id const & rid; // markings starts out as the parent's markings @@ -1623,7 +1623,7 @@ nis); I(new_roster == from_right_r); } - + // SPEEDUP?: instead of constructing new marking from scratch, track which // nodes were modified, and scan only them // load one of the parent markings directly into the new marking map @@ -1745,8 +1745,8 @@ namespace { - - void delta_only_in_from(roster_t const & from, + + void delta_only_in_from(roster_t const & from, node_id nid, node_t n, cset & cs) { @@ -1770,7 +1770,7 @@ { safe_insert(cs.dirs_added, sp); } - for (full_attr_map_t::const_iterator i = n->attrs.begin(); + for (full_attr_map_t::const_iterator i = n->attrs.begin(); i != n->attrs.end(); ++i) if (i->second.first) safe_insert(cs.attrs_set, @@ -1831,13 +1831,13 @@ i.right_data().second)); } else if (i.state() == parallel::in_both - && i.right_data().first + && i.right_data().first && i.left_data().first && i.right_data().second != i.left_data().second) { safe_insert(cs.attrs_set, make_pair(make_pair(to_sp, i.right_key()), - i.right_data().second)); + i.right_data().second)); } } } @@ -1861,7 +1861,7 @@ // deleted delta_only_in_from(from, i.left_key(), i.left_data(), cs); break; - + case parallel::in_right: // added delta_only_in_to(to, i.right_key(), i.right_data(), cs); @@ -1883,7 +1883,7 @@ { if (a.all_nodes().size() != b.all_nodes().size()) return false; - + for (node_map::const_iterator i = a.all_nodes().begin(); i != a.all_nodes().end(); ++i) { @@ -1918,7 +1918,7 @@ included.clear(); excluded.clear(); - L(FL("building restricted csets\n")); + L(FL("building restricted csets")); parallel::iter i(from.all_nodes(), to.all_nodes()); while (i.next()) { @@ -1933,26 +1933,26 @@ if (mask.includes(from, i.left_key())) { delta_only_in_from(from, i.left_key(), i.left_data(), included); - L(FL("included left %d\n") % i.left_key()); + L(FL("included left %d") % i.left_key()); } else { delta_only_in_from(from, i.left_key(), i.left_data(), excluded); - L(FL("excluded left %d\n") % i.left_key()); + L(FL("excluded left %d") % i.left_key()); } break; - + case parallel::in_right: // added if (mask.includes(to, i.right_key())) { delta_only_in_to(to, i.right_key(), i.right_data(), included); - L(FL("included right %d\n") % i.right_key()); + L(FL("included right %d") % i.right_key()); } else { delta_only_in_to(to, i.right_key(), i.right_data(), excluded); - L(FL("excluded right %d\n") % i.right_key()); + L(FL("excluded right %d") % i.right_key()); } break; @@ -1961,12 +1961,12 @@ if (mask.includes(from, i.left_key()) || mask.includes(to, i.right_key())) { delta_in_both(i.left_key(), from, i.left_data(), to, i.right_data(), included); - L(FL("in both %d %d\n") % i.left_key() % i.right_key()); + L(FL("in both %d %d") % i.left_key() % i.right_key()); } else { delta_in_both(i.left_key(), from, i.left_data(), to, i.right_data(), excluded); - L(FL("in both %d %d\n") % i.left_key() % i.right_key()); + L(FL("in both %d %d") % i.left_key() % i.right_key()); } break; } @@ -2012,7 +2012,7 @@ } } - N(missing == 0, F("invalid restriction excludes required directories")); + N(missing == 0, F("invalid restriction excludes required directories")); } @@ -2030,16 +2030,16 @@ // Pre-state damage - copy(cs.nodes_deleted.begin(), cs.nodes_deleted.end(), + copy(cs.nodes_deleted.begin(), cs.nodes_deleted.end(), inserter(modified_prestate_nodes, modified_prestate_nodes.begin())); - + for (map::const_iterator i = cs.nodes_renamed.begin(); i != cs.nodes_renamed.end(); ++i) modified_prestate_nodes.insert(i->first); // Post-state damage - copy(cs.dirs_added.begin(), cs.dirs_added.end(), + copy(cs.dirs_added.begin(), cs.dirs_added.end(), inserter(modified_poststate_nodes, modified_poststate_nodes.begin())); for (map::const_iterator i = cs.files_added.begin(); @@ -2081,15 +2081,15 @@ } //////////////////////////////////////////////////////////////////// -// getting rosters from the workspace +// getting rosters from the workspace //////////////////////////////////////////////////////////////////// -// TODO: doesn't that mean they should go in work.cc ? +// TODO: doesn't that mean they should go in work.cc ? // perhaps do that after propagating back to n.v.m.experiment.rosters // or to mainline so that diffs are more informative inline static bool -inodeprint_unchanged(inodeprint_map const & ipm, file_path const & path) +inodeprint_unchanged(inodeprint_map const & ipm, file_path const & path) { inodeprint_map::const_iterator old_ip = ipm.find(path); if (old_ip != ipm.end()) @@ -2110,7 +2110,7 @@ // automate_inventory which operates on the entire, unrestricted, working // directory. -void +void classify_roster_paths(roster_t const & ros, path_set & unchanged, path_set & changed, @@ -2149,7 +2149,7 @@ // dirs don't have content changes unchanged.insert(sp); } - else + else { file_t file = downcast_to_file_t(node); file_id fid; @@ -2168,8 +2168,8 @@ } } -void -update_current_roster_from_filesystem(roster_t & ros, +void +update_current_roster_from_filesystem(roster_t & ros, restriction const & mask, app_state & app) { @@ -2222,7 +2222,7 @@ } } - N(missing_files == 0, + N(missing_files == 0, F("%d missing files; use '%s ls missing' to view\n" "to restore consistency, on each missing file run either\n" "'%s drop FILE' to remove it permanently, or\n" @@ -2232,8 +2232,8 @@ % missing_files % app.prog_name % app.prog_name % app.prog_name); } -void -update_current_roster_from_filesystem(roster_t & ros, +void +update_current_roster_from_filesystem(roster_t & ros, app_state & app) { restriction tmp(app); @@ -2275,7 +2275,7 @@ symbol const file("file"); symbol const content("content"); symbol const attr("attr"); - + // 'local' roster and marking symbols symbol const ident("ident"); symbol const birth("birth"); @@ -2309,7 +2309,7 @@ } else I(mark.file_content.empty()); - + for (full_attr_map_t::const_iterator i = curr->attrs.begin(); i != curr->attrs.end(); ++i) { @@ -2323,8 +2323,8 @@ void -parse_marking(basic_io::parser & pa, - node_t n, +parse_marking(basic_io::parser & pa, + node_t n, marking_t & marking) { while (pa.symp()) @@ -2367,7 +2367,7 @@ // consider replacing the roster disk format with something that can be // processed more efficiently. -void +void roster_t::print_to(basic_io::printer & pr, marking_map const & mm, bool print_local_parts) const @@ -2389,7 +2389,7 @@ basic_io::stanza st; if (is_dir_t(curr)) { - // L(FL("printing dir %s\n") % fp); + // L(FL("printing dir %s") % fp); st.push_file_pair(syms::dir, fp); } else @@ -2397,7 +2397,7 @@ file_t ftmp = downcast_to_file_t(curr); st.push_file_pair(syms::file, fp); st.push_hex_pair(syms::content, ftmp->content.inner()); - // L(FL("printing file %s\n") % fp); + // L(FL("printing file %s") % fp); } if (print_local_parts) @@ -2413,7 +2413,7 @@ if (j->second.first) { I(!j->second.second().empty()); - // L(FL("printing attr %s : %s = %s\n") % fp % j->first % j->second); + // L(FL("printing attr %s : %s = %s") % fp % j->first % j->second); st.push_str_triple(syms::attr, j->first(), j->second.second()); } } @@ -2454,7 +2454,7 @@ return n; } -void +void roster_t::parse_from(basic_io::parser & pa, marking_map & mm) { @@ -2473,7 +2473,7 @@ nodes.clear(); root_dir.reset(); mm.clear(); - + { pa.esym(syms::format_version); string vers; @@ -2506,7 +2506,7 @@ pa.str(ident); n = dir_t(new dir_node(read_num(ident))); } - else + else break; I(static_cast(n)); @@ -2554,7 +2554,7 @@ } -void +void read_roster_and_marking(roster_data const & dat, roster_t & ros, marking_map & mm) @@ -2598,7 +2598,7 @@ roster_data & dat) { marking_map mm; - write_roster_and_marking(ros, mm, dat, false); + write_roster_and_marking(ros, mm, dat, false); } void calculate_ident(roster_t const & ros, @@ -2730,7 +2730,7 @@ roster_t original = r; MM(original); I(original == r); - + editable_roster_base e(r, nis); cs.apply_to(e); @@ -2803,7 +2803,7 @@ } template -typename M::const_iterator +typename M::const_iterator random_element(M const & m) { size_t i = rand() % m.size(); @@ -2811,7 +2811,7 @@ while (i > 0) { I(j != m.end()); - --i; + --i; ++j; } return j; @@ -2870,10 +2870,10 @@ if (p.size() <= c.size()) { - split_path::const_iterator c_anchor = + split_path::const_iterator c_anchor = search(c.begin(), c.end(), p.begin(), p.end()); - + is_parent = (c_anchor == c.begin()); } @@ -2881,8 +2881,8 @@ // % file_path(p) // % (is_parent ? "" : " not") // % file_path(c)); - - return is_parent; + + return is_parent; } struct @@ -2911,7 +2911,7 @@ node_t n = random_element(r.all_nodes())->second; split_path pth; r.get_name(n->self, pth); - // L(FL("considering acting on '%s'\n") % file_path(pth)); + // L(FL("considering acting on '%s'") % file_path(pth)); switch (rand() % 7) { @@ -2922,19 +2922,19 @@ if (is_file_t(n) || (pth.size() > 1 && flip())) // Add a sibling of an existing entry. pth[pth.size() - 1] = new_component(); - - else + + else // Add a child of an existing entry. pth.push_back(new_component()); - + if (flip()) { - // L(FL("adding dir '%s'\n") % file_path(pth)); + // L(FL("adding dir '%s'") % file_path(pth)); safe_insert(c.dirs_added, pth); } else { - // L(FL("adding file '%s'\n") % file_path(pth)); + // L(FL("adding file '%s'") % file_path(pth)); safe_insert(c.files_added, make_pair(pth, new_ident())); } break; @@ -2942,7 +2942,7 @@ case 3: if (is_file_t(n)) { - safe_insert(c.deltas_applied, + safe_insert(c.deltas_applied, make_pair (pth, make_pair(downcast_to_file_t(n)->content, new_ident()))); @@ -2957,38 +2957,38 @@ if (n == n2) continue; - + if (is_file_t(n2) || (pth2.size() > 1 && flip())) { - // L(FL("renaming to a sibling of an existing entry '%s'\n") % file_path(pth2)); + // L(FL("renaming to a sibling of an existing entry '%s'") % file_path(pth2)); // Move to a sibling of an existing entry. pth2[pth2.size() - 1] = new_component(); } - + else { - // L(FL("renaming to a child of an existing entry '%s'\n") % file_path(pth2)); + // L(FL("renaming to a child of an existing entry '%s'") % file_path(pth2)); // Move to a child of an existing entry. pth2.push_back(new_component()); } - + if (!parent_of(pth, pth2)) { - // L(FL("renaming '%s' -> '%s\n") % file_path(pth) % file_path(pth2)); + // L(FL("renaming '%s' -> '%s") % file_path(pth) % file_path(pth2)); safe_insert(c.nodes_renamed, make_pair(pth, pth2)); } } break; - + case 5: - if (!null_node(n->parent) && + if (!null_node(n->parent) && (is_file_t(n) || downcast_to_dir_t(n)->children.empty())) { - // L(FL("deleting '%s'\n") % file_path(pth)); + // L(FL("deleting '%s'") % file_path(pth)); safe_insert(c.nodes_deleted, pth); } break; - + case 6: if (!n->attrs.empty() && flip()) { @@ -2997,7 +2997,7 @@ { if (flip()) { - // L(FL("clearing attr on '%s'\n") % file_path(pth)); + // L(FL("clearing attr on '%s'") % file_path(pth)); safe_insert(c.attrs_cleared, make_pair(pth, k)); } else @@ -3008,16 +3008,16 @@ } else { - // L(FL("setting previously set attr on '%s'\n") % file_path(pth)); + // L(FL("setting previously set attr on '%s'") % file_path(pth)); safe_insert(c.attrs_set, make_pair(make_pair(pth, k), new_word())); } } else { - // L(FL("setting attr on '%s'\n") % file_path(pth)); + // L(FL("setting attr on '%s'") % file_path(pth)); safe_insert(c.attrs_set, make_pair(make_pair(pth, new_word()), new_word())); } - break; + break; } } } @@ -3033,7 +3033,7 @@ node_id testing_node_id_source::next() { - // L(FL("creating node %x\n") % curr); + // L(FL("creating node %x") % curr); node_id n = curr++; I(!temp_node(n)); return n; @@ -3058,7 +3058,7 @@ { MM(i); if (i % 100 == 0) - P(F("performing random action %d\n") % i); + P(F("performing random action %d") % i); // test operator== I(r == r); aut.perform_random_action(r, nis); @@ -3096,7 +3096,7 @@ testing_node_id_source nis; roster_t r; MM(r); - + // roster must have a root dir MAYBE(BOOST_CHECK_THROW(r.check_sane(false), logic_error)); MAYBE(BOOST_CHECK_THROW(r.check_sane(true), logic_error)); @@ -3244,7 +3244,7 @@ // a a a a a b a b // \ / \ / \ / \ / // a b* c* a? -// +// // Each node has a number of scalars associated with it: // * basename+parent // * file content (iff a file) @@ -3270,7 +3270,7 @@ // And one parent: // * in any of the cases above with one node parent and the attr pre-existing // * in a 2-parent node where the attr exists in only one of the parents -// +// // Plus, just to be sure, in the merge cases we check both the given example // and the mirror-reversed one, since the code implementing this could // conceivably mark merge(A, B) right but get merge(B, A) wrong. And for the @@ -3418,7 +3418,7 @@ safe_insert(markings, make_pair(nid, marking)); } }; - + struct dir_maker { static void make_obj(revision_id const & scalar_origin_rid, node_id nid, @@ -3431,11 +3431,11 @@ safe_insert(markings, make_pair(nid, marking)); } }; - + struct file_content_scalar : public a_scalar { virtual string my_type() const { return "file_content_scalar"; } - + map values; file_content_scalar(node_id_source & nis) : a_scalar(nis) @@ -3578,7 +3578,7 @@ roster.check_sane_against(markings); } }; - + // this scalar represents an attr whose node does not exist; we create the // node when we create the attr. template @@ -3652,7 +3652,7 @@ roster_t empty_roster; cset cs; MM(cs); make_cset(empty_roster, expected_roster, cs); - + roster_t new_roster; MM(new_roster); marking_map new_markings; MM(new_markings); // this function takes the old parent roster/marking and modifies them; in @@ -3689,7 +3689,7 @@ cset cs; MM(cs); make_cset(parent_roster, expected_roster, cs); - + roster_t new_roster; MM(new_roster); marking_map new_markings; MM(new_markings); new_roster = parent_roster; @@ -4058,7 +4058,7 @@ // + + // \ / // a* -// +// // a* + // \ / // a @@ -4070,7 +4070,7 @@ // . . // \ / // a* -// +// // a* . // \ / // a @@ -4300,7 +4300,7 @@ new_rid, new_roster, new_markings, nis), logic_error); - + } @@ -4367,12 +4367,12 @@ r.clear_attr(foo_zoo, attr_key("regime")); mark_new_node(rid, r.get_node(nid), mm[nid]); - { + { // manifest first roster_data mdat; MM(mdat); write_manifest_of_roster(r, mdat); - roster_data + roster_data expected(string("format_version \"1\"\n" "\n" "dir \"\"\n" @@ -4397,14 +4397,14 @@ BOOST_CHECK_NOT_THROW( I(expected == mdat), logic_error); } - { + { // full roster with local parts roster_data rdat; MM(rdat); write_roster_and_marking(r, mm, rdat); // node_id order is a hassle. // root 1, foo 2, xx 3, fo 4, foo_bar 5, foo_ang 6, foo_zoo 7 - roster_data + roster_data expected(string("format_version \"1\"\n" "\n" " dir \"\"\n" @@ -4693,7 +4693,7 @@ left_nid = left_er.create_file_node(fid); right_nid = right_er.create_file_node(fid); } - + left_new_nodes.insert(left_nid); right_new_nodes.insert(right_nid); @@ -4704,14 +4704,14 @@ if (is_file_t(left_n) || (pth.size() > 1 && flip())) // Add a sibling of an existing entry. - pth[pth.size() - 1] = new_component(); - else + pth[pth.size() - 1] = new_component(); + else // Add a child of an existing entry. pth.push_back(new_component()); - + left_er.attach_node(left_nid, pth); right_er.attach_node(right_nid, pth); - } + } } static void @@ -4719,7 +4719,7 @@ { L(FL("TEST: begin checking unification of rosters (randomly)")); temp_node_id_source tmp_nis; - testing_node_id_source test_nis; + testing_node_id_source test_nis; roster_t left, right; for (size_t i = 0; i < 30; ++i) { @@ -4768,7 +4768,7 @@ cset add_cs; MM(add_cs); safe_insert(add_cs.files_added, make_pair(split("foo"), my_fid)); cset no_add_cs; MM(no_add_cs); - + // added in left, then merged { roster_t new_roster; MM(new_roster); @@ -4857,7 +4857,7 @@ safe_insert(second_markings, make_pair(second_roster.get_node(split("bar"))->self, marking)); } - + // put in the attrs on foo { safe_insert(first_roster.get_node(foo_id)->attrs, @@ -4869,11 +4869,11 @@ safe_insert(second_markings.find(foo_id)->second.attrs, make_pair(attr_key("testfoo2"), singleton(second_rid))); } - + cset add_cs; MM(add_cs); safe_insert(add_cs.files_added, make_pair(split("bar"), my_fid)); cset no_add_cs; MM(no_add_cs); - + { roster_t new_roster; MM(new_roster); marking_map new_markings; MM(new_markings); ============================================================ --- roster.hh 5ff1e7a09081ccdf029648256e717075140eba34 +++ roster.hh 0dcd64e317aa7842ea2529178f98782569c060c5 @@ -34,7 +34,7 @@ node_id const the_null_node = 0; -inline bool +inline bool null_node(node_id n) { return n == the_null_node; @@ -56,8 +56,8 @@ node(); node(node_id i); node_id self; - node_id parent; // the_null_node iff this is a root dir - path_component name; // the_null_component iff this is a root dir + node_id parent; // the_null_node iff this is a root dir + path_component name; // the_null_component iff this is a root dir full_attr_map_t attrs; // need a virtual function to make dynamic_cast work @@ -110,7 +110,7 @@ } inline bool -is_root_dir_t(node_t n) +is_root_dir_t(node_t n) { if (is_dir_t(n) && null_name(n->name)) { @@ -194,8 +194,8 @@ void insert_node(node_t n); void attach_node(node_id nid, split_path const & dst); void attach_node(node_id nid, node_id parent, path_component name); - void apply_delta(split_path const & pth, - file_id const & old_id, + void apply_delta(split_path const & pth, + file_id const & old_id, file_id const & new_id); void clear_attr(split_path const & pth, attr_key const & name); @@ -252,7 +252,7 @@ // conservative --- perhaps it will turn out that it is _too_ conservative // and causes problems, in which case we should probably switch to the // former. - // + // // FIXME: This _is_ all a little nasty, because this can be a source of // abstraction leak -- for instance, roster_merge's contract is that nodes // involved in name-related will be detached in the roster it returns. @@ -284,7 +284,7 @@ template friend void dump(T const & val, std::string & out); }; -struct temp_node_id_source +struct temp_node_id_source : public node_id_source { temp_node_id_source(); @@ -298,7 +298,7 @@ struct revision_set; // adaptor class to enable cset application on rosters. -class editable_roster_base +class editable_roster_base : public editable_tree { public: @@ -308,8 +308,8 @@ virtual node_id create_dir_node(); virtual node_id create_file_node(file_id const & content); virtual void attach_node(node_id nid, split_path const & dst); - virtual void apply_delta(split_path const & pth, - file_id const & old_id, + virtual void apply_delta(split_path const & pth, + file_id const & old_id, file_id const & new_id); virtual void clear_attr(split_path const & pth, attr_key const & name); @@ -324,8 +324,8 @@ void -make_cset(roster_t const & from, - roster_t const & to, +make_cset(roster_t const & from, + roster_t const & to, cset & cs); bool @@ -336,7 +336,7 @@ // various (circular?) dependencies prevent inclusion of restrictions.hh class restriction; -void +void make_restricted_csets(roster_t const & from, roster_t const & to, cset & included, cset & excluded, restriction const & mask); @@ -350,43 +350,43 @@ roster_t const & new_roster, std::set & nodes_modified); -void +void classify_roster_paths(roster_t const & ros, path_set & unchanged, path_set & changed, path_set & missing, app_state & app); -void -update_current_roster_from_filesystem(roster_t & ros, +void +update_current_roster_from_filesystem(roster_t & ros, restriction const & mask, app_state & app); -void -update_current_roster_from_filesystem(roster_t & ros, +void +update_current_roster_from_filesystem(roster_t & ros, app_state & app); void -extract_roster_path_set(roster_t const & ros, +extract_roster_path_set(roster_t const & ros, path_set & paths); void -make_roster_for_base_plus_cset(revision_id const & base, +make_roster_for_base_plus_cset(revision_id const & base, cset const & cs, revision_id const & new_rid, - roster_t & result, + roster_t & result, marking_map & marking, node_id_source & nis, app_state & app); -void -make_roster_for_revision(revision_set const & rev, +void +make_roster_for_revision(revision_set const & rev, revision_id const & rid, - roster_t & result, + roster_t & result, marking_map & marking, app_state & app); -void +void read_roster_and_marking(roster_data const & dat, roster_t & ros, marking_map & mm); @@ -406,7 +406,7 @@ #ifdef BUILD_UNIT_TESTS -struct testing_node_id_source +struct testing_node_id_source : public node_id_source { testing_node_id_source(); ============================================================ --- roster_merge.cc ff845578375e028041eb8731d2f870ebfcad9eeb +++ roster_merge.cc 08c28631640c674a9f6da7b5915786ee6afe27fc @@ -47,25 +47,25 @@ % result.rename_target_conflicts.size() % result.directory_loop_conflicts.size()) .str(); - + for (size_t i = 0; i < result.node_name_conflicts.size(); ++i) - out += (FL("name conflict on node %d: [parent %d, self %s] vs. [parent %d, self %s]\n") - % result.node_name_conflicts[i].nid - % result.node_name_conflicts[i].left.first + out += (FL("name conflict on node %d: [parent %d, self %s] vs. [parent %d, self %s]") + % result.node_name_conflicts[i].nid + % result.node_name_conflicts[i].left.first % result.node_name_conflicts[i].left.second - % result.node_name_conflicts[i].right.first + % result.node_name_conflicts[i].right.first % result.node_name_conflicts[i].right.second) .str(); - + for (size_t i = 0; i < result.file_content_conflicts.size(); ++i) - out += (FL("content conflict on node %d: [%s] vs. [%s]\n") + out += (FL("content conflict on node %d: [%s] vs. [%s]") % result.file_content_conflicts[i].nid % result.file_content_conflicts[i].left % result.file_content_conflicts[i].right) .str(); - + for (size_t i = 0; i < result.node_attr_conflicts.size(); ++i) - out += (FL("attribute conflict on node %d, key %s: [%d, %s] vs. [%d, %s]\n") + out += (FL("attribute conflict on node %d, key %s: [%d, %s] vs. [%d, %s]") % result.node_attr_conflicts[i].nid % result.node_attr_conflicts[i].key % result.node_attr_conflicts[i].left.first @@ -73,14 +73,14 @@ % result.node_attr_conflicts[i].right.first % result.node_attr_conflicts[i].right.second) .str(); - + for (size_t i = 0; i < result.orphaned_node_conflicts.size(); ++i) out += (FL("orphaned node conflict on node %d, dead parent %d, name %s") % result.orphaned_node_conflicts[i].nid % result.orphaned_node_conflicts[i].parent_name.first % result.orphaned_node_conflicts[i].parent_name.second) .str(); - + for (size_t i = 0; i < result.rename_target_conflicts.size(); ++i) out += (FL("rename target conflict: nodes %d, %d, both want parent %d, name %s") % result.rename_target_conflicts[i].nid1 @@ -88,7 +88,7 @@ % result.rename_target_conflicts[i].parent_name.first % result.rename_target_conflicts[i].parent_name.second) .str(); - + for (size_t i = 0; i < result.directory_loop_conflicts.size(); ++i) out += (FL("directory loop conflict: node %d, wanted parent %d, name %s") % result.directory_loop_conflicts[i].nid @@ -126,35 +126,35 @@ roster_merge_result::warn_non_content_conflicts() const { for (size_t i = 0; i < node_name_conflicts.size(); ++i) - W(F("name conflict on node %d: [parent %d, self %s] vs. [parent %d, self %s]\n") - % node_name_conflicts[i].nid - % node_name_conflicts[i].left.first + W(F("name conflict on node %d: [parent %d, self %s] vs. [parent %d, self %s]") + % node_name_conflicts[i].nid + % node_name_conflicts[i].left.first % node_name_conflicts[i].left.second - % node_name_conflicts[i].right.first + % node_name_conflicts[i].right.first % node_name_conflicts[i].right.second); - + for (size_t i = 0; i < node_attr_conflicts.size(); ++i) - W(F("attribute conflict on node %d, key %s: [%d, %s] vs. [%d, %s]\n") + W(F("attribute conflict on node %d, key %s: [%d, %s] vs. [%d, %s]") % node_attr_conflicts[i].nid % node_attr_conflicts[i].key % node_attr_conflicts[i].left.first % node_attr_conflicts[i].left.second % node_attr_conflicts[i].right.first % node_attr_conflicts[i].right.second); - + for (size_t i = 0; i < orphaned_node_conflicts.size(); ++i) W(F("orphaned node conflict on node %d, dead parent %d, name %s") % orphaned_node_conflicts[i].nid % orphaned_node_conflicts[i].parent_name.first % orphaned_node_conflicts[i].parent_name.second); - + for (size_t i = 0; i < rename_target_conflicts.size(); ++i) W(F("rename target conflict: nodes %d, %d, both want parent %d, name %s") % rename_target_conflicts[i].nid1 % rename_target_conflicts[i].nid2 % rename_target_conflicts[i].parent_name.first % rename_target_conflicts[i].parent_name.second); - + for (size_t i = 0; i < directory_loop_conflicts.size(); ++i) W(F("directory loop conflict: node %d, wanted parent %d, name %s") % directory_loop_conflicts[i].nid @@ -182,7 +182,7 @@ roster = roster_t(); } -namespace +namespace { // a wins if *(b) > a. Which is to say that all members of b_marks are // ancestors of a. But all members of b_marks are ancestors of the @@ -258,7 +258,7 @@ else I(false); } - + inline void insert_if_unborn(node_t const & n, marking_map const & markings, @@ -269,7 +269,7 @@ if (uncommon_ancestors.find(birth) != uncommon_ancestors.end()) create_node_for(n, new_roster); } - + bool would_make_dir_loop(roster_t const & r, node_id nid, node_id parent) { @@ -374,7 +374,7 @@ downcast_to_file_t(n)->content = downcast_to_file_t(old_n)->content; assign_name(result, n->self, old_n->parent, old_n->name); } - + } // end anonymous namespace void @@ -392,7 +392,7 @@ MM(right_parent); MM(right_markings); MM(result); - + // First handle lifecycles, by die-die-die merge -- our result will contain // everything that is alive in both parents, or alive in one and unborn in // the other, exactly. @@ -567,7 +567,7 @@ } break; } - + } } } @@ -612,12 +612,12 @@ // cases for testing: // // (DONE:) -// +// // lifecycle, file and dir // alive in both // alive in one and unborn in other (left vs. right) // alive in one and dead in other (left vs. right) -// +// // mark merge: // same in both, same mark // same in both, diff marks @@ -814,7 +814,7 @@ split_path thing_name; file_scalar() : thing_name(split("thing")) {} - + void make_thing(roster_t & r, marking_map & markings) { @@ -828,7 +828,7 @@ split_path thing_name; dir_scalar() : thing_name(split("thing")) {} - + void make_thing(roster_t & r, marking_map & markings) { @@ -1152,7 +1152,7 @@ test_a_scalar_merge(scalar_b, "4", "4", scalar_a, "23", "35", scalar_conflict); // different, conflict with 2 marks both conflicting - // + // // .1* // / \. // .2 a3* @@ -1435,7 +1435,7 @@ struct simple_dir_loop_conflict : public structural_conflict_helper { node_id left_top_nid, right_top_nid; - + virtual void setup() { left_top_nid = nis.next(); @@ -1466,7 +1466,7 @@ struct simple_orphan_conflict : public structural_conflict_helper { node_id a_dead_parent_nid, a_live_child_nid, b_dead_parent_nid, b_live_child_nid; - + // in ancestor, both parents are alive // in left, a_dead_parent is dead, and b_live_child is created // in right, b_dead_parent is dead, and a_live_child is created @@ -1518,7 +1518,7 @@ struct simple_illegal_name_conflict : public structural_conflict_helper { node_id new_root_nid, bad_dir_nid; - + // in left, new_root is the root (it existed in old, but was renamed in left) // in right, new_root is still a subdir, the old root still exists, and a // new dir has been created @@ -1554,7 +1554,7 @@ struct simple_missing_root_dir : public structural_conflict_helper { node_id other_root_nid; - + // left and right each have different root nodes, and each has deleted the // other's root node @@ -1728,7 +1728,7 @@ { left_root_nid = nis.next(); right_root_nid = nis.next(); - + left_roster.drop_detached_node(left_roster.detach_node(split(""))); safe_erase(left_markings, root_nid); make_dir(left_roster, left_markings, old_rid, left_rid, "", left_root_nid); @@ -1781,7 +1781,7 @@ { left_root_nid = nis.next(); right_root_nid = nis.next(); - + left_roster.drop_detached_node(left_roster.detach_node(split(""))); safe_erase(left_markings, root_nid); make_dir(left_roster, left_markings, left_rid, left_rid, "", left_root_nid); ============================================================ --- roster_merge.hh 6d06c48935d0fb8f0058b3392facca870d8912c7 +++ roster_merge.hh 481dde9bcf40c4ba63e24f36758fece7b0c18b2b @@ -59,7 +59,7 @@ // 'bar', and 'a' and 'b' both being renamed to 'bar'. Only the former // occurs; 'b' merges cleanly and will be named 'bar' in the resulting // manifest.) -// +// // orphaned nodes always merged their name cleanly, so we simply put that name // here. the node in the resulting roster is detached. ============================================================ --- safe_map.hh b41faf022ccd9f384f6a58f58372cec23e9899d4 +++ safe_map.hh 1cf84b0e0943f513d935dc30b5a1f3d0cea63783 @@ -16,7 +16,7 @@ { if (!container.erase(key)) global_sanity.invariant_failure((F("erasing nonexistent key from %s") - % container_name).str(), + % container_name).str(), file, line); } #define safe_erase(CONT, KEY) \ @@ -32,7 +32,7 @@ std::pair r = container.insert(val); if (!r.second) global_sanity.invariant_failure((F("inserting duplicate entry into %s") - % container_name).str(), + % container_name).str(), file, line); return r.first; } @@ -49,7 +49,7 @@ typename T::const_iterator i = container.find(key); if (i == container.end()) global_sanity.invariant_failure((F("fetching nonexistent entry from %s") - % container_name).str(), + % container_name).str(), file, line); return i->second; } ============================================================ --- sanity.cc eb9f4d9b41e1e2342303e4a618fe5481c10c1eae +++ sanity.cc f61b26fbfbb19efc4f9f4f6860d4fafbca57dcb7 @@ -39,19 +39,19 @@ sanity global_sanity; -sanity::sanity() : - debug(false), quiet(false), reallyquiet(false), relaxed(false), logbuf(0xffff), +sanity::sanity() : + debug(false), quiet(false), reallyquiet(false), relaxed(false), logbuf(0xffff), already_dumping(false), clean_shutdown(false) { string flavour; get_system_flavour(flavour); - L(FL("started up on %s\n") % flavour); + L(FL("started up on %s") % flavour); } sanity::~sanity() {} -void +void sanity::dump_buffer() { if (!filename.empty()) @@ -66,14 +66,14 @@ % filename).str()); } else - ui.inform((FL("failed to write debugging log to %s\n") % filename).str()); + ui.inform((FL("failed to write debugging log to %s") % filename).str()); } else ui.inform("discarding debug log, because I have nowhere to write it\n" "(maybe you want --debug or --dump?)"); } -void +void sanity::set_debug() { quiet = false; @@ -82,7 +82,7 @@ // it is possible that some pre-setting-of-debug data // accumulated in the log buffer (during earlier option processing) - // so we will dump it now + // so we will dump it now ostringstream oss; vector lines; copy(logbuf.begin(), logbuf.end(), ostream_iterator(oss)); @@ -97,7 +97,7 @@ brief = true; } -void +void sanity::set_quiet() { debug = false; @@ -105,7 +105,7 @@ reallyquiet = false; } -void +void sanity::set_reallyquiet() { debug = false; @@ -113,7 +113,7 @@ reallyquiet = true; } -void +void sanity::set_relaxed(bool rel) { relaxed = rel; @@ -137,12 +137,12 @@ } -void -sanity::log(plain_format const & fmt, +void +sanity::log(plain_format const & fmt, char const * file, int line) { string str = do_format(fmt, file, line); - + if (str.size() > constants::log_line_sz) { str.resize(constants::log_line_sz); @@ -156,8 +156,8 @@ ui.inform(str); } -void -sanity::progress(i18n_format const & i18nfmt, +void +sanity::progress(i18n_format const & i18nfmt, char const * file, int line) { string str = do_format(i18nfmt, file, line); @@ -175,8 +175,8 @@ ui.inform(str); } -void -sanity::warning(i18n_format const & i18nfmt, +void +sanity::warning(i18n_format const & i18nfmt, char const * file, int line) { string str = do_format(i18nfmt, file, line); @@ -195,31 +195,31 @@ ui.warn(str); } -void -sanity::naughty_failure(string const & expr, i18n_format const & explain, +void +sanity::naughty_failure(string const & expr, i18n_format const & explain, string const & file, int line) { string message; - log(FL("%s:%d: usage constraint '%s' violated\n") % file % line % expr, + log(FL("%s:%d: usage constraint '%s' violated") % file % line % expr, file.c_str(), line); prefix_lines_with(_("misuse: "), do_format(explain, file.c_str(), line), message); gasp(); throw informative_failure(message); } -void -sanity::error_failure(string const & expr, i18n_format const & explain, +void +sanity::error_failure(string const & expr, i18n_format const & explain, string const & file, int line) { string message; - log(FL("%s:%d: detected error '%s' violated\n") % file % line % expr, + log(FL("%s:%d: detected error '%s' violated") % file % line % expr, file.c_str(), line); prefix_lines_with(_("error: "), do_format(explain, file.c_str(), line), message); throw informative_failure(message); } -void -sanity::invariant_failure(string const & expr, +void +sanity::invariant_failure(string const & expr, string const & file, int line) { char const * pattern = N_("%s:%d: invariant '%s' violated"); @@ -228,9 +228,9 @@ throw logic_error((F(pattern) % file % line % expr).str()); } -void -sanity::index_failure(string const & vec_expr, - string const & idx_expr, +void +sanity::index_failure(string const & vec_expr, + string const & idx_expr, unsigned long sz, unsigned long idx, string const & file, int line) @@ -250,7 +250,7 @@ { if (already_dumping) { - L(FL("ignoring request to give last gasp; already in process of dumping\n")); + L(FL("ignoring request to give last gasp; already in process of dumping")); return; } already_dumping = true; @@ -329,7 +329,7 @@ } -struct +struct format_base::impl { format fmt; @@ -348,17 +348,17 @@ return *this; } - impl(char const * pattern) - : fmt(pattern) + impl(char const * pattern) + : fmt(pattern) {} - impl(string const & pattern) - : fmt(pattern) + impl(string const & pattern) + : fmt(pattern) {} - impl(char const * pattern, locale const & loc) - : fmt(pattern, loc) + impl(char const * pattern, locale const & loc) + : fmt(pattern, loc) {} - impl(string const & pattern, locale const & loc) - : fmt(pattern, loc) + impl(string const & pattern, locale const & loc) + : fmt(pattern, loc) {} }; @@ -373,14 +373,14 @@ delete pimpl; } -format_base & +format_base & format_base::operator=(format_base const & other) { if (&other != this) { impl * tmp = NULL; - try + try { if (other.pimpl) tmp = new impl(*(other.pimpl)); @@ -398,52 +398,52 @@ } return *this; } - + format_base::format_base(char const * pattern) : pimpl(new impl(pattern)) {} - + format_base::format_base(std::string const & pattern) : pimpl(new impl(pattern)) {} - + format_base::format_base(char const * pattern, locale const & loc) : pimpl(new impl(pattern, loc)) {} - + format_base::format_base(string const & pattern, locale const & loc) : pimpl(new impl(pattern, loc)) {} - + ostream & format_base::get_stream() { return pimpl->oss; } - -void + +void format_base::flush() { pimpl->fmt % pimpl->oss.str(); pimpl->oss.str(string()); } - -std::string + +std::string format_base::str() const { return pimpl->fmt.str(); } - + i18n_format::i18n_format(const char * localized_pattern) : format_base(localized_pattern, get_user_locale()) { } - + i18n_format::i18n_format(std::string const & localized_pattern) : format_base(localized_pattern, get_user_locale()) { } - + ostream & operator<<(ostream & os, format_base const & fmt) { ============================================================ --- sanity.hh be515df1539fe9df44d44091a19e7d3b22927bdf +++ sanity.hh 675bca26fedbc70535f81d4e3ca66b87527c344e @@ -67,21 +67,21 @@ bool clean_shutdown; std::vector musings; - void log(plain_format const & fmt, + void log(plain_format const & fmt, char const * file, int line); void progress(i18n_format const & fmt, char const * file, int line); - void warning(i18n_format const & fmt, + void warning(i18n_format const & fmt, char const * file, int line); - void naughty_failure(std::string const & expr, i18n_format const & explain, + void naughty_failure(std::string const & expr, i18n_format const & explain, std::string const & file, int line) NORETURN; - void error_failure(std::string const & expr, i18n_format const & explain, + void error_failure(std::string const & expr, i18n_format const & explain, std::string const & file, int line) NORETURN; - void invariant_failure(std::string const & expr, + void invariant_failure(std::string const & expr, std::string const & file, int line) NORETURN; void index_failure(std::string const & vec_expr, std::string const & idx_expr, - unsigned long sz, + unsigned long sz, unsigned long idx, std::string const & file, int line) NORETURN; void gasp(); @@ -96,9 +96,9 @@ extern sanity global_sanity; // This hides boost::format from infecting every source file. Instead, we -// implement a single very small formatter. +// implement a single very small formatter. -class +class format_base { protected: @@ -122,38 +122,38 @@ struct -plain_format +plain_format : public format_base { - plain_format() + plain_format() {} - explicit plain_format(char const * pattern) - : format_base(pattern) + explicit plain_format(char const * pattern) + : format_base(pattern) {} - explicit plain_format(std::string const & pattern) - : format_base(pattern) + explicit plain_format(std::string const & pattern) + : format_base(pattern) {} - template plain_format & operator %(T const & t) + template plain_format & operator %(T const & t) { - get_stream() << t; + get_stream() << t; flush(); return *this; } - template plain_format & operator %(T & t) + template plain_format & operator %(T & t) { get_stream() << t; flush(); - return *this; + return *this; } }; struct -i18n_format +i18n_format : public format_base { i18n_format() {} @@ -243,26 +243,26 @@ // expression, not as a statement. template -inline T & checked_index(std::vector & v, +inline T & checked_index(std::vector & v, typename std::vector::size_type i, char const * vec, char const * index, char const * file, - int line) -{ + int line) +{ if (UNLIKELY(i >= v.size())) global_sanity.index_failure(vec, index, v.size(), i, file, line); return v[i]; } template -inline T const & checked_index(std::vector const & v, +inline T const & checked_index(std::vector const & v, typename std::vector::size_type i, char const * vec, char const * index, char const * file, - int line) -{ + int line) +{ if (UNLIKELY(i >= v.size())) global_sanity.index_failure(vec, index, v.size(), i, file, line); return v[i]; @@ -270,26 +270,26 @@ #ifdef QA_SUPPORTED template -inline T & checked_index(std::vector & v, +inline T & checked_index(std::vector & v, typename std::vector::size_type i, char const * vec, char const * index, char const * file, - int line) -{ + int line) +{ if (UNLIKELY(i >= v.size())) global_sanity.index_failure(vec, index, v.size(), i, file, line); return v[i]; } template -inline T const & checked_index(std::vector const & v, +inline T const & checked_index(std::vector const & v, typename std::vector::size_type i, char const * vec, char const * index, char const * file, - int line) -{ + int line) +{ if (UNLIKELY(i >= v.size())) global_sanity.index_failure(vec, index, v.size(), i, file, line); return v[i]; @@ -383,15 +383,15 @@ #define fake_M(obj, line) real_M(obj, line) #define MM(obj) fake_M(obj, __LINE__) #else -#define MM(obj) /* */ +#define MM(obj) /* */ #endif template <> void dump(std::string const & obj, std::string & out); ////////////////////////////////////////////////////////////////////////// -// Local Variables: -// mode: C++ -// c-file-style: "gnu" +// Local Variables: +// mode: C++ +// c-file-style: "gnu" // indent-tabs-mode: nil // End: // vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s: ============================================================ --- schema_migration.cc 3b14626a3cf5917254ec38dc54edd63b03a2c6f2 +++ schema_migration.cc 692358550bd9c536ef97ae69eb8893daf3dfb880 @@ -63,7 +63,7 @@ typedef boost::tokenizer > tokenizer; -static string +static string lowercase_facet(string const & in) { I(40==in.size()); @@ -75,7 +75,7 @@ return string(buf,sz); } -static void +static void massage_sql_tokens(string const & in, string & out) { @@ -91,7 +91,7 @@ } } -static void +static void calculate_id(string const & in, string & ident) { @@ -102,7 +102,7 @@ } -struct +struct is_ws { bool operator()(char c) const @@ -111,7 +111,7 @@ } }; -static void +static void sqlite_sha1_fn(sqlite3_context *f, int nargs, sqlite3_value ** args) { string tmp, sha; @@ -144,21 +144,21 @@ sqlite3_result_text(f,sha.c_str(),sha.size(),SQLITE_TRANSIENT); } -int -append_sql_stmt(void * vp, - int ncols, +int +append_sql_stmt(void * vp, + int ncols, char ** values, char ** colnames) { if (ncols != 1) return 1; - + if (vp == NULL) return 1; if (values == NULL) return 1; - + if (values[0] == NULL) return 1; @@ -168,12 +168,12 @@ return 0; } -void +void calculate_schema_id(sqlite3 *sql, string & id) { id.clear(); string tmp, tmp2; - int res = logged_sqlite3_exec(sql, + int res = logged_sqlite3_exec(sql, "SELECT sql FROM sqlite_master " "WHERE (type = 'table' OR type = 'index') " // filter out NULL sql statements, because @@ -181,7 +181,7 @@ // UNIQUE constraints, etc.). "AND sql IS NOT NULL " "AND name not like 'sqlite_stat%' " - "ORDER BY name", + "ORDER BY name", &append_sql_stmt, &tmp, NULL); if (res != SQLITE_OK) { @@ -205,7 +205,7 @@ typedef bool (*migrator_cb)(sqlite3 *, char **, app_state *); -struct +struct migrator { vector< pair > migration_events; @@ -275,7 +275,7 @@ } } } - + // confirm that our target schema was met if (migrating) { @@ -308,12 +308,12 @@ // (no vacuum or anything, even), so that automated scripts can fire // one off optimistically and not have to worry about getting their // administrators to do it by hand. - P(F("no migration performed; database schema already up-to-date at %s\n") % init); + P(F("no migration performed; database schema already up-to-date at %s") % init); } } }; -static bool move_table(sqlite3 *sql, char **errmsg, +static bool move_table(sqlite3 *sql, char **errmsg, char const * srcname, char const * dstname, char const * dstschema) @@ -326,7 +326,7 @@ int res = logged_sqlite3_exec(sql, create.c_str(), NULL, NULL, errmsg); if (res != SQLITE_OK) return false; - + string insert = "INSERT INTO "; insert += dstname; insert += " SELECT * FROM "; @@ -342,21 +342,21 @@ res = logged_sqlite3_exec(sql, drop.c_str(), NULL, NULL, errmsg); if (res != SQLITE_OK) return false; - + return true; } -static bool -migrate_client_merge_url_and_group(sqlite3 * sql, +static bool +migrate_client_merge_url_and_group(sqlite3 * sql, char ** errmsg, app_state *) { // migrate the posting_queue table - if (!move_table(sql, errmsg, - "posting_queue", - "tmp", + if (!move_table(sql, errmsg, + "posting_queue", + "tmp", "(" "url not null," "groupname not null," @@ -379,16 +379,16 @@ "FROM tmp", NULL, NULL, errmsg); if (res != SQLITE_OK) return false; - + res = logged_sqlite3_exec(sql, "DROP TABLE tmp", NULL, NULL, errmsg); if (res != SQLITE_OK) return false; // migrate the incoming_queue table - if (!move_table(sql, errmsg, - "incoming_queue", - "tmp", + if (!move_table(sql, errmsg, + "incoming_queue", + "tmp", "(" "url not null," "groupname not null," @@ -418,9 +418,9 @@ // migrate the sequence_numbers table - if (!move_table(sql, errmsg, - "sequence_numbers", - "tmp", + if (!move_table(sql, errmsg, + "sequence_numbers", + "tmp", "(" "url not null," "groupname not null," @@ -430,7 +430,7 @@ ")" )) return false; - + res = logged_sqlite3_exec(sql, "CREATE TABLE sequence_numbers " "(" "url primary key, -- URL to read from\n" @@ -455,9 +455,9 @@ // migrate the netserver_manifests table - if (!move_table(sql, errmsg, - "netserver_manifests", - "tmp", + if (!move_table(sql, errmsg, + "netserver_manifests", + "tmp", "(" "url not null," "groupname not null," @@ -466,7 +466,7 @@ ")" )) return false; - + res = logged_sqlite3_exec(sql, "CREATE TABLE netserver_manifests " "(" "url not null, -- url of some server\n" @@ -487,20 +487,20 @@ res = logged_sqlite3_exec(sql, "DROP TABLE tmp", NULL, NULL, errmsg); if (res != SQLITE_OK) return false; - - return true; + + return true; } -static bool -migrate_client_add_hashes_and_merkle_trees(sqlite3 * sql, +static bool +migrate_client_add_hashes_and_merkle_trees(sqlite3 * sql, char ** errmsg, app_state *) { // add the column to manifest_certs - if (!move_table(sql, errmsg, - "manifest_certs", - "tmp", + if (!move_table(sql, errmsg, + "manifest_certs", + "tmp", "(" "id not null," "name not null," @@ -537,9 +537,9 @@ return false; // add the column to file_certs - if (!move_table(sql, errmsg, - "file_certs", - "tmp", + if (!move_table(sql, errmsg, + "file_certs", + "tmp", "(" "id not null," "name not null," @@ -576,9 +576,9 @@ return false; // add the column to public_keys - if (!move_table(sql, errmsg, - "public_keys", - "tmp", + if (!move_table(sql, errmsg, + "public_keys", + "tmp", "(" "id primary key," "keydata not null" @@ -607,9 +607,9 @@ return false; // add the column to private_keys - if (!move_table(sql, errmsg, - "private_keys", - "tmp", + if (!move_table(sql, errmsg, + "private_keys", + "tmp", "(" "id primary key," "keydata not null" @@ -639,7 +639,7 @@ // add the merkle tree stuff - res = logged_sqlite3_exec(sql, + res = logged_sqlite3_exec(sql, "CREATE TABLE merkle_nodes\n" "(\n" "type not null, -- \"key\", \"mcert\", \"fcert\", \"manifest\"\n" @@ -655,8 +655,8 @@ return true; } -static bool -migrate_client_to_revisions(sqlite3 * sql, +static bool +migrate_client_to_revisions(sqlite3 * sql, char ** errmsg, app_state *) { @@ -690,7 +690,7 @@ if (res != SQLITE_OK) return false; - res = logged_sqlite3_exec(sql, + res = logged_sqlite3_exec(sql, "CREATE TABLE merkle_nodes\n" "(\n" "type not null, -- \"key\", \"mcert\", \"fcert\", \"rcert\"\n" @@ -732,13 +732,13 @@ ")", NULL, NULL, errmsg); if (res != SQLITE_OK) return false; - + return true; } -static bool -migrate_client_to_epochs(sqlite3 * sql, +static bool +migrate_client_to_epochs(sqlite3 * sql, char ** errmsg, app_state *) { @@ -749,7 +749,7 @@ return false; - res = logged_sqlite3_exec(sql, + res = logged_sqlite3_exec(sql, "CREATE TABLE branch_epochs\n" "(\n" "hash not null unique, -- hash of remaining fields separated by \":\"\n" @@ -768,7 +768,7 @@ app_state *) { int res; - + res = logged_sqlite3_exec(sql, "CREATE TABLE db_vars\n" "(\n" @@ -789,7 +789,7 @@ app_state *) { int res; - + res = logged_sqlite3_exec(sql, "CREATE INDEX revision_ancestry__child " "ON revision_ancestry (child)", @@ -879,7 +879,7 @@ app_state *) { int res; - + res = logged_sqlite3_exec(sql, "CREATE TABLE rosters\n" "(\n" @@ -924,7 +924,7 @@ return true; } -static void +static void sqlite3_unbase64_fn(sqlite3_context *f, int nargs, sqlite3_value ** args) { if (nargs != 1) @@ -944,14 +944,14 @@ app_state *app) { int res; - I(sqlite3_create_function(sql, "unbase64", -1, + I(sqlite3_create_function(sql, "unbase64", -1, SQLITE_UTF8, NULL, - &sqlite3_unbase64_fn, + &sqlite3_unbase64_fn, NULL, NULL) == 0); // change the encoding of file(_delta)s - if (!move_table(sql, errmsg, - "files", - "tmp", + if (!move_table(sql, errmsg, + "files", + "tmp", "(" "id primary key," "data not null" @@ -976,9 +976,9 @@ if (res != SQLITE_OK) return false; - if (!move_table(sql, errmsg, - "file_deltas", - "tmp", + if (!move_table(sql, errmsg, + "file_deltas", + "tmp", "(" "id not null," "base not null," @@ -1007,7 +1007,7 @@ return false; // migrate other contents which are accessed by get|put_version - res = logged_sqlite3_exec(sql, "UPDATE manifests SET data=unbase64(data)", + res = logged_sqlite3_exec(sql, "UPDATE manifests SET data=unbase64(data)", NULL, NULL, errmsg); if (res != SQLITE_OK) return false; @@ -1053,13 +1053,13 @@ return true; } -void +void migrate_monotone_schema(sqlite3 *sql, app_state *app) { migrator m; m.set_app(app); - + m.add("edb5fa6cef65bcb7d0c612023d267c3aeaa1e57a", &migrate_client_merge_url_and_group); ============================================================ --- selectors.cc 6e4fa17b861b28cc469b4adcdcdc58206ab2d654 +++ selectors.cc ebc515a9552d1eb547de8b220e33eeec2e1059ff @@ -26,18 +26,18 @@ { sel = orig_sel; - L(FL("decoding selector '%s'\n") % sel); + L(FL("decoding selector '%s'") % sel); string tmp; if (sel.size() < 2 || sel[1] != ':') { if (!app.lua.hook_expand_selector(sel, tmp)) { - L(FL("expansion of selector '%s' failed\n") % sel); + L(FL("expansion of selector '%s' failed") % sel); } else { - P(F("expanded selector '%s' -> '%s'\n") % sel % tmp); + P(F("expanded selector '%s' -> '%s'") % sel % tmp); sel = tmp; } } @@ -74,7 +74,7 @@ type = sel_earlier; break; default: - W(F("unknown selector type: %c\n") % sel[0]); + W(F("unknown selector type: %c") % sel[0]); break; } sel.erase(0,2); @@ -82,14 +82,14 @@ /* a selector date-related should be validated */ if (sel_date==type || sel_later==type || sel_earlier==type) { - N (app.lua.hook_expand_date(sel, tmp), + N (app.lua.hook_expand_date(sel, tmp), F ("selector '%s' is not a valid date\n") % sel); - + if (tmp.size()<8 && (sel_later==type || sel_earlier==type)) tmp += "-01T00:00:00"; else if (tmp.size()<11 && (sel_later==type || sel_earlier==type)) tmp += "T00:00:00"; - N(tmp.size()==19 || sel_date==type, F ("selector '%s' is not a valid date (%s)\n") % sel % tmp); + N(tmp.size()==19 || sel_date==type, F ("selector '%s' is not a valid date (%s)") % sel % tmp); if (sel != tmp) { P (F ("expanded date '%s' -> '%s'\n") % sel % tmp); ============================================================ --- simplestring_xform.cc dcf9e39b1a9c1bb565447a90f6068bdf82a7ee68 +++ simplestring_xform.cc b48839ca2a3f88b7db657c8aaf5a1fd58a29e1f6 @@ -9,16 +9,16 @@ using std::ostringstream; using std::ostream_iterator; -struct +struct lowerize { - char operator()(char const & c) const - { - return ::tolower(static_cast(c)); + char operator()(char const & c) const + { + return ::tolower(static_cast(c)); } }; -string +string lowercase(string const & in) { string n(in); @@ -26,16 +26,16 @@ return n; } -struct +struct upperize { - char operator()(char const & c) const - { - return ::toupper(static_cast(c)); + char operator()(char const & c) const + { + return ::toupper(static_cast(c)); } }; -string +string uppercase(string const & in) { string n(in); @@ -43,23 +43,23 @@ return n; } -void split_into_lines(string const & in, +void split_into_lines(string const & in, string const & encoding, vector & out) { - string lc_encoding = lowercase(encoding); + string lc_encoding = lowercase(encoding); out.clear(); - // note: this function does not handle ISO-2022-X, Shift-JIS, and - // probably a good deal of other encodings as well. please expand - // the logic here if you can work out an easy way of doing line - // breaking on these encodings. currently it's just designed to + // note: this function does not handle ISO-2022-X, Shift-JIS, and + // probably a good deal of other encodings as well. please expand + // the logic here if you can work out an easy way of doing line + // breaking on these encodings. currently it's just designed to // work with charsets in which 0x0a / 0x0d are *always* \n and \r // respectively. // // as far as I know, this covers the EUC, ISO-8859-X, GB, Big5, KOI, - // ASCII, and UTF-8 families of encodings. - + // ASCII, and UTF-8 families of encodings. + if (lc_encoding == constants::default_encoding || lc_encoding.find("ascii") != string::npos || lc_encoding.find("8859") != string::npos @@ -77,7 +77,7 @@ { out.push_back(in.substr(begin, end-begin)); if (in.at(end) == '\r' - && in.size() > end+1 + && in.size() > end+1 && in.at(end+1) == '\n') begin = end + 2; else @@ -96,14 +96,14 @@ } -void +void split_into_lines(string const & in, vector & out) { split_into_lines(in, constants::default_encoding, out); } -void +void join_lines(vector const & in, string & out, string const & linesep) @@ -113,7 +113,7 @@ out = oss.str(); } -void +void join_lines(vector const & in, string & out) { @@ -135,11 +135,11 @@ if (i != msgs.end()) oss << "\n"; } - + out = oss.str(); } -string +string remove_ws(string const & s) { string tmp; @@ -162,7 +162,7 @@ return tmp; } -string +string trim_ws(string const & s) { string tmp = s; @@ -175,7 +175,7 @@ return tmp; } -void +void line_end_convert(string const & linesep, string const & src, string & dst) { string linesep_str("\n"); @@ -186,7 +186,7 @@ else if (linesep == "LF"|| linesep == "\n") linesep_str = "\n"; - L(FL("doing linesep conversion to %s\n") % linesep); + L(FL("doing linesep conversion to %s") % linesep); vector tmp; split_into_lines(src, tmp); join_lines(tmp, dst, linesep_str); @@ -200,7 +200,7 @@ #include "unit_tests.hh" #include -static void +static void caseconv_test() { BOOST_CHECK(uppercase("hello") == "HELLO"); @@ -211,7 +211,7 @@ BOOST_CHECK(lowercase("address@hidden&*()") == "address@hidden&*()"); } -static void +static void join_lines_test() { vector strs; @@ -231,10 +231,10 @@ strs.push_back("user"); join_lines(strs, joined); - BOOST_CHECK(joined == "hi\nthere\nuser\n"); + BOOST_CHECK(joined == "hi\nthere\nuser\n"); } -static void +static void strip_ws_test() { BOOST_CHECK(trim_ws("\n leading space") == "leading space"); @@ -244,7 +244,7 @@ == "Ilikegoingforwalks"); } -void +void add_simplestring_xform_tests(test_suite * suite) { I(suite); ============================================================ --- simplestring_xform.hh 5226320784043474c9f5fd799b8e86ca2f070d8d +++ simplestring_xform.hh ba15cb86a7300ac69a921bf855a8b8587cf748f9 @@ -24,7 +24,7 @@ void prefix_lines_with(std::string const & prefix, std::string const & lines, std::string & out); - + // remove all whitespace std::string remove_ws(std::string const & s); ============================================================ --- smap.hh d4acf13bff4208cfe2d87cb93fcb182a290d77f8 +++ smap.hh a7675c8e99c425c7ed3531189f8efd74d4eac41a @@ -39,11 +39,11 @@ // We don't use quick_alloc.hh's QA() macro here, because macros don't know // about <>'s as grouping mechanisms, so it thinks the "," in the middle of // std::pair is breaking things into two arguments. -template, #if defined(__GNUC__) && __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4) - typename alloc = std::__allocator, std::__single_client_alloc> > -#else + typename alloc = std::__allocator, std::__single_client_alloc> > +#else typename alloc = std::allocator > > #endif class @@ -61,24 +61,24 @@ { friend class smap; protected: - compare comp; + compare comp; value_compare(compare c) : comp(c) {} - + public: - bool operator()(const value_type & a, + bool operator()(const value_type & a, const value_type & b) const - { - return comp(a.first, b.first); + { + return comp(a.first, b.first); } }; value_compare val_cmp; - typedef std::vector vec_type; + typedef std::vector vec_type; mutable vec_type vec; mutable bool damaged; - inline void + inline void ensure_sort() const { if (damaged) @@ -112,43 +112,43 @@ typedef typename vec_type::iterator iterator; typedef typename vec_type::const_iterator const_iterator; typedef typename vec_type::reverse_iterator reverse_iterator; - typedef typename vec_type::const_reverse_iterator const_reverse_iterator; + typedef typename vec_type::const_reverse_iterator const_reverse_iterator; - smap() - : val_cmp(compare()), - damaged(false) + smap() + : val_cmp(compare()), + damaged(false) { }; - + explicit - smap(compare const & cmp, - alloc const & a = alloc()) - : val_cmp(cmp), + smap(compare const & cmp, + alloc const & a = alloc()) + : val_cmp(cmp), vec(a), damaged(false) { } - + smap(smap const & other) - : val_cmp(other.val_cmp), + : val_cmp(other.val_cmp), vec(other.vec), - damaged(other.damaged) + damaged(other.damaged) { } template smap(InputIterator first, InputIterator last) : damaged(false) - { - insert(first, last); + { + insert(first, last); } - + template smap(InputIterator first, InputIterator last, - compare const & cmp, + compare const & cmp, alloc const & a = alloc()) : val_cmp(cmp), vec(a), - damaged(false) - { - insert(first, last); + damaged(false) + { + insert(first, last); } smap & @@ -162,7 +162,7 @@ allocator_type get_allocator() const { return vec.get_allocator(); } - + iterator begin() { return vec.begin(); } iterator end() { return vec.end(); } reverse_iterator rbegin() { return vec.rbegin(); } @@ -222,19 +222,19 @@ i = insert(i, *first++); } } - - void + + void erase(iterator i) { vec.erase(i); } - - size_type + + size_type erase(key_type const & k) { iterator i = find(k); size_type c = 0; - while (i != end() && i->first == k) + while (i != end() && i->first == k) { erase(i); ++c; @@ -242,7 +242,7 @@ } return c; } - + void erase(iterator first, iterator last) { @@ -361,7 +361,7 @@ friend bool operator== (const smap&, const smap&); - + template friend bool operator< (const smap&, @@ -369,78 +369,78 @@ }; -template inline bool operator==(smap const & a, smap const & b) -{ +{ a.ensure_sort(); b.ensure_sort(); return a.vec == b.vec; } -template inline bool operator<(smap const & a, smap const & b) -{ +{ a.ensure_sort(); b.ensure_sort(); return a.vec < b.vec; } -template inline bool operator!=(smap const & a, smap const & b) -{ +{ return !(a == b); } -template inline bool operator>(smap const & a, smap const & b) -{ +{ return b < a; } -template inline bool operator<=(smap const & a, smap const & b) -{ +{ return !(b < a); } -template inline bool operator>=(smap const & a, smap const & b) -{ +{ return !(a < b); } -template inline void -swap(smap & a, +swap(smap & a, smap & b) -{ - a.swap(b); +{ + a.swap(b); } ============================================================ --- tester.cc cee71a1f004e66cdd9447c23f1c16f9bfdb0c246 +++ tester.cc 285226d2e10fb2785ff38afedec7f1c256321ec2 @@ -57,7 +57,7 @@ char const * infile = luaL_checkstring(L, -3); char const * outfile = luaL_checkstring(L, -2); char const * errfile = luaL_checkstring(L, -1); - + lua_pushnumber(L, infd); lua_pushnumber(L, outfd); lua_pushnumber(L, errfd); ============================================================ --- transforms.cc a4754b188afa931450b7dc5b49d077a5a39e8073 +++ transforms.cc cbf74915e0e547291ea34f948331114d3859383d @@ -89,8 +89,8 @@ *out++ = tab[*i & 0xf]; } } - + string encode_hexenc(string const & in) { if (LIKELY(in.size() == constants::idlen / 2)) @@ -107,12 +107,12 @@ } } -static inline char +static inline char decode_hex_char(char c) { if (c >= '0' && c <= '9') return c - '0'; - else + else { I(c >= 'a' && c <= 'f'); return c - 'a' + 10; @@ -135,7 +135,7 @@ string decode_hexenc(string const & in) { - + I(in.size() % 2 == 0); if (LIKELY(in.size() == constants::idlen)) { @@ -143,7 +143,7 @@ decode_hexenc_inner(in.begin(), in.end(), buf); return string(buf, constants::idlen / 2); } - else + else { scoped_array buf(new char[in.size() / 2]); decode_hexenc_inner(in.begin(), in.end(), buf.get()); @@ -184,7 +184,7 @@ // diffing and patching -void +void diff(data const & olddata, data const & newdata, delta & del) @@ -194,7 +194,7 @@ del = delta(unpacked); } -void +void patch(data const & olddata, delta const & del, data & newdata) @@ -206,7 +206,7 @@ // identifier (a.k.a. sha1 signature) calculation -void +void calculate_ident(data const & dat, hexenc & ident) { @@ -214,21 +214,21 @@ p.process_msg(dat()); id ident_decoded(p.read_all_as_string()); - encode_hexenc(ident_decoded, ident); + encode_hexenc(ident_decoded, ident); } -void +void calculate_ident(base64< gzip > const & dat, hexenc & ident) { gzip data_decoded; - data data_decompressed; + data data_decompressed; decode_base64(dat, data_decoded); - decode_gzip(data_decoded, data_decompressed); + decode_gzip(data_decoded, data_decompressed); calculate_ident(data_decompressed, ident); } -void +void calculate_ident(file_data const & dat, file_id & ident) { @@ -255,7 +255,7 @@ ident = tmp; } -string +string canonical_base64(string const & s) { return xform @@ -267,7 +267,7 @@ #include "unit_tests.hh" #include -static void +static void enc_test() { data d2, d1("the rain in spain"); @@ -281,20 +281,20 @@ BOOST_CHECK(d2 == d1); } -static void +static void rdiff_test() { data dat1(string("the first day of spring\nmakes me want to sing\n")); data dat2(string("the first day of summer\nis a major bummer\n")); delta del; diff(dat1, dat2, del); - + data dat3; patch(dat1, del, dat3); BOOST_CHECK(dat3 == dat2); } -static void +static void calculate_ident_test() { data input(string("the only blender which can be turned into the most powerful vaccum cleaner")); @@ -304,7 +304,7 @@ BOOST_CHECK(output() == ident); } -void +void add_transform_tests(test_suite * suite) { I(suite); ============================================================ --- txt2c.cc 85a07a8bc034fbd6be456d6d5028ba26f362303a +++ txt2c.cc 1298b1829b7a8d0d1c1881913f4f3d407ed850fe @@ -57,7 +57,7 @@ << "\n\n" << static_decl << "char const " << arr << "_constant[" << (dat.size() + 1) << "] = {\n"; - + for (unsigned int i = 0; i < dat.size(); ++i) { if (i == 0) cout << "\t"; ============================================================ --- ui.cc cd43c58d97f3b15c45109e37c1fdad43ba84284a +++ ui.cc 61e835372390db1152c2b34a71dbba52e27881f5 @@ -67,7 +67,7 @@ ui.finish_ticking(); } -void +void ticker::operator++() { I(ui.tickers.find(keyname) != ui.tickers.end()); @@ -77,7 +77,7 @@ ui.write_ticks(); } -void +void ticker::operator+=(size_t t) { I(ui.tickers.find(keyname) != ui.tickers.end()); @@ -220,7 +220,7 @@ } string tickline1; - bool write_tickline1 = !(ui.last_write_was_a_tick + bool write_tickline1 = !(ui.last_write_was_a_tick && (tick_widths == last_tick_widths)); if (write_tickline1) { @@ -250,7 +250,7 @@ tickline2 += " "; tickline2 += ui.tick_trailer; } - + size_t curr_sz = display_width(utf8(tickline2)); if (curr_sz < last_tick_len) tickline2.append(last_tick_len - curr_sz, ' '); @@ -366,7 +366,7 @@ clog.sync_with_stdio(false); #endif clog.unsetf(ios_base::unitbuf); - if (have_smart_terminal()) + if (have_smart_terminal()) set_tick_writer(new tick_write_count); else set_tick_writer(new tick_write_dot); @@ -377,10 +377,10 @@ delete t_writer; } -void +void user_interface::finish_ticking() { - if (tickers.size() == 0 && + if (tickers.size() == 0 && last_write_was_a_tick) { tick_trailer = ""; @@ -389,13 +389,13 @@ } } -void +void user_interface::set_tick_trailer(string const & t) { tick_trailer = t; } -void +void user_interface::set_tick_writer(tick_writer * t) { if (t_writer != 0) @@ -403,7 +403,7 @@ t_writer = t; } -void +void user_interface::write_ticks() { t_writer->write_ticks(); @@ -411,7 +411,7 @@ some_tick_is_dirty = false; } -void +void user_interface::warn(string const & warning) { if (issued_warnings.find(warning) == issued_warnings.end()) @@ -423,7 +423,7 @@ issued_warnings.insert(warning); } -void +void user_interface::fatal(string const & fatal) { inform(F("fatal: %s\n" @@ -449,18 +449,18 @@ return prog_name + ": "; } -static inline string +static inline string sanitize(string const & line) { // FIXME: you might want to adjust this if you're using a charset - // which has safe values in the sub-0x20 range. ASCII, UTF-8, + // which has safe values in the sub-0x20 range. ASCII, UTF-8, // and most ISO8859-x sets do not. string tmp; tmp.reserve(line.size()); for (size_t i = 0; i < line.size(); ++i) { if ((line[i] == '\n') - || (static_cast(line[i]) >= static_cast(0x20) + || (static_cast(line[i]) >= static_cast(0x20) && line[i] != static_cast(0x7F))) tmp += line[i]; else @@ -491,7 +491,7 @@ clog.rdbuf(filestr.rdbuf()); } -void +void user_interface::inform(string const & line) { string prefixedLine; ============================================================ --- ui.hh 0f806f7ebf686e12e5a67297b39ffeb030abe2dc +++ ui.hh ff05469e55ddf9a1773f13104f61ba27d8820d57 @@ -98,8 +98,8 @@ void set_prog_name(std::string const & name); std::string output_prefix(); -private: - std::set issued_warnings; +private: + std::set issued_warnings; bool some_tick_is_dirty; // At least one tick needs being printed bool last_write_was_a_tick; ============================================================ --- unit_tests.cc 5d04490cb15e14a015830a4061607e7985d6e9a6 +++ unit_tests.cc dbf88f87be0394902e8c2ddb827c080a95e3361e @@ -18,10 +18,10 @@ using std::string; static bool clean_shutdown; -void dumper() +void dumper() { if (!clean_shutdown) - global_sanity.dump_buffer(); + global_sanity.dump_buffer(); Botan::Init::deinitialize(); } @@ -49,65 +49,65 @@ if (t.empty() || t.find("file_io") != t.end()) add_file_io_tests(suite); - + if (t.empty() || t.find("key") != t.end()) add_key_tests(suite); - + if (t.empty() || t.find("transform") != t.end()) add_transform_tests(suite); - + if (t.empty() || t.find("charset") != t.end()) add_charset_tests(suite); - + if (t.empty() || t.find("simplestring_xform") != t.end()) add_simplestring_xform_tests(suite); - + if (t.empty() || t.find("vocab") != t.end()) add_vocab_tests(suite); if (t.empty() || t.find("revision") != t.end()) - add_revision_tests(suite); + add_revision_tests(suite); if (t.empty() || t.find("cset") != t.end()) - add_cset_tests(suite); + add_cset_tests(suite); if (t.empty() || t.find("diff_patch") != t.end()) add_diff_patch_tests(suite); if (t.empty() || t.find("xdelta") != t.end()) - add_xdelta_tests(suite); + add_xdelta_tests(suite); if (t.empty() || t.find("packet") != t.end()) add_packet_tests(suite); - + if (t.empty() || t.find("netcmd") != t.end()) - add_netcmd_tests(suite); + add_netcmd_tests(suite); if (t.empty() || t.find("globish") != t.end()) - add_globish_tests(suite); - + add_globish_tests(suite); + if (t.empty() || t.find("crypto") != t.end()) - add_crypto_tests(suite); - + add_crypto_tests(suite); + if (t.empty() || t.find("pipe") != t.end()) - add_pipe_tests(suite); + add_pipe_tests(suite); if (t.empty() || t.find("string_queue") != t.end()) - add_string_queue_tests(suite); - + add_string_queue_tests(suite); + if (t.empty() || t.find("paths") != t.end()) - add_paths_tests(suite); + add_paths_tests(suite); if (t.empty() || t.find("roster") != t.end()) - add_roster_tests(suite); - + add_roster_tests(suite); + if (t.empty() || t.find("roster_merge") != t.end()) add_roster_merge_tests(suite); if (t.empty() || t.find("restrictions") != t.end()) - add_restrictions_tests(suite); + add_restrictions_tests(suite); if (t.empty() || t.find("uri") != t.end()) - add_uri_tests(suite); + add_uri_tests(suite); // all done, add our clean-shutdown-indicator suite->add(BOOST_TEST_CASE(&clean_shutdown_dummy_test)); ============================================================ --- update.cc a6ab1750719839bd9da8ac0db8c9181b60167890 +++ update.cc d27699ab18a2f417a8c154d329c2328b92d8750a @@ -46,7 +46,7 @@ using boost::lexical_cast; -static void +static void get_test_results_for_revision(revision_id const & id, map & results, app_state & app) @@ -59,14 +59,14 @@ { cert_value cv; decode_base64(i->inner().value, cv); - try + try { bool test_ok = lexical_cast(cv()); results.insert(make_pair(i->inner().key, test_ok)); } catch(boost::bad_lexical_cast &) { - W(F("failed to decode boolean testresult cert value '%s'\n") % cv); + W(F("failed to decode boolean testresult cert value '%s'") % cv); } } } @@ -78,8 +78,8 @@ revision_id const & target, app_state & app) { - L(FL("Considering update target %s\n") % target); - + L(FL("Considering update target %s") % target); + // step 1: check the branch base64 val; encode_base64(branch, val); @@ -88,26 +88,26 @@ erase_bogus_certs(certs, app); if (certs.empty()) { - L(FL("%s not in branch %s\n") % target % branch); + L(FL("%s not in branch %s") % target % branch); return false; } - + // step 2: check the testresults map target_results; get_test_results_for_revision(target, target_results, app); if (app.lua.hook_accept_testresult_change(base_results, target_results)) { - L(FL("%s is acceptable update candidate\n") % target); + L(FL("%s is acceptable update candidate") % target); return true; } else { - L(FL("%s has unacceptable test results\n") % target); + L(FL("%s has unacceptable test results") % target); return false; } } - + static void calculate_update_set(revision_id const & base, cert_value const & branch, @@ -131,7 +131,7 @@ app.db.get_revision_children(base, children); copy(children.begin(), children.end(), back_inserter(to_traverse)); - + while (!to_traverse.empty()) { revision_id target = to_traverse.back(); @@ -153,8 +153,8 @@ erase_ancestors(candidates, app); } - - + + void pick_update_candidates(revision_id const & base_ident, app_state & app, set & candidates) @@ -166,5 +166,5 @@ calculate_update_set(base_ident, cert_value(app.branch_name()), app, candidates); } - + ============================================================ --- update.hh f2eabe7487e1b3b6892cc490575fe271d2c0e675 +++ update.hh e30e90bf8b5165dbcac0041953ed9c0ee20273c1 @@ -11,7 +11,7 @@ #include "app_state.hh" #include "vocab.hh" -// this function just encapsulates the (somewhat complex) logic +// this function just encapsulates the (somewhat complex) logic // behind picking an update target. the actual updating takes // place in commands.cc, along with most other file-modifying // actions. ============================================================ --- uri.cc bee5841639bfb4eb75f876c0113d32a2501e313f +++ uri.cc bb529301045c715375306d7577c190a32b8abc82 @@ -26,8 +26,8 @@ string fragment_part = "(?:#(.*))?"; string uri_rx = (string("^") - + scheme_part - + authority_part + + scheme_part + + authority_part + path_part + query_part + fragment_part @@ -57,7 +57,7 @@ I(boost::regex_match(authority, auth_matches, boost::regex(auth_rx))); u.user = auth_matches.str(1); u.port = auth_matches.str(4); - if (auth_matches[2].matched) + if (auth_matches[2].matched) u.host = auth_matches.str(2); else { @@ -90,7 +90,7 @@ #include "transforms.hh" static void -test_one_uri(string scheme, +test_one_uri(string scheme, string user, string ipv6_host, string normal_host, @@ -112,21 +112,21 @@ host += '['; host += (ipv6_host + ']'); } - else + else host = normal_host; - if (! (user.empty() - && host.empty() + if (! (user.empty() + && host.empty() && port.empty())) { built += "//"; - + if (! user.empty()) built += (user + '@'); - + if (! host.empty()) built += host; - + if (! port.empty()) { built += ':'; @@ -151,7 +151,7 @@ built += '#'; built += fragment; } - + L(FL("testing parse of URI '%s'") % built); uri u; BOOST_CHECK(parse_uri(built, u)); @@ -165,7 +165,7 @@ } -static void +static void uri_test() { test_one_uri("ssh", "graydon", "", "venge.net", "22", "/tmp/foo.mtn", "", ""); @@ -178,7 +178,7 @@ } -void +void add_uri_tests(test_suite * suite) { I(suite); ============================================================ --- vocab.cc cd9e884668636ad1bb7cd1607d5d2fd0015fd307 +++ vocab.cc b709a27fe572e529cafa55bbb31dde0eaddfb6cd @@ -41,14 +41,14 @@ verify(T & val) {} -inline void +inline void verify(path_component & val) { // FIXME: probably ought to do something here? val.ok = true; } -inline void +inline void verify(hexenc & val) { if (val.ok) @@ -67,7 +67,7 @@ val.ok = true; } -inline void +inline void verify(ace & val) { if (val.ok) @@ -95,7 +95,7 @@ val.ok = true; } -inline void +inline void verify(cert_name & val) { if (val.ok) @@ -108,7 +108,7 @@ val.ok = true; } -inline void +inline void verify(rsa_keypair_id & val) { if (val.ok) @@ -165,14 +165,14 @@ // 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 +struct +symtab_impl { typedef hashmap::hash_set hset; hset vals; symtab_impl() : vals() {} void clear() { vals.clear(); } - string const & unique(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 @@ -192,7 +192,7 @@ #define ATOMIC(ty) cc_ATOMIC(ty) #define ATOMIC_NOVERIFY(ty) cc_ATOMIC_NOVERIFY(ty) -#define EXTERN +#define EXTERN #include "vocab_terms.hh" ============================================================ --- vocab.hh d39554c722d3487a36bbab7cb996e89435153a29 +++ vocab.hh cac208eacc144d4a80801643162e3e1d235824df @@ -26,8 +26,8 @@ #define ATOMIC(ty) hh_ATOMIC(ty) #define ATOMIC_NOVERIFY(ty) hh_ATOMIC_NOVERIFY(ty) -inline bool is_xdigit(char x) -{ +inline bool is_xdigit(char x) +{ return ((x >= '0' && x <= '9') || (x >= 'a' && x <= 'f') || (x >= 'A' && x <= 'F')); @@ -48,15 +48,15 @@ inline bool is_space(char x) { - return (x == ' ') + return (x == ' ') || (x == '\n') || (x == '\t') || (x == '\r') || (x == '\v') || (x == '\f'); } - + #ifdef HAVE_EXTERN_TEMPLATE #define EXTERN extern #else @@ -120,25 +120,25 @@ }; // do these belong here? -inline bool +inline bool null_id(hexenc const & i) { return i().empty(); } -inline bool +inline bool null_id(file_id const & i) { return i.inner()().empty(); } -inline bool +inline bool null_id(manifest_id const & i) { return i.inner()().empty(); } -inline bool +inline bool null_id(revision_id const & i) { return i.inner()().empty(); ============================================================ --- vocab_terms.hh 5442a9adf37051de74795ca8d6f5b25ed92ab301 +++ vocab_terms.hh 1db914a9c7154295844d74eb2650ea52fe160a82 @@ -1,9 +1,9 @@ // copyright (C) 2002, 2003 graydon hoare // all rights reserved. // licensed to the public under the terms of the GNU GPL (>= 2) // see the file COPYING for details -// this fragment is included into both vocab.hh and vocab.cc, +// this fragment is included into both vocab.hh and vocab.cc, // in order to facilitate external instantiation of most of the // vocabulary, minimize code duplication, speed up compilation, etc. ============================================================ --- work.cc 9e2f2b5bf64d0d0b40ce813e21cfd194cdca64d0 +++ work.cc b60e9e0bdf1b336ccc569e0aa8f493118413b9b4 @@ -52,7 +52,7 @@ this->visit_file(path); } -void +void file_itemizer::visit_file(file_path const & path) { split_path sp; @@ -87,7 +87,7 @@ { split_path sp; new_roster.get_name(nid, sp); - file_path fp(sp); + file_path fp(sp); if (!path_exists(fp)) missing.insert(sp); @@ -96,7 +96,7 @@ } void -find_unknown_and_ignored(app_state & app, vector const & args, +find_unknown_and_ignored(app_state & app, vector const & args, path_set & unknown, path_set & ignored) { revision_set rev; @@ -115,8 +115,8 @@ } -class -addition_builder +class +addition_builder : public tree_walker { app_state & app; @@ -133,7 +133,7 @@ void add_node_for(split_path const & sp); }; -void +void addition_builder::add_node_for(split_path const & sp) { file_path path(sp); @@ -154,7 +154,7 @@ nid = er.create_dir_node(); break; } - + I(nid != the_null_node); er.attach_node(nid, sp); @@ -169,26 +169,26 @@ } -void +void addition_builder::visit_dir(file_path const & path) { this->visit_file(path); } -void +void addition_builder::visit_file(file_path const & path) -{ +{ if (app.lua.hook_ignore_file(path) || app.db.is_dbfile(path)) { P(F("skipping ignorable file %s") % path); return; - } + } split_path sp; path.split(sp); if (ros.has_node(sp)) { - if (sp.size() > 1) + if (sp.size() > 1) P(F("skipping %s, already accounted for in workspace") % path); return; } @@ -217,7 +217,7 @@ { if (paths.empty()) return; - + temp_node_id_source nis; roster_t base_roster, new_roster; get_base_and_current_roster_shape(base_roster, new_roster, nis, app); @@ -243,7 +243,7 @@ } else { - // in the case where we're just handled a set of paths, we use the builder + // in the case where we're just handled a set of paths, we use the builder // in this strange way. build.visit_file(file_path(*i)); } @@ -260,7 +260,7 @@ { if (paths.empty()) return; - + temp_node_id_source nis; roster_t base_roster, new_roster; get_base_and_current_roster_shape(base_roster, new_roster, nis, app); @@ -323,8 +323,8 @@ update_any_attrs(app); } -static void -add_parent_dirs(split_path const & dst, roster_t & ros, node_id_source & nis, +static void +add_parent_dirs(split_path const & dst, roster_t & ros, node_id_source & nis, app_state & app) { editable_roster_base er(ros, nis); @@ -372,7 +372,7 @@ N(is_dir_t(new_roster.get_node(dst)), F("destination %s is an existing file in current revision") % dst_path); - for (set::const_iterator i = src_paths.begin(); + for (set::const_iterator i = src_paths.begin(); i != src_paths.end(); i++) { split_path s; @@ -406,8 +406,8 @@ { node_id nid = new_roster.detach_node(i->first); new_roster.attach_node(nid, i->second); - P(F("renaming %s to %s in workspace manifest") - % file_path(i->first) + P(F("renaming %s to %s in workspace manifest") + % file_path(i->first) % file_path(i->second)); } @@ -471,7 +471,7 @@ N(!new_roster.has_node(new_root__MTN), F("proposed new root directory '%s' contains illegal path %s") % new_root % bookkeeping_root); } - + { file_path current_path_to_put_old = (new_root / put_old.as_internal()); split_path current_path_to_put_old_sp, current_path_to_put_old_parent_sp; @@ -491,7 +491,7 @@ cset cs; 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); cs.apply_to(e); @@ -516,7 +516,7 @@ static void get_work_path(bookkeeping_path & w_path) { w_path = bookkeeping_root / work_file_name; - L(FL("work path is %s\n") % w_path); + L(FL("work path is %s") % w_path); } void get_work_cset(cset & w) @@ -525,15 +525,15 @@ get_work_path(w_path); if (path_exists(w_path)) { - L(FL("checking for un-committed work file %s\n") % w_path); + L(FL("checking for un-committed work file %s") % w_path); data w_data; read_data(w_path, w_data); read_cset(w_data, w); - L(FL("read cset from %s\n") % w_path); + L(FL("read cset from %s") % w_path); } else { - L(FL("no un-committed work file %s\n") % w_path); + L(FL("no un-committed work file %s") % w_path); } } @@ -549,7 +549,7 @@ { bookkeeping_path w_path; get_work_path(w_path); - + if (w.empty()) { if (file_exists(w_path)) @@ -563,14 +563,14 @@ } } -// revision file name +// revision file name string revision_file_name("revision"); static void get_revision_path(bookkeeping_path & m_path) { m_path = bookkeeping_root / revision_file_name; - L(FL("revision path is %s\n") % m_path); + L(FL("revision path is %s") % m_path); } void get_revision_id(revision_id & c) @@ -600,13 +600,13 @@ { bookkeeping_path c_path; get_revision_path(c_path); - L(FL("writing revision id to %s\n") % c_path); + L(FL("writing revision id to %s") % c_path); data c_data(rev.inner()() + "\n"); write_data(c_path, c_data); } void -get_base_revision(app_state & app, +get_base_revision(app_state & app, revision_id & rid, roster_t & ros, marking_map & mm) @@ -618,15 +618,15 @@ N(app.db.revision_exists(rid), F("base revision %s does not exist in database\n") % rid); - + app.db.get_roster(rid, ros, mm); } - L(FL("base roster has %d entries\n") % ros.all_nodes().size()); + L(FL("base roster has %d entries") % ros.all_nodes().size()); } void -get_base_revision(app_state & app, +get_base_revision(app_state & app, revision_id & rid, roster_t & ros) { @@ -635,7 +635,7 @@ } void -get_base_roster(app_state & app, +get_base_roster(app_state & app, roster_t & ros) { revision_id rid; @@ -673,7 +673,7 @@ get_user_log_path(bookkeeping_path & ul_path) { ul_path = bookkeeping_root / user_log_file_name; - L(FL("user log path is %s\n") % ul_path); + L(FL("user log path is %s") % ul_path); } void @@ -716,14 +716,14 @@ // options map file -void +void get_options_path(bookkeeping_path & o_path) { o_path = bookkeeping_root / options_file_name; - L(FL("options path is %s\n") % o_path); + L(FL("options path is %s") % o_path); } -void +void read_options_map(data const & dat, options_map & options) { basic_io::input_source src(dat(), "_MTN/options"); @@ -731,20 +731,20 @@ basic_io::parser parser(tok); // don't clear the options which will have settings from the command line - // options.clear(); + // options.clear(); string opt, val; while (parser.symp()) { parser.sym(opt); parser.str(val); - // options[opt] = val; + // options[opt] = val; // use non-replacing insert versus replacing with options[opt] = val; - options.insert(make_pair(opt, val)); + options.insert(make_pair(opt, val)); } } -void +void write_options_map(data & dat, options_map const & options) { basic_io::printer pr; @@ -763,7 +763,7 @@ void get_local_dump_path(bookkeeping_path & d_path) { d_path = bookkeeping_root / local_dump_file_name; - L(FL("local dump path is %s\n") % d_path); + L(FL("local dump path is %s") % d_path); } // inodeprint file @@ -810,8 +810,8 @@ } -bool -get_attribute_from_roster(roster_t const & ros, +bool +get_attribute_from_roster(roster_t const & ros, file_path const & path, attr_key const & key, attr_value & val) @@ -858,7 +858,7 @@ file_path(sp), j->second.second()); } - } + } } } @@ -923,7 +923,7 @@ editable_working_tree::drop_detached_node(node_id nid) { bookkeeping_path pth = path_for_nid(nid); - 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); @@ -966,7 +966,7 @@ if (!path_exists(src_pth)) { I(root_dir_attached); - map::const_iterator i + map::const_iterator i = written_content.find(src_pth); if (i != written_content.end()) { @@ -1022,8 +1022,8 @@ } void -editable_working_tree::apply_delta(split_path const & pth, - file_id const & old_id, +editable_working_tree::apply_delta(split_path const & pth, + file_id const & old_id, file_id const & new_id) { file_path pth_unsplit(pth); ============================================================ --- work.hh 021506c51a9be289cdffa8872a694b0e9b266c74 +++ work.hh 516b8168864623e72df409a791516b2e76e88a84 @@ -39,7 +39,7 @@ // sha1 fingerprints from those listed in the revision's manifest, or else are // added or deleted or renamed (and the paths of those changes recorded in // '_MTN/work'). -// +// // when it comes time to commit, the cset in _MTN/work (which can have no // deltas) is applied to the base roster, then a new roster is built by // analyzing the content of every file in the roster, as it appears in the @@ -55,7 +55,7 @@ path_set & unknown; path_set & ignored; restriction const & mask; - file_itemizer(app_state & a, path_set & k, path_set & u, path_set & i, restriction const & r) + file_itemizer(app_state & a, path_set & k, path_set & u, path_set & i, restriction const & r) : app(a), known(k), unknown(u), ignored(i), mask(r) {} virtual void visit_dir(file_path const & path); virtual void visit_file(file_path const & path); @@ -65,7 +65,7 @@ find_missing(app_state & app, std::vector const & args, path_set & missing); void -find_unknown_and_ignored(app_state & app, std::vector const & args, +find_unknown_and_ignored(app_state & app, std::vector const & args, path_set & unknown, path_set & ignored); void @@ -95,7 +95,7 @@ void get_revision_id(revision_id & c); void put_revision_id(revision_id const & rev); -void get_base_revision(app_state & app, +void get_base_revision(app_state & app, revision_id & rid, roster_t & ros, marking_map & mm); @@ -153,7 +153,7 @@ void get_local_dump_path(bookkeeping_path & d_path); -// the 'inodeprints file' contains inode fingerprints +// the 'inodeprints file' contains inode fingerprints void get_inodeprints_path(bookkeeping_path & ip_path); @@ -165,7 +165,7 @@ void enable_inodeprints(); -bool get_attribute_from_roster(roster_t const & ros, +bool get_attribute_from_roster(roster_t const & ros, file_path const & path, attr_key const & key, attr_value & val); @@ -199,8 +199,8 @@ virtual node_id create_file_node(file_id const & content); virtual void attach_node(node_id nid, split_path const & dst); - virtual void apply_delta(split_path const & pth, - file_id const & old_id, + virtual void apply_delta(split_path const & pth, + file_id const & old_id, file_id const & new_id); virtual void clear_attr(split_path const & pth, attr_key const & name); ============================================================ --- xdelta.cc a532e5e2f722fc479b28d09deae78cfdc5938368 +++ xdelta.cc 4badced7bdde6de4a2c6b89d47503e88979603b3 @@ -50,7 +50,7 @@ typedef pair extent; typedef hashmap::hash_map match_table; -struct +struct insn { insn(char c) : code(insert), pos(0), len(0), payload("") { payload += c; } @@ -75,7 +75,7 @@ } -static inline void +static inline void init_match_table(string const & a, string::size_type blocksz, match_table & tab) @@ -87,19 +87,19 @@ u32 sum = adler32(reinterpret_cast(a.data() + i), step).sum(); if (tab.find(sum) == tab.end()) tab.insert(make_pair(sum, make_pair(i, step))); - } + } return; } static inline bool -find_match(match_table const & matches, +find_match(match_table const & matches, vector & delta, - adler32 const & rolling, - string const & a, - string const & b, - string::size_type bpos, - string::size_type & apos, + adler32 const & rolling, + string const & a, + string const & b, + string::size_type bpos, + string::size_type & apos, string::size_type & alen, string::size_type & badvance) { @@ -112,14 +112,14 @@ string::size_type tpos = e->second.first; string::size_type tlen = e->second.second; - + I(tpos < a.size()); I(tpos + tlen <= a.size()); // maybe it's a false match? if (memcmp(a.data() + tpos, b.data() + bpos, tlen) != 0) return false; - + apos = tpos; // see if we can extend our match forwards @@ -127,7 +127,7 @@ string::const_iterator ae = a.end(); string::const_iterator bi = b.begin() + bpos + tlen; string::const_iterator be = b.end(); - + while((ai != ae) && (bi != be) && (*ai == *bi)) @@ -143,7 +143,7 @@ // see if we can extend backwards into a previous insert hunk if (! delta.empty() && delta.back().code == insn::insert) { - while(apos > 0 + while(apos > 0 && bpos > 0 && a[apos - 1] == b[bpos - 1] && !delta.back().payload.empty()) @@ -158,19 +158,19 @@ // 'badvance' forward, just alen. } - // if we've extended back to consume the *entire* insert, + // if we've extended back to consume the *entire* insert, // let's do away with it altogether. if (delta.back().payload.empty()) { delta.pop_back(); } } - + I(memcmp(a.data() + apos, b.data() + bpos, alen) == 0); return true; } -static inline void +static inline void insert_insn(vector & delta, char c) { if (delta.empty() || delta.back().code == insn::copy) @@ -180,14 +180,14 @@ } -static inline void +static inline void copy_insn(vector & delta, string::size_type i, string::size_type matchlen) { delta.push_back(insn(i, matchlen)); } - - -static void + + +static void compute_delta_insns(string const & a, string const & b, vector & delta) @@ -202,13 +202,13 @@ insert_insn(delta, b[i]); return; } - - adler32 rolling(reinterpret_cast(b.data()), blocksz); - for (string::size_type + adler32 rolling(reinterpret_cast(b.data()), blocksz); + + for (string::size_type sz = b.size(), - lo = 0, - hi = blocksz; + lo = 0, + hi = blocksz; lo < sz; ) { string::size_type apos = 0, alen = 1, badvance = 1; @@ -220,7 +220,7 @@ copy_insn(delta, apos, alen); } else - { + { I(apos + alen <= a.size()); I(alen == 1); I(alen < blocksz); @@ -241,21 +241,21 @@ } } -void +void write_delta_insns(vector const & delta_insns, string & delta) { delta.clear(); - ostringstream oss; - for (vector::const_iterator i = delta_insns.begin(); + ostringstream oss; + for (vector::const_iterator i = delta_insns.begin(); i != delta_insns.end(); ++i) { oss << *i; } - delta = oss.str(); + delta = oss.str(); } -void +void compute_delta(string const & a, string const & b, string & delta) @@ -282,14 +282,14 @@ { I(a.size() > 0); I(b.size() > 0); - - L(FL("computing binary delta instructions\n")); + + L(FL("computing binary delta instructions")); compute_delta_insns(a, b, delta_insns); - L(FL("computed binary delta instructions\n")); + L(FL("computed binary delta instructions")); } - ostringstream oss; - for (vector::const_iterator i = delta_insns.begin(); + ostringstream oss; + for (vector::const_iterator i = delta_insns.begin(); i != delta_insns.end(); ++i) { oss << *i; @@ -297,35 +297,35 @@ delta = oss.str(); } -struct -simple_applicator +struct +simple_applicator : public delta_applicator { string src; string dst; virtual ~simple_applicator () {} - virtual void begin(string const & base) - { - src = base; + virtual void begin(string const & base) + { + src = base; dst.clear(); } - virtual void next() - { - swap(src,dst); - dst.clear(); + virtual void next() + { + swap(src,dst); + dst.clear(); } - virtual void finish(string & out) - { - out = src; + virtual void finish(string & out) + { + out = src; } - virtual void copy(string::size_type pos, string::size_type len) - { - dst.append(src, pos, len); + virtual void copy(string::size_type pos, string::size_type len) + { + dst.append(src, pos, len); } virtual void insert(string const & str) - { - dst.append(str); + { + dst.append(str); } }; @@ -347,15 +347,15 @@ return n; } -void +void apply_delta(shared_ptr da, string const & delta) -{ - string::const_iterator i = delta.begin(); +{ + string::const_iterator i = delta.begin(); while (i != delta.end() && (*i == 'I' || *i == 'C')) { if (*i == 'I') - { + { ++i; I(i != delta.end()); string::size_type len = read_num(i, delta.end()); @@ -385,7 +385,7 @@ I(i != delta.end()); I(*i == '\n'); ++i; - } + } I(i == delta.end()); } @@ -401,7 +401,7 @@ da->finish(b); } -struct +struct size_accumulating_delta_applicator : public delta_applicator { @@ -411,15 +411,15 @@ virtual void next() {} virtual void finish(string & out) {} - virtual void copy(string::size_type pos, - string::size_type len) + virtual void copy(string::size_type pos, + string::size_type len) { sz += len; } - virtual void insert(string const & str) + virtual void insert(string const & str) { sz += str.size(); } }; -u64 +u64 measure_delta_target_size(string const & delta) { u64 sz = 0; @@ -438,7 +438,7 @@ typedef unsigned long piece_id; struct chunk -{ +{ length len; // how many chars in this chunk piece_id piece; // which piece to take chars from version_pos vpos; // position in the current version @@ -465,20 +465,20 @@ typedef vector version_spec; -struct +struct piece_table { vector pieces; - void clear() + void clear() { pieces.clear(); } - piece_id insert(string const & p) - { - pieces.push_back(p); - return pieces.size() - 1; + piece_id insert(string const & p) + { + pieces.push_back(p); + return pieces.size() - 1; } void append(string & targ, piece_id p, piece_pos pp, length ln) @@ -492,23 +492,23 @@ out.clear(); for (version_spec::const_iterator i = in.begin(); i != in.end(); ++i) - { + { append(out, i->piece, i->ppos, i->len); } } }; -static void +static void apply_insert(piece_table & p, version_spec & out, string const & str) { piece_id piece = p.insert(str); version_pos vpos = 0; - if (!out.empty()) + if (!out.empty()) vpos = out.back().vpos + out.back().len; out.push_back(chunk(str.size(), piece, vpos, 0)); } -struct +struct chunk_less_than { bool operator()(chunk const & ch1, chunk const & ch2) const @@ -520,8 +520,8 @@ } }; -static void -apply_copy(version_spec const & in, version_spec & out, +static void +apply_copy(version_spec const & in, version_spec & out, version_pos src_vpos, length src_len) { // @@ -551,9 +551,9 @@ dst_vpos = out.back().vpos + out.back().len; version_pos dst_final = dst_vpos + src_len; chunk src_bounding_chunk(0,0,src_vpos,0); - version_spec::const_iterator lo = lower_bound(in.begin(), - in.end(), - src_bounding_chunk, + version_spec::const_iterator lo = lower_bound(in.begin(), + in.end(), + src_bounding_chunk, chunk_less_than()); for ( ; src_len > 0; ++lo) { @@ -599,8 +599,8 @@ } -struct -piecewise_applicator +struct +piecewise_applicator : public delta_applicator { piece_table pt; @@ -614,48 +614,48 @@ virtual ~piecewise_applicator () {} - virtual void begin(string const & base) - { + virtual void begin(string const & base) + { pt.clear(); piece_id piece = pt.insert(base); src->clear(); src->push_back(chunk(base.size(), piece, 0, 0)); - dst->clear(); + dst->clear(); } - virtual void next() - { - swap(src,dst); - dst->clear(); + virtual void next() + { + swap(src,dst); + dst->clear(); } - virtual void finish(string & out) - { + virtual void finish(string & out) + { out.clear(); pt.build(*src, out); } - virtual void copy(string::size_type pos, string::size_type len) - { + virtual void copy(string::size_type pos, string::size_type len) + { apply_copy(*src, *dst, pos, len); } virtual void insert(string const & str) - { + { apply_insert(pt, *dst, str); } }; -// these just hide our implementation types from outside +// these just hide our implementation types from outside -shared_ptr +shared_ptr new_simple_applicator() { return shared_ptr(new simple_applicator()); } -shared_ptr +shared_ptr new_piecewise_applicator() { return shared_ptr(new piecewise_applicator()); @@ -683,22 +683,22 @@ } }; -struct +struct inverse_delta_writing_applicator : public delta_applicator { string const & old; set copied_extents; string::size_type new_pos; - - inverse_delta_writing_applicator(string const & old) - : old(old), + + inverse_delta_writing_applicator(string const & old) + : old(old), new_pos(0) {} virtual void begin(string const & base) {} virtual void next() {} - virtual void finish(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', @@ -747,16 +747,16 @@ write_delta_insns(delta_insns, out); } - virtual void copy(string::size_type old_pos, - 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(string const & str) - { + virtual void insert(string const & str) + { new_pos += str.size(); } }; @@ -794,22 +794,22 @@ boost::uniform_smallint xdelta_sizegen(xdelta_prng, 1024, 65536); boost::uniform_smallint xdelta_editgen(xdelta_prng, 3, 10); boost::uniform_smallint xdelta_lengen(xdelta_prng, 1, 256); -#define PRNG +#define PRNG #endif -void +void xdelta_random_string(string & str) { size_t sz = xdelta_sizegen(PRNG); str.clear(); - str.reserve(sz); + str.reserve(sz); while(sz-- > 0) { str += xdelta_chargen(PRNG); } } -void +void xdelta_randomly_insert(string & str) { size_t nedits = xdelta_editgen(PRNG); @@ -828,7 +828,7 @@ } } -void +void xdelta_randomly_change(string & str) { size_t nedits = xdelta_editgen(PRNG); @@ -844,7 +844,7 @@ } } -void +void xdelta_randomly_delete(string & str) { size_t nedits = xdelta_editgen(PRNG); @@ -859,7 +859,7 @@ } } -void +void xdelta_random_simple_delta_test() { for (int i = 0; i < 100; ++i) @@ -872,26 +872,26 @@ xdelta_randomly_delete(b); compute_delta(a, b, fdel); compute_delta(b, a, rdel); - L(FL("src %d, dst %d, fdel %d, rdel %d\n") + L(FL("src %d, dst %d, fdel %d, rdel %d") % a.size() % b.size()% fdel.size() % rdel.size()) ; if (fdel.size() == 0) { - L(FL("confirming src == dst and rdel == 0\n")); + L(FL("confirming src == dst and rdel == 0")); BOOST_CHECK(a == b); BOOST_CHECK(rdel.size() == 0); - } + } else { apply_delta(a, fdel, c); apply_delta(b, rdel, d); - L(FL("confirming dst1 %d, dst2 %d\n") % c.size() % d.size()); + L(FL("confirming dst1 %d, dst2 %d") % c.size() % d.size()); BOOST_CHECK(b == c); BOOST_CHECK(a == d); } } } -void +void add_xdelta_tests(test_suite * suite) { I(suite); ============================================================ --- xdelta.hh a6335a827b6d8ef7d7123d2cf7bacc83c63ead47 +++ xdelta.hh 5699839f590c4ce2585dc0ff89429437c59099e9 @@ -9,7 +9,7 @@ #include #include -void +void compute_delta(std::string const & a, std::string const & b, std::string & delta);