ノード:Annotations -- A Detailed View Of Project Activity, 次:Annotations And Branches, 前:History -- A Summary Of Repository Activity, 上:Advanced CVS
history コマンドがプロジェクトの活動を表示するものだとすると、
annotate コマンドはそれにズームレンズをつけるものだと言えます。
annotate
を使うとあるファイルの各行を最後に触った人が誰か、ど
のリビジョンで触ったかまでわかるのです:
floss$ cvs annotate Annotations for README.txt *************** 1.14 (jrandom 25-Jul-99): blah 1.13 (jrandom 25-Jul-99): test 3 for history 1.12 (qsmith 19-Jul-99): test 2 1.11 (qsmith 19-Jul-99): test 1.10 (jrandom 12-Jul-99): blah 1.1 (jrandom 20-Jun-99): Just a test project. 1.4 (jrandom 21-Jun-99): yeah. 1.5 (jrandom 21-Jun-99): nope. Annotations for hello.c *************** 1.1 (jrandom 20-Jun-99): #include <stdio.h> 1.1 (jrandom 20-Jun-99): 1.1 (jrandom 20-Jun-99): void 1.1 (jrandom 20-Jun-99): main () 1.1 (jrandom 20-Jun-99): { 1.15 (jrandom 25-Jul-99): /* another test for history */ 1.13 (qsmith 19-Jul-99): /* random change number two */ 1.10 (jrandom 12-Jul-99): /* test */ 1.21 (jrandom 25-Jul-99): printf ("Hellooo, world!\n"); 1.3 (jrandom 21-Jun-99): printf ("hmmm\n"); 1.4 (jrandom 21-Jun-99): printf ("double hmmm\n"); 1.11 (qsmith 18-Jul-99): /* added this comment */ 1.16 (qsmith 25-Jul-99): /* will merge these changes */ 1.18 (jrandom 25-Jul-99): /* will merge these changes too */ 1.2 (jrandom 21-Jun-99): printf ("Goodbye, world!\n"); 1.1 (jrandom 20-Jun-99): } Annotations for a-subdir/whatever.c *************** 1.3 (jrandom 25-Jul-99): /* A completely non-empty C file. */ Annotations for a-subdir/subsubdir/fish.c *************** 1.2 (jrandom 25-Jul-99): /* An almost completely empty C file. */ Annotations for b-subdir/random.c *************** 1.1 (jrandom 20-Jun-99): /* A completely empty C file. */ floss$
annotate の出力はとても直観的です。左側は、その行が追加、または最後 に変更されたリビジョン番号、開発者、日付です。右側は現在のリビジョン のその行自体です。全ての行に注釈がついているので、そのファイルの内容 全体を見ようと思えば、注釈情報を無視して右側だけ見ればよいのです。
リビジョン番号かタグを指定すれば、そのリビジョンについての注釈が表示 されます。各行についてそのリビジョン以前の最も最近の変更が表示される、 ということです。ある1つのファイルの特定のリビジョンを調べ、どの開発 者がファイル中のどの部分で活動したかはっきりさせる、というのが annotate の最も普通の使い道です。
例えば上の例の出力で、hello.c の最新のリビジョンは 1.21 で、jrandom
がこの行:
printf ("Hellooo, world!\n");
に何かした、というのがわかると思います。
なにをしたか調べるにはは、そのリビジョンと一つ前のリビジョンの diff
を取ってみるのが1つの方法です:
floss$ cvs diff -r 1.20 -r 1.21 hello.c Index: hello.c =================================================================== RCS file: /usr/local/newrepos/myproj/hello.c,v retrieving revision 1.20 retrieving revision 1.21 diff -r1.20 -r1.21 9c9 < printf ("Hello, world!\n"); -- > printf ("Hellooo, world!\n"); floss$
もう一つの方法は、現在の注釈を一つ前のリビジョンの注釈と比較すること
です。ファイル全体での全員の活動を見たままで調べられます。
floss$ cvs annotate -r 1.20 hello.c Annotations for hello.c *************** 1.1 (jrandom 20-Jun-99): #include <stdio.h> 1.1 (jrandom 20-Jun-99): 1.1 (jrandom 20-Jun-99): void 1.1 (jrandom 20-Jun-99): main () 1.1 (jrandom 20-Jun-99): { 1.15 (jrandom 25-Jul-99): /* another test for history */ 1.13 (qsmith 19-Jul-99): /* random change number two */ 1.10 (jrandom 12-Jul-99): /* test */ 1.1 (jrandom 20-Jun-99): printf ("Hello, world!\n"); 1.3 (jrandom 21-Jun-99): printf ("hmmm\n"); 1.4 (jrandom 21-Jun-99): printf ("double hmmm\n"); 1.11 (qsmith 18-Jul-99): /* added this comment */ 1.16 (qsmith 25-Jul-99): /* will merge these changes */ 1.18 (jrandom 25-Jul-99): /* will merge these changes too */ 1.2 (jrandom 21-Jun-99): printf ("Goodbye, world!\n"); 1.1 (jrandom 20-Jun-99): } floss$
diff ではテキストの変更がより簡潔に示されますが、annotate では
the annotation may be preferable because it places them in
their historical context by showing how long the previous incarnation of
the line had been present (in this case, all the way since revision
1.1). That knowledge can help you decide whether to look at the logs to
find out the motivation for the change:
floss$ cvs log -r 1.21 hello.c RCS file: /usr/local/newrepos/myproj/hello.c,v Working file: hello.c head: 1.21 branch: locks: strict access list: symbolic names: random-tag: 1.20 start: 1.1.1.1 jrandom: 1.1.1 keyword substitution: kv total revisions: 22; selected revisions: 1 description: ---------------------------- revision 1.21 date: 1999/07/25 20:17:42; author: jrandom; state: Exp; lines: +1 -1 say hello with renewed enthusiasm ============================================================================ floss$
-r の他に -D DATE オプションを使って注釈をフィルタリングすることがで
きます:
floss$ cvs annotate -D "5 weeks ago" hello.c Annotations for hello.c *************** 1.1 (jrandom 20-Jun-99): #include <stdio.h> 1.1 (jrandom 20-Jun-99): 1.1 (jrandom 20-Jun-99): void 1.1 (jrandom 20-Jun-99): main () 1.1 (jrandom 20-Jun-99): { 1.1 (jrandom 20-Jun-99): printf ("Hello, world!\n"); 1.1 (jrandom 20-Jun-99): } floss$ cvs annotate -D "3 weeks ago" hello.c Annotations for hello.c *************** 1.1 (jrandom 20-Jun-99): #include <stdio.h> 1.1 (jrandom 20-Jun-99): 1.1 (jrandom 20-Jun-99): void 1.1 (jrandom 20-Jun-99): main () 1.1 (jrandom 20-Jun-99): { 1.1 (jrandom 20-Jun-99): printf ("Hello, world!\n"); 1.3 (jrandom 21-Jun-99): printf ("hmmm\n"); 1.4 (jrandom 21-Jun-99): printf ("double hmmm\n"); 1.2 (jrandom 21-Jun-99): printf ("Goodbye, world!\n"); 1.1 (jrandom 20-Jun-99): } floss$