[BACK]Return to checkout.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / cvs

Annotation of src/usr.bin/cvs/checkout.c, Revision 1.141

1.141   ! joris       1: /*     $OpenBSD: checkout.c,v 1.140 2008/02/27 22:34:04 joris Exp $    */
1.1       jfb         2: /*
1.53      joris       3:  * Copyright (c) 2006 Joris Vink <joris@openbsd.org>
1.1       jfb         4:  *
1.53      joris       5:  * Permission to use, copy, modify, and distribute this software for any
                      6:  * purpose with or without fee is hereby granted, provided that the above
                      7:  * copyright notice and this permission notice appear in all copies.
1.1       jfb         8:  *
1.53      joris       9:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     10:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     11:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     12:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     13:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     14:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     15:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.1       jfb        16:  */
                     17:
1.92      otto       18: #include <sys/param.h>
                     19: #include <sys/dirent.h>
                     20: #include <sys/stat.h>
1.117     tobias     21: #include <sys/time.h>
1.92      otto       22:
                     23: #include <errno.h>
                     24: #include <fcntl.h>
1.100     tobias     25: #include <libgen.h>
1.130     xsa        26: #include <stdlib.h>
1.92      otto       27: #include <string.h>
                     28: #include <unistd.h>
1.1       jfb        29:
                     30: #include "cvs.h"
1.53      joris      31: #include "diff.h"
1.66      joris      32: #include "remote.h"
1.72      joris      33:
1.61      xsa        34: static void checkout_check_repository(int, char **);
1.113     tobias     35: static int checkout_classify(const char *, const char *);
1.53      joris      36: static void checkout_repository(const char *, const char *);
1.14      joris      37:
1.101     joris      38: extern int print_stdout;
1.54      joris      39: extern int prune_dirs;
1.57      joris      40: extern int build_dirs;
1.54      joris      41:
1.78      xsa        42: static int flags = CR_REPO | CR_RECURSE_DIRS;
1.132     tobias     43: static int Aflag = 0;
1.120     joris      44: static char *dflag = NULL;
1.125     tobias     45: static char *koptstr = NULL;
1.133     joris      46: static char *dateflag = NULL;
1.78      xsa        47:
1.127     joris      48: static int nflag = 0;
                     49:
1.133     joris      50: char *checkout_target_dir = NULL;
1.136     joris      51: time_t cvs_specified_date = -1;
1.131     tobias     52:
1.22      jfb        53: struct cvs_cmd cvs_cmd_checkout = {
1.112     tobias     54:        CVS_OP_CHECKOUT, CVS_USE_WDIR, "checkout",
1.22      jfb        55:        { "co", "get" },
1.53      joris      56:        "Checkout a working copy of a repository",
1.33      xsa        57:        "[-AcflNnPpRs] [-D date | -r tag] [-d dir] [-j rev] [-k mode] "
1.22      jfb        58:        "[-t id] module ...",
1.77      xsa        59:        "AcD:d:fj:k:lNnPpRr:st:",
1.59      joris      60:        NULL,
                     61:        cvs_checkout
                     62: };
                     63:
                     64: struct cvs_cmd cvs_cmd_export = {
1.112     tobias     65:        CVS_OP_EXPORT, CVS_USE_WDIR, "export",
1.59      joris      66:        { "exp", "ex" },
                     67:        "Export sources from CVS, similar to checkout",
1.61      xsa        68:        "[-flNnR] [-d dir] [-k mode] -D date | -r rev module ...",
                     69:        "D:d:k:flNnRr:",
1.22      jfb        70:        NULL,
1.61      xsa        71:        cvs_export
1.33      xsa        72: };
                     73:
1.53      joris      74: int
                     75: cvs_checkout(int argc, char **argv)
