I think the net.venge.monotone.work-rev-refactor branch is ready for
mainline. Would appreciate any comments, and also it totally changes
the internal _MTN/revision-related APIs, so people might want to take
note.
The full patch is ~60 kilobytes because there are lots of callsites
switched over to the new API. Not sending the full patch to the list,
but if anyone wants to see it:
mtn diff -r 133d7c3ff21229143d27ccd7cca5d64d2b117335 \
-r 3befc7cb6ed014757134d403ecf3618ec98e44d2
The important changes are in work.hh, and that part of the patch is
attached. Rationale: Currently, when we modify the workspace, we do
something like:
1) load the workspace roster (internally, this is done by loading
_MTN/revision, loading the parent roster(s), and applying the csets
in _MTN/revision to those roster(s).)
2) muck around with the workspace roster
3) load the parent roster(s)
4) use make_revision_for_workspace to calculate the differences from
the parent roster(s) to the new workspace roster, as a revision
5) write the revision to _MTN/revision with put_work_rev
This is inefficient (we load the parent roster(s) twice; often the
roster cache will handle this, but still), poorly factored (the whole
thing is open-coded all over the place instead of being encapsulated
somewhere), and also it interferes with my Secret Plan (which is only
secret at all because CIA is still down, but anyway).
In the modified API, put_work_rev has become a private function, and
get_current_roster_shape has (sort of) been removed. Instead we have
two functions that complement each other:
void get_work_state_shape_only(parent_map & parents,
roster_t & ros,
node_id_source & nis);
void set_work_state(parent_map const & parents,
roster_t const & new_roster);
The first is the same as the old get_current_roster_shape except that
it also returns the parent map; the second encapsulates steps
(4) and (5) above. Also there are a few other utilities like
set_work_state_to_new_root().
-- Nathaniel
--
"Of course, the entire effort is to put oneself
Outside the ordinary range
Of what are called statistics."
-- Stephan Spender
#
# old_revision [133d7c3ff21229143d27ccd7cca5d64d2b117335]
#
# patch "work.hh"
# from [49bf298fac3d660308c2b7106ff46854546401bd]
# to [8f753ef66b7b0eb6402f9b132f79e2615d4aa00d]
#
============================================================
--- work.hh 49bf298fac3d660308c2b7106ff46854546401bd
+++ work.hh 8f753ef66b7b0eb6402f9b132f79e2615d4aa00d
@@ -98,32 +98,44 @@ struct workspace
void update_any_attrs();
- bool has_changes();
-
// write out a new (partial) revision describing the current workspace;
// the important pieces of this are the base revision id and the "shape"
// changeset (representing tree rearrangements).
- void put_work_rev(revision_t const & rev);
+ void set_work_state(parent_map const & parents,
+ roster_t const & new_roster);
+ // For setup:
+ void set_work_state_to_new_root();
+ // For checkout, import:
+ void set_work_state_unchanged(revision_id const & parent_id);
// read the (partial) revision describing the current workspace.
void get_work_rev(revision_t & rev);
+ // if this workspace has exactly one parent, give its revision id;
+ // otherwise, error out.
+ void get_unique_base_rid(revision_id & rid);
+
// convenience wrappers around the above functions.
+ // This returns a map whose keys are revision_ids and whose values are
+ // rosters, there being one such pair for each parent of the current
+ // revision.
+ //
+ // Usually you will need both the parents and the current roster, in which
+ // case it is more efficient to use get_current_roster_shape (below).
+ void get_parent_rosters(parent_map & parents);
+
// This returns the current roster, except it does not bother updating the
// hashes in that roster -- the "shape" is correct, all files and dirs
// exist and under the correct names -- but do not trust file content
// hashes. If you need the current roster with correct file content
// hashes, call update_current_roster_from_filesystem on the result of
// this function. Under almost all conditions, NIS should be a
- // temp_node_id_source.
- void get_current_roster_shape(roster_t & ros, node_id_source & nis);
+ // temp_node_id_source. (It also returns the parent rosters, because this
+ // is free.)
+ void get_work_state_shape_only(parent_map & parents,
+ roster_t & ros, node_id_source & nis);
- // This returns a map whose keys are revision_ids and whose values are
- // rosters, there being one such pair for each parent of the current
- // revision.
- void get_parent_rosters(parent_map & parents);
-
// Inspect the workspace and classify all the paths in it according to
// what ROS thinks of them.
void classify_roster_paths(roster_t const & ros,
@@ -206,6 +218,7 @@ private:
// lua hooks, we don't have to know about app_state.
workspace(database & db, lua_hooks & lua) : db(db), lua(lua) {};
private:
+ void put_work_rev(revision_t const & rev);
database & db;
lua_hooks & lua;
};
_______________________________________________
Monotone-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/monotone-devel