Added a description for my extensions (README-my-extensions.html).
[parsecvs/imz-RCS2git-use-cases.git] / cvs.h
blobbf6c515f13f12b20c6062aac786eadcacdc342cf
1 /*
2 * Copyright © 2006 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or (at
7 * your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 #ifndef _CVS_H_
20 #define _CVS_H_
22 #include <sys/time.h>
23 #include <time.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <stdio.h>
27 #include <assert.h>
28 #include <stdint.h>
29 #include <stdarg.h>
30 #include <ctype.h>
31 #include <unistd.h>
32 #include <sys/stat.h>
33 #include <sys/types.h>
34 #include <errno.h>
36 #ifndef MAXPATHLEN
37 #define MAXPATHLEN 10240
38 #endif
40 #define CVS_MAX_DEPTH 20
41 #define CVS_MAX_REV_LEN (CVS_MAX_DEPTH * 11)
43 typedef struct _cvs_number {
44 int c;
45 short n[CVS_MAX_DEPTH];
46 } cvs_number;
48 struct _cvs_version;
49 struct _cvs_patch;
50 struct _rev_file;
52 typedef struct node {
53 struct node *hash_next;
54 cvs_number number;
55 struct _cvs_version *v;
56 struct _cvs_patch *p;
57 struct node *next;
58 struct node *to;
59 struct node *down;
60 struct node *sib;
61 struct _rev_file *file;
62 int starts;
63 } Node;
65 typedef struct _cvs_symbol {
66 struct _cvs_symbol *next;
67 char *name;
68 cvs_number number;
69 } cvs_symbol;
71 typedef struct _cvs_branch {
72 struct _cvs_branch *next;
73 cvs_number number;
74 Node *node;
75 } cvs_branch;
77 typedef struct _cvs_version {
78 struct _cvs_version *next;
79 cvs_number number;
80 time_t date;
81 char *author;
82 char *state;
83 int dead;
84 cvs_branch *branches;
85 cvs_number parent; /* next in ,v file */
86 char *commitid;
87 Node *node;
88 } cvs_version;
90 typedef struct _cvs_patch {
91 struct _cvs_patch *next;
92 cvs_number number;
93 char *log;
94 char *text;
95 Node *node;
96 } cvs_patch;
99 typedef struct {
100 char *name;
101 cvs_number head;
102 cvs_number branch;
103 cvs_symbol *symbols;
104 cvs_version *versions;
105 cvs_patch *patches;
106 mode_t mode;
107 int nversions;
108 char *expand;
109 } cvs_file;
111 typedef struct _rev_file {
112 char *name;
113 cvs_number number;
114 time_t date;
115 char *sha1;
116 mode_t mode;
117 struct _rev_file *link;
118 } rev_file;
120 typedef struct _rev_dir {
121 int nfiles;
122 rev_file *files[0];
123 } rev_dir;
125 extern time_t time_now;
127 extern int commit_time_window;
129 typedef struct _rev_commit {
130 struct _rev_commit *parent;
131 char tail;
132 char seen;
133 char used;
134 char tailed;
135 char tagged;
136 time_t date;
137 char *log;
138 char *author;
139 char *commitid;
140 char *sha1;
141 struct _rev_commit *user;
142 rev_file *file; /* first file */
143 int nfiles;
144 int ndirs;
145 rev_dir *dirs[0];
146 } rev_commit;
148 typedef struct _rev_ref {
149 struct _rev_ref *next;
150 rev_commit *commit;
151 struct _rev_ref *parent; /* link into tree */
152 int tail;
153 int degree; /* number of digits in original CVS version */
154 int depth; /* depth in branching tree (1 is trunk) */
155 cvs_number number;
156 char *name;
157 int shown;
158 } rev_ref;
160 typedef struct _rev_list {
161 struct _rev_list *next;
162 rev_ref *heads;
163 int watch;
164 } rev_list;
166 typedef struct _rev_file_list {
167 struct _rev_file_list *next;
168 rev_file *file;
169 } rev_file_list;
171 typedef struct _rev_diff {
172 rev_file_list *del;
173 rev_file_list *add;
174 int ndel;
175 int nadd;
176 } rev_diff;
178 typedef enum _rev_execution_mode {
179 ExecuteGit, ExecuteGraph, ExecuteSplits
180 } rev_execution_mode;
182 extern rev_execution_mode rev_mode;
184 extern cvs_file *this_file;
186 int yyparse (void);
188 extern char *yyfilename;
190 char *
191 ctime_nonl (time_t *date);
193 cvs_number
194 lex_number (char *);
196 time_t
197 lex_date (cvs_number *n);
199 char *
200 lex_text (void);
202 rev_list *
203 rev_list_cvs (cvs_file *cvs);
205 rev_list *
206 rev_list_merge (rev_list *lists);
208 void
209 rev_list_free (rev_list *rl, int free_files);
211 enum { Ncommits = 256 };
213 typedef struct _chunk {
214 struct _chunk *next;
215 rev_commit *v[Ncommits];
216 } Chunk;
218 typedef struct _tag {
219 struct _tag *next;
220 struct _tag *hash_next;
221 char *name;
222 Chunk *commits;
223 int count;
224 int left;
225 rev_commit *commit;
226 rev_ref *parent;
227 char *last;
228 } Tag;
230 extern Tag *all_tags;
231 void tag_commit(rev_commit *c, char *name);
232 rev_commit **tagged(Tag *tag);
233 void discard_tags(void);
236 cvs_is_head (cvs_number *n);
239 cvs_same_branch (cvs_number *a, cvs_number *b);
242 cvs_number_compare (cvs_number *a, cvs_number *b);
245 cvs_number_compare_n (cvs_number *a, cvs_number *b, int l);
248 cvs_is_branch_of (cvs_number *trunk, cvs_number *branch);
251 cvs_number_degree (cvs_number *a);
253 cvs_number
254 cvs_previous_rev (cvs_number *n);
256 cvs_number
257 cvs_master_rev (cvs_number *n);
259 cvs_number
260 cvs_branch_head (cvs_file *f, cvs_number *branch);
262 cvs_number
263 cvs_branch_parent (cvs_file *f, cvs_number *branch);
265 Node *
266 cvs_find_version (cvs_file *cvs, cvs_number *number);
269 cvs_is_trunk (cvs_number *number);
272 cvs_is_vendor (cvs_number *number);
274 void
275 cvs_file_free (cvs_file *cvs);
277 char *
278 cvs_number_string (cvs_number *n, char *str);
280 long
281 time_compare (time_t a, time_t b);
283 void
284 dump_ref_name (FILE *f, rev_ref *ref);
286 void
287 dump_number_file (FILE *f, char *name, cvs_number *number);
289 void
290 dump_number (char *name, cvs_number *number);
292 void
293 dump_symbols (char *name, cvs_symbol *symbols);
295 void
296 dump_branches (char *name, cvs_branch *branches);
298 void
299 dump_versions (char *name, cvs_version *versions);
301 void
302 dump_patches (char *name, cvs_patch *patches);
304 void
305 dump_log (FILE *f, char *log);
307 void
308 dump_file (cvs_file *file);
310 void
311 dump_commit (rev_commit *e);
313 void
314 dump_refs (rev_list *rl, rev_ref *refs, char *title, char *shape);
316 void
317 dump_rev_commit (rev_commit *e);
319 void
320 dump_rev_head (rev_ref *h);
322 void
323 dump_rev_list (rev_list *rl);
325 void
326 dump_splits (rev_list *rl);
328 void
329 dump_rev_graph_begin (void);
331 void
332 dump_rev_graph_nodes (rev_list *rl, char *title);
334 void
335 dump_rev_graph_end (void);
337 void
338 dump_commit_graph (rev_commit *c, rev_ref *branch);
340 void
341 dump_rev_graph (rev_list *rl, char *title);
343 void
344 dump_rev_tree (rev_list *rl);
346 extern int yylex (void);
348 char *
349 atom (char *string);
351 void
352 discard_atoms (void);
354 rev_ref *
355 rev_list_add_head (rev_list *rl, rev_commit *commit, char *name, int degree);
358 rev_commit_has_file (rev_commit *c, rev_file *f);
360 rev_diff *
361 rev_commit_diff (rev_commit *old, rev_commit *new);
364 rev_file_list_has_filename (rev_file_list *fl, char *name);
366 void
367 rev_diff_free (rev_diff *d);
369 rev_ref *
370 rev_branch_of_commit (rev_list *rl, rev_commit *commit);
372 rev_file *
373 rev_file_rev (char *name, cvs_number *n, time_t date);
375 void
376 rev_file_free (rev_file *f);
378 void
379 rev_head_free (rev_ref *heads, int free_files);
381 void
382 rev_list_set_tail (rev_list *rl);
385 rev_file_later (rev_file *a, rev_file *b);
388 rev_commit_later (rev_commit *a, rev_commit *b);
390 void
391 rev_list_validate (rev_list *rl);
393 #define time_compare(a,b) ((long) (a) - (long) (b))
396 git_rev_list_commit (rev_list *rl, int strip);
398 void
399 git_rev_list_pack (rev_list *rl, int strip);
402 git_system (char *command);
404 char *
405 git_system_to_string (char *command);
408 git_string_to_system (char *command, char *string);
410 char *
411 git_format_command (const char *fmt, ...);
413 void
414 git_free_author_map (void);
417 * rev - string representation of the rcs revision number eg. 1.1
418 * path - RCS filename path eg. ./cfb16/Makefile,v
419 * sha1_hex - a buffer of at least 41 characterrs to receive
420 * the ascii hexidecimal id of the resulting object
422 void generate_files(cvs_file *cvs);
424 rev_dir **
425 rev_pack_files (rev_file **files, int nfiles, int *ndr);
427 void
428 rev_free_dirs (void);
430 void
431 rev_commit_cleanup (void);
433 void hash_version(cvs_version *);
434 void hash_patch(cvs_patch *);
435 void hash_branch(cvs_branch *);
436 void clean_hash(void);
437 void build_branches(void);
438 extern Node *head_node;
440 void delete_commit(rev_commit *);
441 void set_commit(rev_commit *);
442 void reset_commits(rev_commit **, int);
443 rev_commit *create_tree(rev_commit *);
444 void init_tree(int);
445 void discard_tree(void);
447 #endif /* _CVS_H_ */