monotone

monotone Mtn Source Tree

Root/src/lua_hooks.hh

1// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
2// 2008 Stephen Leake <stephen_leake@stephe-leake.org>
3//
4// This program is made available under the GNU GPL version 2.0 or
5// greater. See the accompanying file COPYING for details.
6//
7// This program is distributed WITHOUT ANY WARRANTY; without even the
8// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9// PURPOSE.
10
11#ifndef __LUA_HOOKS_HH__
12#define __LUA_HOOKS_HH__
13
14// this file defines a typed C++ interface to the various hooks
15// we expose to the user as lua functions or variables
16
17#include <set>
18#include <map>
19#include "file_io.hh"
20#include "option.hh"
21#include "vocab.hh"
22#include "paths.hh"
23#include "commands.hh"
24
25using std::string;
26using std::vector;
27using std::map;
28using std::pair;
29
30struct uri_t;
31class app_state;
32class key_store;
33struct lua_State;
34struct globish;
35struct options;
36class project_t;
37struct key_identity_info;
38
39extern app_state* get_app_state(lua_State *LS);
40
41class lua_hooks
42{
43 struct lua_State * st;
44
45 void add_std_hooks();
46 void load_rcfile(utf8 const & file);
47 void load_rcfile(any_path const & file, bool required);
48
49public:
50 lua_hooks(app_state * app);
51 ~lua_hooks();
52 bool check_lua_state(lua_State * st) const;
53 void load_rcfiles(options const & opts);
54 bool hook_exists(string const & func_name);
55
56 // cert hooks
57 bool hook_expand_selector(string const & sel, string & exp);
58 bool hook_expand_date(string const & sel, string & exp);
59 bool hook_get_branch_key(branch_name const & branchname,
60 key_store & keys,
61 project_t & project, key_id & k);
62 bool hook_get_passphrase(key_identity_info const & info,
63 string & phrase);
64 bool hook_get_local_key_name(key_identity_info & info);
65 bool hook_get_author(branch_name const & branchname,
66 key_identity_info const & info,
67 string & author);
68 bool hook_edit_comment(external const & user_log_message,
69 external & result);
70 bool hook_persist_phrase_ok();
71 bool hook_get_revision_cert_trust(std::set<key_identity_info> const & signers,
72 id const & hash,
73 cert_name const & name,
74 cert_value const & val);
75 bool hook_get_manifest_cert_trust(std::set<key_name> const & signers,
76 id const & hash,
77 cert_name const & name,
78 cert_value const & val);
79 bool hook_accept_testresult_change(map<key_id, bool> const & old_results,
80 map<key_id, bool> const & new_results);
81
82 // network hooks
83 bool hook_get_netsync_client_key(utf8 const & server_address,
84 globish const & include,
85 globish const & exclude,
86 key_store & keys,
87 project_t & project,
88 key_id & k);
89 bool hook_get_netsync_server_key(vector<utf8> const & server_ports,
90 key_store & keys,
91 project_t & project,
92 key_id & k);
93 bool hook_get_netsync_connect_command(uri_t const & uri,
94 globish const & include_pattern,
95 globish const & exclude_pattern,
96 bool debug,
97 vector<string> & argv);
98 bool hook_use_transport_auth(uri_t const & uri);
99
100 bool hook_get_netsync_read_permitted(string const & branch,
101 key_identity_info const & identity);
102 // anonymous no-key version
103 bool hook_get_netsync_read_permitted(string const & branch);
104 bool hook_get_netsync_write_permitted(key_identity_info const & identity);
105
106 bool hook_get_remote_automate_permitted(key_identity_info const & identity,
107 vector<string> const & command_line,
108 vector<pair<string, string> > const & command_opts);
109
110 // local repo hooks
111 bool hook_ignore_file(file_path const & p);
112 bool hook_ignore_branch(branch_name const & branch);
113 bool hook_merge3(file_path const & anc_path,
114 file_path const & left_path,
115 file_path const & right_path,
116 file_path const & merged_path,
117 data const & ancestor,
118 data const & left,
119 data const & right,
120 data & result);
121
122 bool hook_external_diff(file_path const & path,
123 data const & data_old,
124 data const & data_new,
125 bool is_binary,
126 bool diff_args_provided,
127 string const & diff_args,
128 string const & oldrev,
129 string const & newrev);
130
131 bool hook_get_encloser_pattern(file_path const & path,
132 string & pattern);
133
134 bool hook_get_default_command_options(commands::command_id const & cmd,
135 args_vector & args);
136
137 bool hook_get_date_format_spec(date_format_spec in, string & out);
138
139 bool hook_get_default_database_alias(string & alias);
140
141 bool hook_get_default_database_locations(vector<system_path> & out);
142
143 bool hook_get_default_database_glob(globish & out);
144
145 // workspace hooks
146 bool hook_use_inodeprints();
147
148 // attribute hooks
149 bool hook_init_attributes(file_path const & filename,
150 map<string, string> & attrs);
151 bool hook_set_attribute(string const & attr,
152 file_path const & filename,
153 string const & value);
154 bool hook_clear_attribute(string const & attr,
155 file_path const & filename);
156
157 // validation hooks
158 bool hook_validate_changes(revision_data const & new_rev,
159 branch_name const & branchname,
160 bool & validated,
161 string & reason);
162
163 bool hook_validate_commit_message(utf8 const & message,
164 revision_data const & new_rev,
165 branch_name const & branchname,
166 bool & validated,
167 string & reason);
168
169 // misc hooks
170 bool hook_hook_wrapper(string const & func_name,
171 vector<string> const & args,
172 string & out);
173
174 bool hook_get_man_page_formatter_command(string & command);
175
176 // notification hooks
177 bool hook_note_commit(revision_id const & new_id,
178 revision_data const & rdat,
179 map<cert_name, cert_value> const & certs);
180
181 bool hook_note_netsync_start(size_t session_id,
182 string my_role,
183 int sync_type,
184 string remote_host,
185 key_identity_info const & remote_key,
186 globish include_pattern,
187 globish exclude_pattern);
188 bool hook_note_netsync_revision_received(revision_id const & new_id,
189 revision_data const & rdat,
190 std::set<pair<key_identity_info,
191 pair<cert_name,
192 cert_value> > > const & certs,
193 size_t session_id);
194 bool hook_note_netsync_revision_sent(revision_id const & new_id,
195 revision_data const & rdat,
196 std::set<pair<key_identity_info,
197 pair<cert_name,
198 cert_value> > > const & certs,
199 size_t session_id);
200 bool hook_note_netsync_pubkey_received(key_identity_info const & identity,
201 size_t session_id);
202 bool hook_note_netsync_pubkey_sent(key_identity_info const & identity,
203 size_t session_id);
204 bool hook_note_netsync_cert_received(revision_id const & rid,
205 key_identity_info const & identity,
206 cert_name const & name,
207 cert_value const & value,
208 size_t session_id);
209 bool hook_note_netsync_cert_sent(revision_id const & rid,
210 key_identity_info const & identity,
211 cert_name const & name,
212 cert_value const & value,
213 size_t session_id);
214 bool hook_note_netsync_end(size_t session_id, int status,
215 size_t bytes_in, size_t bytes_out,
216 size_t certs_in, size_t certs_out,
217 size_t revs_in, size_t revs_out,
218 size_t keys_in, size_t keys_out);
219 bool hook_note_mtn_startup(args_vector const & args);
220
221 // git export hooks
222 bool hook_unmapped_git_author(string const & unmapped_author,
223 string & fixed_author);
224 bool hook_validate_git_author(string const & author);
225
226};
227
228#endif // __LUA_HOOKS_HH__
229
230// Local Variables:
231// mode: C++
232// fill-column: 76
233// c-file-style: "gnu"
234// indent-tabs-mode: nil
235// End:
236// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status