monotone

monotone Mtn Source Tree

Root/lua_hooks.hh

1#ifndef __LUA_HOOKS_HH__
2#define __LUA_HOOKS_HH__
3
4// Copyright (C) 2008 Stephen Leake <stephen_leake@stephe-leake.org>
5// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
6//
7// This program is made available under the GNU GPL version 2.0 or
8// greater. See the accompanying file COPYING for details.
9//
10// This program is distributed WITHOUT ANY WARRANTY; without even the
11// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12// PURPOSE.
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
25struct uri;
26class app_state;
27struct lua_State;
28struct globish;
29struct options;
30
31extern app_state* get_app_state(lua_State *L);
32
33class lua_hooks
34{
35 struct lua_State * st;
36
37 void add_std_hooks();
38 void load_rcfile(utf8 const & file);
39 void load_rcfile(any_path const & file, bool required);
40
41public:
42 lua_hooks(app_state * app);
43 ~lua_hooks();
44 bool check_lua_state(lua_State * st) const;
45 void load_rcfiles(options & opts);
46 bool hook_exists(std::string const & func_name);
47
48 // cert hooks
49 bool hook_expand_selector(std::string const & sel, std::string & exp);
50 bool hook_expand_date(std::string const & sel, std::string & exp);
51 bool hook_get_branch_key(branch_name const & branchname, rsa_keypair_id & k);
52 bool hook_get_passphrase(rsa_keypair_id const & k, std::string & phrase);
53 bool hook_get_author(branch_name const & branchname,
54 rsa_keypair_id const & k,
55 std::string & author);
56 bool hook_edit_comment(external const & commentary,
57 external const & user_log_message,
58 external & result);
59 bool hook_persist_phrase_ok();
60 bool hook_get_revision_cert_trust(std::set<rsa_keypair_id> const & signers,
61 hexenc<id> const & id,
62 cert_name const & name,
63 cert_value const & val);
64 bool hook_get_revision_cert_trust(std::set<rsa_keypair_id> const & signers,
65 revision_id const & id,
66 cert_name const & name,
67 cert_value const & val);
68 bool hook_get_manifest_cert_trust(std::set<rsa_keypair_id> const & signers,
69 hexenc<id> const & id,
70 cert_name const & name,
71 cert_value const & val);
72 bool hook_get_manifest_cert_trust(std::set<rsa_keypair_id> const & signers,
73 manifest_id const & id,
74 cert_name const & name,
75 cert_value const & val);
76 bool hook_accept_testresult_change(std::map<rsa_keypair_id, bool> const & old_results,
77 std::map<rsa_keypair_id, bool> const & new_results);
78
79 // network hooks
80 bool hook_get_netsync_key(utf8 const & server_address,
81 globish const & include,
82 globish const & exclude,
83 rsa_keypair_id & k);
84 bool hook_get_netsync_connect_command(uri const & u,
85 globish const & include_pattern,
86 globish const & exclude_pattern,
87 bool debug,
88 std::vector<std::string> & argv);
89 bool hook_use_transport_auth(uri const & u);
90
91 bool hook_get_netsync_read_permitted(std::string const & branch,
92 rsa_keypair_id const & identity);
93 // anonymous no-key version
94 bool hook_get_netsync_read_permitted(std::string const & branch);
95 bool hook_get_netsync_write_permitted(rsa_keypair_id const & identity);
96
97 // local repo hooks
98 bool hook_ignore_file(file_path const & p);
99 bool hook_ignore_branch(branch_name const & branch);
100 bool hook_merge3(file_path const & anc_path,
101 file_path const & left_path,
102 file_path const & right_path,
103 file_path const & merged_path,
104 data const & ancestor,
105 data const & left,
106 data const & right,
107 data & result);
108
109 bool hook_external_diff(file_path const & path,
110 data const & data_old,
111 data const & data_new,
112 bool is_binary,
113 bool diff_args_provided,
114 std::string const & diff_args,
115 std::string const & oldrev,
116 std::string const & newrev);
117
118 bool hook_get_encloser_pattern(file_path const & path,
119 std::string & pattern);
120
121 bool hook_get_default_command_options(commands::command_id const & cmd,
122 args_vector & args);
123
124 // workspace hooks
125 bool hook_use_inodeprints();
126
127 // attribute hooks
128 bool hook_init_attributes(file_path const & filename,
129 std::map<std::string, std::string> & attrs);
130 bool hook_apply_attribute(std::string const & attr,
131 file_path const & filename,
132 std::string const & value);
133
134 // validation hooks
135 bool hook_validate_commit_message(utf8 const & message,
136 revision_data const & new_rev,
137 branch_name const & branchname,
138 bool & validated,
139 std::string & reason);
140
141 // notification hooks
142 bool hook_note_commit(revision_id const & new_id,
143 revision_data const & rdat,
144 std::map<cert_name, cert_value> const & certs);
145
146 bool hook_note_netsync_start(size_t session_id,
147 std::string my_role,
148 int sync_type,
149 std::string remote_host,
150 rsa_keypair_id remote_keyname,
151 globish include_pattern,
152 globish exclude_pattern);
153 bool hook_note_netsync_revision_received(revision_id const & new_id,
154 revision_data const & rdat,
155 std::set<std::pair<rsa_keypair_id,
156 std::pair<cert_name,
157 cert_value> > > const & certs,
158 size_t session_id);
159 bool hook_note_netsync_revision_sent(revision_id const & new_id,
160 revision_data const & rdat,
161 std::set<std::pair<rsa_keypair_id,
162 std::pair<cert_name,
163 cert_value> > > const & certs,
164 size_t session_id);
165 bool hook_note_netsync_pubkey_received(rsa_keypair_id const & kid,
166 size_t session_id);
167 bool hook_note_netsync_pubkey_sent(rsa_keypair_id const & kid,
168 size_t session_id);
169 bool hook_note_netsync_cert_received(revision_id const & rid,
170 rsa_keypair_id const & kid,
171 cert_name const & name,
172 cert_value const & value,
173 size_t session_id);
174 bool hook_note_netsync_cert_sent(revision_id const & rid,
175 rsa_keypair_id const & kid,
176 cert_name const & name,
177 cert_value const & value,
178 size_t session_id);
179 bool hook_note_netsync_end(size_t session_id, int status,
180 size_t bytes_in, size_t bytes_out,
181 size_t certs_in, size_t certs_out,
182 size_t revs_in, size_t revs_out,
183 size_t keys_in, size_t keys_out);
184 bool hook_note_mtn_startup(args_vector const & args);
185};
186
187// Local Variables:
188// mode: C++
189// fill-column: 76
190// c-file-style: "gnu"
191// indent-tabs-mode: nil
192// End:
193// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
194
195#endif // __LUA_HOOKS_HH__

Archive Download this file

Branches

Tags

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