# # # patch "ChangeLog" # from [c88c3c75b6c954bde9a6d6b745c234b0aa89b950] # to [1dc063ed4c2cea74c955698bddbe353ed29a96dd] # # patch "cert.cc" # from [6e1ffc5b990cf82e6ee2a7d1492127b2f71aa105] # to [55d8e1bba7293f30447e0b095a3687aec5012cae] # # patch "cert.hh" # from [6ccf880b677340a2460ced453c93700b7bae07b3] # to [7fd1b8cafa9903cfb85096c35eb3c3fc81a27950] # # patch "charset.cc" # from [f55e73d42872fbbf269b3cd9f41af9217030f1a6] # to [14902c1707dc7419e76ce33d79e338e3e1cf21dd] # # patch "charset.hh" # from [e4f776a4afa20b3a770e0a6ac87824ebd24232ef] # to [020f1f2f1e84806b0f854067e8673d1ca990206f] # # patch "cleanup.hh" # from [a450ba2ba4311f0a298c1e102bd5c5f0c5fb2258] # to [988ba5a0718b4329477c239985624410af1b8424] # # patch "cmd.hh" # from [76fe4ececf8426484d8a4aca7c54237c49ce6100] # to [011931fc896ddad4191df829d098bd1c6160abf9] # # patch "cmd_automate.cc" # from [37baff9dc561c7fad66b88559fda15b14f2a4f55] # to [f15afa4d2da31e9aa10bbfe6cef515774a12d274] # # patch "cmd_db.cc" # from [7403b1a1bb54a12e01dee5fcbbc3db7aaf8ba557] # to [d548a1b04279282574eb36cda7e014f2ea2af2a6] # # patch "cmd_diff_log.cc" # from [c2d375111f402eac0c82134f174627d88608dcb0] # to [33b0edc161f98dee63891225132d6276c9909e7d] # # patch "cmd_files.cc" # from [22b692fc7848cf47a7572d4df48b0ffeeaa56c5c] # to [06a9ad1c80d6604a4d1a1414ebbce0c1790d2924] # # patch "cmd_key_cert.cc" # from [4f07a55505d99f4a1680313d47e7a813a4bd1517] # to [b965380d94873ec7db8d59d0795151d2d02eb9e9] # # patch "cmd_list.cc" # from [5edf0ae19d13ccc9d25490eb64576bff4ad907ca] # to [88ec6d14089ab074f8eb702f6e16f39a1399be53] # # patch "cmd_merging.cc" # from [6745bfc6317dad3cf1828d17600aca164accf0e5] # to [78a4f272c04de0799fca5e16a2262536fce14e7a] # # patch "cmd_othervcs.cc" # from [47651b6f63bd48be121a30eec4d1746238151fd2] # to [5666f47510818cfd78256dbf3696b49090b9c877] # # patch "cmd_packet.cc" # from [0d127531d08a403249ba6fea64f09ee1fd0546e3] # to [3ecd60dca3061099e393d432707a9bf82d3793e9] # # patch "cmd_ws_commit.cc" # from [b334deaf56946d327559cb7db10fc82de170da5c] # to [6afeacc30eb66fab0b3d6ba7494a01358a26bb7b] # ============================================================ --- ChangeLog c88c3c75b6c954bde9a6d6b745c234b0aa89b950 +++ ChangeLog 1dc063ed4c2cea74c955698bddbe353ed29a96dd @@ -1,3 +1,8 @@ +2006-06-03 Graydon Hoare + + * {cert,charset,cleanup,cmd*}.{cc,hh}: Coppyright and formatting + fixes. + 2006-06-01 Matthew Gregan * visualc/monotone.vcproj: Add win32/os_strerror.cc to project. ============================================================ --- cert.cc 6e1ffc5b990cf82e6ee2a7d1492127b2f71aa105 +++ cert.cc 55d8e1bba7293f30447e0b095a3687aec5012cae @@ -1,22 +1,16 @@ -// -*- mode: C++; c-file-style: "gnu"; indent-tabs-mode: nil -*- -// 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 +// Copyright (C) 2002 Graydon Hoare +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. -#include "constants.hh" -#include "cert.hh" -#include "packet.hh" -#include "app_state.hh" -#include "interner.hh" -#include "keys.hh" -#include "netio.hh" -#include "sanity.hh" -#include "transforms.hh" -#include "simplestring_xform.hh" -#include "ui.hh" -#include "options.hh" -#include "revision.hh" +#include +#include +#include +#include #include #include @@ -25,10 +19,19 @@ #include #include -#include -#include -#include -#include +#include "app_state.hh" +#include "cert.hh" +#include "constants.hh" +#include "interner.hh" +#include "keys.hh" +#include "netio.hh" +#include "options.hh" +#include "packet.hh" +#include "revision.hh" +#include "sanity.hh" +#include "simplestring_xform.hh" +#include "transforms.hh" +#include "ui.hh" using std::make_pair; using std::map; @@ -42,7 +45,9 @@ using boost::tuple; using boost::lexical_cast; -// The alternaive is to #include "cert.hh" in vocab.*, which is even uglier. +// The alternaive is to #include "cert.hh" in vocab.*, which is even +// uglier. + #include "vocab_macros.hh" cc_DECORATE(revision) cc_DECORATE(manifest) @@ -74,7 +79,8 @@ { 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'\n") + % c.key() % txt); return true; } else @@ -82,7 +88,8 @@ 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'\n") + % c.key() % txt); return true; } } @@ -109,14 +116,17 @@ vector< manifest > tmp_certs; - // sorry, this is a crazy data structure + // Sorry, this is a crazy data structure typedef tuple< hexenc, cert_name, base64 > trust_key; - typedef map< trust_key, pair< shared_ptr< set >, it > > trust_map; + typedef map< trust_key, + pair< shared_ptr< set >, it > > trust_map; trust_map trust; for (it i = certs.begin(); i != certs.end(); ++i) { - trust_key key = trust_key(i->inner().ident, i->inner().name, i->inner().value); + trust_key key = trust_key(i->inner().ident, + i->inner().name, + i->inner().value); trust_map::iterator j = trust.find(key); shared_ptr< set > s; if (j == trust.end()) @@ -139,14 +149,20 @@ get<1>(i->first), decoded_value)) { - L(FL("trust function liked %d signers of %s cert on manifest %s\n") - % i->second.first->size() % get<1>(i->first) % get<0>(i->first)); + L(FL("trust function liked %d signers of %s " + "cert on manifest %s\n") + % 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") - % i->second.first->size() % get<1>(i->first) % get<0>(i->first)); + W(F("trust function disliked %d signers of %s " + "cert on manifest %s\n") + % i->second.first->size() + % get<1>(i->first) + % get<0>(i->first)); } } certs = tmp_certs; @@ -163,13 +179,17 @@ vector< revision > tmp_certs; // sorry, this is a crazy data structure - typedef tuple< hexenc, cert_name, base64 > trust_key; - typedef map< trust_key, pair< shared_ptr< set >, it > > trust_map; + typedef tuple< hexenc, + cert_name, base64 > trust_key; + typedef map< trust_key, + pair< shared_ptr< set >, it > > trust_map; trust_map trust; for (it i = certs.begin(); i != certs.end(); ++i) { - trust_key key = trust_key(i->inner().ident, i->inner().name, i->inner().value); + trust_key key = trust_key(i->inner().ident, + i->inner().name, + i->inner().value); trust_map::iterator j = trust.find(key); shared_ptr< set > s; if (j == trust.end()) @@ -192,14 +212,20 @@ get<1>(i->first), decoded_value)) { - L(FL("trust function liked %d signers of %s cert on revision %s\n") - % i->second.first->size() % get<1>(i->first) % get<0>(i->first)); + L(FL("trust function liked %d signers of %s " + "cert on revision %s\n") + % 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") - % i->second.first->size() % get<1>(i->first) % get<0>(i->first)); + W(F("trust function disliked %d signers of %s " + "cert on revision %s\n") + % i->second.first->size() + % get<1>(i->first) + % get<0>(i->first)); } } certs = tmp_certs; @@ -212,17 +238,17 @@ {} cert::cert(hexenc const & ident, - cert_name const & name, - base64 const & value, - rsa_keypair_id const & key) + cert_name const & name, + base64 const & value, + rsa_keypair_id const & key) : ident(ident), name(name), value(value), key(key) {} cert::cert(hexenc const & ident, - cert_name const & name, - base64 const & value, - rsa_keypair_id const & key, - base64 const & sig) + cert_name const & name, + base64 const & value, + rsa_keypair_id const & key, + base64 const & sig) : ident(ident), name(name), value(value), key(key), sig(sig) {} @@ -236,7 +262,8 @@ || ((((ident == other.ident) && name == other.name) && value == other.value) && key < other.key) || (((((ident == other.ident) && name == other.name) - && value == other.value) && key == other.key) && sig < other.sig); + && value == other.value) && key == other.key) + && sig < other.sig); } bool @@ -250,7 +277,7 @@ && (sig == other.sig); } -// netio support +// Netio support. void read_cert(string const & in, cert & t) @@ -318,9 +345,10 @@ void cert_signable_text(cert const & t, - string & out) + string & out) { - out = (FL("address@hidden:%s]") % t.name % t.ident % remove_ws(t.value())).str(); + out = (FL("address@hidden:%s]") + % t.name % t.ident % remove_ws(t.value())).str(); L(FL("cert: signable text %s\n") % out); } @@ -346,6 +374,7 @@ // Loads a key pair for a given key id, from either a lua hook // or the key store. This will bomb out if the same keyid exists // in both with differing contents. + void load_key_pair(app_state & app, rsa_keypair_id const & id, @@ -355,7 +384,6 @@ static map keys; bool persist_ok = (!keys.empty()) || app.lua.hook_persist_phrase_ok(); - if (persist_ok && keys.find(id) != keys.end()) { kp = keys[id]; @@ -440,11 +468,13 @@ vector all_privkeys; app.keys.get_keys(all_privkeys); - N(!all_privkeys.empty(), F("you have no private key to make signatures with\n" - "perhaps you need to 'genkey '")); + N(!all_privkeys.empty(), + F("you have no private key to make signatures with\n" + "perhaps you need to 'genkey '")); N(all_privkeys.size() == 1, F("you have multiple private keys\n" - "pick one to use for signatures by adding '-k' to your command")); + "pick one to use for signatures " + "by adding '-k' to your command")); key = all_privkeys[0]; } @@ -453,7 +483,8 @@ app_state & app, cert_value & branchname) { - if ((app.branch_name() != "") && app.is_explicit_option(OPT_BRANCH_NAME)) + if ((app.branch_name() != "") + && app.is_explicit_option(OPT_BRANCH_NAME)) { branchname = app.branch_name(); } @@ -499,10 +530,10 @@ static void put_simple_revision_cert(revision_id const & id, - cert_name const & nm, - cert_value const & val, - app_state & app, - packet_consumer & pc) + cert_name const & nm, + cert_value const & val, + app_state & app, + packet_consumer & pc) { cert t; make_simple_cert(id.inner(), nm, val, app, t); @@ -512,12 +543,12 @@ void cert_revision_in_branch(revision_id const & rev, - cert_value const & branchname, - app_state & app, - packet_consumer & pc) + cert_value const & branchname, + app_state & app, + packet_consumer & pc) { put_simple_revision_cert (rev, branch_cert_name, - branchname, app, pc); + branchname, app, pc); } void @@ -564,26 +595,31 @@ put_simple_revision_cert(m, date_cert_name, val, app, pc); } + 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::seconds(static_cast(t))); + // Make sure you do all your CVS conversions by 2038! + 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, app_state & app, packet_consumer & pc) { - cert_revision_date_time(m, boost::posix_time::second_clock::universal_time(), app, pc); + cert_revision_date_time + (m, boost::posix_time::second_clock::universal_time(), app, pc); } + void cert_revision_author(revision_id const & m, string const & author, @@ -594,6 +630,7 @@ author, app, pc); } + void cert_revision_author_default(revision_id const & m, app_state & app, @@ -604,11 +641,12 @@ { rsa_keypair_id key; get_user_key(key, app), - author = key(); + author = key(); } cert_revision_author(m, author, app, pc); } + void cert_revision_tag(revision_id const & m, string const & tagname, @@ -630,6 +668,7 @@ changelog, app, pc); } + void cert_revision_comment(revision_id const & m, string const & comment, @@ -640,6 +679,7 @@ comment, app, pc); } + void cert_revision_testresult(revision_id const & r, string const & results, @@ -658,9 +698,12 @@ results == "0") passed = false; else - throw informative_failure("could not interpret test results, tried '0/1' 'yes/no', 'true/false', 'pass/fail'"); + 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); } @@ -668,3 +711,11 @@ #include "unit_tests.hh" #endif // BUILD_UNIT_TESTS + +// Local Variables: +// mode: C++ +// fill-column: 76 +// 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: ============================================================ --- cert.hh 6ccf880b677340a2460ced453c93700b7bae07b3 +++ cert.hh 7fd1b8cafa9903cfb85096c35eb3c3fc81a27950 @@ -1,27 +1,30 @@ #ifndef __CERT_HH__ #define __CERT_HH__ -// 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 +// Copyright (C) 2002 Graydon Hoare +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. -#include "vocab.hh" - +#include #include -#include #include -#include + #include +#include +#include "vocab.hh" +// Certs associate an opaque name/value pair with a revision ID, and +// are accompanied by an RSA public-key signature attesting to the +// association. Users can write as much extra meta-data as they like +// about revisions, using certs, without needing anyone's special +// permission. -// certs associate an opaque name/value pair with a particular identifier in -// the system (eg. a manifest or file id) and are accompanied by an RSA -// public-key signature attesting to the association. users can write as -// much extra meta-data as they like about files or manifests, using certs, -// without needing anyone's special permission. - class app_state; struct packet_consumer; @@ -50,7 +53,7 @@ EXTERN template class manifest; -// these 3 are for netio support +// These 3 are for netio support. void read_cert(std::string const & in, cert & t); void write_cert(cert const & t, std::string & out); void cert_hash_code(cert const & t, hexenc & out); @@ -76,7 +79,7 @@ void erase_bogus_certs(std::vector< manifest > & certs, app_state & app); -// special certs -- system won't work without them +// Special certs -- system won't work without them. extern std::string const branch_cert_name; @@ -91,7 +94,7 @@ app_state & app, std::set & heads); -// we also define some common cert types, to help establish useful +// We also define some common cert types, to help establish useful // conventions. you should use these unless you have a compelling // reason not to. ============================================================ --- charset.cc f55e73d42872fbbf269b3cd9f41af9217030f1a6 +++ charset.cc 14902c1707dc7419e76ce33d79e338e3e1cf21dd @@ -1,21 +1,30 @@ +// Copyright (C) 2002 Graydon Hoare +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. + #include #include +#include "idna/idna.h" +#include "idna/stringprep.h" + #include "charset.hh" +#include "numeric_vocab.hh" #include "sanity.hh" #include "simplestring_xform.hh" -#include "numeric_vocab.hh" -#include "idna/idna.h" -#include "idna/stringprep.h" - using std::string; using std::vector; using boost::char_separator; -// general character code conversion routines +// General character code conversion routines. static string system_charset() ============================================================ --- charset.hh e4f776a4afa20b3a770e0a6ac87824ebd24232ef +++ charset.hh 020f1f2f1e84806b0f854067e8673d1ca990206f @@ -1,11 +1,23 @@ #ifndef __CHARSET_HH__ #define __CHARSET_HH__ +// Copyright (C) 2002 Graydon Hoare +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. + #include "vocab.hh" -// charset conversions -void charset_convert(std::string const & src_charset, std::string const & dst_charset, - std::string const & src, std::string & dst); +// Charset conversions. + +void charset_convert(std::string const & src_charset, + std::string const & dst_charset, + std::string const & src, + std::string & dst); void system_to_utf8(external const & system, utf8 & utf); void utf8_to_system(utf8 const & utf, external & system); void utf8_to_system(utf8 const & utf, std::string & system); @@ -13,10 +25,10 @@ void utf8_to_ace(utf8 const & utf, ace & a); bool utf8_validate(utf8 const & utf); -// returns length in characters (not bytes) +// Returns length in characters (not bytes). size_t display_width(utf8 const & utf); -// specific internal / external conversions for various vocab terms +// Specific internal / external conversions for various vocab terms. void internalize_cert_name(utf8 const & utf, cert_name & c); void internalize_cert_name(external const & ext, cert_name & c); void externalize_cert_name(cert_name const & c, utf8 & utf); ============================================================ --- cleanup.hh a450ba2ba4311f0a298c1e102bd5c5f0c5fb2258 +++ cleanup.hh 988ba5a0718b4329477c239985624410af1b8424 @@ -1,13 +1,17 @@ #ifndef __CLEANUP_HH__ #define __CLEANUP_HH__ -// 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 +// Copyright (C) 2002 Graydon Hoare +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. -// this is a little "auto-cleanup" container, used to ensure things -// from librsync, sqlite, etc. are deallocated when we leave a scope. +// This is a little "auto-cleanup" container, used to ensure things +// from our helper C libraries are deallocated when we leave a scope. template struct cleanup_ptr { @@ -19,10 +23,12 @@ if (cleanup && ptr) cleanup(ptr); } + T operator()() { return ptr; } + T * paddr() { return &ptr; ============================================================ --- cmd.hh 76fe4ececf8426484d8a4aca7c54237c49ce6100 +++ cmd.hh 011931fc896ddad4191df829d098bd1c6160abf9 @@ -1,12 +1,20 @@ #ifndef __CMD_HH__ #define __CMD_HH__ -#include "sanity.hh" -#include "options.hh" -#include "constants.hh" +// Copyright (C) 2002 Graydon Hoare +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. + #include "app_state.hh" - #include "commands.hh" +#include "constants.hh" +#include "options.hh" +#include "sanity.hh" namespace commands { @@ -26,9 +34,9 @@ struct command { - // NB: these strings are stred _un_translated - // because we cannot translate them until after main starts, by which time - // the command objects have all been constructed. + // NB: these strings are stored _un_translated, because we cannot + // translate them until after main starts, by which time the + // command objects have all been constructed. std::string name; std::string cmdgroup; std::string params; @@ -42,7 +50,8 @@ bool u, command_opts const & o); virtual ~command(); - virtual void exec(app_state & app, std::vector const & args) = 0; + virtual void exec(app_state & app, + std::vector const & args) = 0; }; }; @@ -84,7 +93,9 @@ F("partial id '%s' does not have an expansion") % str); if (completions.size() > 1) { - std::string err = (F("partial id '%s' has multiple ambiguous expansions:\n") % str).str(); + std::string err = + (F("partial id '%s' has multiple ambiguous expansions:\n") + % str).str(); for (typename std::set::const_iterator i = completions.begin(); i != completions.end(); ++i) err += (i->inner()() + "\n"); @@ -121,8 +132,9 @@ void commands::cmd_ ## C::exec(app_state & app, \ std::vector const & args) \ -// use this for commands that should specifically _not_ look for an _MTN dir -// and load options from it +// Use this for commands that should specifically _not_ look for an +// _MTN dir and load options from it. + #define CMD_NO_WORKSPACE(C, group, params, desc, opts) \ namespace commands { \ struct cmd_ ## C : public command \ @@ -143,7 +155,7 @@ realcommand##_cmd.desc + "\nAlias for " #realcommand, \ realcommand##_cmd.options) \ { \ - process(app, std::string(#realcommand), args); \ + process(app, std::string(#realcommand), args); \ } #endif ============================================================ --- cmd_automate.cc 37baff9dc561c7fad66b88559fda15b14f2a4f55 +++ cmd_automate.cc f15afa4d2da31e9aa10bbfe6cef515774a12d274 @@ -1,9 +1,17 @@ -#include "cmd.hh" +// Copyright (C) 2002 Graydon Hoare +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. -#include "automate.hh" - #include +#include "automate.hh" +#include "cmd.hh" + using std::cout; using std::vector; @@ -50,3 +58,11 @@ automate_command(cmd, cmd_args, name, app, cout); } + +// Local Variables: +// mode: C++ +// fill-column: 76 +// 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: ============================================================ --- cmd_db.cc 7403b1a1bb54a12e01dee5fcbbc3db7aaf8ba557 +++ cmd_db.cc d548a1b04279282574eb36cda7e014f2ea2af2a6 @@ -1,11 +1,20 @@ -#include "cmd.hh" -#include "revision.hh" -#include "database_check.hh" -#include "charset.hh" +// Copyright (C) 2002 Graydon Hoare +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. #include #include +#include "charset.hh" +#include "cmd.hh" +#include "database_check.hh" +#include "revision.hh" + using std::cin; using std::cout; using std::make_pair; @@ -13,8 +22,10 @@ using std::set; using std::string; -// Deletes a revision from the local database. This can be used to 'undo' a -// changed revision from a local database without leaving (much of) a trace. +// Deletes a revision from the local database. This can be used to +// 'undo' a changed revision from a local database without leaving +// (much of) a trace. + static void kill_rev_locally(app_state& app, string const& id) { @@ -34,19 +45,19 @@ CMD(db, N_("database"), N_("init\n" - "info\n" - "version\n" - "dump\n" - "load\n" - "migrate\n" - "execute\n" - "kill_rev_locally ID\n" - "kill_branch_certs_locally BRANCH\n" - "kill_tag_locally TAG\n" - "check\n" - "changesetify\n" - "rosterify\n" - "set_epoch BRANCH EPOCH\n"), + "info\n" + "version\n" + "dump\n" + "load\n" + "migrate\n" + "execute\n" + "kill_rev_locally ID\n" + "kill_branch_certs_locally BRANCH\n" + "kill_tag_locally TAG\n" + "check\n" + "changesetify\n" + "rosterify\n" + "set_epoch BRANCH EPOCH\n"), N_("manipulate database state"), OPT_DROP_ATTR) { @@ -94,7 +105,8 @@ { epoch_data ed(idx(args,2)()); N(ed.inner()().size() == constants::epochlen, - F("The epoch must be %s characters") % constants::epochlen); + F("The epoch must be %s characters") + % constants::epochlen); app.db.set_epoch(cert_value(idx(args, 1)()), ed); } else @@ -132,7 +144,8 @@ internalize_var_domain(idx(args, 0), d); n = var_name(idx(args, 1)()); var_key k(d, n); - N(app.db.var_exists(k), F("no var with name %s in domain %s") % n % d); + N(app.db.var_exists(k), + F("no var with name %s in domain %s") % n % d); app.db.clear_var(k); } @@ -184,3 +197,10 @@ throw usage(name); } +// Local Variables: +// mode: C++ +// fill-column: 76 +// 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: ============================================================ --- cmd_diff_log.cc c2d375111f402eac0c82134f174627d88608dcb0 +++ cmd_diff_log.cc 33b0edc161f98dee63891225132d6276c9909e7d @@ -1,16 +1,25 @@ +// Copyright (C) 2002 Graydon Hoare +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. + +#include +#include +#include +#include + #include "cmd.hh" #include "diff_patch.hh" +#include "localized_file_io.hh" +#include "restrictions.hh" #include "revision.hh" -#include "transforms.hh" #include "simplestring_xform.hh" -#include "restrictions.hh" -#include "localized_file_io.hh" +#include "transforms.hh" -#include -#include -#include -#include - using std::cout; using std::deque; using std::make_pair; @@ -113,13 +122,15 @@ for (map::const_iterator i = cs.nodes_renamed.begin(); i != cs.nodes_renamed.end(); i++) - os << " " << file_path(i->first) << " to " << file_path(i->second) << "\n"; + os << " " << file_path(i->first) + << " to " << file_path(i->second) << "\n"; } if (! cs.files_added.empty()) { path_set tmp; - for (map::const_iterator i = cs.files_added.begin(); + for (map::const_iterator + i = cs.files_added.begin(); i != cs.files_added.end(); ++i) tmp.insert(i->first); os << "Added files:" << "\n"; @@ -135,7 +146,8 @@ if (! cs.deltas_applied.empty()) { path_set tmp; - for (map >::const_iterator i = cs.deltas_applied.begin(); + for (map >::const_iterator + i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) tmp.insert(i->first); os << "Modified files:" << "\n"; @@ -145,11 +157,13 @@ if (! cs.attrs_set.empty() || ! cs.attrs_cleared.empty()) { path_set tmp; - for (set >::const_iterator i = cs.attrs_cleared.begin(); + for (set >::const_iterator + i = cs.attrs_cleared.begin(); i != cs.attrs_cleared.end(); ++i) tmp.insert(i->first); - for (map, attr_value>::const_iterator i = cs.attrs_set.begin(); + for (map, attr_value>::const_iterator + i = cs.attrs_set.begin(); i != cs.attrs_set.end(); ++i) tmp.insert(i->first.first); @@ -243,8 +257,10 @@ 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) + 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()); for (vector::const_iterator j = lines.begin(); j != lines.end(); ++j) @@ -294,7 +310,9 @@ if (guess_binary(data_new()) || guess_binary(data_old())) - cout << "# " << file_path(delta_entry_path(i)) << " is binary\n"; + cout << "# " + << file_path(delta_entry_path(i)) + << " is binary\n"; else { split_into_lines(data_old(), old_lines); @@ -331,9 +349,10 @@ 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" - "them is given. If no format is specified, unified is used by default."), + "If one revision is given, the diff between the workspace and\n" + "that revision is shown. If two revisions are given, the diff\n" + "between them is given. If no format is specified, unified\n" + "is used by default."), OPT_REVISION % OPT_DEPTH % OPT_EXCLUDE % OPT_UNIFIED_DIFF % OPT_CONTEXT_DIFF % OPT_EXTERNAL_DIFF % OPT_EXTERNAL_DIFF_ARGS) @@ -350,7 +369,7 @@ cset included, excluded; - // initialize before transaction so we have a database to work with + // initialize before transaction so we have a database to work with. if (app.revision_selectors.size() == 0) app.require_workspace(); @@ -362,13 +381,16 @@ roster_t new_roster, old_roster; revision_id old_rid; - get_base_and_current_roster_shape(old_roster, new_roster, nis, app); + get_base_and_current_roster_shape(old_roster, new_roster, + nis, app); get_revision_id(old_rid); - restriction mask(args, app.exclude_patterns, old_roster, new_roster, 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); + make_restricted_csets(old_roster, new_roster, + included, excluded, mask); check_restricted_cset(old_roster, included); new_is_archived = false; @@ -383,17 +405,22 @@ N(app.db.revision_exists(r_old_id), F("no such revision '%s'") % r_old_id); - get_base_and_current_roster_shape(old_roster, new_roster, nis, app); + get_base_and_current_roster_shape(old_roster, + new_roster, + nis, app); // Clobber old_roster with the one specified app.db.get_roster(r_old_id, old_roster); // FIXME: handle no ancestor case - // N(r_new.edges.size() == 1, F("current revision has no ancestor")); + // N(r_new.edges.size() == 1, + // F("current revision has no ancestor")); - restriction mask(args, app.exclude_patterns, old_roster, new_roster, 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); + make_restricted_csets(old_roster, new_roster, + included, excluded, mask); check_restricted_cset(old_roster, included); new_is_archived = false; @@ -415,19 +442,20 @@ app.db.get_roster(r_old_id, old_roster); app.db.get_roster(r_new_id, new_roster); - restriction mask(args, app.exclude_patterns, old_roster, new_roster, app); + 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 - // 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; - // discuss implications first. + // 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 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; discuss + // implications first. // - // let the discussion begin... + // Let the discussion begin... // // - "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 @@ -439,7 +467,8 @@ // (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); + make_restricted_csets(old_roster, new_roster, + included, excluded, mask); check_restricted_cset(old_roster, included); new_is_archived = true; @@ -459,7 +488,8 @@ if (summary().size() > 0) { cout << header.str() << "# " << "\n"; - for (vector::iterator i = lines.begin(); i != lines.end(); ++i) + for (vector::iterator i = lines.begin(); + i != lines.end(); ++i) cout << "# " << *i << "\n"; } else @@ -516,7 +546,8 @@ } static void -log_certs(app_state & app, revision_id id, cert_name name, string label, bool multiline) +log_certs(app_state & app, revision_id id, cert_name name, + string label, bool multiline) { log_certs(app, id, name, label, label, multiline, true); } @@ -528,10 +559,11 @@ } CMD(log, N_("informative"), N_("[FILE] ..."), - N_("print history in reverse order (filtering by 'FILE'). If one or more\n" - "revisions are given, use them as a starting point."), - OPT_LAST % OPT_NEXT % OPT_REVISION % OPT_BRIEF % OPT_DIFFS % OPT_NO_MERGES % - OPT_NO_FILES) + N_("print history in reverse order (filtering by 'FILE'). " + "If one or more revisions are given, " + "use them as a starting point."), + OPT_LAST % OPT_NEXT % OPT_REVISION % OPT_BRIEF % OPT_DIFFS + % OPT_NO_MERGES % OPT_NO_FILES) { if (app.revision_selectors.size() == 0) app.require_workspace("try passing a --revision to start at"); @@ -547,7 +579,8 @@ } else { - for (vector::const_iterator i = app.revision_selectors.begin(); + for (vector::const_iterator + i = app.revision_selectors.begin(); i != app.revision_selectors.end(); i++) { set rids; @@ -566,12 +599,15 @@ roster_t old_roster, new_roster; if (app.revision_selectors.size() == 0) - get_base_and_current_roster_shape(old_roster, new_roster, nis, app); + get_base_and_current_roster_shape(old_roster, + new_roster, nis, app); else 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); + // FIXME_RESTRICTIONS: should this add paths from the rosters of + // all selected revs? + mask = restriction(args, app.exclude_patterns, + old_roster, new_roster, app); } @@ -591,7 +627,8 @@ revision_set rev; - while(! frontier.empty() && (last == -1 || last > 0) && (next == -1 || next > 0)) + while(! frontier.empty() && (last == -1 || last > 0) + && (next == -1 || next > 0)) { set next_frontier; @@ -613,8 +650,9 @@ if (!mask.empty()) { - // 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 + // 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); @@ -623,7 +661,8 @@ 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)) @@ -674,8 +713,7 @@ } else { - cout << "-----------------------------------------------------------------" - << "\n"; + cout << string(65, '-') << "\n"; cout << "Revision: " << rid << "\n"; changes_summary csum; @@ -689,7 +727,8 @@ csum.add_change_set(edge_changes(e)); } - for (set::const_iterator anc = ancestors.begin(); + for (set::const_iterator + anc = ancestors.begin(); anc != ancestors.end(); ++anc) cout << "Ancestor: " << *anc << "\n"; @@ -734,3 +773,10 @@ } } +// Local Variables: +// mode: C++ +// fill-column: 76 +// 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: ============================================================ --- cmd_files.cc 22b692fc7848cf47a7572d4df48b0ffeeaa56c5c +++ cmd_files.cc 06a9ad1c80d6604a4d1a1414ebbce0c1790d2924 @@ -1,14 +1,22 @@ -#include "cmd.hh" +// Copyright (C) 2002 Graydon Hoare +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. -#include "transforms.hh" -#include "simplestring_xform.hh" -#include "packet.hh" +#include + #include "annotate.hh" +#include "cmd.hh" #include "diff_patch.hh" #include "localized_file_io.hh" +#include "packet.hh" +#include "simplestring_xform.hh" +#include "transforms.hh" -#include - using std::cout; using std::ostream_iterator; using std::string; @@ -37,17 +45,21 @@ if (args.size() != 3) throw usage(name); - file_id anc_id(idx(args, 0)()), left_id(idx(args, 1)()), right_id(idx(args, 2)()); + file_id + anc_id(idx(args, 0)()), + left_id(idx(args, 1)()), + right_id(idx(args, 2)()); + file_data anc, left, right; N(app.db.file_version_exists (anc_id), - F("ancestor file id does not exist")); + F("ancestor file id does not exist")); N(app.db.file_version_exists (left_id), - F("left file id does not exist")); + F("left file id does not exist")); N(app.db.file_version_exists (right_id), - F("right file id does not exist")); + F("right file id does not exist")); app.db.get_file_version(anc_id, anc); app.db.get_file_version(left_id, left); @@ -58,8 +70,10 @@ split_into_lines(anc.inner()(), anc_lines); split_into_lines(left.inner()(), left_lines); 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")); + N(merge3(anc_lines, left_lines, right_lines, merged_lines), + F("merge failed")); + copy(merged_lines.begin(), merged_lines.end(), + ostream_iterator(cout, "\n")); } @@ -84,8 +98,10 @@ 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); + 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); @@ -93,9 +109,11 @@ roster_t roster; marking_map marks; app.db.get_roster(rid, roster, marks); - N(roster.has_node(sp), F("no such file '%s' in revision '%s'") % file % rid); + N(roster.has_node(sp), + F("no such file '%s' in revision '%s'") % file % rid); node_t node = roster.get_node(sp); - N(is_file_t(node), F("'%s' in revision '%s' is not a file") % file % rid); + 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); @@ -113,7 +131,8 @@ if (args.size() == 1) { - read_localized_data(file_path_external(idx(args, 0)), dat, app.lua); + read_localized_data(file_path_external(idx(args, 0)), + dat, app.lua); } else { @@ -143,10 +162,11 @@ get_revision_id(rid); else complete(app, idx(app.revision_selectors, 0)(), rid); - N(app.db.revision_exists(rid), F("no such revision '%s'") % rid); + N(app.db.revision_exists(rid), + F("no such revision '%s'") % rid); - // paths are interpreted as standard external ones when we're in a - // workspace, but as project-rooted external ones otherwise + // Paths are interpreted as standard external ones when we're in a + // workspace, but as project-rooted external ones otherwise. file_path fp; split_path sp; fp = file_path_external(idx(args, 0)); @@ -155,9 +175,11 @@ 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'\n") % 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'\n") % fp % rid); file_t file_node = downcast_to_file_t(node); file_id ident = file_node->content; @@ -168,3 +190,11 @@ guard.commit(); } + +// Local Variables: +// mode: C++ +// fill-column: 76 +// 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: ============================================================ --- cmd_key_cert.cc 4f07a55505d99f4a1680313d47e7a813a4bd1517 +++ cmd_key_cert.cc b965380d94873ec7db8d59d0795151d2d02eb9e9 @@ -1,21 +1,30 @@ -#include "cmd.hh" +// Copyright (C) 2002 Graydon Hoare +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. -#include "keys.hh" +#include +#include + #include "cert.hh" -#include "transforms.hh" #include "charset.hh" +#include "cmd.hh" +#include "keys.hh" #include "packet.hh" +#include "transforms.hh" -#include -#include - using std::cout; using std::ostream_iterator; using std::ostringstream; using std::set; using std::string; -CMD(genkey, N_("key and cert"), N_("KEYID"), N_("generate an RSA key-pair"), OPT_NONE) +CMD(genkey, N_("key and cert"), N_("KEYID"), + N_("generate an RSA key-pair"), OPT_NONE) { if (args.size() != 1) throw usage(name); @@ -35,11 +44,13 @@ keypair kp; P(F("generating key-pair '%s'") % ident); generate_key_pair(app.lua, ident, kp); - P(F("storing key-pair '%s' in %s/") % ident % app.keys.get_key_dir()); + P(F("storing key-pair '%s' in %s/") + % ident % app.keys.get_key_dir()); app.keys.put_key_pair(ident, kp); } -CMD(dropkey, N_("key and cert"), N_("KEYID"), N_("drop a public and private key"), OPT_NONE) +CMD(dropkey, N_("key and cert"), N_("KEYID"), + N_("drop a public and private key"), OPT_NONE) { bool key_deleted = false; @@ -70,9 +81,11 @@ i18n_format fmt; if (checked_db) - fmt = F("public or private key '%s' does not exist in keystore or database"); + fmt = F("public or private key '%s' does not exist " + "in keystore or database"); else - fmt = F("public or private key '%s' does not exist in keystore, and no database was specified"); + fmt = F("public or private key '%s' does not exist " + "in keystore, and no database was specified"); N(key_deleted, fmt % idx(args, 0)()); } @@ -133,9 +146,10 @@ guard.commit(); } -CMD(trusted, N_("key and cert"), N_("REVISION NAME VALUE SIGNER1 [SIGNER2 [...]]"), +CMD(trusted, N_("key and cert"), + N_("REVISION NAME VALUE SIGNER1 [SIGNER2 [...]]"), N_("test whether a hypothetical cert would be trusted\n" - "by current settings"), + "by current settings"), OPT_NONE) { if (args.size() < 4) @@ -192,7 +206,8 @@ } -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) @@ -243,3 +258,10 @@ cert_revision_comment(r, comment, app, dbw); } +// Local Variables: +// mode: C++ +// fill-column: 76 +// 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: ============================================================ --- cmd_list.cc 5edf0ae19d13ccc9d25490eb64576bff4ad907ca +++ cmd_list.cc 88ec6d14089ab074f8eb702f6e16f39a1399be53 @@ -1,21 +1,29 @@ -#include "cmd.hh" +// Copyright (C) 2002 Graydon Hoare +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. +#include +#include +#include +#include + +#include "cert.hh" +#include "charset.hh" +#include "cmd.hh" +#include "database.hh" #include "globish.hh" +#include "keys.hh" #include "restrictions.hh" #include "revision.hh" -#include "transforms.hh" #include "simplestring_xform.hh" -#include "charset.hh" -#include "database.hh" +#include "transforms.hh" #include "ui.hh" -#include "keys.hh" -#include "cert.hh" -#include -#include -#include -#include - using std::cout; using std::make_pair; using std::map; @@ -27,7 +35,8 @@ using std::vector; static void -ls_certs(string const & name, app_state & app, vector const & args) +ls_certs(string const & name, app_state & app, + vector const & args) { if (args.size() != 1) throw usage(name); @@ -55,8 +64,8 @@ } } - // Make the output deterministic; this is useful for the test suite, in - // particular. + // Make the output deterministic; this is useful for the test suite, + // in particular. sort(certs.begin(), certs.end()); string str = _("Key : %s\n" @@ -125,7 +134,8 @@ } static void -ls_keys(string const & name, app_state & app, vector const & args) +ls_keys(string const & name, app_state & app, + vector const & args) { vector pubs; vector privkeys; @@ -186,7 +196,8 @@ cout << hash_code << " " << keyid << " (*)" << "\n"; } if (!all_in_db) - cout << F("(*) - only in %s/") % app.keys.get_key_dir() << "\n"; + cout << (F("(*) - only in %s/") + % app.keys.get_key_dir()) << "\n"; cout << "\n"; } @@ -216,7 +227,8 @@ } static void -ls_branches(string name, app_state & app, vector const & args) +ls_branches(string name, app_state & app, + vector const & args) { utf8 inc("*"); utf8 exc; @@ -231,19 +243,22 @@ sort(names.begin(), names.end()); for (size_t i = 0; i < names.size(); ++i) - if (match(idx(names, i)) && !app.lua.hook_ignore_branch(idx(names, i))) + if (match(idx(names, i)) + && !app.lua.hook_ignore_branch(idx(names, i))) cout << idx(names, i) << "\n"; } static void -ls_epochs(string name, app_state & app, vector const & args) +ls_epochs(string name, app_state & app, + vector const & args) { map epochs; app.db.get_epochs(epochs); if (args.size() == 0) { - for (map::const_iterator i = epochs.begin(); + for (map::const_iterator + i = epochs.begin(); i != epochs.end(); ++i) { cout << i->second << " " << i->first << "\n"; @@ -251,10 +266,12 @@ } else { - for (vector::const_iterator i = args.begin(); i != args.end(); + for (vector::const_iterator i = args.begin(); + i != args.end(); ++i) { - map::const_iterator j = epochs.find(cert_value((*i)())); + map::const_iterator + j = epochs.find(cert_value((*i)())); N(j != epochs.end(), F("no epoch for branch %s\n") % *i); cout << j->second << " " << j->first << "\n"; } @@ -267,7 +284,8 @@ vector< revision > certs; app.db.get_revision_certs(tag_cert_name, certs); - set< pair > > sorted_vals; + set< pair > > + sorted_vals; for (vector< revision >::const_iterator i = certs.begin(); i != certs.end(); ++i) @@ -313,7 +331,9 @@ continue; external ext_domain, ext_name; externalize_var_domain(i->first.first, ext_domain); - cout << ext_domain << ": " << i->first.second << " " << i->second << "\n"; + cout << ext_domain << ": " + << i->first.second << " " + << i->second << "\n"; } } @@ -329,11 +349,13 @@ restriction mask(args, app.exclude_patterns, new_roster, app); node_map const & nodes = new_roster.all_nodes(); - for (node_map::const_iterator i = nodes.begin(); i != nodes.end(); ++i) + for (node_map::const_iterator i = nodes.begin(); + i != nodes.end(); ++i) { node_id nid = i->first; - if (!new_roster.is_root(nid) && mask.includes(new_roster, nid)) + if (!new_roster.is_root(nid) + && mask.includes(new_roster, nid)) { split_path sp; new_roster.get_name(nid, sp); @@ -343,7 +365,8 @@ } static void -ls_unknown_or_ignored(app_state & app, bool want_ignored, vector const & args) +ls_unknown_or_ignored(app_state & app, bool want_ignored, + vector const & args) { app.require_workspace(); @@ -351,10 +374,12 @@ find_unknown_and_ignored(app, args, unknown, ignored); if (want_ignored) - for (path_set::const_iterator i = ignored.begin(); i != ignored.end(); ++i) + for (path_set::const_iterator i = ignored.begin(); + i != ignored.end(); ++i) cout << file_path(*i) << "\n"; else - for (path_set::const_iterator i = unknown.begin(); i != unknown.end(); ++i) + for (path_set::const_iterator i = unknown.begin(); + i != unknown.end(); ++i) cout << file_path(*i) << "\n"; } @@ -364,7 +389,8 @@ path_set missing; find_missing(app, args, missing); - for (path_set::const_iterator i = missing.begin(); i != missing.end(); ++i) + for (path_set::const_iterator i = missing.begin(); + i != missing.end(); ++i) { cout << file_path(*i) << "\n"; } @@ -381,17 +407,22 @@ app.require_workspace(); - get_base_and_current_roster_shape(old_roster, new_roster, nis, app); + get_base_and_current_roster_shape(old_roster, + new_roster, + nis, app); - restriction mask(args, app.exclude_patterns, old_roster, new_roster, 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); + make_restricted_csets(old_roster, new_roster, + included, excluded, mask); check_restricted_cset(old_roster, included); // FIXME: this would probably be better as a function of roster.cc // set nodes; - // select_nodes_modified_by_cset(included, old_roster, new_roster, nodes); + // select_nodes_modified_by_cset(included, old_roster, + // new_roster, nodes); for (path_set::const_iterator i = included.nodes_deleted.begin(); i != included.nodes_deleted.end(); ++i) @@ -413,14 +444,16 @@ if (mask.includes(*i)) files.insert(file_path(*i)); } - for (map::const_iterator i = included.files_added.begin(); + for (map::const_iterator + i = included.files_added.begin(); i != included.files_added.end(); ++i) { if (mask.includes(i->first)) files.insert(file_path(i->first)); } for (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)) @@ -445,8 +478,9 @@ "ignored\n" "missing\n" "changed"), - N_("show database objects, or the current workspace manifest, or known,\n" - "unknown, intentionally ignored, missing, or changed state files"), + N_("show database objects, or the current workspace manifest, \n" + "or known, unknown, intentionally ignored, missing, or \n" + "changed-state files"), OPT_DEPTH % OPT_EXCLUDE) { if (args.size() == 0) @@ -482,3 +516,11 @@ } ALIAS(ls, list) + +// Local Variables: +// mode: C++ +// fill-column: 76 +// 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: ============================================================ --- cmd_merging.cc 6745bfc6317dad3cf1828d17600aca164accf0e5 +++ cmd_merging.cc 78a4f272c04de0799fca5e16a2262536fce14e7a @@ -1,17 +1,25 @@ -#include "cmd.hh" +// Copyright (C) 2002 Graydon Hoare +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. -#include "work.hh" -#include "restrictions.hh" -#include "roster_merge.hh" +#include + +#include "cmd.hh" +#include "diff_patch.hh" +#include "merge.hh" #include "packet.hh" +#include "restrictions.hh" #include "revision.hh" -#include "merge.hh" -#include "diff_patch.hh" +#include "roster_merge.hh" #include "transforms.hh" #include "update.hh" +#include "work.hh" -#include - using std::cout; using std::map; using std::set; @@ -32,7 +40,9 @@ void get_file_content(file_id const & fid, file_data & dat) const { - map::const_iterator i = temporary_store.find(fid); + map::const_iterator + i = temporary_store.find(fid); + if (i != temporary_store.end()) dat = i->second; else @@ -68,7 +78,8 @@ // such. But it should work for now; revisit if performance is // intolerable. - get_base_and_current_roster_shape(*old_roster, working_roster, nis, app); + get_base_and_current_roster_shape(*old_roster, + working_roster, nis, app); update_current_roster_from_filesystem(working_roster, app); get_revision_id(r_old_id); @@ -195,9 +206,18 @@ { cset transplant; make_cset (*old_roster, chosen_roster, transplant); - // just pick something, all that's important is that it not + + // Just pick some unused revid, 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")); + r_target_id = + revision_id(hexenc("5432100000000000000000000500000000000000")); + while (app.db.revision_exists(r_target_id)) + { + // Iterate the hash until we don't have a collision. This might not + // terminate, but it'll be extremely surprising if it doesn't, and + // it's easy. + calculate_ident(revision_data(r_target_id.inner()()), r_target_id); + } make_roster_for_base_plus_cset(r_old_id, transplant, r_target_id, @@ -227,23 +247,25 @@ result, wca, app); I(result.is_clean()); - // temporary node ids may appear if updating to a non-ancestor + + // Temporary node ids may appear if updating to a non-ancestor. merged_roster.check_sane(true); - // we have the following + // We have the following // // old --> working // | | // V V // chosen --> merged // - // - old is the revision specified in _MTN/revision - // - 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 + // - Old is the revision specified in _MTN/revision. + // - 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 - // and write the cset from chosen to merged changeset in _MTN/work + // 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); @@ -263,16 +285,19 @@ 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. + // 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. + put_revision_id(r_chosen_id); if (!app.branch_name().empty()) { app.make_branch_sticky(); } if (switched_branch) - P(F("switched branch; next commit will use branch %s") % app.branch_name()); + P(F("switched branch; next commit will use branch %s") + % app.branch_name()); P(F("updated to base revision %s\n") % r_chosen_id); put_work_cset(remaining); @@ -351,29 +376,30 @@ N_("merge one branch into a subdirectory in another branch"), OPT_DATE % OPT_AUTHOR % OPT_MESSAGE % OPT_MSGFILE) { - // this is a special merge operator, but very useful for people maintaining - // "slightly disparate but related" trees. it does a one-way merge; less - // powerful than putting things in the same branch and also more flexible. + // This is a special merge operator, but very useful for people + // maintaining "slightly disparate but related" trees. It does a one-way + // merge; less powerful than putting things in the same branch and also + // more flexible. // - // 1. check to see if src and dst branches are merged, if not abort, if so + // 1. Check to see if src and dst branches are merged, if not abort, if so // call heads N1 and N2 respectively. // - // 2. (FIXME: not yet present) run the hook propagate ("src-branch", + // 2. (FIXME: not yet present) Run the hook propagate ("src-branch", // "dst-branch", N1, N2) which gives the user a chance to massage N1 into // a state which is likely to "merge nicely" with N2, eg. edit pathnames, // omit optional files of no interest. // - // 3. do a normal 2 or 3-way merge on N1 and N2, depending on the + // 3. Do a normal 2 or 3-way merge on N1 and N2, depending on the // existence of common ancestors. // - // 4. save the results as the delta (N2,M), the ancestry edges (N1,M) + // 4. Save the results as the delta (N2,M), the ancestry edges (N1,M) // and (N2,M), and the cert (N2,dst). // - // there are also special cases we have to check for where no merge is + // There are also special cases we have to check for where no merge is // actually necessary, because there hasn't been any divergence since the // last time propagate was run. // - // if dir is not the empty string, rename the root of N1 to have the name + // 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))") @@ -385,11 +411,15 @@ 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\n") % idx(args, 0)()); + N(src_heads.size() == 1, + F("branch '%s' is not merged\n") % 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\n") % idx(args, 1)()); + N(dst_heads.size() == 1, + F("branch '%s' is not merged\n") % idx(args, 1)()); set::const_iterator src_i = src_heads.begin(); set::const_iterator dst_i = dst_heads.begin(); @@ -402,7 +432,7 @@ 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") - % idx(args, 1)() % idx(args, 0)()); + % idx(args, 1)() % idx(args, 0)()); P(F("no action taken\n")); } else if (is_ancestor(*dst_i, *src_i, app)) @@ -425,7 +455,9 @@ MM(left_roster); MM(right_roster); marking_map left_marking_map, right_marking_map; - set left_uncommon_ancestors, right_uncommon_ancestors; + set + left_uncommon_ancestors, + right_uncommon_ancestors; app.db.get_roster(left_rid, left_roster, left_marking_map); app.db.get_roster(right_rid, right_roster, right_marking_map); @@ -447,7 +479,8 @@ node_t parent = right_roster.get_node(dirname); moved_root->parent = parent->self; moved_root->name = basename; - marking_map::iterator i=left_marking_map.find(moved_root->self); + marking_map::iterator + i = left_marking_map.find(moved_root->self); I(i != left_marking_map.end()); i->second.parent_name.clear(); i->second.parent_name.insert(left_rid); @@ -455,11 +488,17 @@ } roster_merge_result result; - roster_merge(left_roster, left_marking_map, left_uncommon_ancestors, - right_roster, right_marking_map, right_uncommon_ancestors, + roster_merge(left_roster, + left_marking_map, + left_uncommon_ancestors, + right_roster, + right_marking_map, + right_uncommon_ancestors, result); - content_merge_database_adaptor dba(app, left_rid, right_rid, left_marking_map); + content_merge_database_adaptor + dba(app, left_rid, right_rid, left_marking_map); + resolve_merge_conflicts (left_rid, right_rid, left_roster, right_roster, left_marking_map, right_marking_map, @@ -471,7 +510,7 @@ moved_root->name = the_null_component; } - // write new files into the db + // Write new files into the db. store_roster_merge_result(left_roster, right_roster, result, left_rid, right_rid, merged, app); @@ -499,7 +538,8 @@ CMD(explicit_merge, N_("tree"), N_("LEFT-REVISION RIGHT-REVISION DEST-BRANCH"), - N_("merge two explicitly given revisions, placing result in given branch"), + N_("merge two explicitly given revisions, " + "placing result in given branch"), OPT_DATE % OPT_AUTHOR) { revision_id left, right; @@ -519,7 +559,9 @@ N(!is_ancestor(right, left, app), F("%s is already an ancestor of %s") % right % left); - // Somewhat redundant, but consistent with output of plain "merge" command. + // Somewhat redundant, but consistent with output of plain "merge" + // command. + P(F("[source] %s\n") % left); P(F("[source] %s\n") % right); @@ -542,7 +584,9 @@ P(F("[merged] %s\n") % merged); } -CMD(show_conflicts, N_("informative"), N_("REV REV"), N_("Show what conflicts would need to be resolved to merge the given revisions."), +CMD(show_conflicts, N_("informative"), N_("REV REV"), + N_("Show what conflicts would need to be resolved " + "to merge the given revisions."), OPT_BRANCH_NAME % OPT_DATE % OPT_AUTHOR) { if (args.size() != 2) @@ -567,12 +611,18 @@ r_roster, r_marking, r_uncommon_ancestors, result); - P(F("There are %s node_name_conflicts.") % result.node_name_conflicts.size()); - P(F("There are %s file_content_conflicts.") % result.file_content_conflicts.size()); - P(F("There are %s node_attr_conflicts.") % result.node_attr_conflicts.size()); - P(F("There are %s orphaned_node_conflicts.") % result.orphaned_node_conflicts.size()); - P(F("There are %s rename_target_conflicts.") % result.rename_target_conflicts.size()); - P(F("There are %s directory_loop_conflicts.") % result.directory_loop_conflicts.size()); + P(F("There are %s node_name_conflicts.") + % result.node_name_conflicts.size()); + P(F("There are %s file_content_conflicts.") + % result.file_content_conflicts.size()); + P(F("There are %s node_attr_conflicts.") + % result.node_attr_conflicts.size()); + P(F("There are %s orphaned_node_conflicts.") + % result.orphaned_node_conflicts.size()); + P(F("There are %s rename_target_conflicts.") + % result.rename_target_conflicts.size()); + P(F("There are %s directory_loop_conflicts.") + % result.directory_loop_conflicts.size()); } CMD(heads, N_("tree"), "", N_("show unmerged head revisions of branch"), @@ -617,3 +667,12 @@ write_roster_and_marking(roster, mm, dat); cout << dat; } + + +// Local Variables: +// mode: C++ +// fill-column: 76 +// 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: ============================================================ --- cmd_othervcs.cc 47651b6f63bd48be121a30eec4d1746238151fd2 +++ cmd_othervcs.cc 5666f47510818cfd78256dbf3696b49090b9c877 @@ -1,5 +1,13 @@ -#include "cmd.hh" +// Copyright (C) 2002 Graydon Hoare +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. +#include "cmd.hh" #include "rcs_import.hh" using std::vector; @@ -21,7 +29,8 @@ } -CMD(cvs_import, N_("rcs"), N_("CVSROOT"), N_("import all versions in CVS repository"), +CMD(cvs_import, N_("rcs"), N_("CVSROOT"), + N_("import all versions in CVS repository"), OPT_BRANCH_NAME) { if (args.size() != 1) @@ -29,3 +38,12 @@ import_cvs_repo(system_path(idx(args, 0)()), app); } + + +// Local Variables: +// mode: C++ +// fill-column: 76 +// 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: ============================================================ --- cmd_packet.cc 0d127531d08a403249ba6fea64f09ee1fd0546e3 +++ cmd_packet.cc 3ecd60dca3061099e393d432707a9bf82d3793e9 @@ -1,16 +1,25 @@ -#include "cmd.hh" +// Copyright (C) 2002 Graydon Hoare +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. -#include "packet.hh" - #include #include +#include "cmd.hh" +#include "packet.hh" + using std::cin; using std::cout; using std::istringstream; using std::vector; -CMD(pubkey, N_("packet i/o"), N_("ID"), N_("write public key packet to stdout"), +CMD(pubkey, N_("packet i/o"), N_("ID"), + N_("write public key packet to stdout"), OPT_NONE) { if (args.size() != 1) @@ -38,7 +47,8 @@ pw.consume_public_key(ident, key); } -CMD(privkey, N_("packet i/o"), N_("ID"), N_("write private key packet to stdout"), +CMD(privkey, N_("packet i/o"), N_("ID"), + N_("write private key packet to stdout"), OPT_NONE) { if (args.size() != 1) @@ -47,7 +57,7 @@ rsa_keypair_id ident(idx(args, 0)()); N(app.keys.key_pair_exists(ident), F("public and private key '%s' do not exist in keystore") - % idx(args, 0)()); + % idx(args, 0)()); packet_writer pw(cout); keypair kp; @@ -69,7 +79,8 @@ } else { - for (vector::const_iterator i = args.begin(); i != args.end(); ++i) + for (vector::const_iterator i = args.begin(); + i != args.end(); ++i) { data dat; read_data(system_path(*i), dat); @@ -82,3 +93,12 @@ } P(FP("read %d packet", "read %d packets", count) % count); } + + +// Local Variables: +// mode: C++ +// fill-column: 76 +// 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: ============================================================ --- cmd_ws_commit.cc b334deaf56946d327559cb7db10fc82de170da5c +++ cmd_ws_commit.cc 6afeacc30eb66fab0b3d6ba7494a01358a26bb7b @@ -1,16 +1,24 @@ -#include "cmd.hh" +// Copyright (C) 2002 Graydon Hoare +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. +#include +#include + +#include "cmd.hh" #include "diff_patch.hh" +#include "localized_file_io.hh" #include "packet.hh" #include "restrictions.hh" #include "revision.hh" #include "transforms.hh" #include "work.hh" -#include "localized_file_io.hh" -#include -#include - using std::cout; using std::make_pair; using std::pair; @@ -30,12 +38,13 @@ data summary, user_log_message; write_revision_set(cs, summary); read_user_log(user_log_message); - commentary += "----------------------------------------------------------------------\n"; + commentary += string(70, '-') + "\n"; commentary += _("Enter a description of this change.\n" - "Lines beginning with `MTN:' are removed automatically.\n"); + "Lines beginning with `MTN:' " + "are removed automatically.\n"); commentary += "\n"; commentary += summary(); - commentary += "----------------------------------------------------------------------\n"; + commentary += string(70, '-') + "\n"; N(app.lua.hook_edit_comment(commentary, user_log_message(), log_message), F("edit of log message failed")); @@ -59,9 +68,10 @@ if (app.missing) { - // --missing is a further filter on the files included by a restriction - // we first find all missing files included by the specified args - // and then make a restriction that includes only these missing files + // --missing is a further filter on the files included by a + // restriction we first find all missing files included by the + // specified args and then make a restriction that includes only + // these missing files. path_set missing; find_missing(app, args, missing); if (missing.empty()) @@ -70,7 +80,8 @@ return; } - for (path_set::const_iterator i = missing.begin(); i != missing.end(); i++) + for (path_set::const_iterator i = missing.begin(); + i != missing.end(); i++) { file_path fp(*i); L(FL("missing files are '%s'") % fp); @@ -86,13 +97,18 @@ get_base_and_current_roster_shape(old_roster, new_roster, nis, app); restriction mask(includes, excludes, old_roster, new_roster, app); - make_restricted_csets(old_roster, new_roster, included, excluded, mask); - // the included cset will be thrown away (reverted) leaving the excluded - // cset pending in MTN/work which must be valid against the old roster + make_restricted_csets(old_roster, new_roster, + included, excluded, mask); + + // The included cset will be thrown away (reverted) leaving the + // excluded cset pending in MTN/work which must be valid against the + // old roster. + check_restricted_cset(old_roster, excluded); node_map const & nodes = old_roster.all_nodes(); - for (node_map::const_iterator i = nodes.begin(); i != nodes.end(); ++i) + for (node_map::const_iterator i = nodes.begin(); + i != nodes.end(); ++i) { node_id nid = i->first; node_t node = i->second; @@ -142,11 +158,12 @@ } } - // included_work is thrown away which effectively reverts any adds, drops and - // renames it contains. drops and rename sources will have been rewritten - // above but this may leave rename targets laying around. + // Included_work is thrown away which effectively reverts any adds, + // drops and renames it contains. Drops and rename sources will have + // been rewritten above but this may leave rename targets laying + // around. - // race + // Race. put_work_cset(excluded); update_any_attrs(app); maybe_update_inodeprints(app); @@ -166,11 +183,13 @@ app.db.get_revision(r, rev); N(rev.edges.size() == 1, - F("revision '%s' has %d changesets, cannot invert\n") % r % rev.edges.size()); + 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), @@ -197,7 +216,9 @@ 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); + cert_revision_changelog(inv_id, + (FL("disapproval of revision '%s'") + % r).str(), app, dbw); guard.commit(); } } @@ -218,7 +239,8 @@ find_unknown_and_ignored(app, args, paths, ignored); } else - for (vector::const_iterator i = args.begin(); i != args.end(); ++i) + for (vector::const_iterator i = args.begin(); + i != args.end(); ++i) { split_path sp; file_path_external(*i).split(sp); @@ -230,7 +252,8 @@ } CMD(drop, N_("workspace"), N_("[PATH]..."), - N_("drop files from workspace"), OPT_EXECUTE % OPT_MISSING % OPT_RECURSIVE) + N_("drop files from workspace"), + OPT_EXECUTE % OPT_MISSING % OPT_RECURSIVE) { if (!app.missing && (args.size() < 1)) throw usage(name); @@ -241,7 +264,8 @@ if (app.missing) find_missing(app, args, paths); else - for (vector::const_iterator i = args.begin(); i != args.end(); ++i) + for (vector::const_iterator i = args.begin(); + i != args.end(); ++i) { split_path sp; file_path_external(*i).split(sp); @@ -279,13 +303,15 @@ ALIAS(mv, rename) -CMD(pivot_root, N_("workspace"), N_("NEW_ROOT PUT_OLD"), - N_("rename the root directory\n" - "after this command, the directory that currently has the name NEW_ROOT\n" - "will be the root directory, and the directory that is currently the root\n" - "directory will have name PUT_OLD.\n" - "Using --execute is strongly recommended."), - OPT_EXECUTE) + CMD(pivot_root, N_("workspace"), N_("NEW_ROOT PUT_OLD"), + N_("rename the root directory\n" + "after this command, the directory that currently " + "has the name NEW_ROOT\n" + "will be the root directory, and the directory " + "that is currently the root\n" + "directory will have name PUT_OLD.\n" + "Using --execute is strongly recommended."), + OPT_EXECUTE) { if (args.size() != 2) throw usage(name); @@ -296,7 +322,8 @@ perform_pivot_root(new_root, put_old, app); } -CMD(status, N_("informative"), N_("[PATH]..."), N_("show status of workspace"), +CMD(status, N_("informative"), N_("[PATH]..."), + N_("show status of workspace"), OPT_DEPTH % OPT_EXCLUDE % OPT_BRIEF) { roster_t old_roster, new_roster, restricted_roster; @@ -309,10 +336,12 @@ app.require_workspace(); get_base_and_current_roster_shape(old_roster, new_roster, nis, app); - restriction mask(args, app.exclude_patterns, old_roster, new_roster, 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); + make_restricted_csets(old_roster, new_roster, + included, excluded, mask); check_restricted_cset(old_roster, included); restricted_roster = old_roster; @@ -332,7 +361,7 @@ cout << "dropped " << *i << "\n"; for (map::const_iterator - i = cs.nodes_renamed.begin(); + i = cs.nodes_renamed.begin(); i != cs.nodes_renamed.end(); ++i) cout << "renamed " << i->first << "\n" << " to " << i->second << "\n"; @@ -341,12 +370,14 @@ i != cs.dirs_added.end(); ++i) cout << "added " << *i << "\n"; - for (map::const_iterator i = cs.files_added.begin(); + for (map::const_iterator + i = cs.files_added.begin(); i != cs.files_added.end(); ++i) cout << "added " << i->first << "\n"; for (map >::const_iterator - i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) + i = cs.deltas_applied.begin(); + i != cs.deltas_applied.end(); ++i) cout << "patched " << i->first << "\n"; } else @@ -358,14 +389,14 @@ CMD(checkout, N_("tree"), N_("[DIRECTORY]\n"), N_("check out a revision from database into directory.\n" - "If a revision is given, that's the one that will be checked out.\n" - "Otherwise, it will be the head of the branch (given or implicit).\n" - "If no directory is given, the branch name will be used as directory"), + "If a revision is given, that's the one that will be checked out.\n" + "Otherwise, it will be the head of the branch (given or implicit).\n" + "If no directory is given, the branch name will be used as directory"), OPT_BRANCH_NAME % OPT_REVISION) { revision_id ident; system_path dir; - // we have a special case for "checkout .", i.e., to current dir + // We have a special case for "checkout .", i.e., to current dir. bool checkout_dot = false; transaction_guard guard(app.db, false); @@ -375,35 +406,41 @@ if (args.size() == 0) { - // no checkout dir specified, use branch name for dir - N(!app.branch_name().empty(), F("need --branch argument for branch-based checkout")); + // No checkout dir specified, use branch name for dir. + N(!app.branch_name().empty(), + F("need --branch argument for branch-based checkout")); dir = system_path(app.branch_name()); } else { - // checkout to specified dir + // Checkout to specified dir. dir = system_path(idx(args, 0)); if (idx(args, 0) == utf8(".")) checkout_dot = true; } if (!checkout_dot) - require_path_is_nonexistent(dir, - F("checkout directory '%s' already exists") - % dir); + require_path_is_nonexistent + (dir, F("checkout directory '%s' already exists") % dir); if (app.revision_selectors.size() == 0) { // use branch head revision - N(!app.branch_name().empty(), F("need --branch argument for branch-based checkout")); + N(!app.branch_name().empty(), + F("need --branch argument for branch-based checkout")); + set heads; get_branch_heads(app.branch_name(), app, heads); - N(heads.size() > 0, F("branch '%s' is empty") % app.branch_name); + N(heads.size() > 0, + F("branch '%s' is empty") % app.branch_name); if (heads.size() > 1) { P(F("branch %s has multiple heads:") % app.branch_name); - for (set::const_iterator i = heads.begin(); i != heads.end(); ++i) + + for (set::const_iterator i = heads.begin(); + i != heads.end(); ++i) P(i18n_format(" %s\n") % 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); } @@ -425,14 +462,16 @@ encode_base64(branch_name, branch_encoded); vector< revision > certs; - app.db.get_revision_certs(ident, branch_cert_name, branch_encoded, certs); + app.db.get_revision_certs(ident, branch_cert_name, + branch_encoded, certs); L(FL("found %d %s branch certs on revision %s\n") % 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\n") % ident % app.branch_name); } @@ -444,11 +483,13 @@ 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\n") + % 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) + for (node_map::const_iterator i = nodes.begin(); + i != nodes.end(); ++i) { node_t node = i->second; split_path sp; @@ -484,9 +525,10 @@ ALIAS(co, checkout) -CMD(attr, N_("workspace"), N_("set PATH ATTR VALUE\nget PATH [ATTR]\ndrop PATH [ATTR]"), - N_("set, get or drop file attributes"), - OPT_NONE) + CMD(attr, N_("workspace"), + N_("set PATH ATTR VALUE\nget PATH [ATTR]\ndrop PATH [ATTR]"), + N_("set, get or drop file attributes"), + OPT_NONE) { if (args.size() < 2 || args.size() > 4) throw usage(name); @@ -520,7 +562,7 @@ } else { - // Clear all attrs (or a specific attr) + // Clear all attrs (or a specific attr). if (args.size() == 2) { for (full_attr_map_t::iterator i = node->attrs.begin(); @@ -553,7 +595,9 @@ i != node->attrs.end(); ++i) if (i->second.first) { - cout << path << " : " << i->first << "=" << i->second.second << "\n"; + cout << path << " : " + << i->first << "=" + << i->second.second << "\n"; has_any_live_attrs = true; } if (!has_any_live_attrs) @@ -564,9 +608,12 @@ attr_key a_key = idx(args, 2)(); 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"; + cout << path << " : " + << i->first << "=" + << i->second.second << "\n"; else - cout << F("No attribute '%s' on path '%s'") % a_key % path << "\n"; + cout << (F("No attribute '%s' on path '%s'") + % a_key % path) << "\n"; } else throw usage(name); @@ -594,10 +641,12 @@ app.require_workspace(); get_base_and_current_roster_shape(old_roster, new_roster, nis, app); - restriction mask(args, app.exclude_patterns, old_roster, new_roster, 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); + make_restricted_csets(old_roster, new_roster, + included, excluded, mask); check_restricted_cset(old_roster, included); restricted_roster = old_roster; @@ -605,7 +654,8 @@ included.apply_to(er); get_revision_id(old_rev_id); - make_revision_set(old_rev_id, old_roster, restricted_roster, restricted_rev); + make_revision_set(old_rev_id, old_roster, + restricted_roster, restricted_rev); calculate_ident(restricted_rev, restricted_rev_id); @@ -621,37 +671,44 @@ if (app.branch_name() != "") branchname = app.branch_name(); else - guess_branch(edge_old_revision(restricted_rev.edges.begin()), app, branchname); + guess_branch(edge_old_revision(restricted_rev.edges.begin()), + app, branchname); P(F("beginning commit on branch '%s'\n") % branchname); L(FL("new manifest '%s'\n" - "new revision '%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" + 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 + // This call handles _MTN/log. + get_log_message_interactively(restricted_rev, app, log_message); - // we only check for empty log messages when the user entered them + + // 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, 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 - // message by default. we only do this for interactively entered - // messages, because otherwise 'monotone commit -mfoo' giving an error, - // means that after you correct that error and hit up-arrow to try - // again, you get an "_MTN/log non-empty and message given on command - // line" error... which is annoying. + + // We save interactively entered log messages to _MTN/log, so if + // something goes wrong, the next commit will pop up their old + // log message by default. We only do this for interactively + // entered messages, because otherwise 'monotone commit -mfoo' + // giving an error, means that after you correct that error and + // hit up-arrow to try again, you get an "_MTN/log non-empty and + // message given on command line" error... which is annoying. + write_user_log(data(log_message)); } @@ -671,7 +728,8 @@ 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\n") + % restricted_rev_id); } else { @@ -685,7 +743,8 @@ // process file deltas or new files cset const & cs = edge_changes(edge); - for (map >::const_iterator i = cs.deltas_applied.begin(); + for (map >::const_iterator + i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) { file_path path(i->first); @@ -718,12 +777,15 @@ file_delta(del)); } else - // If we don't err out here, our packet writer will later. - E(false, F("Your database is missing version %s of file '%s'") - % old_content % path); + // If we don't err out here, our packet writer will + // later. + E(false, + F("Your database is missing version %s of file '%s'") + % old_content % path); } - for (map::const_iterator i = cs.files_added.begin(); + for (map::const_iterator + i = cs.files_added.begin(); i != cs.files_added.end(); ++i) { file_path path(i->first); @@ -747,19 +809,22 @@ dbw.consume_revision_data(restricted_rev_id, rdat); 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 cert_revision_date_now(restricted_rev_id, app, dbw); + if (app.author().length() > 0) cert_revision_author(restricted_rev_id, app.author(), app, dbw); else cert_revision_author_default(restricted_rev_id, app, dbw); + cert_revision_changelog(restricted_rev_id, log_message, app, dbw); guard.commit(); } - // small race condition here... + // Small race condition here. put_work_cset(excluded); put_revision_id(restricted_rev_id); P(F("committed revision %s\n") % restricted_rev_id); @@ -777,10 +842,11 @@ maybe_update_inodeprints(app); { - // tell lua what happened. yes, we might lose some information here, - // but it's just an indicator for lua, eg. to post stuff to a mailing - // list. if the user *really* cares about cert validity, multiple certs - // with same name, etc. they can inquire further, later. + // Tell lua what happened. Yes, we might lose some information + // here, but it's just an indicator for lua, eg. to post stuff to + // a mailing list. If the user *really* cares about cert validity, + // multiple certs with same name, etc. they can inquire further, + // later. map certs; vector< revision > ctmp; app.db.get_revision_certs(restricted_rev_id, ctmp); @@ -800,8 +866,9 @@ ALIAS(ci, commit); -CMD_NO_WORKSPACE(setup, N_("tree"), N_("[DIRECTORY]"), N_("setup a new workspace directory, default to current"), - OPT_BRANCH_NAME) +CMD_NO_WORKSPACE(setup, N_("tree"), N_("[DIRECTORY]"), + N_("setup a new workspace directory, default to current"), + OPT_BRANCH_NAME) { if (args.size() > 1) throw usage(name); @@ -820,10 +887,20 @@ put_revision_id(null); } -CMD(refresh_inodeprints, N_("tree"), "", N_("refresh the inodeprint cache"), +CMD(refresh_inodeprints, N_("tree"), "", + N_("refresh the inodeprint cache"), OPT_NONE) { app.require_workspace(); enable_inodeprints(); maybe_update_inodeprints(app); } + + +// Local Variables: +// mode: C++ +// fill-column: 76 +// 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: