[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.138

1.138   ! xsa         1: /*     $OpenBSD: checkout.c,v 1.137 2008/02/10 13:01:08 tobias 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) {
                    274:                        (void)xsnprintf(repo, sizeof(repo), "%s/%s",
                    275:                            current_cvsroot->cr_dir, fl->file_path);
1.121     joris     276:
1.123     joris     277:                        if (!(mc->mc_flags & MODULE_ALIAS) || dflag != NULL)
                    278:                                module_repo_root = fl->file_path;
                    279:
                    280:                        if (mc->mc_flags & MODULE_NORECURSE)
                    281:                                flags &= ~CR_RECURSE_DIRS;
                    282:
                    283:                        if (dflag != NULL)
                    284:                                wdir = dflag;
1.124     joris     285:                        else if (mc->mc_flags & MODULE_ALIAS)
                    286:                                wdir = fl->file_path;
1.123     joris     287:                        else
1.124     joris     288:                                wdir = mc->mc_name;
1.123     joris     289:
                    290:                        switch (checkout_classify(repo, fl->file_path)) {
                    291:                        case CVS_FILE:
                    292:                                cr.fileproc = cvs_update_local;
                    293:                                cr.flags = flags;
                    294:
                    295:                                if (!(mc->mc_flags & MODULE_ALIAS)) {
                    296:                                        module_repo_root =
                    297:                                            dirname(fl->file_path);
                    298:                                        d = wdir;
                    299:                                        (void)xsnprintf(fpath, sizeof(fpath),
                    300:                                            "%s/%s", d,
                    301:                                            basename(fl->file_path));
                    302:                                } else {
                    303:                                        d = dirname(wdir);
                    304:                                        strlcpy(fpath, fl->file_path,
                    305:                                            sizeof(fpath));
                    306:                                }
                    307:
                    308:                                if (build_dirs == 1)
                    309:                                        cvs_mkpath(d, cvs_specified_tag);
                    310:
                    311:                                f[0] = fpath;
                    312:                                cvs_file_run(1, f, &cr);
                    313:                                break;
                    314:                        case CVS_DIR:
                    315:                                if (build_dirs == 1)
                    316:                                        cvs_mkpath(wdir, cvs_specified_tag);
                    317:                                checkout_repository(repo, wdir);
                    318:                                break;
                    319:                        default:
                    320:                                break;
                    321:                        }
1.126     joris     322:
1.127     joris     323:                        if (nflag != 1 && mc->mc_prog != NULL &&
1.128     joris     324:                            mc->mc_flags & MODULE_RUN_ON_CHECKOUT)
1.126     joris     325:                                cvs_exec(mc->mc_prog);
1.123     joris     326:                }
1.119     joris     327:
1.123     joris     328:                if (mc->mc_canfree == 1) {
                    329:                        for (fl = TAILQ_FIRST(&(mc->mc_modules));
                    330:                            fl != TAILQ_END(&(mc->mc_modules)); fl = nxt) {
                    331:                                nxt = TAILQ_NEXT(fl, flist);
                    332:                                TAILQ_REMOVE(&(mc->mc_modules), fl, flist);
                    333:                                xfree(fl->file_path);
                    334:                                xfree(fl);
                    335:                        }
                    336:                }
1.120     joris     337:
1.123     joris     338:                while ((ip = TAILQ_FIRST(&checkout_ign_pats)) != NULL) {
                    339:                        TAILQ_REMOVE(&checkout_ign_pats, ip, ip_list);
                    340:                        xfree(ip);
1.113     tobias    341:                }
1.119     joris     342:
                    343:                xfree(mc);
1.113     tobias    344:        }
                    345: }
1.100     tobias    346:
1.113     tobias    347: static int
                    348: checkout_classify(const char *repo, const char *arg)
                    349: {
                    350:        char *d, *f, fpath[MAXPATHLEN];
                    351:        struct stat sb;
                    352:
                    353:        if (stat(repo, &sb) == 0) {
1.123     joris     354:                if (S_ISDIR(sb.st_mode))
                    355:                        return CVS_DIR;
1.113     tobias    356:        }
1.97      joris     357:
1.113     tobias    358:        d = dirname(repo);
                    359:        f = basename(repo);
                    360:
                    361:        (void)xsnprintf(fpath, sizeof(fpath), "%s/%s%s", d, f, RCS_FILE_EXT);
                    362:        if (stat(fpath, &sb) == 0) {
                    363:                if (!S_ISREG(sb.st_mode)) {
                    364:                        cvs_log(LP_ERR, "ignoring %s: not a regular file", arg);
                    365:                        return 0;
                    366:                }
                    367:                return CVS_FILE;
1.33      xsa       368:        }
1.113     tobias    369:
                    370:        (void)xsnprintf(fpath, sizeof(fpath), "%s/%s/%s%s",
                    371:            d, CVS_PATH_ATTIC, f, RCS_FILE_EXT);
                    372:        if (stat(fpath, &sb) == 0) {
                    373:                if (!S_ISREG(sb.st_mode)) {
                    374:                        cvs_log(LP_ERR, "ignoring %s: not a regular file", arg);
                    375:                        return 0;
                    376:                }
                    377:                return CVS_FILE;
                    378:        }
                    379:
                    380:        cvs_log(LP_ERR, "cannot find module `%s' - ignored", arg);
                    381:        return 0;
1.14      joris     382: }
1.9       jfb       383:
1.53      joris     384: static void
                    385: checkout_repository(const char *repobase, const char *wdbase)
1.14      joris     386: {
1.53      joris     387:        struct cvs_flisthead fl, dl;
                    388:        struct cvs_recursion cr;
                    389:
                    390:        TAILQ_INIT(&fl);
                    391:        TAILQ_INIT(&dl);
1.94      joris     392:
1.99      xsa       393:        cvs_history_add((cvs_cmdop == CVS_OP_CHECKOUT) ?
                    394:            CVS_HISTORY_CHECKOUT : CVS_HISTORY_EXPORT, NULL, wdbase);
1.41      joris     395:
1.112     tobias    396:        if (print_stdout) {
                    397:                cr.enterdir = NULL;
                    398:                cr.leavedir = NULL;
                    399:        } else {
                    400:                cr.enterdir = cvs_update_enterdir;
1.118     tobias    401:                cr.leavedir = prune_dirs ? cvs_update_leavedir : NULL;
1.112     tobias    402:        }
1.64      joris     403:        cr.fileproc = cvs_update_local;
1.78      xsa       404:        cr.flags = flags;
1.41      joris     405:
1.53      joris     406:        cvs_repository_lock(repobase);
1.111     tobias    407:        cvs_repository_getdir(repobase, wdbase, &fl, &dl,
                    408:            flags & CR_RECURSE_DIRS ? 1 : 0);
1.1       jfb       409:
1.53      joris     410:        cvs_file_walklist(&fl, &cr);
                    411:        cvs_file_freelist(&fl);
1.23      joris     412:
1.53      joris     413:        cvs_repository_unlock(repobase);
1.23      joris     414:
1.53      joris     415:        cvs_file_walklist(&dl, &cr);
                    416:        cvs_file_freelist(&dl);
                    417: }
1.23      joris     418:
1.58      joris     419: void
1.105     joris     420: cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags)
1.53      joris     421: {
1.125     tobias    422:        int cf_kflag, oflags, exists;
1.53      joris     423:        time_t rcstime;
                    424:        CVSENTRIES *ent;
                    425:        struct timeval tv[2];
1.134     tobias    426:        struct tm *datetm;
1.87      joris     427:        char *tosend;
1.135     xsa       428:        char template[MAXPATHLEN], *entry;
1.115     xsa       429:        char kbuf[8], sticky[CVS_REV_BUFSZ], rev[CVS_REV_BUFSZ];
1.96      xsa       430:        char timebuf[CVS_TIME_BUFSZ], tbuf[CVS_TIME_BUFSZ];
1.22      jfb       431:
1.87      joris     432:        exists = 0;
                    433:        tosend = NULL;
1.104     joris     434:
                    435:        if (!(co_flags & CO_REMOVE))
                    436:                rcsnum_tostr(rnum, rev, sizeof(rev));
1.41      joris     437:
1.66      joris     438:        cvs_log(LP_TRACE, "cvs_checkout_file(%s, %s, %d) -> %s",
1.78      xsa       439:            cf->file_path, rev, co_flags,
1.66      joris     440:            (cvs_server_active) ? "to client" : "to disk");
1.42      joris     441:
1.78      xsa       442:        if (co_flags & CO_DUMP) {
1.106     tobias    443:                rcs_rev_write_fd(cf->file_rcs, rnum, STDOUT_FILENO, 0);
1.65      reyk      444:                return;
                    445:        }
1.87      joris     446:
1.66      joris     447:        if (cvs_server_active == 0) {
1.87      joris     448:                if (!(co_flags & CO_MERGE)) {
                    449:                        oflags = O_WRONLY | O_TRUNC;
                    450:                        if (cf->fd != -1) {
                    451:                                exists = 1;
                    452:                                (void)close(cf->fd);
                    453:                        } else  {
                    454:                                oflags |= O_CREAT;
                    455:                        }
                    456:
                    457:                        cf->fd = open(cf->file_path, oflags);
                    458:                        if (cf->fd == -1)
                    459:                                fatal("cvs_checkout_file: open: %s",
                    460:                                    strerror(errno));
                    461:
1.106     tobias    462:                        rcs_rev_write_fd(cf->file_rcs, rnum, cf->fd, 0);
1.87      joris     463:                } else {
                    464:                        cvs_merge_file(cf, 1);
1.66      joris     465:                }
                    466:
                    467:                if (fchmod(cf->fd, 0644) == -1)
                    468:                        fatal("cvs_checkout_file: fchmod: %s", strerror(errno));
                    469:
1.87      joris     470:                if ((exists == 0) && (cf->file_ent == NULL) &&
                    471:                    !(co_flags & CO_MERGE))
1.66      joris     472:                        rcstime = rcs_rev_getdate(cf->file_rcs, rnum);
1.84      joris     473:                else
1.66      joris     474:                        time(&rcstime);
                    475:
                    476:                tv[0].tv_sec = rcstime;
                    477:                tv[0].tv_usec = 0;
                    478:                tv[1] = tv[0];
                    479:                if (futimes(cf->fd, tv) == -1)
                    480:                        fatal("cvs_checkout_file: futimes: %s",
                    481:                            strerror(errno));
1.53      joris     482:        } else {
                    483:                time(&rcstime);
1.41      joris     484:        }
                    485:
1.84      joris     486:        asctime_r(gmtime(&rcstime), tbuf);
1.107     tobias    487:        tbuf[strcspn(tbuf, "\n")] = '\0';
1.58      joris     488:
1.78      xsa       489:        if (co_flags & CO_MERGE) {
1.89      xsa       490:                (void)xsnprintf(timebuf, sizeof(timebuf), "Result of merge+%s",
1.58      joris     491:                    tbuf);
                    492:        } else {
                    493:                strlcpy(timebuf, tbuf, sizeof(timebuf));
                    494:        }
1.41      joris     495:
1.89      xsa       496:        if (co_flags & CO_SETSTICKY)
1.105     joris     497:                if (tag != NULL)
1.114     xsa       498:                        (void)xsnprintf(sticky, sizeof(sticky), "T%s", tag);
1.136     joris     499:                else if (cvs_specified_date != -1) {
1.138   ! xsa       500:                        datetm = gmtime(&cvs_specified_date);
        !           501:                        (void)strftime(sticky, sizeof(sticky),
        !           502:                            "D"CVS_DATE_FMT, datetm);
1.134     tobias    503:                } else
1.114     xsa       504:                        (void)xsnprintf(sticky, sizeof(sticky), "T%s", rev);
1.132     tobias    505:        else if (!reset_tag && cf->file_ent != NULL &&
1.109     tobias    506:            cf->file_ent->ce_tag != NULL)
1.114     xsa       507:                (void)xsnprintf(sticky, sizeof(sticky), "T%s",
1.109     tobias    508:                    cf->file_ent->ce_tag);
1.89      xsa       509:        else
1.114     xsa       510:                sticky[0] = '\0';
1.60      joris     511:
1.85      xsa       512:        kbuf[0] = '\0';
1.125     tobias    513:        if (cf->file_rcs->rf_expand != NULL) {
                    514:                cf_kflag = rcs_kflag_get(cf->file_rcs->rf_expand);
                    515:                if (kflag || cf_kflag != RCS_KWEXP_DEFAULT)
                    516:                        (void)xsnprintf(kbuf, sizeof(kbuf),
                    517:                            "-k%s", cf->file_rcs->rf_expand);
1.132     tobias    518:        } else if (!reset_option && cf->file_ent != NULL) {
1.85      xsa       519:                if (cf->file_ent->ce_opts != NULL)
                    520:                        strlcpy(kbuf, cf->file_ent->ce_opts, sizeof(kbuf));
                    521:        }
                    522:
1.135     xsa       523:        entry = xmalloc(CVS_ENT_MAXLINELEN);
                    524:        cvs_ent_line_str(cf->file_name, rev, timebuf, kbuf, sticky, 0, 0,
                    525:            entry, CVS_ENT_MAXLINELEN);
1.41      joris     526:
1.66      joris     527:        if (cvs_server_active == 0) {
1.108     tobias    528:                if (!(co_flags & CO_REMOVE) && cvs_cmdop != CVS_OP_EXPORT) {
1.95      joris     529:                        ent = cvs_ent_open(cf->file_wd);
                    530:                        cvs_ent_add(ent, entry);
                    531:                        cvs_ent_close(ent, ENT_SYNC);
1.135     xsa       532:                        xfree(entry);
1.95      joris     533:                }
1.66      joris     534:        } else {
1.87      joris     535:                if (co_flags & CO_MERGE) {
                    536:                        cvs_merge_file(cf, 1);
                    537:                        tosend = cf->file_path;
                    538:                }
                    539:
1.78      xsa       540:                if (co_flags & CO_COMMIT)
1.137     tobias    541:                        cvs_server_update_entry("Updated", cf);
1.87      joris     542:                else if (co_flags & CO_MERGE)
                    543:                        cvs_server_update_entry("Merged", cf);
1.95      joris     544:                else if (co_flags & CO_REMOVE)
                    545:                        cvs_server_update_entry("Removed", cf);
1.69      joris     546:                else
                    547:                        cvs_server_update_entry("Updated", cf);
1.68      joris     548:
1.135     xsa       549:                if (!(co_flags & CO_REMOVE)) {
1.95      joris     550:                        cvs_remote_output(entry);
1.135     xsa       551:                        xfree(entry);
                    552:                }
1.66      joris     553:
1.137     tobias    554:                if (!(co_flags & CO_REMOVE)) {
1.87      joris     555:                        if (!(co_flags & CO_MERGE)) {
1.89      xsa       556:                                (void)xsnprintf(template, MAXPATHLEN,
1.87      joris     557:                                    "%s/checkout.XXXXXXXXXX", cvs_tmpdir);
1.89      xsa       558:
1.87      joris     559:                                rcs_rev_write_stmp(cf->file_rcs, rnum,
                    560:                                    template, 0);
                    561:                                tosend = template;
                    562:                        }
                    563:
                    564:                        cvs_remote_send_file(tosend);
                    565:
                    566:                        if (!(co_flags & CO_MERGE)) {
                    567:                                (void)unlink(template);
                    568:                                cvs_worklist_run(&temp_files,
                    569:                                    cvs_worklist_unlink);
                    570:                        }
1.68      joris     571:                }
1.66      joris     572:        }
1.1       jfb       573: }