1.1       jfb        76: {
1.78      xsa        77:        int ch;
1.13      jfb        78:
1.53      joris      79:        while ((ch = getopt(argc, argv, cvs_cmd_checkout.cmd_opts)) != -1) {
1.1       jfb        80:                switch (ch) {
1.76      xsa        81:                case 'A':
1.132     tobias     82:                        Aflag = 1;
                     83:                        if (koptstr == NULL)
                     84:                                reset_option = 1;
                     85:                        if (cvs_specified_tag == NULL)
                     86:                                reset_tag = 1;
1.76      xsa        87:                        break;
1.129     joris      88:                case 'c':
                     89:                        cvs_modules_list();
                     90:                        exit(0);
1.131     tobias     91:                case 'D':
1.133     joris      92:                        dateflag = optarg;
                     93:                        cvs_specified_date = cvs_date_parse(dateflag);
1.131     tobias     94:                        break;
1.120     joris      95:                case 'd':
                     96:                        if (dflag != NULL)
                     97:                                fatal("-d specified two or more times");
                     98:                        dflag = optarg;
1.133     joris      99:                        checkout_target_dir = dflag;
1.120     joris     100:                        break;
1.125     tobias    101:                case 'k':
1.132     tobias    102:                        reset_option = 0;
1.125     tobias    103:                        koptstr = optarg;
                    104:                        kflag = rcs_kflag_get(koptstr);
                    105:                        if (RCS_KWEXP_INVAL(kflag)) {
                    106:                                cvs_log(LP_ERR,
                    107:                                    "invalid RCS keyword expension mode");
                    108:                                fatal("%s", cvs_cmd_add.cmd_synopsis);
                    109:                        }
                    110:                        break;
1.77      xsa       111:                case 'l':
                    112:                        flags &= ~CR_RECURSE_DIRS;
                    113:                        break;
1.104     joris     114:                case 'N':
                    115:                        break;
1.127     joris     116:                case 'n':
                    117:                        nflag = 1;
                    118:                        break;
1.54      joris     119:                case 'P':
                    120:                        prune_dirs = 1;
1.77      xsa       121:                        break;
1.101     joris     122:                case 'p':
1.112     tobias    123:                        cmdp->cmd_flags &= ~CVS_USE_WDIR;
1.101     joris     124:                        print_stdout = 1;
                    125:                        cvs_noexec = 1;
1.127     joris     126:                        nflag = 1;
1.101     joris     127:                        break;
1.77      xsa       128:                case 'R':
1.110     tobias    129:                        flags |= CR_RECURSE_DIRS;
1.54      joris     130:                        break;
1.93      niallo    131:                case 'r':
1.132     tobias    132:                        reset_tag = 0;
1.97      joris     133:                        cvs_specified_tag = optarg;
1.93      niallo    134:                        break;
1.1       jfb       135:                default:
1.53      joris     136:                        fatal("%s", cvs_cmd_checkout.cmd_synopsis);
1.1       jfb       137:                }
                    138:        }
                    139:
                    140:        argc -= optind;
                    141:        argv += optind;
                    142:
1.53      joris     143:        if (argc == 0)
                    144:                fatal("%s", cvs_cmd_checkout.cmd_synopsis);
1.22      jfb       145:
1.61      xsa       146:        checkout_check_repository(argc, argv);
                    147:
                    148:        return (0);
                    149: }
                    150:
                    151: int
                    152: cvs_export(int argc, char **argv)
                    153: {
1.78      xsa       154:        int ch;
1.61      xsa       155:
                    156:        prune_dirs = 1;
                    157:
                    158:        while ((ch = getopt(argc, argv, cvs_cmd_export.cmd_opts)) != -1) {
                    159:                switch (ch) {
1.125     tobias    160:                case 'k':
                    161:                        koptstr = optarg;
                    162:                        kflag = rcs_kflag_get(koptstr);
                    163:                        if (RCS_KWEXP_INVAL(kflag)) {
                    164:                                cvs_log(LP_ERR,
                    165:                                    "invalid RCS keyword expension mode");
                    166:                                fatal("%s", cvs_cmd_add.cmd_synopsis);
                    167:                        }
                    168:                        break;
1.61      xsa       169:                case 'l':
                    170:                        flags &= ~CR_RECURSE_DIRS;
                    171:                        break;
                    172:                case 'R':
1.110     tobias    173:                        flags |= CR_RECURSE_DIRS;
1.98      xsa       174:                        break;
                    175:                case 'r':
                    176:                        cvs_specified_tag = optarg;
1.61      xsa       177:                        break;
                    178:                default:
                    179:                        fatal("%s", cvs_cmd_export.cmd_synopsis);
                    180:                }
                    181:        }
                    182:
                    183:        argc -= optind;
                    184:        argv += optind;
                    185:
1.108     tobias    186:        if (cvs_specified_tag == NULL)
                    187:                fatal("must specify a tag or date");
                    188:
1.61      xsa       189:        if (argc == 0)
                    190:                fatal("%s", cvs_cmd_export.cmd_synopsis);
                    191:
                    192:        checkout_check_repository(argc, argv);
                    193:
                    194:        return (0);
                    195: }
                    196:
                    197: static void
                    198: checkout_check_repository(int argc, char **argv)
                    199: {
1.67      xsa       200:        int i;
1.123     joris     201:        char *wdir, *d;
1.79      joris     202:        struct cvs_recursion cr;
1.119     joris     203:        struct module_checkout *mc;
1.123     joris     204:        struct cvs_ignpat *ip;
                    205:        struct cvs_filelist *fl, *nxt;
                    206:        char repo[MAXPATHLEN], fpath[MAXPATHLEN], *f[1];
1.79      joris     207:
1.102     tobias    208:        build_dirs = print_stdout ? 0 : 1;
                    209:
1.79      joris     210:        if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
                    211:                cvs_client_connect_to_server();
                    212:
1.97      joris     213:                if (cvs_specified_tag != NULL)
                    214:                        cvs_client_send_request("Argument -r%s",
                    215:                            cvs_specified_tag);
1.132     tobias    216:                if (Aflag)
1.79      joris     217:                        cvs_client_send_request("Argument -A");
1.133     joris     218:
                    219:                if (dateflag != NULL)
                    220:                        cvs_client_send_request("Argument -D%s", dateflag);
1.122     joris     221:
1.125     tobias    222:                if (kflag)
                    223:                        cvs_client_send_request("Argument -k%s", koptstr);
                    224:
1.122     joris     225:                if (dflag != NULL)
                    226:                        cvs_client_send_request("Argument -d%s", dflag);
1.80      xsa       227:
                    228:                if (!(flags & CR_RECURSE_DIRS))
                    229:                        cvs_client_send_request("Argument -l");
1.79      joris     230:
                    231:                if (cvs_cmdop == CVS_OP_CHECKOUT && prune_dirs == 1)
                    232:                        cvs_client_send_request("Argument -P");
                    233:
1.101     joris     234:                if (print_stdout == 1)
                    235:                        cvs_client_send_request("Argument -p");
                    236:
1.127     joris     237:                if (nflag == 1)
                    238:                        cvs_client_send_request("Argument -n");
                    239:
1.79      joris     240:                cr.enterdir = NULL;
                    241:                cr.leavedir = NULL;
1.103     tobias    242:                if (print_stdout)
                    243:                        cr.fileproc = NULL;
                    244:                else
                    245:                        cr.fileproc = cvs_client_sendfile;
                    246:
                    247:                flags &= ~CR_REPO;
1.79      joris     248:                cr.flags = flags;
                    249:
1.108     tobias    250:                if (cvs_cmdop != CVS_OP_EXPORT)
                    251:                        cvs_file_run(argc, argv, &cr);
1.79      joris     252:
                    253:                cvs_client_send_files(argv, argc);
                    254:                cvs_client_senddir(".");
                    255:
                    256:                cvs_client_send_request("%s",
                    257:                    (cvs_cmdop == CVS_OP_CHECKOUT) ? "co" : "export");
                    258:
                    259:                cvs_client_get_responses();
                    260:
                    261:                return;
                    262:        }
