Fossil

Check-in [73b7faa5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add an "annotate" command to the command-line to suppliment the "annotate" web page.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 73b7faa58b4b457b2c4179863dea9ebfbdac17df
User & Date: drh 2009-12-18 20:15:45
Context
2009-12-18
21:38
Change the name of the strnlen_() function in printf.c to StrNLen32(). check-in: 9a8fdf72 user: drh tags: trunk
20:15
Add an "annotate" command to the command-line to suppliment the "annotate" web page. check-in: 73b7faa5 user: drh tags: trunk
00:29
Detect when the check-out contains missing files and filesystem objects that ought to be files but are not. Issue reasonable warnings. check-in: 76f169fc user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/diff.c.

708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
...
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757









































    fnid
  );
  while( db_step(&q)==SQLITE_ROW ){
    int pid = db_column_int(&q, 0);
    const char *zUuid = db_column_text(&q, 1);
    const char *zDate = db_column_text(&q, 2);
    const char *zUser = db_column_text(&q, 3);
    if( g.okHistory ){
      zLabel = mprintf("<a href='%s/info/%s'>%.10s</a> %s %9.9s", 
                       g.zBaseURL, zUuid, zUuid, zDate, zUser);
    }else{
      zLabel = mprintf("%.10s %s %9.9s", zUuid, zDate, zUser);
    }
    content_get(pid, &step);
    annotation_step(p, &step, zLabel);
................................................................................
  login_check_credentials();
  if( !g.okRead ){ login_needed(); return; }
  if( mid==0 || fnid==0 ){ fossil_redirect_home(); }
  if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){
    fossil_redirect_home();
  }
  style_header("File Annotation");
  annotate_file(&ann, fnid, mid, 1);
  @ <pre>
  for(i=0; i<ann.nOrig; i++){
    ((char*)ann.aOrig[i].z)[ann.aOrig[i].n] = 0;
    @ %s(ann.aOrig[i].zSrc): %h(ann.aOrig[i].z)
  }
  @ </pre>
  style_footer();
}
















































|







 







|








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
...
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
    fnid
  );
  while( db_step(&q)==SQLITE_ROW ){
    int pid = db_column_int(&q, 0);
    const char *zUuid = db_column_text(&q, 1);
    const char *zDate = db_column_text(&q, 2);
    const char *zUser = db_column_text(&q, 3);
    if( webLabel ){
      zLabel = mprintf("<a href='%s/info/%s'>%.10s</a> %s %9.9s", 
                       g.zBaseURL, zUuid, zUuid, zDate, zUser);
    }else{
      zLabel = mprintf("%.10s %s %9.9s", zUuid, zDate, zUser);
    }
    content_get(pid, &step);
    annotation_step(p, &step, zLabel);
................................................................................
  login_check_credentials();
  if( !g.okRead ){ login_needed(); return; }
  if( mid==0 || fnid==0 ){ fossil_redirect_home(); }
  if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){
    fossil_redirect_home();
  }
  style_header("File Annotation");
  annotate_file(&ann, fnid, mid, g.okHistory);
  @ <pre>
  for(i=0; i<ann.nOrig; i++){
    ((char*)ann.aOrig[i].z)[ann.aOrig[i].n] = 0;
    @ %s(ann.aOrig[i].zSrc): %h(ann.aOrig[i].z)
  }
  @ </pre>
  style_footer();
}

/*
** COMMAND: annotate
**
** %fossil annotate FILENAME
**
** Output the text of a file with markings to show when each line of
** the file was introduced.
*/
void annotate_cmd(void){
  int fnid;         /* Filename ID */
  int fid;          /* File instance ID */
  int mid;          /* Manifest where file was checked in */
  Blob treename;    /* FILENAME translated to canonical form */
  char *zFilename;  /* Cannonical filename */
  Annotator ann;    /* The annotation of the file */
  int i;            /* Loop counter */

  db_must_be_within_tree();
  if (g.argc<3) {
    usage("FILENAME");
  }
  file_tree_name(g.argv[2], &treename, 1);
  zFilename = blob_str(&treename);
  fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
  if( fnid==0 ){
    fossil_fatal("no such file: %s", zFilename);
  }
  fid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFilename);
  if( fid==0 ){
    fossil_fatal("not part of current checkout: %s", zFilename);
  }
  mid = db_int(0, "SELECT mid FROM mlink WHERE fid=%d AND fnid=%d", fid, fnid);
  if( mid==0 ){
    fossil_panic("unable to find manifest");
  }
  annotate_file(&ann, fnid, mid, 0);
  for(i=0; i<ann.nOrig; i++){
    printf("%s: %.*s\n", ann.aOrig[i].zSrc, ann.aOrig[i].n, ann.aOrig[i].z);
  }
}