# # patch "transforms.cc" # from [2ac91b4236887a082140fd0199ef0019c4bba67d] # to [4e98b04da9cf4198537eecac44c5e518b2133ef0] # # patch "transforms.hh" # from [276d94ce639726024f4cca68dda38c77cbf1b6c6] # to [20649bff0b21dec65062baa1de4b11ab1f05d950] # # patch "work.cc" # from [4a3e8be8a554563d87b4bbd0a76a706500e20232] # to [b3cb789b8d340fdf48ce687bce6b71e620668e67] # # patch "work.hh" # from [56b2b9be3b0cb7fcabee21e948788a57658af3eb] # to [81add376cf6c2448fa5d48c117b6b472d02def69] # # patch "xdelta.cc" # from [b842258e0b59f3c95c8389cd61d1611f80f4328e] # to [7c8499810d4afe6687979cdccbaef6ecf65c20fe] # # patch "xdelta.hh" # from [16bbaaed2e75018ccc76fa6ed421b38556f30e61] # to [1b06a9dce1174f9c40fd5e8541aa0c6d81f13d50] # ======================================================================== --- transforms.cc 2ac91b4236887a082140fd0199ef0019c4bba67d +++ transforms.cc 4e98b04da9cf4198537eecac44c5e518b2133ef0 @@ -205,16 +205,6 @@ newdata = result; } -void -diff(manifest_map const & oldman, - manifest_map const & newman, - delta & del) -{ - string xd; - compute_delta(oldman, newman, xd); - del = delta(xd); -} - // identifier (a.k.a. sha1 signature) calculation void @@ -248,62 +238,6 @@ ident = tmp; } -void -calculate_ident(manifest_map const & m, - manifest_id & ident) -{ - size_t sz = 0; - static size_t bufsz = 0; - static char *buf = NULL; - - for (manifest_map::const_iterator i = m.begin(); - i != m.end(); ++i) - { - sz += i->second.inner()().size(); - sz += i->first.as_internal().size(); - sz += 3; - } - - if (sz > bufsz) - { - bufsz = sz; - buf = static_cast(realloc(buf, bufsz)); - I(buf); - } - - // this has to go quite fast, for cvs importing - char *c = buf; - for (manifest_map::const_iterator i = m.begin(); - i != m.end(); ++i) - { - memcpy(c, i->second.inner()().data(), i->second.inner()().size()); - c += i->second.inner()().size(); - *c++ = ' '; - *c++ = ' '; - memcpy(c, i->first.as_internal().data(), i->first.as_internal().size()); - c += i->first.as_internal().size(); - *c++ = '\n'; - } - - Botan::Pipe p(new Botan::Hash_Filter("SHA-1")); - p.process_msg(reinterpret_cast(buf), sz); - - id ident_decoded(p.read_all_as_string()); - hexenc raw_ident; - encode_hexenc(ident_decoded, raw_ident); - ident = manifest_id(raw_ident); -} - -void -calculate_ident(manifest_data const & dat, - manifest_id & ident) -{ - hexenc tmp; - calculate_ident(dat.inner(), tmp); - ident = tmp; -} - - void calculate_ident(revision_data const & dat, revision_id & ident) { ======================================================================== --- transforms.hh 276d94ce639726024f4cca68dda38c77cbf1b6c6 +++ transforms.hh 20649bff0b21dec65062baa1de4b11ab1f05d950 @@ -8,7 +8,6 @@ #include "revision.hh" #include "lua.hh" -#include "manifest.hh" #include "vocab.hh" #include "roster.hh" @@ -104,10 +103,6 @@ data const & newdata, delta & del); -void diff(manifest_map const & oldman, - manifest_map const & newman, - delta & del); - void patch(data const & olddata, delta const & del, data & newdata); @@ -127,9 +122,6 @@ void calculate_ident(manifest_data const & dat, manifest_id & ident); -void calculate_ident(manifest_map const & mm, - manifest_id & ident); - void calculate_ident(revision_data const & dat, revision_id & ident); ======================================================================== --- work.cc 4a3e8be8a554563d87b4bbd0a76a706500e20232 +++ work.cc b3cb789b8d340fdf48ce687bce6b71e620668e67 @@ -602,95 +602,12 @@ write_data(ip_path, dat); } -void -get_attr_path(file_path & a_path) -{ - a_path = file_path_internal(attr_file_name); - L(F("attribute map path is %s\n") % a_path); -} - -namespace -{ - namespace syms - { - std::string const file("file"); - } -} - -void -read_attr_map(data const & dat, attr_map & attr) -{ - std::istringstream iss(dat()); - basic_io::input_source src(iss, attr_file_name); - basic_io::tokenizer tok(src); - basic_io::parser parser(tok); - - std::string file, name, value; - - attr.clear(); - - while (parser.symp(syms::file)) - { - parser.sym(); - parser.str(file); - file_path fp = file_path_internal(file); - - while (parser.symp() && - !parser.symp(syms::file)) - { - parser.sym(name); - parser.str(value); - attr[fp][name] = value; - } - } -} - -void -write_attr_map(data & dat, attr_map const & attr) -{ - std::ostringstream oss; - basic_io::printer pr(oss); - - for (attr_map::const_iterator i = attr.begin(); - i != attr.end(); ++i) - { - basic_io::stanza st; - st.push_str_pair(syms::file, i->first.as_internal()); - - for (std::map::const_iterator j = i->second.begin(); - j != i->second.end(); ++j) - st.push_str_pair(j->first, j->second); - - pr.print_stanza(st); - } - - dat = oss.str(); -} - - string const encoding_attribute("encoding"); string const binary_encoding("binary"); string const default_encoding("default"); string const manual_merge_attribute("manual_merge"); -static bool find_in_attr_map(attr_map const & attr, - file_path const & file, - std::string const & attr_key, - std::string & attr_val) -{ - attr_map::const_iterator f = attr.find(file); - if (f == attr.end()) - return false; - - std::map::const_iterator a = f->second.find(attr_key); - if (a == f->second.end()) - return false; - - attr_val = a->second; - return true; -} - bool get_attribute_from_roster(roster_t const & ros, file_path const & path, @@ -713,49 +630,6 @@ } -bool get_attribute_from_db(file_path const & file, - std::string const & attr_key, - manifest_map const & man, - std::string & attr_val, - app_state & app) -{ - file_path fp; - get_attr_path(fp); - manifest_map::const_iterator i = man.find(fp); - if (i == man.end()) - return false; - - file_id fid = manifest_entry_id(i); - if (!app.db.file_version_exists(fid)) - return false; - - file_data attr_data; - app.db.get_file_version(fid, attr_data); - - attr_map attr; - read_attr_map(data(attr_data.inner()()), attr); - - return find_in_attr_map(attr, file, attr_key, attr_val); -} - -bool get_attribute_from_working_copy(file_path const & file, - std::string const & attr_key, - std::string & attr_val) -{ - file_path fp; - get_attr_path(fp); - if (!file_exists(fp)) - return false; - - data attr_data; - read_data(fp, attr_data); - - attr_map attr; - read_attr_map(attr_data, attr); - - return find_in_attr_map(attr, file, attr_key, attr_val); -} - void update_any_attrs(app_state & app) { temp_node_id_source nis; ======================================================================== --- work.hh 56b2b9be3b0cb7fcabee21e948788a57658af3eb +++ work.hh 81add376cf6c2448fa5d48c117b6b472d02def69 @@ -160,28 +160,6 @@ void enable_inodeprints(); -// the "attribute map" is part of a working copy. it is *not* stored in MT, -// because its contents are considered part of the "content" of a tree of -// files. it is therefore stored in .mt-attrs, in the root of your -// tree. you do not need a .mt-attrs file, it's just an extension -// mechanism. -// -// the contents of the .mt-attrs file is a list of [file, name, value] -// triples, each of which assigns a particular "extended attribute" to a -// file in your manifest. example "extended attributes" are things like -// "set the execute bit" or "this file is read-only" or whatnot. they are -// intrinsic properties of the files, but not actually part of the file's -// data stream. so they're kept here. - -typedef std::map > attr_map; - -void get_attr_path(file_path & a_path); - -void read_attr_map(data const & dat, attr_map & attrs); - -void write_attr_map(data & dat, - attr_map const & options); - extern std::string const encoding_attribute; extern std::string const manual_merge_attribute; @@ -190,16 +168,6 @@ attr_key const & key, attr_value & val); -bool get_attribute_from_db(file_path const & file, - std::string const & attr_key, - manifest_map const & man, - std::string & attr_val, - app_state & app); - -bool get_attribute_from_working_copy(file_path const & file, - std::string const & attr_key, - std::string & attr_val); - void update_any_attrs(app_state & app); extern std::string const binary_encoding; ======================================================================== --- xdelta.cc b842258e0b59f3c95c8389cd61d1611f80f4328e +++ xdelta.cc 7c8499810d4afe6687979cdccbaef6ecf65c20fe @@ -230,91 +230,7 @@ } -// specialized form for manifest maps, which -// are sorted, so have far more structure - -static void -flush_copy(ostringstream & oss, u32 & pos, u32 & len) -{ - if (len != 0) - { - // flush any copy which is going on - oss << insn(pos, len); - pos = pos + len; - len = 0; - } -} - void -compute_delta(manifest_map const & a, - manifest_map const & b, - string & delta) -{ - delta.clear(); - ostringstream oss; - - manifest_map::const_iterator i = a.begin(); - manifest_map::const_iterator j = b.begin(); - - u32 pos = 0; - u32 len = 0; - while (j != b.end()) - { - size_t isz = 0; - - if (i != a.end()) - isz = i->first.as_internal().size() + 2 + i->second.inner()().size() + 1; - - if (i != a.end() && i->first == j->first) - { - if (i->second == j->second) - { - // this line was copied - len += isz; - } - else - { - // this line was changed, but the *entry* remained, so we - // treat it as a simultaneous delete + insert. that means - // advance pos over what used to be here, set len to 0, and - // copy the new data. - flush_copy(oss, pos, len); - pos += isz; - ostringstream ss; - ss << *j; - oss << insn(ss.str()); - } - ++i; ++j; - } - else - { - - flush_copy(oss, pos, len); - - if (i != a.end() && i->first < j->first) - { - // this line was deleted - ++i; - pos += isz; - } - - else - { - // this line was added - ostringstream ss; - ss << *j; - oss << insn(ss.str()); - ++j; - } - } - } - - flush_copy(oss,pos,len); - delta = oss.str(); -} - - -void compute_delta(string const & a, string const & b, string & delta) ======================================================================== --- xdelta.hh 16bbaaed2e75018ccc76fa6ed421b38556f30e61 +++ xdelta.hh 1b06a9dce1174f9c40fd5e8541aa0c6d81f13d50 @@ -17,11 +17,6 @@ std::string & delta); void -compute_delta(manifest_map const & a, - manifest_map const & b, - std::string & delta); - -void apply_delta(std::string const & a, std::string const & delta, std::string & b);