Fossil

Check-in [ff41d4be]
Login

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

Overview
Comment:Make sure sbsdiff lines are escaped properly. Started adding side-by-side diff support to fdiff.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | jan-sbsdiff
Files: files | file ages | folders
SHA1:ff41d4be8a2a3c3b35e897029269cceb83346c50
User & Date: jan 2011-10-15 12:22:31
Original Comment: Make sure sbsdiff lines are escaped properly.
Context
2011-10-15
12:49
Fix bug which disabled patch file generation. check-in: dc27e134 user: jan tags: jan-sbsdiff
12:22
Make sure sbsdiff lines are escaped properly. Started adding side-by-side diff support to fdiff. check-in: ff41d4be user: jan tags: jan-sbsdiff
00:26
Code documentation. check-in: 9b7955b5 user: jan tags: jan-sbsdiff
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/diff.c.

680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
...
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
...
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
...
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
      }else{
        if( !allowExp )
           continue;
        @ <tr style="display:none;">
      }

      copylimline(linebuf, &c.aFrom[iFrom+j], collim);
      @ <td class="lineno">%d(iFrom+j+1)</td><td>%s(linebuf)</td>

      @ <td> </td>

      copylimline(linebuf, &c.aTo[iTo+j], collim);
      @ <td class="lineno">%d(iTo+j+1)</td><td>%s(linebuf)</td>

      @ </tr>
    }
    iFrom+=c.aEdit[i];
    iTo+=c.aEdit[i];

    if( c.aEdit[i+1]!=0 && c.aEdit[i+2]!=0 ){
................................................................................
      for( j=0; j<lim; j++ ){
        int len;
        @ <tr>

        if( j<c.aEdit[i+1] ){
          copylimline(linebuf, &c.aFrom[iFrom+j], collim);
          @ <td class="changed lineno">%d(iFrom+j+1)</td>
          @ <td class="changed">%s(linebuf)</td>
        }else{
           @ <td colspan="2"/>
        }

        @ <td class="changed">|</td>

        if( j<c.aEdit[i+2] ){
          copylimline(linebuf, &c.aTo[iTo+j], collim);
          @ <td class="changed lineno">%d(iTo+j+1)</td>
          @ <td class="changed">%s(linebuf)</td>
        }else{
          @ <td colspan="2"/>
        }

        @ </tr>
      }
      iFrom+=c.aEdit[i+1];
................................................................................
      /* Process deleted lines */
      for( j=0; j<c.aEdit[i+1]; j++ ){
        int len;
        @ <tr>

        copylimline(linebuf, &c.aFrom[iFrom+j], collim);
        @ <td class="removed lineno">%d(iFrom+j+1)</td>
        @ <td class="removed">%s(linebuf)</td>

        @ <td>&lt;</td>

        @ <td colspan="2"/>

        @ </tr>
      }
................................................................................
        @ <tr>
        @ <td colspan="2"/>

        @ <td>&gt;</td>

        copylimline(linebuf, &c.aTo[iTo+j], collim);
        @ <td class="added lineno">%d(iTo+j+1)</td>
        @ <td class="added">%s(linebuf)</td>

        @ </tr>
      }
      iTo+=c.aEdit[i+2];
    }

    i+=3;







|




|







 







|

|







|







 







|







 







|







680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
...
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
...
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
...
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
      }else{
        if( !allowExp )
           continue;
        @ <tr style="display:none;">
      }

      copylimline(linebuf, &c.aFrom[iFrom+j], collim);
      @ <td class="lineno">%d(iFrom+j+1)</td><td>%h(linebuf)</td>

      @ <td> </td>

      copylimline(linebuf, &c.aTo[iTo+j], collim);
      @ <td class="lineno">%d(iTo+j+1)</td><td>%h(linebuf)</td>

      @ </tr>
    }
    iFrom+=c.aEdit[i];
    iTo+=c.aEdit[i];

    if( c.aEdit[i+1]!=0 && c.aEdit[i+2]!=0 ){
................................................................................
      for( j=0; j<lim; j++ ){
        int len;
        @ <tr>

        if( j<c.aEdit[i+1] ){
          copylimline(linebuf, &c.aFrom[iFrom+j], collim);
          @ <td class="changed lineno">%d(iFrom+j+1)</td>
          @ <td class="changed">%h(linebuf)</td>
        }else{
          @ <td colspan="2"/>
        }

        @ <td class="changed">|</td>

        if( j<c.aEdit[i+2] ){
          copylimline(linebuf, &c.aTo[iTo+j], collim);
          @ <td class="changed lineno">%d(iTo+j+1)</td>
          @ <td class="changed">%h(linebuf)</td>
        }else{
          @ <td colspan="2"/>
        }

        @ </tr>
      }
      iFrom+=c.aEdit[i+1];
................................................................................
      /* Process deleted lines */
      for( j=0; j<c.aEdit[i+1]; j++ ){
        int len;
        @ <tr>

        copylimline(linebuf, &c.aFrom[iFrom+j], collim);
        @ <td class="removed lineno">%d(iFrom+j+1)</td>
        @ <td class="removed">%h(linebuf)</td>

        @ <td>&lt;</td>

        @ <td colspan="2"/>

        @ </tr>
      }
................................................................................
        @ <tr>
        @ <td colspan="2"/>

        @ <td>&gt;</td>

        copylimline(linebuf, &c.aTo[iTo+j], collim);
        @ <td class="added lineno">%d(iTo+j+1)</td>
        @ <td class="added">%h(linebuf)</td>

        @ </tr>
      }
      iTo+=c.aEdit[i+2];
    }

    i+=3;

