monotone

monotone Mtn Source Tree

Root/lua_hooks.hh

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

Archive Download this file

Branches

Tags

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