1.61      xsa       263:
1.104     joris     264:        cvs_directory_tag = cvs_specified_tag;
                    265:
1.53      joris     266:        for (i = 0; i < argc; i++) {
1.119     joris     267:                mc = cvs_module_lookup(argv[i]);
                    268:                current_module = mc;
1.116     joris     269:
1.123     joris     270:                TAILQ_FOREACH(fl, &(mc->mc_ignores), flist)
                    271:                        cvs_file_ignore(fl->file_path, &checkout_ign_pats);
1.13      jfb       272:
1.123     joris     273:                TAILQ_FOREACH(fl, &(mc->mc_modules), flist) {
1.139     tobias    274:                        module_repo_root = NULL;
                    275:
1.123     joris     276:                        (void)xsnprintf(repo, sizeof(repo), "%s/%s",
                    277:                            current_cvsroot->cr_dir, fl->file_path);
1.121     joris     278:
1.123     joris     279:                        if (!(mc->mc_flags & MODULE_ALIAS) || dflag != NULL)
1.139     tobias    280:                                module_repo_root = xstrdup(fl->file_path);
1.123     joris     281:
                    282:                        if (mc->mc_flags & MODULE_NORECURSE)
                    283:                                flags &= ~CR_RECURSE_DIRS;
                    284:
                    285:                        if (dflag != NULL)
                    286:                                wdir = dflag;
1.124     joris     287:                        else if (mc->mc_flags & MODULE_ALIAS)
                    288:                                wdir = fl->file_path;
1.123     joris     289:                        else
1.124     joris     290:                                wdir = mc->mc_name;
1.123     joris     291:
                    292:                        switch (checkout_classify(repo, fl->file_path)) {
                    293:                        case CVS_FILE:
                    294:                                cr.fileproc = cvs_update_local;
                    295:                                cr.flags = flags;
                    296:
                    297:                                if (!(mc->mc_flags & MODULE_ALIAS)) {
                    298:                                        module_repo_root =
1.139     tobias    299:                                            xstrdup(dirname(fl->file_path));
1.123     joris     300:                                        d = wdir;
                    301:                                        (void)xsnprintf(fpath, sizeof(fpath),
                    302:                                            "%s/%s", d,
                    303:                                            basename(fl->file_path));
                    304:                                } else {
                    305:                                        d = dirname(wdir);
                    306:                                        strlcpy(fpath, fl->file_path,
                    307:                                            sizeof(fpath));
                    308:                                }
                    309:
                    310:                                if (build_dirs == 1)
                    311:                                        cvs_mkpath(d, cvs_specified_tag);
                    312:
                    313:                                f[0] = fpath;
                    314:                                cvs_file_run(1, f, &cr);
                    315:                                break;
                    316:                        case CVS_DIR:
                    317:                                if (build_dirs == 1)
                    318:                                        cvs_mkpath(wdir, cvs_specified_tag);
                    319:                                checkout_repository(repo, wdir);
                    320:                                break;
                    321:                        default:
                    322:                                break;
                    323:                        }
1.126     joris     324:
1.127     joris     325:                        if (nflag != 1 && mc->mc_prog != NULL &&
1.128     joris     326:                            mc->mc_flags & MODULE_RUN_ON_CHECKOUT)
1.126     joris     327:                                cvs_exec(mc->mc_prog);
1.139     tobias    328:
                    329:                        if (module_repo_root != NULL)
                    330:                                xfree(module_repo_root);
1.123     joris     331:                }
1.119     joris     332:
1.123     joris     333:                if (mc->mc_canfree == 1) {
                    334:                        for (fl = TAILQ_FIRST(&(mc->mc_modules));
                    335:                            fl != TAILQ_END(&(mc->mc_modules)); fl = nxt) {
                    336:                                nxt = TAILQ_NEXT(fl, flist);
                    337:                                TAILQ_REMOVE(&(mc->mc_modules), fl, flist);
                    338:                                xfree(fl->file_path);
                    339:                                xfree(fl);
                    340:                        }
                    341:                }
1.120     joris     342:
1.123     joris     343:                while ((ip = TAILQ_FIRST(&checkout_ign_pats)) != NULL) {
                    344:                        TAILQ_REMOVE(&checkout_ign_pats, ip, ip_list);
                    345:                        xfree(ip);
1.113     tobias    346:                }
1.119     joris     347:
                    348:                xfree(mc);
1.113     tobias    349:        }
                    350: }
