Fossil with Commonmark

Check-in [c9fb495e3d]
Login

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

Overview
Comment:fixes for various edge cases
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | svn-import
Files: files | file ages | folders
SHA1:c9fb495e3d22433766aea793585877afbc40256b
User & Date: baruch 2014-11-05 15:37:17
Context
2014-11-06
07:50
merge trunk check-in: a4b654ec6c user: baruch tags: svn-import
2014-11-05
15:37
fixes for various edge cases check-in: c9fb495e3d user: baruch tags: svn-import
09:36
Fix name of trunk when using --trunk option check-in: 5488f7dd82 user: baruch tags: svn-import
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/db.c.

284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
    va_start(ap, zFormat);
    rc = db_vprepare(pStmt, 0, zFormat, ap);
    pStmt->pNext = db.pAllStmt;
    pStmt->pPrev = 0;
    if( db.pAllStmt ) db.pAllStmt->pPrev = pStmt;
    db.pAllStmt = pStmt;
    va_end(ap);
  }else{
    db_reset(pStmt);
  }
  return rc;
}

/*
** Return the index of a bind parameter
*/







<
<







284
285
286
287
288
289
290


291
292
293
294
295
296
297
    va_start(ap, zFormat);
    rc = db_vprepare(pStmt, 0, zFormat, ap);
    pStmt->pNext = db.pAllStmt;
    pStmt->pPrev = 0;
    if( db.pAllStmt ) db.pAllStmt->pPrev = pStmt;
    db.pAllStmt = pStmt;
    va_end(ap);


  }
  return rc;
}

/*
** Return the index of a bind parameter
*/

Changes to src/import.c.

840
841
842
843
844
845
846





847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875

876
877
878
879
880
881
882
...
909
910
911
912
913
914
915

916
917
918
919
920
921
922
...
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
...
945
946
947
948
949
950
951


952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969

970



971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
...
997
998
999
1000
1001
1002
1003


1004
1005
1006
1007
1008
1009
1010
1011
1012

1013
1014
1015
1016
1017
1018
1019
....
1026
1027
1028
1029
1030
1031
1032




1033
1034
1035
1036
1037
1038
1039
....
1177
1178
1179
1180
1181
1182
1183


1184

1185
1186
1187
1188
1189
1190
1191
....
1209
1210
1211
1212
1213
1214
1215
1216


1217
1218
1219
1220
1221
1222
1223
    if( memcmp(&pRawProps[got-10], "PROPS-END\n", 10)!=0 ){
      fossil_fatal("svn-dump data ended unexpectedly");
    }
    zLine = pRawProps;
    while( zLine<(pRawProps+nRawProps-10) ){
      char *eol;
      int propLen;





      if( zLine[0]!='K' ){
        fossil_fatal("svn-dump data format broken");
      }
      propLen = atoi(&zLine[2]);
      eol = strchr(zLine, '\n');
      zLine = eol+1;
      eol = zLine+propLen;
      if( *eol!='\n' ){
        fossil_fatal("svn-dump data format broken");
      }
      *eol = 0;
      rec->nProps += 1;
      rec->aProps = fossil_realloc(rec->aProps,
        sizeof(rec->aProps[0])*rec->nProps);
      rec->aProps[rec->nProps-1].zKey = zLine;
      zLine = eol+1;
      if( zLine[0]!='V' ){
        fossil_fatal("svn-dump data format broken");
      }
      propLen = atoi(&zLine[2]);
      eol = strchr(zLine, '\n');
      zLine = eol+1;
      eol = zLine+propLen;
      if( *eol!='\n' ){
        fossil_fatal("svn-dump data format broken");
      }
      *eol = 0;
      rec->aProps[rec->nProps-1].zVal = zLine;
      zLine = eol+1;

    }
  }
}

