version 1.39, 2007/09/22 16:01:22 |
version 1.40, 2007/10/09 12:22:27 |
|
|
/* $OpenBSD$ */ |
/* $OpenBSD$ */ |
/* |
/* |
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> |
|
* Copyright (c) 2007 Tobias Stoeckmann <tobias@openbsd.org> |
* Copyright (c) 2007 Tobias Stoeckmann <tobias@openbsd.org> |
|
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
|
|
void cvs_annotate_local(struct cvs_file *); |
void cvs_annotate_local(struct cvs_file *); |
|
|
static int force_head = 0; |
static int force_head = 0; |
static char *rev = NULL; |
|
|
|
struct cvs_cmd cvs_cmd_annotate = { |
struct cvs_cmd cvs_cmd_annotate = { |
CVS_OP_ANNOTATE, 0, "annotate", |
CVS_OP_ANNOTATE, 0, "annotate", |
|
|
case 'R': |
case 'R': |
break; |
break; |
case 'r': |
case 'r': |
rev = optarg; |
cvs_specified_tag = optarg; |
break; |
break; |
default: |
default: |
fatal("%s", cvs_cmd_annotate.cmd_synopsis); |
fatal("%s", cvs_cmd_annotate.cmd_synopsis); |
|
|
if (!(flags & CR_RECURSE_DIRS)) |
if (!(flags & CR_RECURSE_DIRS)) |
cvs_client_send_request("Argument -l"); |
cvs_client_send_request("Argument -l"); |
|
|
if (rev != NULL) |
if (cvs_specified_tag != NULL) |
cvs_client_send_request("Argument -r%s", rev); |
cvs_client_send_request("Argument -r%s", |
|
cvs_specified_tag); |
} else { |
} else { |
cr.fileproc = cvs_annotate_local; |
cr.fileproc = cvs_annotate_local; |
} |
} |
|
|
{ |
{ |
int i; |
int i; |
char date[10], rnum[13], *p; |
char date[10], rnum[13], *p; |
RCSNUM *crev; |
RCSNUM *rev; |
|
struct cvs_line *line; |
struct cvs_line **alines; |
struct cvs_line **alines; |
|
|
cvs_log(LP_TRACE, "cvs_annotate_local(%s)", cf->file_path); |
cvs_log(LP_TRACE, "cvs_annotate_local(%s)", cf->file_path); |
|
|
cf->file_type != CVS_FILE) |
cf->file_type != CVS_FILE) |
return; |
return; |
|
|
if (rev == NULL) |
if (cvs_specified_tag == NULL) |
rcs_rev_getlines(cf->file_rcs, cf->file_rcsrev, &alines); |
rcs_rev_getlines(cf->file_rcs, cf->file_rcsrev, &alines); |
else { |
else { |
crev = rcsnum_parse(rev); |
rev = rcsnum_parse(cvs_specified_tag); |
|
|
if (rcsnum_cmp(crev, cf->file_rcsrev, 0) < 0) { |
if (rcsnum_cmp(rev, cf->file_rcsrev, 0) < 0) { |
if (!force_head) { |
if (!force_head) { |
/* Stick at weird GNU cvs, ignore error. */ |
/* Stick at weird GNU cvs, ignore error. */ |
rcsnum_free(crev); |
rcsnum_free(rev); |
return; |
return; |
} |
} |
rcsnum_cpy(cf->file_rcsrev, crev, 0); |
rcsnum_cpy(cf->file_rcsrev, rev, 0); |
} |
} |
rcs_rev_getlines(cf->file_rcs, crev, &alines); |
rcs_rev_getlines(cf->file_rcs, rev, &alines); |
rcsnum_free(crev); |
rcsnum_free(rev); |
} |
} |
|
|
/* Stick at weird GNU cvs, ignore error. */ |
/* Stick at weird GNU cvs, ignore error. */ |
|
|
cvs_log(LP_RCS, "***************"); |
cvs_log(LP_RCS, "***************"); |
|
|
for (i = 0; alines[i] != NULL; i++) { |
for (i = 0; alines[i] != NULL; i++) { |
rcsnum_tostr(alines[i]->l_delta->rd_num, rnum, sizeof(rnum)); |
line = alines[i]; |
|
|
|
rcsnum_tostr(line->l_delta->rd_num, rnum, sizeof(rnum)); |
strftime(date, sizeof(date), "%d-%b-%y", |
strftime(date, sizeof(date), "%d-%b-%y", |
&(alines[i]->l_delta->rd_date)); |
&(line->l_delta->rd_date)); |
if (alines[i]->l_len && |
if (line->l_len && line->l_line[line->l_len - 1] == '\n') |
alines[i]->l_line[alines[i]->l_len - 1] == '\n') |
line->l_line[line->l_len - 1] = '\0'; |
alines[i]->l_line[alines[i]->l_len - 1] = '\0'; |
|
else { |
else { |
p = xmalloc(alines[i]->l_len + 1); |
p = xmalloc(line->l_len + 1); |
memcpy(p, alines[i]->l_line, alines[i]->l_len); |
memcpy(p, line->l_line, line->l_len); |
p[alines[i]->l_len] = '\0'; |
p[line->l_len] = '\0'; |
|
|
if (alines[i]->l_needsfree) |
if (line->l_needsfree) |
xfree(alines[i]->l_line); |
xfree(line->l_line); |
alines[i]->l_line = p; |
line->l_line = p; |
alines[i]->l_len++; |
line->l_len++; |
alines[i]->l_needsfree = 1; |
line->l_needsfree = 1; |
} |
} |
cvs_printf("%-12.12s (%-8.8s %s): %s\n", rnum, |
cvs_printf("%-12.12s (%-8.8s %s): %s\n", rnum, |
alines[i]->l_delta->rd_author, date, alines[i]->l_line); |
line->l_delta->rd_author, date, line->l_line); |
|
|
if (alines[i]->l_needsfree) |
if (line->l_needsfree) |
xfree(alines[i]->l_line); |
xfree(line->l_line); |
xfree(alines[i]); |
xfree(line); |
} |
} |
|
|
xfree(alines); |
xfree(alines); |