# # # add_dir "tests/importing_cvs_ignore_symbol" # # add_dir "tests/importing_cvs_ignore_symbol/cvs-repository" # # add_dir "tests/importing_cvs_ignore_symbol/cvs-repository/test" # # add_file "tests/importing_cvs_ignore_symbol/__driver__.lua" # content [934ece1dd4ebf9003b08f41529389d92d024c7aa] # # add_file "tests/importing_cvs_ignore_symbol/cvs-repository/test/foo,v" # content [485b4eea51d5cdd4324208ec75d7b8629460fabc] # # add_file "tests/importing_cvs_ignore_symbol/ignhook.lua" # content [e001b9a4c938804082171474c451358600efd093] # # add_file "tests/importing_cvs_ignore_symbol/makerepo.sh" # content [a633103837ef9b935631e505c8d1f07015843e29] # # patch "lua_hooks.cc" # from [26dbfb8306a7b7b4871f61877c7fd0f72abadfdd] # to [2e11a62e9cd68d4d45a42d4c6f26cfc816a0b1c0] # # patch "lua_hooks.hh" # from [a03b6a9de65a23204776355184e50a093f65f649] # to [88672a9f0e17b68c5683ea175117a34d3e4d74b6] # # patch "rcs_import.cc" # from [6b5f07ff953e11ce3a13329a867ca9cb8913e15d] # to [d03d087c53f1ce816d59a0aa997973cfa6325a41] # # set "tests/importing_cvs_ignore_symbol/makerepo.sh" # attr "mtn:execute" # value "true" # ============================================================ --- tests/importing_cvs_ignore_symbol/__driver__.lua 934ece1dd4ebf9003b08f41529389d92d024c7aa +++ tests/importing_cvs_ignore_symbol/__driver__.lua 934ece1dd4ebf9003b08f41529389d92d024c7aa @@ -0,0 +1,20 @@ + +mtn_setup() + +-- loosely based on importing_cvs_files, but with some tags and an +-- ignore_cvs_symbol hook. + +-- See makerepo.sh on how this repository was created. +check(get("cvs-repository")) +check(get("ignhook.lua")) + +-- import into monotone and check presence of tags +check(mtn("--branch=testbranch", "--debug", "--rcfile=ignhook.lua", "cvs_import", "cvs-repository/test"), 0, false, false) +check(mtn("ls", "tags"), 0, true, false) + +-- check if we have the tag we want.. +check(qgrep("TAG_TO_RESPECT", "stdout")) + +-- ..but not the one we don't +check(not qgrep("TAG_TO_IGNORE", "stdout")) + ============================================================ --- tests/importing_cvs_ignore_symbol/cvs-repository/test/foo,v 485b4eea51d5cdd4324208ec75d7b8629460fabc +++ tests/importing_cvs_ignore_symbol/cvs-repository/test/foo,v 485b4eea51d5cdd4324208ec75d7b8629460fabc @@ -0,0 +1,27 @@ +head 1.1; +access; +symbols + TAG_TO_RESPECT:1.1 + TAG_TO_IGNORE:1.1; +locks; strict; +comment @# @; + + +1.1 +date 2008.01.04.22.09.47; author markus; state Exp; +branches; +next ; +commitid wQ3xKAMPGDyL89Ms; + + +desc +@@ + + +1.1 +log address@hidden 0 +@ +text address@hidden 0 of test file foo +@ ============================================================ --- tests/importing_cvs_ignore_symbol/ignhook.lua e001b9a4c938804082171474c451358600efd093 +++ tests/importing_cvs_ignore_symbol/ignhook.lua e001b9a4c938804082171474c451358600efd093 @@ -0,0 +1,9 @@ +function ignore_cvs_symbol(symbol_name) + if symbol_name == "TAG_TO_IGNORE" + then + return true + else + return false + end +end + ============================================================ --- tests/importing_cvs_ignore_symbol/makerepo.sh a633103837ef9b935631e505c8d1f07015843e29 +++ tests/importing_cvs_ignore_symbol/makerepo.sh a633103837ef9b935631e505c8d1f07015843e29 @@ -0,0 +1,32 @@ +#!/bin/sh + +CVSROOT=`pwd`/cvs-repository +export CVSROOT + +# deleting the existing cvs-repository +rm -vrf $CVSROOT + +# initializing a new repository +cvs init + +# do a full checkout of the repository +mkdir full_checkout +cd full_checkout +cvs co . +mkdir test +cvs add test + +# do some commits on file foo +echo "version 0 of test file foo" > test/foo +cvs add test/foo +cvs commit -m "commit 0" test/foo + +# tag file foo twice +cvs rtag TAG_TO_IGNORE test/foo +cvs rtag TAG_TO_RESPECT test/foo + +cd .. +rm -rf full_checkout + +# clean up the CVS repository bookkeeping dir +rm -rf cvs-repository/CVSROOT ============================================================ --- lua_hooks.cc 26dbfb8306a7b7b4871f61877c7fd0f72abadfdd +++ lua_hooks.cc 2e11a62e9cd68d4d45a42d4c6f26cfc816a0b1c0 @@ -978,6 +978,19 @@ lua_hooks::hook_note_mtn_startup(args_ve return ll.ok(); } +bool +lua_hooks::hook_ignore_cvs_symbol(string const & symbol_name) +{ + bool ignore_it = false; + bool exec_ok = Lua(st) + .func("ignore_cvs_symbol") + .push_str(symbol_name) + .call(1,1) + .extract_bool(ignore_it) + .ok(); + return exec_ok && ignore_it; +} + namespace commands { class cmd_lua : public command { ============================================================ --- lua_hooks.hh a03b6a9de65a23204776355184e50a093f65f649 +++ lua_hooks.hh 88672a9f0e17b68c5683ea175117a34d3e4d74b6 @@ -159,6 +159,9 @@ public: size_t revs_in, size_t revs_out, size_t keys_in, size_t keys_out); bool hook_note_mtn_startup(args_vector const & args); + + // cvs_import hooks + bool hook_ignore_cvs_symbol(std::string const & symbol_name); }; // Local Variables: ============================================================ --- rcs_import.cc 6b5f07ff953e11ce3a13329a867ca9cb8913e15d +++ rcs_import.cc d03d087c53f1ce816d59a0aa997973cfa6325a41 @@ -1323,7 +1323,7 @@ process_rcs_branch(cvs_symbol_no const & rcs_file const & r, database & db, cvs_history & cvs, - bool dryrun, + app_state & app, bool reverse_import) { cvs_event_ptr curr_commit = NULL, @@ -1402,6 +1402,11 @@ process_rcs_branch(cvs_symbol_no const & { L(FL("version %s -> tag %s") % curr_version % i->second); + // allow the user to ignore tag symbols depending on their + // name. + if (app.lua.hook_ignore_cvs_symbol(i->second)) + continue; + cvs_symbol_no tag = cvs.symbol_interner.intern(i->second); cvs_event_ptr tag_symbol = (cvs_event_ptr) @@ -1482,7 +1487,7 @@ process_rcs_branch(cvs_symbol_no const & construct_version(*curr_lines, *i, branch_lines, r); insert_into_db(curr_data, curr_id, branch_lines, branch_data, branch_id, db, - dryrun); + app.opts.dryrun); } cvs_symbol_no bname = cvs.symbol_interner.intern(branchname); @@ -1490,8 +1495,7 @@ process_rcs_branch(cvs_symbol_no const & // recursively process child branches cvs_event_ptr first_event_in_branch = process_rcs_branch(bname, *i, branch_lines, branch_data, - branch_id, r, db, cvs, dryrun, - false); + branch_id, r, db, cvs, app, false); if (!priv) L(FL("finished RCS branch %s = '%s'") % (*i) % branchname); else @@ -1573,7 +1577,8 @@ process_rcs_branch(cvs_symbol_no const & next_version); insert_into_db(curr_data, curr_id, - *next_lines, next_data, next_id, db, dryrun); + *next_lines, next_data, next_id, db, + app.opts.dryrun); } if (!r.deltas.find(curr_version)->second->next.empty()) @@ -1678,7 +1683,7 @@ import_rcs_file_with_cvs(string const & cvs_event_ptr first_event = process_rcs_branch(cvs.base_branch, r.admin.head, head_lines, - dat, id, r, app.db, cvs, app.opts.dryrun, true); + dat, id, r, app.db, cvs, app, true); // link the pseudo trunk branch to the first event in the branch cvs.add_dependency(first_event, cvs.root_event);