# # patch "ChangeLog" # from [02d8fa3ae843691cc540fb7e611f5b1d4e00b065] # to [63149c1de56b1d2b6ea34dc4542f6f7f8b9c6603] # # patch "commands.cc" # from [1a8a533c2f8e8cf9bd121653e87b8290757dacc2] # to [464b57a840edfc3a9474d6a263ba5637845dbe5b] # # patch "manifest.cc" # from [e7a6e846ee9a5cb05960b4b9f3eee71c723c258e] # to [cfa44e867c9068323e6cfe566b69d2e84f103264] # # patch "manifest.hh" # from [8e814036b2b84d20634979a941f2cb27412eff48] # to [d96380ff7a7e4e2cef53ad864608b6e97e484207] # # patch "revision.cc" # from [38aee4ec6634d7e11d7d5db73e1ad5d4349f7de9] # to [e3df88382e4fd3be836ca176063ae93244f6f268] # # patch "revision.hh" # from [9600fe27d3ee00d922d158b0fe2e3abb6a1a56fb] # to [810c1d47de4549a1e13d7e94b2fb4fe55c8df338] # # patch "work.cc" # from [29f75856fcd8eff9496ea288a1a57c4900e81950] # to [ae44332f15b2bcd9c3212b99413dc86b672d4941] # # patch "work.hh" # from [41939ab23e00e777cc07da3df1b31a74082c0ae8] # to [7d962298e1f4f0e65ec9b058caeb0f1db5b881fd] # --- ChangeLog +++ ChangeLog @@ -1,5 +1,35 @@ 2005-04-28 Derek Scherger + * commands.cc (get_work_path): + (get_revision_path): + (get_revision_id): + (put_revision_id): + (get_path_rearrangement): + (remove_path_rearrangement): + (put_path_rearrangement): + (update_any_attrs): + (get_base_revision): + (get_base_manifest): move to work.{cc,hh} + (update): indicate optional revision with [ and ] + (explicit_merge): indicate optional ancestor with [ and ] + + * manifest.{cc,hh} (extract_path_set): move here from work.{cc,hh} + * revision.{cc,hh} (revision_file_name): move to work.{cc,hh} + + * work.{cc,hh} (extract_path_set): move to manifest.{cc,hh} + (get_work_path): + (get_path_rearrangement): + (remove_path_rearrangement): + (put_path_rearrangement): + (get_revision_path): + (get_revision_id): + (put_revision_id): + (get_base_revision): + (get_base_manifest): + (update_any_attrs): move here from commands.cc + +2005-04-28 Derek Scherger + * ChangeLog: * Makefile.am * tests/t_automate_select.at: merge fixups --- commands.cc +++ commands.cc @@ -244,93 +244,6 @@ process(app, string(#realcommand), args); \ } -static void -get_work_path(local_path & w_path) -{ - w_path = (mkpath(book_keeping_dir) / mkpath(work_file_name)).string(); - L(F("work path is %s\n") % w_path); -} - -static void -get_revision_path(local_path & m_path) -{ - m_path = (mkpath(book_keeping_dir) / mkpath(revision_file_name)).string(); - L(F("revision path is %s\n") % m_path); -} - -static void -get_revision_id(revision_id & c) -{ - c = revision_id(); - local_path c_path; - get_revision_path(c_path); - - N(file_exists(c_path), - F("working copy is corrupt: %s does not exist\n") % c_path); - - data c_data; - L(F("loading revision id from %s\n") % c_path); - read_data(c_path, c_data); - c = revision_id(remove_ws(c_data())); -} - -static void -put_revision_id(revision_id const & rev) -{ - local_path c_path; - get_revision_path(c_path); - L(F("writing revision id to %s\n") % c_path); - data c_data(rev.inner()() + "\n"); - write_data(c_path, c_data); -} - -static void -get_path_rearrangement(change_set::path_rearrangement & w) -{ - local_path w_path; - get_work_path(w_path); - if (file_exists(w_path)) - { - L(F("checking for un-committed work file %s\n") % w_path); - data w_data; - read_data(w_path, w_data); - read_path_rearrangement(w_data, w); - L(F("read rearrangement from %s\n") % w_path); - } - else - { - L(F("no un-committed work file %s\n") % w_path); - } -} - -static void -remove_path_rearrangement() -{ - local_path w_path; - get_work_path(w_path); - if (file_exists(w_path)) - delete_file(w_path); -} - -static void -put_path_rearrangement(change_set::path_rearrangement & w) -{ - local_path w_path; - get_work_path(w_path); - - if (w.empty()) - { - if (file_exists(w_path)) - delete_file(w_path); - } - else - { - data w_data; - write_path_rearrangement(w, w_data); - write_data(w_path, w_data); - } -} - static void extract_rearranged_paths(change_set::path_rearrangement const & rearrangement, path_set & paths) { @@ -482,60 +395,7 @@ } } -static void -update_any_attrs(app_state & app) -{ - file_path fp; - data attr_data; - attr_map attr; - - get_attr_path(fp); - if (!file_exists(fp)) - return; - - read_data(fp, attr_data); - read_attr_map(attr_data, attr); - apply_attributes(app, attr); -} - static void -get_base_revision(app_state & app, - revision_id & rid, - manifest_id & mid, - manifest_map & man) -{ - man.clear(); - - get_revision_id(rid); - - if (!null_id(rid)) - { - - N(app.db.revision_exists(rid), - F("base revision %s does not exist in database\n") % rid); - - app.db.get_revision_manifest(rid, mid); - L(F("old manifest is %s\n") % mid); - - N(app.db.manifest_version_exists(mid), - F("base manifest %s does not exist in database\n") % mid); - - app.db.get_manifest(mid, man); - } - - L(F("old manifest has %d entries\n") % man.size()); -} - -static void -get_base_manifest(app_state & app, - manifest_map & man) -{ - revision_id rid; - manifest_id mid; - get_base_revision(app, rid, mid, man); -} - -static void calculate_restricted_rearrangement(app_state & app, vector const & args, manifest_id & old_manifest_id, @@ -3276,8 +3136,8 @@ write_localized_data(pth, tmp.inner(), app.lua); } } - + // static void dump_change_set(string const & name, // change_set & cs) // { @@ -3286,7 +3146,7 @@ // cout << "change set '" << name << "'\n" << dat << endl; // } -CMD(update, "working copy", "\nREVISION", "update working copy to be based off another revision") +CMD(update, "working copy", "[REVISION]", "update working copy to be based off another revision") { manifest_map m_old, m_ancestor, m_working, m_chosen; manifest_id m_ancestor_id, m_chosen_id; @@ -3665,7 +3525,9 @@ maybe_update_inodeprints(app); } -CMD(explicit_merge, "tree", "LEFT-REVISION RIGHT-REVISION DEST-BRANCH\nLEFT-REVISION RIGHT-REVISION COMMON-ANCESTOR DEST-BRANCH", +CMD(explicit_merge, "tree", + "LEFT-REVISION RIGHT-REVISION DEST-BRANCH\n" + "LEFT-REVISION RIGHT-REVISION [COMMON-ANCESTOR] DEST-BRANCH", "merge two explicitly given revisions, placing result in given branch") { revision_id left, right, ancestor; --- manifest.cc +++ manifest.cc @@ -58,6 +58,15 @@ man.insert(manifest_entry(path, file_id(ident))); } +void +extract_path_set(manifest_map const & man, path_set & paths) +{ + paths.clear(); + for (manifest_map::const_iterator i = man.begin(); + i != man.end(); ++i) + paths.insert(manifest_entry_path(i)); +} + inline static bool inodeprint_unchanged(inodeprint_map const & ipm, file_path const & path) { --- manifest.hh +++ manifest.hh @@ -74,6 +74,8 @@ class app_state; +void extract_path_set(manifest_map const & man, path_set & paths); + void classify_paths(app_state & app, path_set const & paths, manifest_map const & m_old, --- revision.cc +++ revision.cc @@ -1606,8 +1606,6 @@ // i/o stuff -std::string revision_file_name("revision"); - namespace { namespace syms --- revision.hh +++ revision.hh @@ -46,8 +46,6 @@ // from [95b50ede90037557fd0fbbfad6a9fdd67b0bf413] // to [bd39086b9da776fc22abd45734836e8afb59c8c0] -extern std::string revision_file_name; - typedef std::map > > edge_map; --- work.cc +++ work.cc @@ -19,8 +19,6 @@ using namespace boost; using namespace std; -std::string const work_file_name("work"); - class addition_builder : public tree_walker @@ -292,17 +290,132 @@ pr = pr_concatenated; } +// work file containing rearrangement from uncommitted adds/drops/renames -void -extract_path_set(manifest_map const & man, - path_set & paths) +std::string const work_file_name("work"); + +static void get_work_path(local_path & w_path) { - paths.clear(); - for (manifest_map::const_iterator i = man.begin(); - i != man.end(); ++i) - paths.insert(manifest_entry_path(i)); + w_path = (mkpath(book_keeping_dir) / mkpath(work_file_name)).string(); + L(F("work path is %s\n") % w_path); } +void get_path_rearrangement(change_set::path_rearrangement & w) +{ + local_path w_path; + get_work_path(w_path); + if (file_exists(w_path)) + { + L(F("checking for un-committed work file %s\n") % w_path); + data w_data; + read_data(w_path, w_data); + read_path_rearrangement(w_data, w); + L(F("read rearrangement from %s\n") % w_path); + } + else + { + L(F("no un-committed work file %s\n") % w_path); + } +} + +void remove_path_rearrangement() +{ + local_path w_path; + get_work_path(w_path); + if (file_exists(w_path)) + delete_file(w_path); +} + +void put_path_rearrangement(change_set::path_rearrangement & w) +{ + local_path w_path; + get_work_path(w_path); + + if (w.empty()) + { + if (file_exists(w_path)) + delete_file(w_path); + } + else + { + data w_data; + write_path_rearrangement(w, w_data); + write_data(w_path, w_data); + } +} + +// revision file name + +std::string revision_file_name("revision"); + +static void get_revision_path(local_path & m_path) +{ + m_path = (mkpath(book_keeping_dir) / mkpath(revision_file_name)).string(); + L(F("revision path is %s\n") % m_path); +} + +void get_revision_id(revision_id & c) +{ + c = revision_id(); + local_path c_path; + get_revision_path(c_path); + + N(file_exists(c_path), + F("working copy is corrupt: %s does not exist\n") % c_path); + + data c_data; + L(F("loading revision id from %s\n") % c_path); + read_data(c_path, c_data); + c = revision_id(remove_ws(c_data())); +} + +void put_revision_id(revision_id const & rev) +{ + local_path c_path; + get_revision_path(c_path); + L(F("writing revision id to %s\n") % c_path); + data c_data(rev.inner()() + "\n"); + write_data(c_path, c_data); +} + +void +get_base_revision(app_state & app, + revision_id & rid, + manifest_id & mid, + manifest_map & man) +{ + man.clear(); + + get_revision_id(rid); + + if (!null_id(rid)) + { + + N(app.db.revision_exists(rid), + F("base revision %s does not exist in database\n") % rid); + + app.db.get_revision_manifest(rid, mid); + L(F("old manifest is %s\n") % mid); + + N(app.db.manifest_version_exists(mid), + F("base manifest %s does not exist in database\n") % mid); + + app.db.get_manifest(mid, man); + } + + L(F("old manifest has %d entries\n") % man.size()); +} + +void +get_base_manifest(app_state & app, + manifest_map & man) +{ + revision_id rid; + manifest_id mid; + get_base_revision(app, rid, mid, man); +} + + // user log file string const user_log_file_name("log"); @@ -516,7 +629,7 @@ } -void +static void apply_attributes(app_state & app, attr_map const & attr) { for (attr_map::const_iterator i = attr.begin(); @@ -591,3 +704,18 @@ return find_in_attr_map(attr, file, attr_key, attr_val); } + +void update_any_attrs(app_state & app) +{ + file_path fp; + data attr_data; + attr_map attr; + + get_attr_path(fp); + if (!file_exists(fp)) + return; + + read_data(fp, attr_data); + read_attr_map(attr_data, attr); + apply_attributes(app, attr); +} --- work.hh +++ work.hh @@ -42,15 +42,10 @@ // delta_set between the modified manifest and the files in the working // copy. // -// MT/inodes, if prsent, can be used to speed up this last step. +// MT/inodes, if present, can be used to speed up this last step. typedef std::set path_set; -extern std::string const work_file_name; - -void extract_path_set(manifest_map const & man, - path_set & paths); - void build_additions(std::vector const & args, manifest_map const & m_old, @@ -70,6 +65,24 @@ change_set::path_rearrangement & pr); +// the "work" file contains the current path rearrangement representing +// uncommitted add/drop/rename operations in the serialized change set format + +void get_path_rearrangement(change_set::path_rearrangement & w); +void remove_path_rearrangement(); +void put_path_rearrangement(change_set::path_rearrangement & w); + +// the "revision" file contains the base revision id that the current working +// copy was checked out from + +void get_revision_id(revision_id & c); +void put_revision_id(revision_id const & rev); +void get_base_revision(app_state & app, + revision_id & rid, + manifest_id & mid, + manifest_map & man); +void get_base_manifest(app_state & app, manifest_map & man); + // the "user log" is a file the user can edit as they program to record // changes they make to their source code. Upon commit the file is read // and passed to the edit_comment lua hook. If the commit is a success, @@ -138,9 +151,6 @@ void write_attr_map(data & dat, attr_map const & options); -void apply_attributes(app_state & app, - attr_map const & attr); - extern std::string const encoding_attribute; bool get_attribute_from_db(file_path const & file, @@ -153,6 +163,8 @@ std::string const & attr_key, std::string & attr_val); +void update_any_attrs(app_state & app); + extern std::string const binary_encoding; extern std::string const default_encoding;