update.c (102843) | update.c (107487) |
---|---|
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 * "update" updates the version in the present directory with respect to the RCS --- 18 unchanged lines hidden (view full) --- 27 * Files added but not yet committed are reported as A <user_file>. Files 28 * removed but not yet committed are reported as R <user_file>. 29 * 30 * If the current directory contains subdirectories that hold concurrent 31 * versions, these are updated too. If the -d option was specified, new 32 * directories added to the repository are automatically created and updated 33 * as well. 34 * | 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 * "update" updates the version in the present directory with respect to the RCS --- 18 unchanged lines hidden (view full) --- 27 * Files added but not yet committed are reported as A <user_file>. Files 28 * removed but not yet committed are reported as R <user_file>. 29 * 30 * If the current directory contains subdirectories that hold concurrent 31 * versions, these are updated too. If the -d option was specified, new 32 * directories added to the repository are automatically created and updated 33 * as well. 34 * |
35 * $FreeBSD: head/contrib/cvs/src/update.c 102843 2002-09-02 05:57:14Z peter $ | 35 * $FreeBSD: head/contrib/cvs/src/update.c 107487 2002-12-02 03:17:49Z peter $ |
36 */ 37 38#include "cvs.h" 39#include "savecwd.h" 40#ifdef SERVER_SUPPORT 41# include "md5.h" 42#endif 43#include "watch.h" --- 249 unchanged lines hidden (view full) --- 293 server doesn't try to send patches which will just fail 294 again. At least currently, the client also clobbers the 295 file and tells the server it is lost, which also will get 296 a full file instead of a patch, but it seems clean to omit 297 -u. */ 298 if (supported_request ("update-patches")) 299 send_arg ("-u"); 300 | 36 */ 37 38#include "cvs.h" 39#include "savecwd.h" 40#ifdef SERVER_SUPPORT 41# include "md5.h" 42#endif 43#include "watch.h" --- 249 unchanged lines hidden (view full) --- 293 server doesn't try to send patches which will just fail 294 again. At least currently, the client also clobbers the 295 file and tells the server it is lost, which also will get 296 a full file instead of a patch, but it seems clean to omit 297 -u. */ 298 if (supported_request ("update-patches")) 299 send_arg ("-u"); 300 |
301 send_arg ("--"); 302 |
|
301 if (update_build_dirs) 302 flags |= SEND_BUILD_DIRS; 303 304 if (toss_local_changes) { 305 flags |= SEND_NO_CONTENTS; 306 flags |= BACKUP_MODIFIED_FILES; 307 } 308 --- 11 unchanged lines hidden (view full) --- 320 program_name); 321 322 if (toplevel_wd != NULL 323 && CVS_CHDIR (toplevel_wd) < 0) 324 { 325 error (1, errno, "could not chdir to %s", toplevel_wd); 326 } 327 | 303 if (update_build_dirs) 304 flags |= SEND_BUILD_DIRS; 305 306 if (toss_local_changes) { 307 flags |= SEND_NO_CONTENTS; 308 flags |= BACKUP_MODIFIED_FILES; 309 } 310 --- 11 unchanged lines hidden (view full) --- 322 program_name); 323 324 if (toplevel_wd != NULL 325 && CVS_CHDIR (toplevel_wd) < 0) 326 { 327 error (1, errno, "could not chdir to %s", toplevel_wd); 328 } 329 |
330 send_arg ("--"); 331 |
|
328 for (i = 0; i < failed_patches_count; i++) 329 if (unlink_file (failed_patches[i]) < 0 330 && !existence_error (errno)) 331 error (0, errno, "cannot remove %s", 332 failed_patches[i]); 333 send_files (failed_patches_count, failed_patches, local, 334 aflag, update_build_dirs ? SEND_BUILD_DIRS : 0); 335 send_file_names (failed_patches_count, failed_patches, 0); --- 155 unchanged lines hidden (view full) --- 491 hardlist = getlist(); 492 working_dir = xgetwd(); /* save top-level working dir */ 493 494 /* FIXME-twp: the arguments to start_recursion make me dizzy. This 495 function call was copied from the update_fileproc call that 496 follows it; someone should make sure that I did it right. */ 497 err = start_recursion (get_linkinfo_proc, (FILESDONEPROC) NULL, 498 (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL, | 332 for (i = 0; i < failed_patches_count; i++) 333 if (unlink_file (failed_patches[i]) < 0 334 && !existence_error (errno)) 335 error (0, errno, "cannot remove %s", 336 failed_patches[i]); 337 send_files (failed_patches_count, failed_patches, local, 338 aflag, update_build_dirs ? SEND_BUILD_DIRS : 0); 339 send_file_names (failed_patches_count, failed_patches, 0); --- 155 unchanged lines hidden (view full) --- 495 hardlist = getlist(); 496 working_dir = xgetwd(); /* save top-level working dir */ 497 498 /* FIXME-twp: the arguments to start_recursion make me dizzy. This 499 function call was copied from the update_fileproc call that 500 follows it; someone should make sure that I did it right. */ 501 err = start_recursion (get_linkinfo_proc, (FILESDONEPROC) NULL, 502 (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL, |
499 argc, argv, local, which, aflag, 1, | 503 argc, argv, local, which, aflag, LOCK_READ, |
500 preload_update_dir, 1); 501 if (err) 502 return (err); 503 504 /* FIXME-twp: at this point we should walk the hardlist 505 and update the `links' field of each hardlink_info struct 506 to list the files that are linked on dist. That would make 507 it easier & more efficient to compare the disk linkage with 508 the repository linkage (a simple strcmp). */ 509 } 510#endif 511 512 /* call the recursion processor */ 513 err = start_recursion (update_fileproc, update_filesdone_proc, 514 update_dirent_proc, update_dirleave_proc, NULL, | 504 preload_update_dir, 1); 505 if (err) 506 return (err); 507 508 /* FIXME-twp: at this point we should walk the hardlist 509 and update the `links' field of each hardlink_info struct 510 to list the files that are linked on dist. That would make 511 it easier & more efficient to compare the disk linkage with 512 the repository linkage (a simple strcmp). */ 513 } 514#endif 515 516 /* call the recursion processor */ 517 err = start_recursion (update_fileproc, update_filesdone_proc, 518 update_dirent_proc, update_dirleave_proc, NULL, |
515 argc, argv, local, which, aflag, 1, | 519 argc, argv, local, which, aflag, LOCK_READ, |
516 preload_update_dir, 1); 517 518#ifdef SERVER_SUPPORT 519 if (server_active) 520 return err; 521#endif 522 523 /* see if we need to sleep before returning to avoid time-stamp races */ --- 1262 unchanged lines hidden (view full) --- 1786 retcode = diff_exec (file1, file2, NULL, NULL, diff_options, finfo->file); 1787 1788 /* A retcode of 0 means no differences. 1 means some differences. */ 1789 if (retcode != 0 1790 && retcode != 1) 1791 { 1792 fail = 1; 1793 } | 520 preload_update_dir, 1); 521 522#ifdef SERVER_SUPPORT 523 if (server_active) 524 return err; 525#endif 526 527 /* see if we need to sleep before returning to avoid time-stamp races */ --- 1262 unchanged lines hidden (view full) --- 1790 retcode = diff_exec (file1, file2, NULL, NULL, diff_options, finfo->file); 1791 1792 /* A retcode of 0 means no differences. 1 means some differences. */ 1793 if (retcode != 0 1794 && retcode != 1) 1795 { 1796 fail = 1; 1797 } |
1794 else 1795 { 1796# define BINARY "Binary" 1797 char buf[sizeof BINARY]; 1798 unsigned int c; | 1798 } |
1799 | 1799 |
1800 /* Stat the original RCS file, and then adjust it the way 1801 that RCS_checkout would. FIXME: This is an abstraction 1802 violation. */ 1803 if (CVS_STAT (vers_ts->srcfile->path, file_info) < 0) 1804 error (1, errno, "could not stat %s", vers_ts->srcfile->path); 1805 if (chmod (finfo->file, 1806 file_info->st_mode & ~(S_IWRITE | S_IWGRP | S_IWOTH)) 1807 < 0) 1808 error (0, errno, "cannot change mode of file %s", finfo->file); 1809 if (cvswrite 1810 && !fileattr_get (finfo->file, "_watched")) 1811 xchmod (finfo->file, 1); | 1800 if (! fail) 1801 { 1802 struct stat file2_info; |
1812 | 1803 |
1813 /* Check the diff output to make sure patch will be handle it. */ 1814 e = CVS_FOPEN (finfo->file, "r"); 1815 if (e == NULL) 1816 error (1, errno, "could not open diff output file %s", 1817 finfo->fullname); 1818 c = fread (buf, 1, sizeof BINARY - 1, e); 1819 buf[c] = '\0'; 1820 if (strcmp (buf, BINARY) == 0) 1821 { 1822 /* These are binary files. We could use diff -a, but 1823 patch can't handle that. */ 1824 fail = 1; 1825 } 1826 fclose (e); | 1804 /* Check to make sure the patch is really shorter */ 1805 if (CVS_STAT (file2, &file2_info) < 0) 1806 error (1, errno, "could not stat %s", file2); 1807 if (CVS_STAT (finfo->file, file_info) < 0) 1808 error (1, errno, "could not stat %s", finfo->file); 1809 if (file2_info.st_size <= file_info->st_size) 1810 fail = 1; 1811 } 1812 1813 if (! fail) 1814 { 1815# define BINARY "Binary" 1816 char buf[sizeof BINARY]; 1817 unsigned int c; 1818 1819 /* Check the diff output to make sure patch will be handle it. */ 1820 e = CVS_FOPEN (finfo->file, "r"); 1821 if (e == NULL) 1822 error (1, errno, "could not open diff output file %s", 1823 finfo->fullname); 1824 c = fread (buf, 1, sizeof BINARY - 1, e); 1825 buf[c] = '\0'; 1826 if (strcmp (buf, BINARY) == 0) 1827 { 1828 /* These are binary files. We could use diff -a, but 1829 patch can't handle that. */ 1830 fail = 1; |
1827 } | 1831 } |
1832 fclose (e); |
|
1828 } 1829 1830 if (! fail) 1831 { 1832 Vers_TS *xvers_ts; 1833 | 1833 } 1834 1835 if (! fail) 1836 { 1837 Vers_TS *xvers_ts; 1838 |
1839 /* Stat the original RCS file, and then adjust it the way 1840 that RCS_checkout would. FIXME: This is an abstraction 1841 violation. */ 1842 if (CVS_STAT (vers_ts->srcfile->path, file_info) < 0) 1843 error (1, errno, "could not stat %s", vers_ts->srcfile->path); 1844 if (chmod (finfo->file, 1845 file_info->st_mode & ~(S_IWRITE | S_IWGRP | S_IWOTH)) 1846 < 0) 1847 error (0, errno, "cannot change mode of file %s", finfo->file); 1848 if (cvswrite 1849 && !fileattr_get (finfo->file, "_watched")) 1850 xchmod (finfo->file, 1); 1851 |
|
1834 /* This stuff is just copied blindly from checkout_file. I 1835 don't really know what it does. */ 1836 xvers_ts = Version_TS (finfo, options, tag, date, 1837 force_tag_match, 0); 1838 if (strcmp (xvers_ts->options, "-V4") == 0) 1839 xvers_ts->options[0] = '\0'; 1840 1841 Register (finfo->entries, finfo->file, xvers_ts->vn_rcs, --- 842 unchanged lines hidden (view full) --- 2684 then presumably it doesn't matter, and indicates no conflict. */ 2685 2686 if (rev1 == NULL) 2687 { 2688 if (islink (finfo->file)) 2689 rev1_symlink = xreadlink (finfo->file); 2690 else 2691 { | 1852 /* This stuff is just copied blindly from checkout_file. I 1853 don't really know what it does. */ 1854 xvers_ts = Version_TS (finfo, options, tag, date, 1855 force_tag_match, 0); 1856 if (strcmp (xvers_ts->options, "-V4") == 0) 1857 xvers_ts->options[0] = '\0'; 1858 1859 Register (finfo->entries, finfo->file, xvers_ts->vn_rcs, --- 842 unchanged lines hidden (view full) --- 2702 then presumably it doesn't matter, and indicates no conflict. */ 2703 2704 if (rev1 == NULL) 2705 { 2706 if (islink (finfo->file)) 2707 rev1_symlink = xreadlink (finfo->file); 2708 else 2709 { |
2692# ifdef HAVE_ST_RDEV | 2710# ifdef HAVE_STRUCT_STAT_ST_RDEV |
2693 if (CVS_LSTAT (finfo->file, &sb) < 0) 2694 error (1, errno, "could not get file information for %s", 2695 finfo->file); 2696 rev1_uid = sb.st_uid; 2697 rev1_gid = sb.st_gid; 2698 rev1_mode = sb.st_mode; 2699 if (S_ISBLK (rev1_mode) || S_ISCHR (rev1_mode)) 2700 rev1_dev = sb.st_rdev; --- 61 unchanged lines hidden (view full) --- 2762 2763 /* Obtain file information for REV2. */ 2764 if (rev2 == NULL) 2765 { 2766 if (islink (finfo->file)) 2767 rev2_symlink = xreadlink (finfo->file); 2768 else 2769 { | 2711 if (CVS_LSTAT (finfo->file, &sb) < 0) 2712 error (1, errno, "could not get file information for %s", 2713 finfo->file); 2714 rev1_uid = sb.st_uid; 2715 rev1_gid = sb.st_gid; 2716 rev1_mode = sb.st_mode; 2717 if (S_ISBLK (rev1_mode) || S_ISCHR (rev1_mode)) 2718 rev1_dev = sb.st_rdev; --- 61 unchanged lines hidden (view full) --- 2780 2781 /* Obtain file information for REV2. */ 2782 if (rev2 == NULL) 2783 { 2784 if (islink (finfo->file)) 2785 rev2_symlink = xreadlink (finfo->file); 2786 else 2787 { |
2770# ifdef HAVE_ST_RDEV | 2788# ifdef HAVE_STRUCT_STAT_ST_RDEV |
2771 if (CVS_LSTAT (finfo->file, &sb) < 0) 2772 error (1, errno, "could not get file information for %s", 2773 finfo->file); 2774 rev2_uid = sb.st_uid; 2775 rev2_gid = sb.st_gid; 2776 rev2_mode = sb.st_mode; 2777 if (S_ISBLK (rev2_mode) || S_ISCHR (rev2_mode)) 2778 rev2_dev = sb.st_rdev; --- 169 unchanged lines hidden --- | 2789 if (CVS_LSTAT (finfo->file, &sb) < 0) 2790 error (1, errno, "could not get file information for %s", 2791 finfo->file); 2792 rev2_uid = sb.st_uid; 2793 rev2_gid = sb.st_gid; 2794 rev2_mode = sb.st_mode; 2795 if (S_ISBLK (rev2_mode) || S_ISCHR (rev2_mode)) 2796 rev2_dev = sb.st_rdev; --- 169 unchanged lines hidden --- |