static int svn_read_rec(FILE *pIn, SvnRecord *rec){
  const char *zLen;
  int nLen = 0;
................................................................................
  static Stmt qTags;
  int nBaseFilter;
  int nFilter;
  int rid;
  const char *zParentBranch = 0;
  Blob mcksum;


  nBaseFilter = blob_size(&gsvn.filter);
  if( !gsvn.flatFlag ){
    if( gsvn.zBranch==0 ){ return; }
    if( strncmp(gsvn.zBranch, gsvn.zTrunk, gsvn.lenTrunk-1)==0 ){
      blob_appendf(&gsvn.filter, "%s*", gsvn.zTrunk);
    }else{
      blob_appendf(&gsvn.filter, "%s%s/*", gsvn.zBranches, gsvn.zBranch);
................................................................................
    }
  }else{
    blob_append(&gsvn.filter, "*", 1);
  }
  if( db_int(0, "SELECT 1 FROM xhist WHERE trev=%d AND tpath GLOB %Q LIMIT 1",
             gsvn.rev, blob_str(&gsvn.filter))==0
  ){
    blob_resize(&gsvn.filter, nBaseFilter);
    return;
  }
  db_static_prepare(&insRev, "REPLACE INTO xrevisions (trev, tbranch, tuuid) "
                             "VALUES(:rev, :branch, "
                             " (SELECT uuid FROM blob WHERE rid=:rid))");
  db_static_prepare(&qParent, "SELECT tuuid, max(trev) FROM xrevisions "
                              "WHERE trev<=:rev AND tbranch=:branch");
  db_static_prepare(&qParent2, "SELECT tuuid, min(trev) "
................................................................................
      gsvn.parentRev = db_int(-1, "SELECT ifnull(max(trev),-1) FROM xrevisions "
                                  "WHERE tbranch=%Q", gsvn.zBranch);
      if( gsvn.parentRev<0 ){
        gsvn.parentRev =
            db_int(-1, "SELECT ifnull(max(trev),-1) FROM xrevisions");
      }
      gsvn.zParentBranch = gsvn.zBranch;


    }
    db_bind_int(&insRev, ":rev", gsvn.rev);
    db_bind_text(&insRev, ":branch", gsvn.zBranch);
    db_bind_int(&insRev, ":rid", 0);
    db_step(&insRev);
    db_reset(&insRev);
  }else{
    static int prevRev = -1;
    gsvn.parentRev = prevRev;
    gsvn.zParentBranch = gsvn.zBranch = "";
    prevRev = gsvn.rev;
  }
  blob_zero(&manifest);
  if( gsvn.zComment ){
    blob_appendf(&manifest, "C %F\n", gsvn.zComment);
  }else{
    blob_append(&manifest, "C (no\\scomment)\n", 16);
  }

  blob_appendf(&manifest, "D %s\n", gsvn.zDate);



  nFilter = blob_size(&gsvn.filter)-1;
  db_bind_text(&qFiles, ":filter", blob_str(&gsvn.filter));
  while( db_step(&qFiles)==SQLITE_ROW ){
    const char *zFile = db_column_text(&qFiles, 0);
    int rid = db_column_int(&qFiles, 1);
    const char *zPerm = db_column_text(&qFiles, 2);
    const char *zUuid;
    zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
    blob_appendf(&manifest, "F %F %s %s\n", zFile+nFilter, zUuid, zPerm);
    fossil_free(zUuid);
  }
  blob_resize(&gsvn.filter, nBaseFilter);
  if( gsvn.parentRev>=0 ){
    const char *zParentUuid;
    db_bind_int(&qParent, ":rev", gsvn.parentRev);
    db_bind_text(&qParent, ":branch", gsvn.zParentBranch);
    db_step(&qParent);
    zParentUuid = db_column_text(&qParent, 0);
    if( zParentUuid==0 ){
................................................................................
        blob_appendf(&manifest, "T *branch * %F\n", gsvn.zBranch);
        blob_appendf(&manifest, "T *sym-%F *\n", gsvn.zBranch);
        zParentBranch = mprintf("%F", gsvn.zParentBranch);
      }else{
        zParentBranch = 0;
      }
    }


  }else{
    blob_appendf(&manifest, "T *branch * trunk\n");
    blob_appendf(&manifest, "T *sym-trunk *\n");
  }
  db_bind_int(&qTags, ":rev", gsvn.rev);
  while( db_step(&qTags)==SQLITE_ROW ){
    const char *zTag = db_column_text(&qTags, 0);
    blob_appendf(&manifest, "T +sym-%s *\n", zTag);
  }

  blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev);
  if( zParentBranch ) {
    blob_appendf(&manifest, "T -sym-%s *\n", zParentBranch);
    fossil_free(zParentBranch);
  }
  if( gsvn.zUser ){
    blob_appendf(&manifest, "U %F\n", gsvn.zUser);
................................................................................
  blob_reset(&mcksum);

  rid = content_put(&manifest);
  db_bind_int(&insRev, ":rev", gsvn.rev);
  db_bind_text(&insRev, ":branch", gsvn.zBranch);
  db_bind_int(&insRev, ":rid", rid);
  db_step(&insRev);




  if( gsvn.zParentBranch == gsvn.zBranch ){
    gsvn.zParentBranch = 0;
  }
  if( gsvn.flatFlag ){
    gsvn.zBranch = 0;
  }
  blob_reset(&manifest);
................................................................................
        fossil_free(gsvn.zBranch);
        fossil_free(gsvn.zParentBranch);
      }
      /* start new revision */
      gsvn.rev = atoi(zTemp);
      gsvn.zUser = mprintf("%s", svn_find_prop(rec, "svn:author"));
      gsvn.zComment = mprintf("%s", svn_find_prop(rec, "svn:log"));


      gsvn.zDate = date_in_standard_format(svn_find_prop(rec, "svn:date"));

      gsvn.parentRev = -1;
      gsvn.zParentBranch = 0;
      gsvn.zBranch = 0;
      bHasFiles = 0;
      fossil_print("\rImporting SVN revision: %d", gsvn.rev);
      db_bind_int(&addHist, ":rev", gsvn.rev);
      db_bind_int(&cpyPath, ":rev", gsvn.rev);
