# # patch "ChangeLog" # from [7ea13e6ee21fdeb720e6317972e61d061cd694bc] # to [0efd318d22c59269a1c02defbcd9b5782a6d7a9f] # # patch "file_io.cc" # from [ff47ce57304e48a07f9e6c539610f7d992c5e773] # to [aa6562b55467ac15f77741a9f3383a29aff99450] # # patch "file_io.hh" # from [80ef83f6cd2479dd5dbcfd13bca81172d90fde4d] # to [5712c71aa04e18828ae63e33ed0e0030d4d40e8d] # # patch "manifest.cc" # from [2d4e047a2587f9b379fad559d192b317d6e2b47e] # to [4c8967bd6dc098db8de70863c3f42678d2a0f400] # # patch "ui.cc" # from [228f2912ff4f24f41df4f4b0c62f2b5321970aee] # to [4bba764f10d15f4e0302e26825c28b37cd4a96e9] # --- ChangeLog +++ ChangeLog @@ -1,3 +1,12 @@ +2005-07-08 Matt Johnston + + * file_io.cc (ident_existing_file): new function to calculate + the ident of a file failing gracefully if it doesn't exist + or is a directory. + * file_io.hh (classify_manifest_paths, + build_restricted_manifest_map): use ident_existing_file + * ui.cc: cast to avoid compiler warnings + 2005-07-07 Nathaniel Smith * contrib/ciabot_monotone.py (Monotone.log): Fix to work with --- file_io.cc +++ file_io.cc @@ -254,6 +254,27 @@ return fs::exists(localized(p)); } +bool +ident_existing_file(file_path const & p, file_id & ident, lua_hooks & lua) +{ + fs::path local_p(localized(p)); + + if (!fs::exists(local_p)) + return false; + + if (fs::is_directory(local_p)) + { + W(F("expected file '%s', but it is a directory.") % p()); + return false; + } + + hexenc id; + calculate_ident(p, id, lua); + ident = file_id(id); + + return true; +} + bool guess_binary(string const & s) { // these do not occur in ASCII text files --- file_io.hh +++ file_io.hh @@ -59,6 +59,8 @@ bool file_exists(local_path const & path); bool file_exists(file_path const & path); +bool ident_existing_file(file_path const & p, file_id & ident, lua_hooks & lua); + // returns true if the string content is binary according to monotone euristic bool guess_binary(std::string const & s); --- manifest.cc +++ manifest.cc @@ -119,19 +119,19 @@ } // ...ah, well, no good fingerprint, just check directly. - if (file_exists(i->first)) + file_id ident; + if (ident_existing_file(i->first, ident, app.lua)) { - hexenc ident; - calculate_ident(i->first, ident, app.lua); - - if (ident == i->second.inner()) + if (ident == i->second) unchanged.insert(i->first); else changed.insert(i->first); - } else - missing.insert(i->first); + { + missing.insert(i->first); + } + } else { @@ -179,11 +179,11 @@ } // ...ah, well, no good fingerprint, just check directly. - if (file_exists(*i)) + // ...ah, well, no good fingerprint, just check directly. + file_id ident; + if (ident_existing_file(*i, ident, app.lua)) { - hexenc ident; - calculate_ident(*i, ident, app.lua); - m_new.insert(manifest_entry(*i, file_id(ident))); + m_new.insert(manifest_entry(*i, ident)); } else { --- ui.cc +++ ui.cc @@ -121,7 +121,7 @@ suffix = "k"; } // we reset the mod to the divider, to avoid spurious screen updates - i->second->mod = div / 10; + i->second->mod = static_cast(div / 10.0); count = (F("%.1f%s") % (i->second->ticks / div) % suffix).str(); } else