Commit | Line | Data |
---|---|---|
fe37a9c9 WJ |
1 | /* |
2 | * Copyright (c) 1992, Brian Berliner and Jeff Polk | |
3 | * Copyright (c) 1989-1992, Brian Berliner | |
4 | * | |
5 | * You may distribute under the terms of the GNU General Public License as | |
6 | * specified in the README file that comes with the CVS 1.3 kit. | |
7 | * | |
8 | * Status Information | |
9 | */ | |
10 | ||
11 | #include "cvs.h" | |
12 | ||
13 | #ifndef lint | |
14 | static char rcsid[] = "@(#)status.c 1.48 92/03/31"; | |
15 | #endif | |
16 | ||
17 | #if __STDC__ | |
18 | static Dtype status_dirproc (char *dir, char *repos, char *update_dir); | |
19 | static int status_fileproc (char *file, char *update_dir, | |
20 | char *repository, List * entries, | |
21 | List * srcfiles); | |
22 | static int tag_list_proc (Node * p); | |
23 | #else | |
24 | static int tag_list_proc (); | |
25 | static int status_fileproc (); | |
26 | static Dtype status_dirproc (); | |
27 | #endif /* __STDC__ */ | |
28 | ||
29 | static int local = 0; | |
30 | static int long_format = 0; | |
31 | ||
32 | static char *status_usage[] = | |
33 | { | |
34 | "Usage: %s %s [-vlR] [files...]\n", | |
35 | "\t-v\tVerbose format; includes tag information for the file\n", | |
36 | "\t-l\tProcess this directory only (not recursive).\n", | |
37 | "\t-R\tProcess directories recursively.\n", | |
38 | NULL | |
39 | }; | |
40 | ||
41 | int | |
42 | status (argc, argv) | |
43 | int argc; | |
44 | char *argv[]; | |
45 | { | |
46 | int c; | |
47 | int err = 0; | |
48 | ||
49 | if (argc == -1) | |
50 | usage (status_usage); | |
51 | ||
52 | optind = 1; | |
53 | while ((c = gnu_getopt (argc, argv, "vlR")) != -1) | |
54 | { | |
55 | switch (c) | |
56 | { | |
57 | case 'v': | |
58 | long_format = 1; | |
59 | break; | |
60 | case 'l': | |
61 | local = 1; | |
62 | break; | |
63 | case 'R': | |
64 | local = 0; | |
65 | break; | |
66 | case '?': | |
67 | default: | |
68 | usage (status_usage); | |
69 | break; | |
70 | } | |
71 | } | |
72 | argc -= optind; | |
73 | argv += optind; | |
74 | ||
75 | /* start the recursion processor */ | |
76 | err = start_recursion (status_fileproc, (int (*) ()) NULL, status_dirproc, | |
77 | (int (*) ()) NULL, argc, argv, local, | |
78 | W_LOCAL, 0, 1, (char *) NULL, 1); | |
79 | ||
80 | return (err); | |
81 | } | |
82 | ||
83 | /* | |
84 | * display the status of a file | |
85 | */ | |
86 | /* ARGSUSED */ | |
87 | static int | |
88 | status_fileproc (file, update_dir, repository, entries, srcfiles) | |
89 | char *file; | |
90 | char *update_dir; | |
91 | char *repository; | |
92 | List *entries; | |
93 | List *srcfiles; | |
94 | { | |
95 | Ctype status; | |
96 | char *sstat; | |
97 | Vers_TS *vers; | |
98 | ||
99 | status = Classify_File (file, (char *) NULL, (char *) NULL, (char *) NULL, | |
100 | 1, 0, repository, entries, srcfiles, &vers); | |
101 | switch (status) | |
102 | { | |
103 | case T_UNKNOWN: | |
104 | sstat = "Unknown"; | |
105 | break; | |
106 | case T_CHECKOUT: | |
107 | sstat = "Needs Checkout"; | |
108 | break; | |
109 | case T_CONFLICT: | |
110 | sstat = "Unresolved Conflict"; | |
111 | break; | |
112 | case T_ADDED: | |
113 | sstat = "Locally Added"; | |
114 | break; | |
115 | case T_REMOVED: | |
116 | sstat = "Locally Removed"; | |
117 | break; | |
118 | case T_MODIFIED: | |
119 | sstat = "Locally Modified"; | |
120 | break; | |
121 | case T_REMOVE_ENTRY: | |
122 | sstat = "Entry Invalid"; | |
123 | break; | |
124 | case T_UPTODATE: | |
125 | sstat = "Up-to-date"; | |
126 | break; | |
127 | case T_NEEDS_MERGE: | |
128 | sstat = "Needs Merge"; | |
129 | break; | |
130 | default: | |
131 | sstat = "Classify Error"; | |
132 | break; | |
133 | } | |
134 | ||
135 | (void) printf ("===================================================================\n"); | |
136 | if (vers->ts_user == NULL) | |
137 | (void) printf ("File: no file %s\t\tStatus: %s\n\n", file, sstat); | |
138 | else | |
139 | (void) printf ("File: %-17.17s\tStatus: %s\n\n", file, sstat); | |
140 | ||
141 | if (vers->vn_user == NULL) | |
142 | (void) printf (" Version:\t\tNo entry for %s\n", file); | |
143 | else if (vers->vn_user[0] == '0' && vers->vn_user[1] == '\0') | |
144 | (void) printf (" Version:\t\tNew file!\n"); | |
145 | else | |
146 | (void) printf (" Version:\t\t%s\t%s\n", vers->vn_user, | |
147 | &vers->ts_rcs[25]); | |
148 | ||
149 | if (vers->vn_rcs == NULL) | |
150 | (void) printf (" RCS Version:\tNo revision control file\n"); | |
151 | else | |
152 | (void) printf (" RCS Version:\t%s\t%s\n", vers->vn_rcs, | |
153 | vers->srcfile->path); | |
154 | ||
155 | if (vers->entdata) | |
156 | { | |
157 | Entnode *edata; | |
158 | ||
159 | edata = vers->entdata; | |
160 | if (edata->tag) | |
161 | { | |
162 | if (vers->vn_rcs == NULL) | |
163 | (void) printf ( | |
164 | " Sticky Tag:\t\t%s - MISSING from RCS file!\n", | |
165 | edata->tag); | |
166 | else | |
167 | { | |
168 | if (isdigit (edata->tag[0])) | |
169 | (void) printf (" Sticky Tag:\t\t%s\n", edata->tag); | |
170 | else | |
171 | (void) printf (" Sticky Tag:\t\t%s (%s: %s)\n", | |
172 | edata->tag, numdots (vers->vn_rcs) % 2 ? | |
173 | "revision" : "branch", vers->vn_rcs); | |
174 | } | |
175 | } | |
176 | else | |
177 | (void) printf (" Sticky Tag:\t\t(none)\n"); | |
178 | ||
179 | if (edata->date) | |
180 | (void) printf (" Sticky Date:\t%s\n", edata->date); | |
181 | else | |
182 | (void) printf (" Sticky Date:\t(none)\n"); | |
183 | ||
184 | if (edata->options && edata->options[0]) | |
185 | (void) printf (" Sticky Options:\t%s\n", edata->options); | |
186 | else | |
187 | (void) printf (" Sticky Options:\t(none)\n"); | |
188 | ||
189 | if (long_format && vers->srcfile) | |
190 | { | |
191 | (void) printf ("\n Existing Tags:\n"); | |
192 | if (vers->srcfile->symbols) | |
193 | (void) walklist (vers->srcfile->symbols, tag_list_proc); | |
194 | else | |
195 | (void) printf ("\tNo Tags Exist\n"); | |
196 | } | |
197 | } | |
198 | ||
199 | (void) printf ("\n"); | |
200 | freevers_ts (&vers); | |
201 | return (0); | |
202 | } | |
203 | ||
204 | /* | |
205 | * Print a warm fuzzy message | |
206 | */ | |
207 | /* ARGSUSED */ | |
208 | static Dtype | |
209 | status_dirproc (dir, repos, update_dir) | |
210 | char *dir; | |
211 | char *repos; | |
212 | char *update_dir; | |
213 | { | |
214 | if (!quiet) | |
215 | error (0, 0, "Examining %s", update_dir); | |
216 | return (R_PROCESS); | |
217 | } | |
218 | ||
219 | /* | |
220 | * Print out a tag and its type | |
221 | */ | |
222 | static int | |
223 | tag_list_proc (p) | |
224 | Node *p; | |
225 | { | |
226 | (void) printf ("\t%-25.25s\t(%s: %s)\n", p->key, | |
227 | numdots (p->data) % 2 ? "revision" : "branch", | |
228 | p->data); | |
229 | return (0); | |
230 | } |