1.100     tobias    351:
1.113     tobias    352: static int
                    353: checkout_classify(const char *repo, const char *arg)
                    354: {
                    355:        char *d, *f, fpath[MAXPATHLEN];
                    356:        struct stat sb;
                    357:
                    358:        if (stat(repo, &sb) == 0) {
1.123     joris     359:                if (S_ISDIR(sb.st_mode))
                    360:                        return CVS_DIR;
1.113     tobias    361:        }
1.97      joris     362:
1.113     tobias    363:        d = dirname(repo);
                    364:        f = basename(repo);
                    365:
                    366:        (void)xsnprintf(fpath, sizeof(fpath), "%s/%s%s", d, f, RCS_FILE_EXT);
                    367:        if (stat(fpath, &sb) == 0) {
                    368:                if (!S_ISREG(sb.st_mode)) {
                    369:                        cvs_log(LP_ERR, "ignoring %s: not a regular file", arg);
                    370:                        return 0;
                    371:                }
                    372:                return CVS_FILE;
1.33      xsa       373:        }
1.113     tobias    374:
                    375:        (void)xsnprintf(fpath, sizeof(fpath), "%s/%s/%s%s",
                    376:            d, CVS_PATH_ATTIC, f, RCS_FILE_EXT);
                    377:        if (stat(fpath, &sb) == 0) {
                    378:                if (!S_ISREG(sb.st_mode)) {
                    379:                        cvs_log(LP_ERR, "ignoring %s: not a regular file", arg);
                    380:                        return 0;
                    381:                }
                    382:                return CVS_FILE;
                    383:        }
                    384:
                    385:        cvs_log(LP_ERR, "cannot find module `%s' - ignored", arg);
                    386:        return 0;
1.14      joris     387: }
1.9       jfb       388:
1.53      joris     389: static void
                    390: checkout_repository(const char *repobase, const char *wdbase)
