# # patch "rcs_import.cc" # from [a21b094e9ed7c016087996ee1b9597d08d946461] # to [438e41e4370dfe139c40914c59b2b4021c03c888] # # patch "tests/t_cvsimport_drepper.at" # from [99b2dc609f08a0dfa0649226a11951534ce6c743] # to [9971343eeaf1e731f921931d47e7152d64332d68] # # patch "tests/t_cvsimport_drepper2.at" # from [6cbbd86a7d4476646de2b9db9a6bbaf199296701] # to [71bb28761fbd140ec26f78aa9d1f96751c3277a8] # ======================================================================== --- rcs_import.cc a21b094e9ed7c016087996ee1b9597d08d946461 +++ rcs_import.cc 438e41e4370dfe139c40914c59b2b4021c03c888 @@ -29,16 +29,17 @@ #include "cycle_detector.hh" #include "database.hh" #include "file_io.hh" +#include "interner.hh" #include "keys.hh" -#include "interner.hh" #include "manifest.hh" #include "packet.hh" +#include "paths.hh" +#include "platform.hh" #include "rcs_file.hh" +#include "safe_map.hh" #include "sanity.hh" #include "transforms.hh" #include "ui.hh" -#include "platform.hh" -#include "paths.hh" using namespace std; using boost::shared_ptr; @@ -151,10 +152,7 @@ interner file_version_interner; interner path_interner; interner tag_interner; - interner manifest_version_interner; - cycle_detector manifest_cycle_detector; - // assume admin has foo:X.Y.0.N in it, then // this multimap contains entries of the form // X.Y -> foo @@ -463,31 +461,7 @@ } } -void -rcs_put_raw_manifest_edge(hexenc const & old_id, - hexenc const & new_id, - delta const & del, - database & db) -{ - if (old_id == new_id) - { - L(F("skipping identity manifest edge\n")); - return; - } - if (db.manifest_version_exists(old_id)) - { - // we already have a way to get to this old version, - // no need to insert another reconstruction path - L(F("existing path to %s found, skipping\n") % old_id); - } - else - { - db.put_delta(old_id, new_id, del, "manifest_deltas"); - } -} - - static void insert_into_db(data const & curr_data, hexenc const & curr_id, @@ -987,9 +961,6 @@ // commit to the rev with the closest initial timestamp. that is, // the *latest* beginning time. -/* -// FIXME_ROSTERS: disabled until rewritten to use rosters - struct cvs_cluster { @@ -1030,8 +1001,8 @@ app_state & app; string const & branchname; cvs_branch const & branch; + set created_dirs; map live_files; - ticker & n_manifests; ticker & n_revisions; struct prepared_revision @@ -1049,22 +1020,21 @@ vector preps; - manifest_map parent_map, child_map; - manifest_id parent_mid, child_mid; + roster_t ros; + temp_node_id_source nis; + editable_roster_base editable_ros; revision_id parent_rid, child_rid; + manifest_id parent_mid, child_mid; cluster_consumer(cvs_history & cvs, app_state & app, string const & branchname, cvs_branch const & branch, - ticker & n_manifests, ticker & n_revs); - void consume_cluster(cvs_cluster const & c, - bool head_p); - void build_change_set(cvs_cluster const & c, - change_set & cs); - void store_manifest_edge(bool head_p); + void consume_cluster(cvs_cluster const & c); + void add_missing_parents(split_path const & sp, cset & cs); + void build_cset(cvs_cluster const & c, cset & cs); void store_auxiliary_certs(prepared_revision const & p); void store_revisions(); }; @@ -1090,11 +1060,10 @@ app_state & app, string const & branchname, shared_ptr const & branch, - ticker & n_manifests, ticker & n_revs) { cluster_set clusters; - cluster_consumer cons(cvs, app, branchname, *branch, n_manifests, n_revs); + cluster_consumer cons(cvs, app, branchname, *branch, n_revs); unsigned long commits_remaining = branch->lineage.size(); // step 1: sort the lineage @@ -1119,7 +1088,7 @@ if ((*j)->first_time + constants::cvs_window < i->time) { L(F("expiring cluster\n")); - cons.consume_cluster(**j, false); + cons.consume_cluster(**j); clusters.erase(j); } else @@ -1208,7 +1177,7 @@ L(F("finished branch commits, writing all pending clusters\n")); while (!clusters.empty()) { - cons.consume_cluster(**clusters.begin(), clusters.size() == 1); + cons.consume_cluster(**clusters.begin()); clusters.erase(clusters.begin()); } L(F("finished writing pending clusters\n")); @@ -1216,14 +1185,11 @@ cons.store_revisions(); } -*/ void import_cvs_repo(system_path const & cvsroot, app_state & app) { -/* -// FIXME_ROSTERS: disabled until rewritten to use rosters N(!directory_exists(cvsroot / "CVSROOT"), F("%s appears to be a CVS repository root directory\n" "try importing a module instead, with 'cvs_import %s/") @@ -1260,7 +1226,6 @@ I(cvs.stk.size() == 1); ticker n_revs(_("revisions"), "r", 1); - ticker n_manifests(_("manifests"), "m", 1); while (cvs.branches.size() > 0) { @@ -1269,7 +1234,7 @@ string branchname = i->first; shared_ptr branch = i->second; L(F("branch %s has %d entries\n") % branchname % branch->lineage.size()); - import_branch(cvs, app, branchname, branch, n_manifests, n_revs); + import_branch(cvs, app, branchname, branch, n_revs); // free up some memory cvs.branches.erase(branchname); @@ -1279,7 +1244,7 @@ { transaction_guard guard(app.db); L(F("trunk has %d entries\n") % cvs.trunk->lineage.size()); - import_branch(cvs, app, cvs.base_branch, cvs.trunk, n_manifests, n_revs); + import_branch(cvs, app, cvs.base_branch, cvs.trunk, n_revs); guard.commit(); } @@ -1301,23 +1266,19 @@ return; -*/ } -/* -// FIXME_ROSTERS: disabled until rewritten to use rosters cluster_consumer::cluster_consumer(cvs_history & cvs, app_state & app, string const & branchname, cvs_branch const & branch, - ticker & n_mans, ticker & n_revs) : cvs(cvs), app(app), branchname(branchname), branch(branch), - n_manifests(n_mans), - n_revisions(n_revs) + n_revisions(n_revs), + editable_ros(ros, nis) { if (!branch.live_at_beginning.empty()) { @@ -1345,7 +1306,7 @@ cvs.file_version_interner.lookup(i->second)); initial_cluster.entries.insert(make_pair(i->first, e)); } - consume_cluster(initial_cluster, branch.lineage.empty()); + consume_cluster(initial_cluster); } } @@ -1383,73 +1344,6 @@ } } -void -cluster_consumer::store_manifest_edge(bool head_p) -{ - L(F("storing manifest '%s' (base %s)\n") % parent_mid % child_mid); - ++n_manifests; - - if (head_p) - { - L(F("storing head %s\n") % child_mid); - // a branch has one very important manifest: the head. this is - // the "newest" of all manifests within the branch (including - // the trunk), and we store it in its entirety, before the - // cluster consumer is destroyed. - if (! app.db.manifest_version_exists(child_mid)) - { - manifest_data mdat; - write_manifest_map(child_map, mdat); - app.db.put_manifest(child_mid, mdat); - } - } - - if (null_id(parent_mid)) - { - L(F("skipping delta to null manifest\n")); - return; - } - - unsigned long older, newer; - - older = cvs.manifest_version_interner.intern(parent_mid.inner()()); - newer = cvs.manifest_version_interner.intern(child_mid.inner()()); - - if (cvs.manifest_cycle_detector.edge_makes_cycle(older,newer)) - { - - L(F("skipping cyclical manifest delta %s -> %s\n") - % parent_mid % child_mid); - // we are potentially breaking the chain one would use to get to - // p. we need to make sure p exists. - if (!app.db.manifest_version_exists(parent_mid)) - { - L(F("writing full manifest %s\n") % parent_mid); - manifest_data mdat; - write_manifest_map(parent_map, mdat); - app.db.put_manifest(parent_mid, mdat); - } - return; - } - - cvs.manifest_cycle_detector.put_edge(older,newer); - - L(F("storing manifest delta %s -> %s\n") - % child_mid % parent_mid); - - // the ancestry-based 'child' is a 'new' version as far as the - // storage system is concerned; that is to say that the - // ancestry-based 'parent' is a temporally older tree version, which - // can be constructed from the 'newer' child. so the delta should - // run from child (new) -> parent (old). - - delta del; - diff(child_map, parent_map, del); - rcs_put_raw_manifest_edge(parent_mid.inner(), - child_mid.inner(), - del, app.db); -} - void cluster_consumer::store_auxiliary_certs(prepared_revision const & p) { @@ -1482,22 +1376,44 @@ cert_revision_date_time(p.rid, p.time, app, dbw); } +void +cluster_consumer::add_missing_parents(split_path const & sp, cset & cs) +{ + split_path tmp(sp); + if (tmp.empty()) + return; + tmp.pop_back(); + while (!tmp.empty()) + { + if (created_dirs.find(tmp) == created_dirs.end()) + { + safe_insert(created_dirs, tmp); + safe_insert(cs.dirs_added, tmp); + } + tmp.pop_back(); + } +} + void -cluster_consumer::build_change_set(cvs_cluster const & c, - change_set & cs) +cluster_consumer::build_cset(cvs_cluster const & c, + cset & cs) { for (cvs_cluster::entry_map::const_iterator i = c.entries.begin(); i != c.entries.end(); ++i) { file_path pth = file_path_internal(cvs.path_interner.lookup(i->first)); + split_path sp; + pth.split(sp); + file_id fid(cvs.file_version_interner.lookup(i->second.version)); if (i->second.live) { map::const_iterator e = live_files.find(i->first); if (e == live_files.end()) { - L(F("adding entry state '%s' on '%s'\n") % fid % pth); - cs.add_file(pth, fid); + add_missing_parents(sp, cs); + L(F("adding entry state '%s' on '%s'\n") % fid % pth); + safe_insert(cs.files_added, make_pair(sp, fid)); live_files[i->first] = i->second.version; } else if (e->second != i->second.version) @@ -1505,7 +1421,8 @@ file_id old_fid(cvs.file_version_interner.lookup(e->second)); L(F("applying state delta on '%s' : '%s' -> '%s'\n") % pth % old_fid % fid); - cs.apply_delta(pth, old_fid, fid); + safe_insert(cs.deltas_applied, + make_pair(sp, make_pair(old_fid, fid))); live_files[i->first] = i->second.version; } } @@ -1515,7 +1432,7 @@ if (e != live_files.end()) { L(F("deleting entry state '%s' on '%s'\n") % fid % pth); - cs.delete_file(pth); + safe_insert(cs.nodes_deleted, sp); live_files.erase(i->first); } } @@ -1523,8 +1440,7 @@ } void -cluster_consumer::consume_cluster(cvs_cluster const & c, - bool head_p) +cluster_consumer::consume_cluster(cvs_cluster const & c) { // we should never have an empty cluster; it's *possible* to have // an empty changeset (say on a vendor import) but every cluster @@ -1533,26 +1449,18 @@ // you have an empty cluster. I(!c.entries.empty()); - L(F("BEGIN consume_cluster()\n")); shared_ptr rev(new revision_set()); - boost::shared_ptr cs(new change_set()); - build_change_set(c, *cs); + boost::shared_ptr cs(new cset()); + build_cset(c, *cs); - apply_change_set(*cs, child_map); - calculate_ident(child_map, child_mid); - + cs->apply_to(editable_ros); + calculate_ident(ros, child_mid); rev->new_manifest = child_mid; rev->edges.insert(make_pair(parent_rid, make_pair(parent_mid, cs))); calculate_ident(*rev, child_rid); - store_manifest_edge(head_p); - preps.push_back(prepared_revision(child_rid, rev, c)); - // now apply same change set to parent_map, making parent_map == child_map - apply_change_set(*cs, parent_map); - parent_mid = child_mid; parent_rid = child_rid; - L(F("END consume_cluster('%s') (parent '%s')\n") % child_rid % rev->edges.begin()->first); + parent_mid = child_mid; } -*/ ======================================================================== --- tests/t_cvsimport_drepper.at 99b2dc609f08a0dfa0649226a11951534ce6c743 +++ tests/t_cvsimport_drepper.at 9971343eeaf1e731f921931d47e7152d64332d68 @@ -6,9 +6,20 @@ NEED_UNGZB64 -AT_DATA(test.manifest, [94c86fa749ed82d76fe8d6cce18d11b8c3f0ee38 src/objdump.c -01f722126e54806abfa32f867dbeb8529b79298b tests/asm-tst3.c -7968cb0c8f62e6f15d710ce0cd42a65f7acd2567 tests/asm-tst4.c +AT_DATA(test.manifest, [dir "" + +dir "src" + + file "src/objdump.c" +content @<:@94c86fa749ed82d76fe8d6cce18d11b8c3f0ee38@:>@ + +dir "tests" + + file "tests/asm-tst3.c" +content @<:@01f722126e54806abfa32f867dbeb8529b79298b@:>@ + + file "tests/asm-tst4.c" +content @<:@7968cb0c8f62e6f15d710ce0cd42a65f7acd2567@:>@ ]) AT_DATA(e.tar.gz.enc, [H4sIACBaoUIAA+w8+1fbRrP51fortu6B2GCMMa8UBxoHTMKpAxzjtMlJOLqyJGM1 ======================================================================== --- tests/t_cvsimport_drepper2.at 6cbbd86a7d4476646de2b9db9a6bbaf199296701 +++ tests/t_cvsimport_drepper2.at 71bb28761fbd140ec26f78aa9d1f96751c3277a8 @@ -6,13 +6,24 @@ NEED_UNGZB64 -AT_DATA(test.manifest, [73c0eabf76cc611c33d821d203a52670b8f6265a t/libasm/ChangeLog -411cfd008f4a72e433b48d6421733b6a792ca3b7 t/libelf-po/POTFILES.in +AT_DATA(test.manifest, [dir "" + +dir "t" + +dir "t/libasm" + + file "t/libasm/ChangeLog" +content @<:@73c0eabf76cc611c33d821d203a52670b8f6265a@:>@ + +dir "t/libelf-po" + + file "t/libelf-po/POTFILES.in" +content @<:@411cfd008f4a72e433b48d6421733b6a792ca3b7@:>@ ]) -AT_DATA(test.tags, [initial f5e868d2572c2ae5b50fd93bc8d0cb827e416e50 address@hidden -portable-branch-base 1455aa956c2b095d476e803b8b3d85d8e8509bf7 address@hidden -portable-branch-fork-20050601T0139 1455aa956c2b095d476e803b8b3d85d8e8509bf7 address@hidden +AT_DATA(test.tags, [initial 8e6facbf8211cdff0c885e38e1f87ec2386bfe4d address@hidden +portable-branch-base ed6faa22e4e06d575189a2771959350b56dbc594 address@hidden +portable-branch-fork-20050601T0139 ed6faa22e4e06d575189a2771959350b56dbc594 address@hidden ]) AT_DATA(e.tar.gz.enc, [H4sIAEJyw0IAA+1YbW/bOBLOV+tXEOiHSw+xqhdKTuq9g4u03SuQbIumub1vAS3R