- Make sure comparisons are done on file types as well.

- Handle the case where a repository may have been copied, and the symlinks have
  not been preserved. CVSup removes the files and creates the symlinks, so
  enable this behaviour in csup as well.
- While there, fix comments and style issues.
This commit is contained in:
Ulf Lilleengen 2008-11-23 16:44:49 +00:00
parent c978f37d88
commit 41a9dd24e4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/csup_cvsmode/; revision=185211
2 changed files with 22 additions and 8 deletions

View File

@ -840,6 +840,19 @@ fattr_install(struct fattr *fa, const char *topath, const char *frompath)
} }
#endif #endif
/*
* If it is changed from a file to a symlink, remove the file
* and create the symlink.
*/
if (inplace && (fa->type == FT_SYMLINK) &&
(old->type == FT_FILE)) {
error = unlink(topath);
if (error)
goto bad;
error = symlink(fa->linktarget, topath);
if (error)
goto bad;
}
/* Determine whether we need to remove the target first. */ /* Determine whether we need to remove the target first. */
if (!inplace && (fa->type == FT_DIRECTORY) != if (!inplace && (fa->type == FT_DIRECTORY) !=
(old->type == FT_DIRECTORY)) { (old->type == FT_DIRECTORY)) {
@ -919,6 +932,9 @@ fattr_equal(const struct fattr *fa1, const struct fattr *fa2)
mask = fa1->mask & fa2->mask; mask = fa1->mask & fa2->mask;
if (fa1->type == FT_UNKNOWN || fa2->type == FT_UNKNOWN) if (fa1->type == FT_UNKNOWN || fa2->type == FT_UNKNOWN)
return (0); return (0);
if (mask & FA_FILETYPE)
if (fa1->type != fa2->type)
return (0);
if (mask & FA_MODTIME) if (mask & FA_MODTIME)
if (fa1->modtime != fa2->modtime) if (fa1->modtime != fa2->modtime)
return (0); return (0);

View File

@ -1255,13 +1255,13 @@ updater_diff_apply(struct updater *up, struct file_update *fup, char *state)
/* Update or create a node. */ /* Update or create a node. */
static int static int
updater_updatenode(struct updater *up, struct coll *coll, struct file_update *fup, char *name, updater_updatenode(struct updater *up, struct coll *coll,
char *attr) struct file_update *fup, char *name, char *attr)
{ {
struct fattr *fa, *fileattr; struct fattr *fa, *fileattr;
struct status *st; struct status *st;
struct statusrec *sr; struct statusrec *sr;
int error, issymlink, rv; int error, rv;
sr = &fup->srbuf; sr = &fup->srbuf;
st = fup->st; st = fup->st;
@ -1270,10 +1270,8 @@ updater_updatenode(struct updater *up, struct coll *coll, struct file_update *fu
if (fattr_type(fa) == FT_SYMLINK) { if (fattr_type(fa) == FT_SYMLINK) {
lprintf(1, " Symlink %s -> %s\n", name, lprintf(1, " Symlink %s -> %s\n", name,
fattr_getlinktarget(fa)); fattr_getlinktarget(fa));
issymlink = 1;
} else { } else {
lprintf(1, " Mknod %s\n", name); lprintf(1, " Mknod %s\n", name);
issymlink = 0;
} }
/* Create directory. */ /* Create directory. */
@ -1281,11 +1279,11 @@ updater_updatenode(struct updater *up, struct coll *coll, struct file_update *fu
if (error) if (error)
return (UPDATER_ERR_PROTO); return (UPDATER_ERR_PROTO);
/* If it exists, update attributes. */ /* If it does not exist, create it. */
if (access(fup->destpath, F_OK) != 0) if (access(fup->destpath, F_OK) != 0)
fattr_makenode(fa, fup->destpath); fattr_makenode(fa, fup->destpath);
/* /*
* Coming from attic? I don't think this is a problem since we have * Coming from attic? I don't think this is a problem since we have
* determined attic before we call this function (Look at UpdateNode in * determined attic before we call this function (Look at UpdateNode in
* cvsup). * cvsup).