Changes to src/info.c.

1029
1030
1031
1032
1033
1034
1035

1036
1037
1038
1039
1040
1041
1042
1043
1044

1045
1046
1047
1048
1049
1050
1051
1052
1053
1054

1055
1056
1057
1058
1059

1060
1061
1062
1063
1064
1065
1066
1067
1068
1069







1070
1071
1072

1073
1074
1075
1076
1077
1078
1079
** Two arguments, v1 and v2, identify the files to be diffed.  Show the 
** difference between the two artifacts.  Generate plaintext if "patch"
** is present.
*/
void diff_page(void){
  int v1, v2;
  int isPatch;

  Blob c1, c2, diff, *pOut;
  char *zV1;
  char *zV2;

  login_check_credentials();
  if( !g.perm.Read ){ login_needed(); return; }
  v1 = name_to_rid_www("v1");
  v2 = name_to_rid_www("v2");
  if( v1==0 || v2==0 ) fossil_redirect_home();

  zV1 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v1);
  zV2 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v2);
  isPatch = P("patch")!=0;
  if( isPatch ){
    pOut = cgi_output_blob();
    cgi_set_content_type("text/plain");
  }else{
    blob_zero(&diff);
    pOut = &diff;
  }

  content_get(v1, &c1);
  content_get(v2, &c2);
  text_diff(&c1, &c2, pOut, 4, 1);
  blob_reset(&c1);
  blob_reset(&c2);

  if( !isPatch ){
    style_header("Diff");
    style_submenu_element("Patch", "Patch", "%s/fdiff?v1=%T&v2=%T&patch",
                          g.zTop, P("v1"), P("v2"));
    @ <h2>Differences From
    @ Artifact <a href="%s(g.zTop)/artifact/%S(zV1)">[%S(zV1)]</a>:</h2>
    object_description(v1, 0, 0);
    @ <h2>To Artifact <a href="%s(g.zTop)/artifact/%S(zV2)">[%S(zV2)]</a>:</h2>
    object_description(v2, 0, 0);
    @ <hr />







    @ <blockquote><pre>
    @ %h(blob_str(&diff))
    @ </pre></blockquote>

    blob_reset(&diff);
    style_footer();
  }
}

/*
** WEBPAGE: raw







>









>










>
|
|
|
|
|
>










>
>
>
>
>
>
>
|
|
|
>







1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
** Two arguments, v1 and v2, identify the files to be diffed.  Show the 
** difference between the two artifacts.  Generate plaintext if "patch"
** is present.
*/
void diff_page(void){
  int v1, v2;
  int isPatch;
  int sideBySide;
  Blob c1, c2, diff, *pOut;
  char *zV1;
  char *zV2;

  login_check_credentials();
  if( !g.perm.Read ){ login_needed(); return; }
  v1 = name_to_rid_www("v1");
  v2 = name_to_rid_www("v2");
  if( v1==0 || v2==0 ) fossil_redirect_home();
  sideBySide = atoi(PD("sbs","1"));
  zV1 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v1);
  zV2 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v2);
  isPatch = P("patch")!=0;
  if( isPatch ){
    pOut = cgi_output_blob();
    cgi_set_content_type("text/plain");
  }else{
    blob_zero(&diff);
    pOut = &diff;
  }
  if( !sideBySide ){
    content_get(v1, &c1);
    content_get(v2, &c2);
    text_diff(&c1, &c2, pOut, 4, 1);
    blob_reset(&c1);
    blob_reset(&c2);
  }
  if( !isPatch ){
    style_header("Diff");
    style_submenu_element("Patch", "Patch", "%s/fdiff?v1=%T&v2=%T&patch",
                          g.zTop, P("v1"), P("v2"));
    @ <h2>Differences From
    @ Artifact <a href="%s(g.zTop)/artifact/%S(zV1)">[%S(zV1)]</a>:</h2>
    object_description(v1, 0, 0);
    @ <h2>To Artifact <a href="%s(g.zTop)/artifact/%S(zV2)">[%S(zV2)]</a>:</h2>
    object_description(v2, 0, 0);
    @ <hr />
    if( sideBySide ){
      @ <table class="sbsdiff">
      @ <tr><th colspan="2" class="diffhdr">Old (%S(zV1))</th><th/>
      @ <th colspan="2" class="diffhdr">New (%S(zV2))</th></tr>
      generate_sbsdiff(zV1, zV2);
      @ </table>
    }else{
      @ <blockquote><pre>
      @ %h(blob_str(&diff))
      @ </pre></blockquote>
    }
    blob_reset(&diff);
    style_footer();
  }
}

/*
** WEBPAGE: raw