................................................................................
        }else{
          fossil_fatal("Missing copyfrom-rev");
        }
      }
      if( !gsvn.flatFlag ){
        if( (zTemp=svn_extract_branch(zPath))!=0 ){
          if( gsvn.zBranch!=0 ){
            if( strcmp(zTemp, gsvn.zBranch)!=0 ){


              fossil_fatal("Commit to multiple branches");
            }
            fossil_free(zTemp);
          }else{
            gsvn.zBranch = zTemp;
          }
        }







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







 







>







 







|
<







 







>
>

|



|






|





>
|
>
>
>











|







 







>
>









>







 







>
>
>
>







 







>
>
|
>







 







|
>
>







840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
...
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
...
930
931
932
933
934
935
936
937

938
939
940
941
942
943
944
...
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
....
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
....
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
....
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
....
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
    if( memcmp(&pRawProps[got-10], "PROPS-END\n", 10)!=0 ){
      fossil_fatal("svn-dump data ended unexpectedly");
    }
    zLine = pRawProps;
    while( zLine<(pRawProps+nRawProps-10) ){
      char *eol;
      int propLen;
      if( zLine[0]=='D' ){
        propLen = atoi(&zLine[2]);
        eol = strchr(zLine, '\n');
        zLine = eol+1+propLen+1;
      }else{
        if( zLine[0]!='K' ){
          fossil_fatal("svn-dump data format broken");
        }
        propLen = atoi(&zLine[2]);
        eol = strchr(zLine, '\n');
        zLine = eol+1;
        eol = zLine+propLen;
        if( *eol!='\n' ){
          fossil_fatal("svn-dump data format broken");
        }
        *eol = 0;
        rec->nProps += 1;
        rec->aProps = fossil_realloc(rec->aProps,
          sizeof(rec->aProps[0])*rec->nProps);
        rec->aProps[rec->nProps-1].zKey = zLine;
        zLine = eol+1;
        if( zLine[0]!='V' ){
          fossil_fatal("svn-dump data format broken");
        }
        propLen = atoi(&zLine[2]);
        eol = strchr(zLine, '\n');
        zLine = eol+1;
        eol = zLine+propLen;
        if( *eol!='\n' ){
          fossil_fatal("svn-dump data format broken");
        }
        *eol = 0;
        rec->aProps[rec->nProps-1].zVal = zLine;
        zLine = eol+1;
      }
    }
  }
}

static int svn_read_rec(FILE *pIn, SvnRecord *rec){
  const char *zLen;
  int nLen = 0;
................................................................................
  static Stmt qTags;
  int nBaseFilter;
  int nFilter;
  int rid;
  const char *zParentBranch = 0;
  Blob mcksum;

  blob_zero(&manifest);
  nBaseFilter = blob_size(&gsvn.filter);
  if( !gsvn.flatFlag ){
    if( gsvn.zBranch==0 ){ return; }
    if( strncmp(gsvn.zBranch, gsvn.zTrunk, gsvn.lenTrunk-1)==0 ){
      blob_appendf(&gsvn.filter, "%s*", gsvn.zTrunk);
    }else{
      blob_appendf(&gsvn.filter, "%s%s/*", gsvn.zBranches, gsvn.zBranch);
................................................................................
    }
  }else{
    blob_append(&gsvn.filter, "*", 1);
  }
  if( db_int(0, "SELECT 1 FROM xhist WHERE trev=%d AND tpath GLOB %Q LIMIT 1",
             gsvn.rev, blob_str(&gsvn.filter))==0
  ){
    goto skip_revision;

  }
  db_static_prepare(&insRev, "REPLACE INTO xrevisions (trev, tbranch, tuuid) "
                             "VALUES(:rev, :branch, "
                             " (SELECT uuid FROM blob WHERE rid=:rid))");
  db_static_prepare(&qParent, "SELECT tuuid, max(trev) FROM xrevisions "
                              "WHERE trev<=:rev AND tbranch=:branch");
  db_static_prepare(&qParent2, "SELECT tuuid, min(trev) "
................................................................................
      gsvn.parentRev = db_int(-1, "SELECT ifnull(max(trev),-1) FROM xrevisions "
                                  "WHERE tbranch=%Q", gsvn.zBranch);
      if( gsvn.parentRev<0 ){
        gsvn.parentRev =
            db_int(-1, "SELECT ifnull(max(trev),-1) FROM xrevisions");
      }
      gsvn.zParentBranch = gsvn.zBranch;
    }else if( gsvn.zParentBranch==0 ){
      gsvn.zParentBranch = mprintf("trunk");
    }
    /*db_bind_int(&insRev, ":rev", gsvn.rev);
    db_bind_text(&insRev, ":branch", gsvn.zBranch);
    db_bind_int(&insRev, ":rid", 0);
    db_step(&insRev);
    db_reset(&insRev);*/
  }else{
    static int prevRev = -1;
    gsvn.parentRev = prevRev;
    gsvn.zParentBranch = gsvn.zBranch = "";
    prevRev = gsvn.rev;
  }

  if( gsvn.zComment ){
    blob_appendf(&manifest, "C %F\n", gsvn.zComment);
  }else{
    blob_append(&manifest, "C (no\\scomment)\n", 16);
  }
  if( gsvn.zDate ){
    blob_appendf(&manifest, "D %s\n", gsvn.zDate);
  }else{
    goto skip_revision;
  }
  nFilter = blob_size(&gsvn.filter)-1;
  db_bind_text(&qFiles, ":filter", blob_str(&gsvn.filter));
  while( db_step(&qFiles)==SQLITE_ROW ){
    const char *zFile = db_column_text(&qFiles, 0);
    int rid = db_column_int(&qFiles, 1);
    const char *zPerm = db_column_text(&qFiles, 2);
    const char *zUuid;
    zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
    blob_appendf(&manifest, "F %F %s %s\n", zFile+nFilter, zUuid, zPerm);
    fossil_free(zUuid);
  }
  db_reset(&qFiles);
  if( gsvn.parentRev>=0 ){
    const char *zParentUuid;
    db_bind_int(&qParent, ":rev", gsvn.parentRev);
    db_bind_text(&qParent, ":branch", gsvn.zParentBranch);
    db_step(&qParent);
    zParentUuid = db_column_text(&qParent, 0);
    if( zParentUuid==0 ){
................................................................................
        blob_appendf(&manifest, "T *branch * %F\n", gsvn.zBranch);
        blob_appendf(&manifest, "T *sym-%F *\n", gsvn.zBranch);
        zParentBranch = mprintf("%F", gsvn.zParentBranch);
      }else{
        zParentBranch = 0;
      }
    }
    db_reset(&qParent);
    db_reset(&qParent2);
  }else{
    blob_appendf(&manifest, "T *branch * trunk\n");
    blob_appendf(&manifest, "T *sym-trunk *\n");
  }
  db_bind_int(&qTags, ":rev", gsvn.rev);
  while( db_step(&qTags)==SQLITE_ROW ){
    const char *zTag = db_column_text(&qTags, 0);
    blob_appendf(&manifest, "T +sym-%s *\n", zTag);
  }
  db_reset(&qTags);
  blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev);
  if( zParentBranch ) {
    blob_appendf(&manifest, "T -sym-%s *\n", zParentBranch);
    fossil_free(zParentBranch);
  }
  if( gsvn.zUser ){
    blob_appendf(&manifest, "U %F\n", gsvn.zUser);
................................................................................
  blob_reset(&mcksum);

  rid = content_put(&manifest);
  db_bind_int(&insRev, ":rev", gsvn.rev);
  db_bind_text(&insRev, ":branch", gsvn.zBranch);
  db_bind_int(&insRev, ":rid", rid);
  db_step(&insRev);
  db_reset(&insRev);

skip_revision:
  blob_resize(&gsvn.filter, nBaseFilter);
  if( gsvn.zParentBranch == gsvn.zBranch ){
    gsvn.zParentBranch = 0;
  }
  if( gsvn.flatFlag ){
    gsvn.zBranch = 0;
  }
  blob_reset(&manifest);
................................................................................
        fossil_free(gsvn.zBranch);
        fossil_free(gsvn.zParentBranch);
      }
      /* start new revision */
      gsvn.rev = atoi(zTemp);
      gsvn.zUser = mprintf("%s", svn_find_prop(rec, "svn:author"));
      gsvn.zComment = mprintf("%s", svn_find_prop(rec, "svn:log"));
      gsvn.zDate = svn_find_prop(rec, "svn:date");
      if( gsvn.zDate ){
        gsvn.zDate = date_in_standard_format(gsvn.zDate);
      }
      gsvn.parentRev = -1;
      gsvn.zParentBranch = 0;
      gsvn.zBranch = 0;
      bHasFiles = 0;
      fossil_print("\rImporting SVN revision: %d", gsvn.rev);
      db_bind_int(&addHist, ":rev", gsvn.rev);
      db_bind_int(&cpyPath, ":rev", gsvn.rev);
................................................................................
        }else{
          fossil_fatal("Missing copyfrom-rev");
        }
      }
      if( !gsvn.flatFlag ){
        if( (zTemp=svn_extract_branch(zPath))!=0 ){
          if( gsvn.zBranch!=0 ){
            if( strcmp(zTemp, gsvn.zBranch)!=0
             && strncmp(zAction, "delete", 6)!=0)
            {
              fossil_fatal("Commit to multiple branches");
            }
            fossil_free(zTemp);
          }else{
            gsvn.zBranch = zTemp;
          }
        }