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.
33 #include <sys/types.h>
37 #define MAXPATHLEN 10240
40 #define CVS_MAX_DEPTH 20
41 #define CVS_MAX_REV_LEN (CVS_MAX_DEPTH * 11)
43 typedef struct _cvs_number
{
45 short n
[CVS_MAX_DEPTH
];
53 struct node
*hash_next
;
55 struct _cvs_version
*v
;
61 struct _rev_file
*file
;
65 typedef struct _cvs_symbol
{
66 struct _cvs_symbol
*next
;
71 typedef struct _cvs_branch
{
72 struct _cvs_branch
*next
;
77 typedef struct _cvs_version
{
78 struct _cvs_version
*next
;
85 cvs_number parent
; /* next in ,v file */
90 typedef struct _cvs_patch
{
91 struct _cvs_patch
*next
;
104 cvs_version
*versions
;
111 typedef struct _rev_file
{
117 struct _rev_file
*link
;
120 typedef struct _rev_dir
{
125 extern time_t time_now
;
127 extern int commit_time_window
;
129 typedef struct _rev_commit
{
130 struct _rev_commit
*parent
;
141 struct _rev_commit
*user
;
142 rev_file
*file
; /* first file */
148 typedef struct _rev_ref
{
149 struct _rev_ref
*next
;
151 struct _rev_ref
*parent
; /* link into tree */
153 int degree
; /* number of digits in original CVS version */
154 int depth
; /* depth in branching tree (1 is trunk) */
160 typedef struct _rev_list
{
161 struct _rev_list
*next
;
166 typedef struct _rev_file_list
{
167 struct _rev_file_list
*next
;
171 typedef struct _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
;
188 extern char *yyfilename
;
191 ctime_nonl (time_t *date
);
197 lex_date (cvs_number
*n
);
203 rev_list_cvs (cvs_file
*cvs
);
206 rev_list_merge (rev_list
*lists
);
209 rev_list_free (rev_list
*rl
, int free_files
);
211 enum { Ncommits
= 256 };
213 typedef struct _chunk
{
215 rev_commit
*v
[Ncommits
];
218 typedef struct _tag
{
220 struct _tag
*hash_next
;
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
);
254 cvs_previous_rev (cvs_number
*n
);
257 cvs_master_rev (cvs_number
*n
);
260 cvs_branch_head (cvs_file
*f
, cvs_number
*branch
);
263 cvs_branch_parent (cvs_file
*f
, cvs_number
*branch
);
266 cvs_find_version (cvs_file
*cvs
, cvs_number
*number
);
269 cvs_is_trunk (cvs_number
*number
);
272 cvs_is_vendor (cvs_number
*number
);
275 cvs_file_free (cvs_file
*cvs
);
278 cvs_number_string (cvs_number
*n
, char *str
);
281 time_compare (time_t a
, time_t b
);
284 dump_ref_name (FILE *f
, rev_ref
*ref
);
287 dump_number_file (FILE *f
, char *name
, cvs_number
*number
);
290 dump_number (char *name
, cvs_number
*number
);
293 dump_symbols (char *name
, cvs_symbol
*symbols
);
296 dump_branches (char *name
, cvs_branch
*branches
);
299 dump_versions (char *name
, cvs_version
*versions
);
302 dump_patches (char *name
, cvs_patch
*patches
);
305 dump_log (FILE *f
, char *log
);
308 dump_file (cvs_file
*file
);
311 dump_commit (rev_commit
*e
);
314 dump_refs (rev_list
*rl
, rev_ref
*refs
, char *title
, char *shape
);
317 dump_rev_commit (rev_commit
*e
);
320 dump_rev_head (rev_ref
*h
);
323 dump_rev_list (rev_list
*rl
);
326 dump_splits (rev_list
*rl
);
329 dump_rev_graph_begin (void);
332 dump_rev_graph_nodes (rev_list
*rl
, char *title
);
335 dump_rev_graph_end (void);
338 dump_commit_graph (rev_commit
*c
, rev_ref
*branch
);
341 dump_rev_graph (rev_list
*rl
, char *title
);
344 dump_rev_tree (rev_list
*rl
);
346 extern int yylex (void);
352 discard_atoms (void);
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
);
361 rev_commit_diff (rev_commit
*old
, rev_commit
*new);
364 rev_file_list_has_filename (rev_file_list
*fl
, char *name
);
367 rev_diff_free (rev_diff
*d
);
370 rev_branch_of_commit (rev_list
*rl
, rev_commit
*commit
);
373 rev_file_rev (char *name
, cvs_number
*n
, time_t date
);
376 rev_file_free (rev_file
*f
);
379 rev_head_free (rev_ref
*heads
, int free_files
);
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
);
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
);
399 git_rev_list_pack (rev_list
*rl
, int strip
);
402 git_system (char *command
);
405 git_system_to_string (char *command
);
408 git_string_to_system (char *command
, char *string
);
411 git_format_command (const char *fmt
, ...);
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
);
425 rev_pack_files (rev_file
**files
, int nfiles
, int *ndr
);
428 rev_free_dirs (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
*);
445 void discard_tree(void);