import.c (bde78045) import.c (79822b2a)
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 source distribution.
7 *
8 * "import" checks in the vendor release located in the current directory into

--- 157 unchanged lines hidden (view full) ---

166 if (strcmp (argv[j], argv[i]) == 0)
167 error (1, 0, "tag `%s' was specified more than once", argv[i]);
168 }
169
170 /* XXX - this should be a module, not just a pathname */
171 if (! isabsolute (argv[0])
172 && pathname_levels (argv[0]) == 0)
173 {
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 source distribution.
7 *
8 * "import" checks in the vendor release located in the current directory into

--- 157 unchanged lines hidden (view full) ---

166 if (strcmp (argv[j], argv[i]) == 0)
167 error (1, 0, "tag `%s' was specified more than once", argv[i]);
168 }
169
170 /* XXX - this should be a module, not just a pathname */
171 if (! isabsolute (argv[0])
172 && pathname_levels (argv[0]) == 0)
173 {
174 if (CVSroot_directory == NULL)
174 if (current_parsed_root == NULL)
175 {
176 error (0, 0, "missing CVSROOT environment variable\n");
177 error (1, 0, "Set it or specify the '-d' option to %s.",
178 program_name);
179 }
175 {
176 error (0, 0, "missing CVSROOT environment variable\n");
177 error (1, 0, "Set it or specify the '-d' option to %s.",
178 program_name);
179 }
180 repository = xmalloc (strlen (CVSroot_directory) + strlen (argv[0])
181 + 10);
182 (void) sprintf (repository, "%s/%s", CVSroot_directory, argv[0]);
183 repos_len = strlen (CVSroot_directory);
180 repository = xmalloc (strlen (current_parsed_root->directory)
181 + strlen (argv[0])
182 + 2);
183 (void) sprintf (repository, "%s/%s", current_parsed_root->directory, argv[0]);
184 repos_len = strlen (current_parsed_root->directory);
184 }
185 else
186 {
187 /* It is somewhere between a security hole and "unexpected" to
188 let the client start mucking around outside the cvsroot
189 (wouldn't get the right CVSROOT configuration, &c). */
190 error (1, 0, "directory %s not relative within the repository",
191 argv[0]);

--- 10 unchanged lines hidden (view full) ---

202 error (1, 0, "%s is not a numeric branch", vbranch);
203 if (numdots (vbranch) != 2)
204 error (1, 0, "Only branches with two dots are supported: %s", vbranch);
205 vhead = xstrdup (vbranch);
206 cp = strrchr (vhead, '.');
207 *cp = '\0';
208
209#ifdef CLIENT_SUPPORT
185 }
186 else
187 {
188 /* It is somewhere between a security hole and "unexpected" to
189 let the client start mucking around outside the cvsroot
190 (wouldn't get the right CVSROOT configuration, &c). */
191 error (1, 0, "directory %s not relative within the repository",
192 argv[0]);

--- 10 unchanged lines hidden (view full) ---

203 error (1, 0, "%s is not a numeric branch", vbranch);
204 if (numdots (vbranch) != 2)
205 error (1, 0, "Only branches with two dots are supported: %s", vbranch);
206 vhead = xstrdup (vbranch);
207 cp = strrchr (vhead, '.');
208 *cp = '\0';
209
210#ifdef CLIENT_SUPPORT
210 if (client_active)
211 if (current_parsed_root->isremote)
211 {
212 /* For rationale behind calling start_server before do_editor, see
213 commit.c */
214 start_server ();
215 }
216#endif
217
218 if (use_editor)

--- 12 unchanged lines hidden (view full) ---

231 (void) strcpy (nm, message);
232 free (message);
233 }
234 (void) strcat (nm + msglen, "\n");
235 message = nm;
236 }
237
238#ifdef CLIENT_SUPPORT
212 {
213 /* For rationale behind calling start_server before do_editor, see
214 commit.c */
215 start_server ();
216 }
217#endif
218
219 if (use_editor)

--- 12 unchanged lines hidden (view full) ---

232 (void) strcpy (nm, message);
233 free (message);
234 }
235 (void) strcat (nm + msglen, "\n");
236 message = nm;
237 }
238
239#ifdef CLIENT_SUPPORT
239 if (client_active)
240 if (current_parsed_root->isremote)
240 {
241 int err;
242
243 if (vbranch[0] != '\0')
244 option_with_arg ("-b", vbranch);
245 if (message)
246 option_with_arg ("-m", message);
247 if (keyword_opt != NULL)

--- 37 unchanged lines hidden (view full) ---

285 /*
286 * Make all newly created directories writable. Should really use a more
287 * sophisticated security mechanism here.
288 */
289 (void) umask (cvsumask);
290 make_directories (repository);
291
292 /* Create the logfile that will be logged upon completion */
241 {
242 int err;
243
244 if (vbranch[0] != '\0')
245 option_with_arg ("-b", vbranch);
246 if (message)
247 option_with_arg ("-m", message);
248 if (keyword_opt != NULL)

--- 37 unchanged lines hidden (view full) ---

286 /*
287 * Make all newly created directories writable. Should really use a more
288 * sophisticated security mechanism here.
289 */
290 (void) umask (cvsumask);
291 make_directories (repository);
292
293 /* Create the logfile that will be logged upon completion */
293 tmpfile = cvs_temp_name ();
294 if ((logfp = CVS_FOPEN (tmpfile, "w+")) == NULL)
294 if ((logfp = cvs_temp_file (&tmpfile)) == NULL)
295 error (1, errno, "cannot create temporary file `%s'", tmpfile);
296 /* On systems where we can unlink an open file, do so, so it will go
297 away no matter how we exit. FIXME-maybe: Should be checking for
298 errors but I'm not sure which error(s) we get if we are on a system
299 where one can't unlink open files. */
300 (void) CVS_UNLINK (tmpfile);
301 (void) fprintf (logfp, "\nVendor Tag:\t%s\n", argv[1]);
302 (void) fprintf (logfp, "Release Tags:\t");

--- 117 unchanged lines hidden (view full) ---

420 if ((dirp = CVS_OPENDIR (".")) == NULL)
421 {
422 error (0, errno, "cannot open directory");
423 err++;
424 }
425 else
426 {
427 errno = 0;
295 error (1, errno, "cannot create temporary file `%s'", tmpfile);
296 /* On systems where we can unlink an open file, do so, so it will go
297 away no matter how we exit. FIXME-maybe: Should be checking for
298 errors but I'm not sure which error(s) we get if we are on a system
299 where one can't unlink open files. */
300 (void) CVS_UNLINK (tmpfile);
301 (void) fprintf (logfp, "\nVendor Tag:\t%s\n", argv[1]);
302 (void) fprintf (logfp, "Release Tags:\t");

--- 117 unchanged lines hidden (view full) ---

420 if ((dirp = CVS_OPENDIR (".")) == NULL)
421 {
422 error (0, errno, "cannot open directory");
423 err++;
424 }
425 else
426 {
427 errno = 0;
428 while ((dp = readdir (dirp)) != NULL)
428 while ((dp = CVS_READDIR (dirp)) != NULL)
429 {
430 if (strcmp (dp->d_name, ".") == 0 || strcmp (dp->d_name, "..") == 0)
431 goto one_more_time_boys;
432#ifdef SERVER_SUPPORT
433 /* CVS directories are created in the temp directory by
434 server.c because it doesn't special-case import. So
435 don't print a message about them, regardless of -I!. */
436 if (server_active && strcmp (dp->d_name, CVSADM) == 0)

--- 34 unchanged lines hidden (view full) ---

471 )
472 {
473 add_log ('L', dp->d_name);
474 err++;
475 }
476 else
477 {
478#ifdef CLIENT_SUPPORT
429 {
430 if (strcmp (dp->d_name, ".") == 0 || strcmp (dp->d_name, "..") == 0)
431 goto one_more_time_boys;
432#ifdef SERVER_SUPPORT
433 /* CVS directories are created in the temp directory by
434 server.c because it doesn't special-case import. So
435 don't print a message about them, regardless of -I!. */
436 if (server_active && strcmp (dp->d_name, CVSADM) == 0)

--- 34 unchanged lines hidden (view full) ---

471 )
472 {
473 add_log ('L', dp->d_name);
474 err++;
475 }
476 else
477 {
478#ifdef CLIENT_SUPPORT
479 if (client_active)
479 if (current_parsed_root->isremote)
480 err += client_process_import_file (message, dp->d_name,
481 vtag, targc, targv,
482 repository,
483 keyword_opt != NULL &&
484 keyword_opt[0] == 'b',
485 use_file_modtime);
486 else
487#endif
488 err += process_import_file (message, dp->d_name,
489 vtag, targc, targv);
490 }
491 one_more_time_boys:
492 errno = 0;
493 }
494 if (errno != 0)
495 {
496 error (0, errno, "cannot read directory");
497 ++err;
498 }
480 err += client_process_import_file (message, dp->d_name,
481 vtag, targc, targv,
482 repository,
483 keyword_opt != NULL &&
484 keyword_opt[0] == 'b',
485 use_file_modtime);
486 else
487#endif
488 err += process_import_file (message, dp->d_name,
489 vtag, targc, targv);
490 }
491 one_more_time_boys:
492 errno = 0;
493 }
494 if (errno != 0)
495 {
496 error (0, errno, "cannot read directory");
497 ++err;
498 }
499 (void) closedir (dirp);
499 (void) CVS_CLOSEDIR (dirp);
500 }
501
502 if (dirlist != NULL)
503 {
504 Node *head, *p;
505
506 head = dirlist->list;
507 for (p = head->next; p != head; p = p->next)

--- 1054 unchanged lines hidden (view full) ---

1562 strcpy (new, repository);
1563 (void) strcat (new, "/");
1564 (void) strcat (new, dir);
1565 free (repository);
1566 repository = new;
1567 }
1568
1569#ifdef CLIENT_SUPPORT
500 }
501
502 if (dirlist != NULL)
503 {
504 Node *head, *p;
505
506 head = dirlist->list;
507 for (p = head->next; p != head; p = p->next)

--- 1054 unchanged lines hidden (view full) ---

1562 strcpy (new, repository);
1563 (void) strcat (new, "/");
1564 (void) strcat (new, dir);
1565 free (repository);
1566 repository = new;
1567 }
1568
1569#ifdef CLIENT_SUPPORT
1570 if (!quiet && !client_active)
1570 if (!quiet && !current_parsed_root->isremote)
1571#else
1572 if (!quiet)
1573#endif
1574 error (0, 0, "Importing %s", repository);
1575
1576 if ( CVS_CHDIR (dir) < 0)
1577 {
1578 ierrno = errno;
1579 fperrmsg (logfp, 0, ierrno, "ERROR: cannot chdir to %s", repository);
1580 error (0, ierrno, "ERROR: cannot chdir to %s", repository);
1581 err = 1;
1582 goto out;
1583 }
1584#ifdef CLIENT_SUPPORT
1571#else
1572 if (!quiet)
1573#endif
1574 error (0, 0, "Importing %s", repository);
1575
1576 if ( CVS_CHDIR (dir) < 0)
1577 {
1578 ierrno = errno;
1579 fperrmsg (logfp, 0, ierrno, "ERROR: cannot chdir to %s", repository);
1580 error (0, ierrno, "ERROR: cannot chdir to %s", repository);
1581 err = 1;
1582 goto out;
1583 }
1584#ifdef CLIENT_SUPPORT
1585 if (!client_active && !isdir (repository))
1585 if (!current_parsed_root->isremote && !isdir (repository))
1586#else
1587 if (!isdir (repository))
1588#endif
1589 {
1590 rcs = xmalloc (strlen (repository) + sizeof (RCSEXT) + 5);
1591 (void) sprintf (rcs, "%s%s", repository, RCSEXT);
1592 if (isfile (repository) || isfile(rcs))
1593 {

--- 32 unchanged lines hidden ---
1586#else
1587 if (!isdir (repository))
1588#endif
1589 {
1590 rcs = xmalloc (strlen (repository) + sizeof (RCSEXT) + 5);
1591 (void) sprintf (rcs, "%s%s", repository, RCSEXT);
1592 if (isfile (repository) || isfile(rcs))
1593 {

--- 32 unchanged lines hidden ---