File: lua_hooks.hh

package info (click to toggle)
monotone 0.48-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 20,096 kB
  • ctags: 8,077
  • sloc: cpp: 81,000; sh: 6,402; perl: 1,241; lisp: 1,045; makefile: 655; python: 566; sql: 112; ansic: 52
file content (223 lines) | stat: -rw-r--r-- 9,288 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
//               2008 Stephen Leake <stephen_leake@stephe-leake.org>
//
// This program is made available under the GNU GPL version 2.0 or
// greater. See the accompanying file COPYING for details.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the
// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE.

#ifndef __LUA_HOOKS_HH__
#define __LUA_HOOKS_HH__

// this file defines a typed C++ interface to the various hooks
// we expose to the user as lua functions or variables

#include <set>
#include <map>
#include "file_io.hh"
#include "option.hh"
#include "vocab.hh"
#include "paths.hh"
#include "commands.hh"

using std::string;
using std::vector;
using std::map;
using std::pair;

struct uri_t;
class app_state;
class key_store;
struct lua_State;
struct globish;
struct options;
class project_t;
struct key_identity_info;

extern app_state* get_app_state(lua_State *LS);

class lua_hooks
{
  struct lua_State * st;

  void add_std_hooks();
  void load_rcfile(utf8 const & file);
  void load_rcfile(any_path const & file, bool required);

public:
  lua_hooks(app_state * app);
  ~lua_hooks();
  bool check_lua_state(lua_State * st) const;
  void load_rcfiles(options & opts);
  bool hook_exists(string const & func_name);

  // cert hooks
  bool hook_expand_selector(string const & sel, string & exp);
  bool hook_expand_date(string const & sel, string & exp);
  bool hook_get_branch_key(branch_name const & branchname,
                           key_store & keys,
                           project_t & project, key_id & k);
  bool hook_get_passphrase(key_identity_info const & info,
                           string & phrase);
  bool hook_get_local_key_name(key_identity_info & info);
  bool hook_get_author(branch_name const & branchname,
                       key_identity_info const & info,
                       string & author);
  bool hook_edit_comment(external const & user_log_message,
                         external & result);
  bool hook_persist_phrase_ok();
  bool hook_get_revision_cert_trust(std::set<key_identity_info> const & signers,
                                   id const & hash,
                                   cert_name const & name,
                                   cert_value const & val);
  bool hook_get_manifest_cert_trust(std::set<key_name> const & signers,
                                    id const & hash,
                                    cert_name const & name,
                                    cert_value const & val);
  bool hook_accept_testresult_change(map<key_id, bool> const & old_results,
                                     map<key_id, bool> const & new_results);

  // network hooks
  bool hook_get_netsync_key(utf8 const & server_address,
                            globish const & include,
                            globish const & exclude,
                            key_store & keys,
                            project_t & project,
                            key_id & k);
  bool hook_get_netsync_connect_command(uri_t const & uri,
                                        globish const & include_pattern,
                                        globish const & exclude_pattern,
                                        bool debug,
                                        vector<string> & argv);
  bool hook_use_transport_auth(uri_t const & uri);

  bool hook_get_netsync_read_permitted(string const & branch,
                                       key_identity_info const & identity);
  // anonymous no-key version
  bool hook_get_netsync_read_permitted(string const & branch);
  bool hook_get_netsync_write_permitted(key_identity_info const & identity);

  bool hook_get_remote_automate_permitted(key_identity_info const & identity,
                                          vector<string> const & command_line,
                                          vector<pair<string, string> > const & command_opts);

  // local repo hooks
  bool hook_ignore_file(file_path const & p);
  bool hook_ignore_branch(branch_name const & branch);
  bool hook_merge3(file_path const & anc_path,
                   file_path const & left_path,
                   file_path const & right_path,
                   file_path const & merged_path,
                   data const & ancestor,
                   data const & left,
                   data const & right,
                   data & result);

  bool hook_external_diff(file_path const & path,
                          data const & data_old,
                          data const & data_new,
                          bool is_binary,
                          bool diff_args_provided,
                          string const & diff_args,
                          string const & oldrev,
                          string const & newrev);

  bool hook_get_encloser_pattern(file_path const & path,
                                 string & pattern);

  bool hook_get_default_command_options(commands::command_id const & cmd,
                                        args_vector & args);

  bool hook_get_date_format_spec(date_format_spec in, string & out);

  bool hook_get_default_database_alias(string & alias);

  bool hook_get_default_database_locations(vector<system_path> & out);

  // workspace hooks
  bool hook_use_inodeprints();

  // attribute hooks
  bool hook_init_attributes(file_path const & filename,
                            map<string, string> & attrs);
  bool hook_set_attribute(string const & attr,
                          file_path const & filename,
                          string const & value);
  bool hook_clear_attribute(string const & attr,
                            file_path const & filename);

  // validation hooks
  bool hook_validate_commit_message(utf8 const & message,
                                    revision_data const & new_rev,
                                    branch_name const & branchname,
                                    bool & validated,
                                    string & reason);

  // meta hooks
  bool hook_hook_wrapper(string const & func_name,
                         vector<string> const & args,
                         string & out);

  // notification hooks
  bool hook_note_commit(revision_id const & new_id,
                        revision_data const & rdat,
                        map<cert_name, cert_value> const & certs);

  bool hook_note_netsync_start(size_t session_id,
                               string my_role,
                               int sync_type,
                               string remote_host,
                               key_identity_info const & remote_key,
                               globish include_pattern,
                               globish exclude_pattern);
  bool hook_note_netsync_revision_received(revision_id const & new_id,
                                           revision_data const & rdat,
                                           std::set<pair<key_identity_info,
                                           pair<cert_name,
                                           cert_value> > > const & certs,
                                           size_t session_id);
  bool hook_note_netsync_revision_sent(revision_id const & new_id,
                                       revision_data const & rdat,
                                       std::set<pair<key_identity_info,
                                       pair<cert_name,
                                       cert_value> > > const & certs,
                                       size_t session_id);
  bool hook_note_netsync_pubkey_received(key_identity_info const & identity,
                                         size_t session_id);
  bool hook_note_netsync_pubkey_sent(key_identity_info const & identity,
                                     size_t session_id);
  bool hook_note_netsync_cert_received(revision_id const & rid,
                                       key_identity_info const & identity,
                                       cert_name const & name,
                                       cert_value const & value,
                                       size_t session_id);
  bool hook_note_netsync_cert_sent(revision_id const & rid,
                                   key_identity_info const & identity,
                                   cert_name const & name,
                                   cert_value const & value,
                                   size_t session_id);
  bool hook_note_netsync_end(size_t session_id, int status,
                             size_t bytes_in, size_t bytes_out,
                             size_t certs_in, size_t certs_out,
                             size_t revs_in, size_t revs_out,
                             size_t keys_in, size_t keys_out);
  bool hook_note_mtn_startup(args_vector const & args);

  // git export hooks
  bool hook_unmapped_git_author(string const & unmapped_author,
                                string & fixed_author);
  bool hook_validate_git_author(string const & author);

};

#endif // __LUA_HOOKS_HH__

// Local Variables:
// mode: C++
// fill-column: 76
// c-file-style: "gnu"
// indent-tabs-mode: nil
// End:
// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s: