Fossil

Check-in [962694ada0]
Login

Check-in [962694ada0]

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

Overview
Comment:The "fossil patch diff" command should now emit an error message if there is a repository mismatch or a base artifact is missing.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 962694ada0de586eded1ef61f6c9c13107595694b29f683d4431bb539625af25
User & Date: drh 2021-06-23 19:55:55.005
Context
2021-06-23
20:05
Add the -f flag to "fossil patch diff". ... (check-in: 5ee62c4033 user: drh tags: trunk)
19:55
The "fossil patch diff" command should now emit an error message if there is a repository mismatch or a base artifact is missing. ... (check-in: 962694ada0 user: drh tags: trunk)
19:14
The "-f" flag on "fossil patch create" causes an existing patch with the same name to be overwritten. ... (check-in: a332f1a64f user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/patch.c.
709
710
711
712
713
714
715













716






















717
718
719
720
721

722
723
724
725
726
727
728
729
730












731
732
733
734
735
736
737
  const char *zBinGlob,    /* GLOB pattern to determine binary files */
  int fIncludeBinary,      /* Do diffs against binary files */
  u64 diffFlags            /* Other diff flags */
){
  Stmt q;
  Blob empty;
  blob_zero(&empty);













  db_prepare(&q,






















     "SELECT"
       " blob.rid,"    /* 0: rid of the baseline */
       " pathname,"    /* 1: new pathname */
       " origname,"    /* 2: original pathname.  Null if not renamed */
       " delta"        /* 3: delta.  NULL if deleted.  empty is no change */

     " FROM patch.chng, blob WHERE blob.uuid=patch.chng.hash"
     " ORDER BY pathname"
  );
  while( db_step(&q)==SQLITE_ROW ){
    int rid = db_column_int(&q, 0);
    /* const char *zOrig = db_column_text(&q, 2); */
    const char *zName = db_column_text(&q, 1);
    int isBin1, isBin2;
    Blob a, b;












    if( db_column_type(&q,3)==SQLITE_NULL ){
      fossil_print("DELETE %s\n", zName);
      diff_print_index(zName, diffFlags, 0);
      isBin2 = 0;
      content_get(rid, &a);
      isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
      diff_file_mem(&a, &empty, isBin1, isBin2, zName, zDiffCmd,







>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|


|
>
|



|
<
|


>
>
>
>
>
>
>
>
>
>
>
>







709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
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
  const char *zBinGlob,    /* GLOB pattern to determine binary files */
  int fIncludeBinary,      /* Do diffs against binary files */
  u64 diffFlags            /* Other diff flags */
){
  Stmt q;
  Blob empty;
  blob_zero(&empty);

  /* Check to ensure that the patch against the repository that we
  ** have opened.
  **
  ** To do: If there is a mismatch, should we scan all of the repositories
  ** listed in the global_config table looking for a match?
  */
  if( db_exists(
      "SELECT 1 FROM patch.cfg"
      " WHERE cfg.key='baseline'"
      "   AND NOT EXISTS(SELECT 1 FROM blob WHERE uuid=cfg.value)"
  )){
    char *zBaseline;
    db_prepare(&q,
       "SELECT config.value, cfg.value FROM config, cfg"
       " WHERE config.name='project-name'"
       "   AND cfg.key='project-name'"
       "   AND config.value<>cfg.value"
    );
    if( db_step(&q)==SQLITE_ROW ){
      char *zRepo = fossil_strdup(db_column_text(&q,0));
      char *zPatch = fossil_strdup(db_column_text(&q,1));
      db_finalize(&q);
      fossil_fatal("the patch is against project \"%z\" but you are using "
                   "project \"%z\"", zPatch, zRepo);
    }
    db_finalize(&q);
    zBaseline = db_text(0, "SELECT value FROM patch.cfg"
                           " WHERE key='baseline'");
    if( zBaseline ){
      fossil_fatal("the baseline of the patch (check-in %S) is not found "
                   "in the %s repository", zBaseline, g.zRepositoryName);
    }
  }
  
  db_prepare(&q,
     "SELECT"
       " (SELECT blob.rid FROM blob WHERE blob.uuid=chng.hash),"
       " pathname,"    /* 1: new pathname */
       " origname,"    /* 2: original pathname.  Null if not renamed */
       " delta,"       /* 3: delta.  NULL if deleted.  empty is no change */
       " hash"         /* 4: baseline hash */
     " FROM patch.chng"
     " ORDER BY pathname"
  );
  while( db_step(&q)==SQLITE_ROW ){
    int rid;

    const char *zName;
    int isBin1, isBin2;
    Blob a, b;
 
    if( db_column_type(&q,0)!=SQLITE_INTEGER
     && db_column_type(&q,4)==SQLITE_TEXT
    ){
      char *zUuid = fossil_strdup(db_column_text(&q,4));
      char *zName = fossil_strdup(db_column_text(&q,1));
      db_finalize(&q);
      fossil_fatal("base artifact %S for file \"%s\" not found", zUuid, zName);
    }
    zName = db_column_text(&q, 1);
    rid = db_column_int(&q, 0);

    if( db_column_type(&q,3)==SQLITE_NULL ){
      fossil_print("DELETE %s\n", zName);
      diff_print_index(zName, diffFlags, 0);
      isBin2 = 0;
      content_get(rid, &a);
      isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
      diff_file_mem(&a, &empty, isBin1, isBin2, zName, zDiffCmd,