# # # patch "lua_hooks.cc" # from [33bca9e22966624a7caaa69386b3e949517199ef] # to [14c47b49b38e31bc04dd47c1ea5d53231c772f8d] # # patch "lua_hooks.hh" # from [25ed66326986fb26e1887a752eb19eae19ed2302] # to [13b02250e084d7e1d04d9df095f4409d3b6189bb] # # patch "merge_conflict.cc" # from [d453ad29aaf2576188b37c0f866eb5726a65398b] # to [69d21b97a7ad03d8905137bb3f859259f212ce27] # # patch "monotone.texi" # from [0989dbcc231553830b0c89b47e88eb990534fc56] # to [4f6e32c7445c20c85d07ca8005034f1fb4f2dca2] # # patch "work.cc" # from [518958b5c1abd181d67132ef354e11f1c73a7027] # to [b5811c6d3cc22d001ab1673b1c828a0e2683a73c] # ============================================================ --- lua_hooks.cc 33bca9e22966624a7caaa69386b3e949517199ef +++ lua_hooks.cc 14c47b49b38e31bc04dd47c1ea5d53231c772f8d @@ -824,9 +824,9 @@ bool } bool -lua_hooks::hook_apply_attribute(string const & attr, - file_path const & filename, - string const & value) +lua_hooks::hook_set_attribute(string const & attr, + file_path const & filename, + string const & value) { return Lua(st) .push_str("attr_functions") @@ -839,6 +839,20 @@ lua_hooks::hook_apply_attribute(string c .ok(); } +bool +lua_hooks::hook_clear_attribute(string const & attr, + file_path const & filename) +{ + return Lua(st) + .push_str("attr_functions") + .get_tab() + .push_str(attr) + .get_fn(-2) + .push_str(filename.as_external()) + .push_nil() + .call(2,0) + .ok(); +} bool lua_hooks::hook_validate_commit_message(utf8 const & message, ============================================================ --- lua_hooks.hh 25ed66326986fb26e1887a752eb19eae19ed2302 +++ lua_hooks.hh 13b02250e084d7e1d04d9df095f4409d3b6189bb @@ -119,9 +119,11 @@ public: // attribute hooks bool hook_init_attributes(file_path const & filename, std::map & attrs); - bool hook_apply_attribute(std::string const & attr, - file_path const & filename, - std::string const & value); + bool hook_set_attribute(std::string const & attr, + file_path const & filename, + std::string const & value); + bool hook_clear_attribute(std::string const & attr, + file_path const & filename); // validation hooks bool hook_validate_commit_message(utf8 const & message, ============================================================ --- merge_conflict.cc d453ad29aaf2576188b37c0f866eb5726a65398b +++ merge_conflict.cc 69d21b97a7ad03d8905137bb3f859259f212ce27 @@ -2220,7 +2220,7 @@ attach_node (lua_hooks & lua, for (attr_map_t::const_iterator attr = node->attrs.begin(); attr != node->attrs.end(); ++attr) - lua.hook_apply_attribute (attr->first(), target_path, attr->second.second()); + lua.hook_set_attribute(attr->first(), target_path, attr->second.second()); } // attach_node ============================================================ --- monotone.texi 0989dbcc231553830b0c89b47e88eb990534fc56 +++ monotone.texi 4f6e32c7445c20c85d07ca8005034f1fb4f2dca2 @@ -10244,11 +10244,20 @@ @subsection Attribute Handling This is not a hook function, but a @emph{table} of hook functions. Each entry in the table @code{attr_functions}, at table entry @var{attribute}, is a function taking a file name @var{filename} -and a attribute value @var{value}. The function should ``apply'' the -attribute to the file, possibly in a platform-specific way. +and an attribute value @var{value}. The function should ``apply'' the +attribute to the file, possibly in a platform-specific way. When +called to set an attribute the value this hook receives will be a +string representing the value of the attribute. When called to clear +an attribute the value this hook receives will be @code{nil}. -Hook functions from this table are called for each existing attr, -after any command which modifies the workspace. This facility can +Hook functions from this table are called for each existing attribute, +after any command which modifies the workspace. These functions are +also called during creation and modification of a workspace by the address@hidden, @command{merge_into_workspace}, @command{pluck}, address@hidden and @command{checkout} commands to set or clear +attributes as they change. + +This facility can be used to extend monotone's understanding of files with platform-specific attributes, such as permission bits, access control lists, or special file types. ============================================================ --- work.cc 518958b5c1abd181d67132ef354e11f1c73a7027 +++ work.cc b5811c6d3cc22d001ab1673b1c828a0e2683a73c @@ -1195,7 +1195,7 @@ editable_working_tree::clear_attr(file_p attr_key const & key) { L(FL("calling hook to clear attribute %s on %s") % key % path); - lua.hook_apply_attribute(key(), path, ""); + lua.hook_clear_attribute(key(), path); } void @@ -1204,7 +1204,7 @@ editable_working_tree::set_attr(file_pat attr_value const & value) { L(FL("calling hook to set attribute %s on %s to %s") % key % path % value); - lua.hook_apply_attribute(key(), path, value()); + lua.hook_set_attribute(key(), path, value()); } void @@ -1880,7 +1880,7 @@ workspace::update_any_attrs(database & d for (attr_map_t::const_iterator j = n->attrs.begin(); j != n->attrs.end(); ++j) if (j->second.first) - lua.hook_apply_attribute(j->first(), fp, j->second.second()); + lua.hook_set_attribute(j->first(), fp, j->second.second()); } }