1.14      joris     391: {
1.53      joris     392:        struct cvs_flisthead fl, dl;
                    393:        struct cvs_recursion cr;
                    394:
                    395:        TAILQ_INIT(&fl);
                    396:        TAILQ_INIT(&dl);
1.94      joris     397:
1.99      xsa       398:        cvs_history_add((cvs_cmdop == CVS_OP_CHECKOUT) ?
                    399:            CVS_HISTORY_CHECKOUT : CVS_HISTORY_EXPORT, NULL, wdbase);
1.41      joris     400:
1.112     tobias    401:        if (print_stdout) {
                    402:                cr.enterdir = NULL;
                    403:                cr.leavedir = NULL;
                    404:        } else {
                    405:                cr.enterdir = cvs_update_enterdir;
1.118     tobias    406:                cr.leavedir = prune_dirs ? cvs_update_leavedir : NULL;
1.112     tobias    407:        }
1.64      joris     408:        cr.fileproc = cvs_update_local;
1.78      xsa       409:        cr.flags = flags;
1.41      joris     410:
1.53      joris     411:        cvs_repository_lock(repobase);
1.111     tobias    412:        cvs_repository_getdir(repobase, wdbase, &fl, &dl,
                    413:            flags & CR_RECURSE_DIRS ? 1 : 0);
1.1       jfb       414:
1.53      joris     415:        cvs_file_walklist(&fl, &cr);
                    416:        cvs_file_freelist(&fl);
1.23      joris     417:
1.53      joris     418:        cvs_repository_unlock(repobase);
1.23      joris     419:
1.53      joris     420:        cvs_file_walklist(&dl, &cr);
                    421:        cvs_file_freelist(&dl);
                    422: }
