Lines Matching refs:fup

106 static int	 updater_updatefile(struct updater *, struct file_update *fup,
124 struct file_update *fup;
126 fup = xmalloc(sizeof(struct file_update));
127 memset(fup, 0, sizeof(*fup));
128 fup->coll = coll;
129 fup->st = st;
130 return (fup);
134 fup_prepare(struct file_update *fup, char *name, int attic)
138 coll = fup->coll;
139 fup->attic = 0;
140 fup->origpath = NULL;
143 fup->destpath = checkoutpath(coll->co_prefix, name);
145 fup->destpath = cvspath(coll->co_prefix, name, attic);
146 fup->origpath = atticpath(coll->co_prefix, name);
148 if (fup->origpath != NULL &&
149 strcmp(fup->origpath, fup->destpath) == 0) {
150 free(fup->origpath);
151 fup->origpath = NULL;
153 fup->attic = attic;
155 if (fup->destpath == NULL)
157 fup->coname = fup->destpath + coll->co_prefixlen + 1;
163 fup_cleanup(struct file_update *fup)
167 sr = &fup->srbuf;
169 if (fup->destpath != NULL) {
170 free(fup->destpath);
171 fup->destpath = NULL;
173 if (fup->temppath != NULL) {
174 free(fup->temppath);
175 fup->temppath = NULL;
177 if (fup->origpath != NULL) {
178 free(fup->origpath);
179 fup->origpath = NULL;
181 fup->coname = NULL;
182 if (fup->author != NULL) {
183 free(fup->author);
184 fup->author = NULL;
186 fup->expand = 0;
187 if (fup->wantmd5 != NULL) {
188 free(fup->wantmd5);
189 fup->wantmd5 = NULL;
191 if (fup->orig != NULL) {
192 stream_close(fup->orig);
193 fup->orig = NULL;
195 if (fup->to != NULL) {
196 stream_close(fup->to);
197 fup->to = NULL;
215 fup_free(struct file_update *fup)
218 fup_cleanup(fup);
219 free(fup);
284 struct file_update *fup;
318 fup = fup_new(coll, st);
319 error = updater_docoll(up, fup, isfixups);
321 fup_free(fup);
344 updater_docoll(struct updater *up, struct file_update *fup, int isfixups)
360 coll = fup->coll;
390 error = fup_prepare(fup, name, 0);
393 error = updater_setattrs(up, fup, name, tag, date,
408 error = fup_prepare(fup, name, 0);
414 if (access(fup->destpath, F_OK) == 0) {
415 error = updater_delete(up, fup);
429 error = status_put(fup->st, sr);
432 up->errmsg = status_errmsg(fup->st);
450 sr = &fup->srbuf;
459 fup->expand = keyword_decode_expand(expand);
460 if (fup->expand == -1)
462 error = fup_prepare(fup, name, 0);
466 fup->wantmd5 = xstrdup(wantmd5);
467 fup->temppath = tempname(fup->destpath);
468 error = updater_diff(up, fup);
481 error = fup_prepare(fup, name, 0);
484 error = updater_delete(up, fup);
495 error = status_put(fup->st, sr);
498 up->errmsg = status_errmsg(fup->st);
514 sr = &fup->srbuf;
535 error = fup_prepare(fup, name, 0);
538 fup->temppath = tempname(fup->destpath);
540 error = updater_checkout(up, fup, 1);
542 error = updater_checkout(up, fup, 0);
551 error = fup_prepare(fup, name, 0);
554 error = updater_delete(up, fup);
557 error = status_delete(fup->st, name, 0);
559 up->errmsg = status_errmsg(fup->st);
571 error = fup_prepare(fup, name, attic);
575 fup->temppath = tempname(fup->destpath);
576 sr = &fup->srbuf;
586 error = updater_addfile(up, fup, attr, 0);
599 error = fup_prepare(fup, name, 0);
602 fup->wantmd5 = xstrdup(wantmd5);
603 fup->temppath = tempname(fup->destpath);
604 sr = &fup->srbuf;
610 error = updater_rsync(up, fup, strtol(blocksize, NULL,
623 error = fup_prepare(fup, name, 0);
626 sr = &fup->srbuf;
633 error = mkdirhier(fup->destpath, coll->co_umask);
636 if (access(fup->destpath, F_OK) != 0) {
639 fup->destpath);
643 error = status_put(fup->st, sr);
645 up->errmsg = status_errmsg(fup->st);
654 error = fup_prepare(fup, name, 0);
657 error = status_delete(fup->st, name, 0);
659 up->errmsg = status_errmsg(fup->st);
674 error = fup_prepare(fup, name, 0);
677 error = updater_setdirattrs(up, coll, fup, name, attr);
689 error = fup_prepare(fup, name, 0);
693 updater_deletefile(fup->destpath);
694 error = status_delete(fup->st, name, 0);
696 up->errmsg = status_errmsg(fup->st);
709 sr = &fup->srbuf;
724 error = status_put(fup->st, sr);
726 up->errmsg = status_errmsg(fup->st);
737 error = fup_prepare(fup, name, attic);
740 sr = &fup->srbuf;
747 error = updater_updatenode(up, coll, fup, name, attr);
761 error = fup_prepare(fup, name, attic);
764 fup->temppath = tempname(fup->destpath);
765 fup->wantmd5 = xstrdup(wantmd5);
766 sr = &fup->srbuf;
773 error = updater_rcsedit(up, fup, name, rcsopt);
784 error = fup_prepare(fup, name, attic);
788 fup->temppath = tempname(fup->destpath);
789 sr = &fup->srbuf;
796 error = updater_addfile(up, fup, attr, 1);
807 error = fup_prepare(fup, name, 0);
808 fup->temppath = tempname(fup->destpath);
809 sr = &fup->srbuf;
817 error = updater_append_file(up, fup, position);
831 fup_cleanup(fup);
840 updater_delete(struct updater *up, struct file_update *fup)
846 coll = fup->coll;
848 lprintf(1, " Delete %s\n", fup->coname);
853 updater_deletefile(fup->destpath);
855 updater_prunedirs(coll->co_prefix, fup->destpath);
857 lprintf(1," NoDelete %s\n", fup->coname);
875 updater_setattrs(struct updater *up, struct file_update *fup, char *name,
885 coll = fup->coll;
886 st = fup->st;
887 path = fup->destpath;
905 lprintf(1, " SetAttrs %s\n", fup->coname);
912 lprintf(1, " SetAttrs %s\n", fup->coname);
947 updater_updatefile(struct updater *up, struct file_update *fup,
956 coll = fup->coll;
957 sr = &fup->srbuf;
958 st = fup->st;
960 if (strcmp(fup->wantmd5, md5) != 0) {
963 "file not updated\n", fup->destpath);
966 "will transfer entire file\n", fup->destpath);
967 fixups_put(up->config->fixups, fup->coll, sr->sr_file);
970 lprintf(-1, "Bad version saved in %s\n", fup->temppath);
972 updater_deletefile(fup->temppath);
977 rv = fattr_install(sr->sr_clientattr, fup->destpath, fup->temppath);
980 fup->temppath, fup->destpath, strerror(errno));
995 fileattr = fattr_frompath(fup->destpath, FATTR_NOFOLLOW);
997 xasprintf(&up->errmsg, "Cannot stat \"%s\": %s", fup->destpath,
1031 struct file_update *fup, char *name, char *attr)
1037 sr = &fup->srbuf;
1046 rv = fattr_install(sr->sr_clientattr, fup->destpath, NULL);
1050 fup->temppath, fup->destpath, strerror(errno));
1057 fa = fattr_frompath(fup->destpath, FATTR_NOFOLLOW);
1059 xasprintf(&up->errmsg, "Cannot open \%s\": %s", fup->destpath,
1066 error = status_put(fup->st, sr);
1068 up->errmsg = status_errmsg(fup->st);
1076 updater_diff(struct updater *up, struct file_update *fup)
1086 coll = fup->coll;
1087 sr = &fup->srbuf;
1088 path = fup->destpath;
1090 lprintf(1, " Edit %s\n", fup->coname);
1107 if (fup->author != NULL)
1108 free(fup->author);
1111 fup->author = xstrdup(author);
1112 if (fup->orig == NULL) {
1114 fup->orig = stream_open_file(path, O_RDONLY);
1115 if (fup->orig == NULL) {
1122 stream_close(fup->orig);
1123 fup->orig = fup->to;
1124 stream_rewind(fup->orig);
1125 unlink(fup->temppath);
1126 free(fup->temppath);
1127 fup->temppath = tempname(path);
1129 fup->to = stream_open_file(fup->temppath,
1131 if (fup->to == NULL) {
1133 fup->temppath, strerror(errno));
1137 sr->sr_revdate, fup->author);
1138 error = updater_diff_batch(up, fup);
1152 if (MD5_File(fup->temppath, md5) == -1) {
1158 error = updater_updatefile(up, fup, md5, 0);
1166 updater_diff_batch(struct updater *up, struct file_update *fup)
1205 error = updater_diff_apply(up, fup, state);
1228 updater_diff_apply(struct updater *up, struct file_update *fup, char *state)
1235 coll = fup->coll;
1236 sr = &fup->srbuf;
1243 di->di_author = fup->author;
1246 di->di_expand = fup->expand;
1248 error = diff_apply(up->rd, fup->orig, fup->to, coll->co_keyword, di, 1);
1260 struct file_update *fup, char *name, char *attr)
1267 sr = &fup->srbuf;
1268 st = fup->st;
1279 error = mkdirhier(fup->destpath, coll->co_umask);
1284 if (access(fup->destpath, F_OK) != 0)
1285 fattr_makenode(fa, fup->destpath);
1293 rv = fattr_install(fa, fup->destpath, fup->temppath);
1296 "\"%s\": %s", fup->destpath, strerror(errno));
1313 fileattr = fattr_frompath(fup->destpath, FATTR_NOFOLLOW);
1315 xasprintf(&up->errmsg, "Cannot stat \"%s\": %s", fup->destpath,
1353 updater_addfile(struct updater *up, struct file_update *fup, char *attr,
1367 coll = fup->coll;
1368 path = fup->destpath;
1369 sr = &fup->srbuf;
1376 to = stream_open_file(fup->temppath, O_WRONLY | O_CREAT | O_TRUNC, 0755);
1379 fup->temppath, strerror(errno));
1405 fup->wantmd5 = proto_get_ascii(&line);
1406 if (fup->wantmd5 == NULL || line != NULL || strcmp(cmd, "5") != 0)
1409 sr->sr_clientattr = fattr_frompath(fup->temppath, FATTR_NOFOLLOW);
1414 error = updater_updatefile(up, fup, md5, isfixup);
1415 fup->wantmd5 = NULL; /* So that it doesn't get freed. */
1418 xasprintf(&up->errmsg, "%s: Cannot write: %s", fup->temppath,
1424 updater_checkout(struct updater *up, struct file_update *fup, int isfixup)
1435 coll = fup->coll;
1436 sr = &fup->srbuf;
1437 path = fup->destpath;
1440 lprintf(1, " Fixup %s\n", fup->coname);
1442 lprintf(1, " Checkout %s\n", fup->coname);
1451 to = stream_open_file(fup->temppath,
1455 fup->temppath, strerror(errno));
1497 fup->wantmd5 = proto_get_ascii(&line);
1498 if (fup->wantmd5 == NULL || line != NULL || strcmp(cmd, "5") != 0)
1500 error = updater_updatefile(up, fup, md5, isfixup);
1501 fup->wantmd5 = NULL; /* So that it doesn't get freed. */
1506 xasprintf(&up->errmsg, "%s: Cannot write: %s", fup->temppath,
1535 updater_rcsedit(struct updater *up, struct file_update *fup, char *name,
1548 coll = fup->coll;
1549 sr = &fup->srbuf;
1550 st = fup->st;
1551 temppath = fup->temppath;
1552 path = fup->origpath != NULL ? fup->origpath : fup->destpath;
1556 if (fup->origpath != NULL) {
1557 error = mkdirhier(fup->destpath, coll->co_umask);
1560 "%s\n", fup->origpath);
1580 lprintf(1, " Edit %s", fup->coname); \
1581 if (fup->attic) \
1666 lprintf(1, " SetAttrs %s", fup->coname);
1668 lprintf(1, " Touch %s", fup->coname);
1671 fattr_install(sr->sr_serverattr, fup->destpath, NULL);
1672 if (fup->attic)
1680 dest = stream_open_file(fup->temppath,
1684 fup->temppath, strerror(errno));
1692 xasprintf(&up->errmsg, "%s: Cannot write: %s", fup->temppath,
1701 fup->destpath, strerror(errno));
1707 error = updater_updatefile(up, fup, md5, 0);
1708 fup->wantmd5 = NULL; /* So that it doesn't get freed. */
1728 if (fup->origpath != NULL)
1729 updater_deletefile(fup->origpath);
1826 updater_append_file(struct updater *up, struct file_update *fup, off_t pos)
1837 sr = &fup->srbuf;
1839 to = stream_open_file(fup->temppath, O_WRONLY | O_CREAT | O_TRUNC,
1842 xasprintf(&up->errmsg, "%s: Cannot open: %s", fup->temppath,
1846 fd = open(fup->destpath, O_RDONLY);
1848 xasprintf(&up->errmsg, "%s: Cannot open: %s", fup->destpath,
1860 xasprintf(&up->errmsg, "%s: Error reading: %s", fup->destpath,
1890 fup->wantmd5 = proto_get_ascii(&line);
1891 if (fup->wantmd5 == NULL || line != NULL || strcmp(cmd, "5") != 0)
1894 sr->sr_clientattr = fattr_frompath(fup->destpath, FATTR_NOFOLLOW);
1899 error = updater_updatefile(up, fup, md5, 0);
1900 fup->wantmd5 = NULL; /* So that it doesn't get freed. */
1903 xasprintf(&up->errmsg, "%s: Cannot write: %s", fup->temppath,
1955 updater_rsync(struct updater *up, struct file_update *fup, size_t blocksize)
1965 sr = &fup->srbuf;
1967 lprintf(1, " Rsync %s\n", fup->coname);
1969 to = stream_open_file(fup->temppath, O_WRONLY | O_CREAT | O_TRUNC,
1973 fup->temppath, strerror(errno));
1976 orig = open(fup->destpath, O_RDONLY);
1979 fup->destpath, strerror(errno));
1986 xasprintf(&up->errmsg, "%s: Cannot write: %s", fup->temppath,
2010 fup->destpath, strerror(errno));
2016 fup->temppath, strerror(errno));
2024 fup->temppath, strerror(errno));
2032 sr->sr_clientattr = fattr_frompath(fup->destpath, FATTR_NOFOLLOW);
2038 error = updater_updatefile(up, fup, md5, 0);
2039 fup->wantmd5 = NULL; /* So that it doesn't get freed. */