1.23      joris     423:
1.58      joris     424: void
1.105     joris     425: cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags)
1.53      joris     426: {
1.141   ! joris     427:        int cf_kflag, exists, fd;
1.53      joris     428:        time_t rcstime;
                    429:        CVSENTRIES *ent;
                    430:        struct timeval tv[2];
1.134     tobias    431:        struct tm *datetm;
1.87      joris     432:        char *tosend;
1.135     xsa       433:        char template[MAXPATHLEN], *entry;
1.115     xsa       434:        char kbuf[8], sticky[CVS_REV_BUFSZ], rev[CVS_REV_BUFSZ];
1.96      xsa       435:        char timebuf[CVS_TIME_BUFSZ], tbuf[CVS_TIME_BUFSZ];
1.22      jfb       436:
1.87      joris     437:        exists = 0;
                    438:        tosend = NULL;
1.104     joris     439:
                    440:        if (!(co_flags & CO_REMOVE))
                    441:                rcsnum_tostr(rnum, rev, sizeof(rev));
1.41      joris     442:
1.66      joris     443:        cvs_log(LP_TRACE, "cvs_checkout_file(%s, %s, %d) -> %s",
1.78      xsa       444:            cf->file_path, rev, co_flags,
1.66      joris     445:            (cvs_server_active) ? "to client" : "to disk");
1.42      joris     446:
1.78      xsa       447:        if (co_flags & CO_DUMP) {
1.106     tobias    448:                rcs_rev_write_fd(cf->file_rcs, rnum, STDOUT_FILENO, 0);
1.65      reyk      449:                return;
                    450:        }
1.87      joris     451:
1.66      joris     452:        if (cvs_server_active == 0) {
1.141   ! joris     453:                (void)unlink(cf->file_path);
        !           454:
1.87      joris     455:                if (!(co_flags & CO_MERGE)) {
                    456:                        if (cf->fd != -1) {
                    457:                                exists = 1;
                    458:                                (void)close(cf->fd);
                    459:                        }
                    460:
1.141   ! joris     461:                        cf->fd = open(cf->file_path,
        !           462:                            O_CREAT | O_WRONLY | O_TRUNC);
1.87      joris     463:                        if (cf->fd == -1)
                    464:                                fatal("cvs_checkout_file: open: %s",
                    465:                                    strerror(errno));
                    466:
1.106     tobias    467:                        rcs_rev_write_fd(cf->file_rcs, rnum, cf->fd, 0);
1.87      joris     468:                } else {
                    469:                        cvs_merge_file(cf, 1);
1.66      joris     470:                }
                    471:
                    472:                if (fchmod(cf->fd, 0644) == -1)
                    473:                        fatal("cvs_checkout_file: fchmod: %s", strerror(errno));
                    474:
1.87      joris     475:                if ((exists == 0) && (cf->file_ent == NULL) &&
                    476:                    !(co_flags & CO_MERGE))
1.66      joris     477:                        rcstime = rcs_rev_getdate(cf->file_rcs, rnum);
1.84      joris     478:                else
1.66      joris     479:                        time(&rcstime);
                    480:
                    481:                tv[0].tv_sec = rcstime;
                    482:                tv[0].tv_usec = 0;
                    483:                tv[1] = tv[0];
                    484:                if (futimes(cf->fd, tv) == -1)
                    485:                        fatal("cvs_checkout_file: futimes: %s",
                    486:                            strerror(errno));
1.53      joris     487:        } else {
                    488:                time(&rcstime);
1.41      joris     489:        }
                    490:
1.84      joris     491:        asctime_r(gmtime(&rcstime), tbuf);
1.107     tobias    492:        tbuf[strcspn(tbuf, "\n")] = '\0';
1.58      joris     493:
1.78      xsa       494:        if (co_flags & CO_MERGE) {
1.89      xsa       495:                (void)xsnprintf(timebuf, sizeof(timebuf), "Result of merge+%s",
1.58      joris     496:                    tbuf);
                    497:        } else {
                    498:                strlcpy(timebuf, tbuf, sizeof(timebuf));
                    499:        }
1.41      joris     500:
1.89      xsa       501:        if (co_flags & CO_SETSTICKY)
1.105     joris     502:                if (tag != NULL)
1.114     xsa       503:                        (void)xsnprintf(sticky, sizeof(sticky), "T%s", tag);
1.136     joris     504:                else if (cvs_specified_date != -1) {
1.138     xsa       505:                        datetm = gmtime(&cvs_specified_date);
                    506:                        (void)strftime(sticky, sizeof(sticky),
                    507:                            "D"CVS_DATE_FMT, datetm);
1.134     tobias    508:                } else
1.114     xsa       509:                        (void)xsnprintf(sticky, sizeof(sticky), "T%s", rev);
1.132     tobias    510:        else if (!reset_tag && cf->file_ent != NULL &&
1.109     tobias    511:            cf->file_ent->ce_tag != NULL)
1.114     xsa       512:                (void)xsnprintf(sticky, sizeof(sticky), "T%s",
1.109     tobias    513:                    cf->file_ent->ce_tag);
1.89      xsa       514:        else
1.114     xsa       515:                sticky[0] = '\0';
1.60      joris     516:
1.85      xsa       517:        kbuf[0] = '\0';
1.125     tobias    518:        if (cf->file_rcs->rf_expand != NULL) {
                    519:                cf_kflag = rcs_kflag_get(cf->file_rcs->rf_expand);
                    520:                if (kflag || cf_kflag != RCS_KWEXP_DEFAULT)
                    521:                        (void)xsnprintf(kbuf, sizeof(kbuf),
                    522:                            "-k%s", cf->file_rcs->rf_expand);
1.132     tobias    523:        } else if (!reset_option && cf->file_ent != NULL) {
1.85      xsa       524:                if (cf->file_ent->ce_opts != NULL)
                    525:                        strlcpy(kbuf, cf->file_ent->ce_opts, sizeof(kbuf));
                    526:        }
                    527:
1.135     xsa       528:        entry = xmalloc(CVS_ENT_MAXLINELEN);
                    529:        cvs_ent_line_str(cf->file_name, rev, timebuf, kbuf, sticky, 0, 0,
                    530:            entry, CVS_ENT_MAXLINELEN);
1.41      joris     531:
1.66      joris     532:        if (cvs_server_active == 0) {
1.108     tobias    533:                if (!(co_flags & CO_REMOVE) && cvs_cmdop != CVS_OP_EXPORT) {
1.95      joris     534:                        ent = cvs_ent_open(cf->file_wd);
                    535:                        cvs_ent_add(ent, entry);
                    536:                        cvs_ent_close(ent, ENT_SYNC);
1.135     xsa       537:                        xfree(entry);
1.95      joris     538:                }
1.66      joris     539:        } else {
1.87      joris     540:                if (co_flags & CO_MERGE) {
1.141   ! joris     541:                        (void)unlink(cf->file_path);
1.87      joris     542:                        cvs_merge_file(cf, 1);
                    543:                        tosend = cf->file_path;
1.140     joris     544:                        fd = cf->fd;
1.87      joris     545:                }
                    546:
1.78      xsa       547:                if (co_flags & CO_COMMIT)
1.137     tobias    548:                        cvs_server_update_entry("Updated", cf);
1.87      joris     549:                else if (co_flags & CO_MERGE)
                    550:                        cvs_server_update_entry("Merged", cf);
1.95      joris     551:                else if (co_flags & CO_REMOVE)
                    552:                        cvs_server_update_entry("Removed", cf);
1.69      joris     553:                else
                    554:                        cvs_server_update_entry("Updated", cf);
1.68      joris     555:
1.135     xsa       556:                if (!(co_flags & CO_REMOVE)) {
1.95      joris     557:                        cvs_remote_output(entry);
1.135     xsa       558:                        xfree(entry);
                    559:                }
1.66      joris     560:
1.137     tobias    561:                if (!(co_flags & CO_REMOVE)) {
1.87      joris     562:                        if (!(co_flags & CO_MERGE)) {
1.89      xsa       563:                                (void)xsnprintf(template, MAXPATHLEN,
1.87      joris     564:                                    "%s/checkout.XXXXXXXXXX", cvs_tmpdir);
1.89      xsa       565:
1.140     joris     566:                                fd = rcs_rev_write_stmp(cf->file_rcs, rnum,
1.87      joris     567:                                    template, 0);
                    568:                                tosend = template;
                    569:                        }
                    570:
1.140     joris     571:                        cvs_remote_send_file(tosend, fd);
1.87      joris     572:
                    573:                        if (!(co_flags & CO_MERGE)) {
1.140     joris     574:                                close(fd);
1.87      joris     575:                                (void)unlink(template);
                    576:                                cvs_worklist_run(&temp_files,
                    577:                                    cvs_worklist_unlink);
                    578:                        }
1.68      joris     579:                }
1.66      joris     580:        }
1.1       jfb       581: }