Fossil

Check-in [bb020aed]
Login

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

Overview
Comment:Much better detection of changes to tags. Prevent commit with no changes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | svn-import
Files: files | file ages | folders
SHA1:bb020aed6259245580adad127978a71ca1772cf9
User & Date: baruch 2015-01-18 14:10:42
Context
2015-01-18
20:35
Fix handling paths when branching to/from a subdir check-in: 261ff58e user: baruch tags: svn-import
14:10
Much better detection of changes to tags. Prevent commit with no changes. check-in: bb020aed user: baruch tags: svn-import
2015-01-15
16:17
Fix for new branch detection and handling check-in: 7673518b user: baruch tags: svn-import
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/import.c.

933
934
935
936
937
938
939
940













941



942
943
944
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
...
980
981
982
983
984
985
986
987
988

989
990
991
992
993
994
995
996
997
998
999
1000
1001

1002
1003
1004
1005
1006










1007

1008
1009
1010
1011
1012
1013
1014
....
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
....
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
....
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
....
1482
1483
1484
1485
1486
1487
1488
1489
1490

1491
1492
1493
1494
1495
1496
1497
                             " WHERE trev=%d AND tbranch=:branch", gsvn.rev);
  while( db_step(&getChanges)==SQLITE_ROW ){
    int branchId = db_column_int(&getChanges, 0);
    const char *zBranch = db_column_text(&getChanges, 1);
    int branchType = db_column_int(&getChanges, 2);
    int parentRid = db_column_int(&getChanges, 3);
    int mergeRid = parentRid;
    int rid;













    if( branchType!=SVN_TAG ){



      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);
      db_bind_int(&getFiles, ":branch", branchId);
      while( db_step(&getFiles)==SQLITE_ROW ){
        const char *zFile = db_column_text(&getFiles, 0);
        const char *zUuid = db_column_text(&getFiles, 1);
        const char *zPerm = db_column_text(&getFiles, 2);
        blob_appendf(&manifest, "F %F %s %s\n", zFile, zUuid, zPerm);









      }
      db_reset(&getFiles);
      if( !bag_find(&gsvn.newBranches, branchId) ){
        parentRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions"
                              " WHERE trev<%d AND tbranch=%d",
                           gsvn.rev, branchId);
      }






      if( parentRid>0 ){
        char *zParentUuid = rid_to_uuid(parentRid);
        if( parentRid==mergeRid || mergeRid==0){
          char *zParentBranch =
            db_text(0, "SELECT tname FROM xbranches WHERE tid="
                       " (SELECT tbranch FROM xrevisions WHERE trid=%d)",
                    parentRid
            );
          blob_appendf(&manifest, "P %s\n", zParentUuid);
          blob_appendf(&manifest, "T *branch * %F\n", zBranch);
          blob_appendf(&manifest, "T *sym-%F *\n", zBranch);
          blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev);
          blob_appendf(&manifest, "T -sym-%F *\n", zParentBranch);
          fossil_free(zParentBranch);
................................................................................
        }
        fossil_free(zParentUuid);
      }else{
        blob_appendf(&manifest, "T *branch * %F\n", zBranch);
        blob_appendf(&manifest, "T *sym-%F *\n", zBranch);
        blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev);
      }
    }else{
      char *zParentUuid = rid_to_uuid(parentRid);

      blob_appendf(&manifest, "D %s\n", gsvn.zDate);
      blob_appendf(&manifest, "T +sym-%F %s\n", zBranch, zParentUuid);
      fossil_free(zParentUuid);
    }
    if( gsvn.zUser ){
      blob_appendf(&manifest, "U %F\n", gsvn.zUser);
    }else{
      const char *zUserOvrd = find_option("user-override",0,1);
      blob_appendf(&manifest, "U %F\n", zUserOvrd ? zUserOvrd : login_name());
    }
    md5sum_blob(&manifest, &mcksum);
    blob_appendf(&manifest, "Z %b\n", &mcksum);
    blob_reset(&mcksum);

    rid = content_put(&manifest);
    db_bind_int(&setRid, ":branch", branchId);
    db_bind_int(&setRid, ":rid", rid);
    db_step(&setRid);
    db_reset(&setRid);










    blob_reset(&manifest);

  }
  db_reset(&getChanges);
  db_finalize(&setRid);
}

static u64 svn_get_varint(const char **pz){
  unsigned int v = 0;
................................................................................
    }else
    if( (zTemp = svn_find_header(rec, "Node-path")) ){ /* file/dir node */
      char *zFile;
      int branchType;
      int branchId = svn_parse_path(zTemp, &zFile, &branchType);
      char *zAction = svn_find_header(rec, "Node-action");
      char *zKind = svn_find_header(rec, "Node-kind");
      char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0;
      int deltaFlag = 0;
      int srcRev = 0;
      if( branchId==0 ){
        svn_free_rec(&rec);
        continue;
      }
      if( (zTemp = svn_find_header(rec, "Text-delta")) ){
................................................................................
          }else{
            fossil_fatal("Missing copyfrom-rev");
          }
          srcBranch = svn_parse_path(zSrcPath, &zSrcFile, &branchType);
          if( srcBranch==0 ){
            fossil_fatal("Copy from path outside the import paths");
          }
          if( branchType!=SVN_TAG ){
            srcRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions"
                               " WHERE trev<=%d AND tbranch=%d",
                            srcRev, srcBranch);
          }else{
            srcRid = db_int(0, "SELECT tparent, max(trev) FROM xrevisions"
                               " WHERE trev<=%d AND tbranch=%d",
                            srcRev, srcBranch);
          }
          if( srcRid>0 && srcBranch!=branchId ){
            db_bind_int(&addRev, ":branch", branchId);
            db_step(&addRev);
            db_reset(&addRev);
            db_bind_int(&revSrc, ":parent", srcRid);
            db_bind_int(&revSrc, ":rev", gsvn.rev);
            db_bind_int(&revSrc, ":branch", branchId);
................................................................................
            db_step(&revSrc);
            db_reset(&revSrc);
          }
        }
        if( zKind==0 ){
          fossil_fatal("Missing Node-kind");
        }else if( strncmp(zKind, "dir", 3)==0 ){
          if( zSrcPath && branchType!=SVN_TAG ){
            if( srcRid>0 ){
              if( zSrcFile[0]==0 ){
                db_bind_text(&cpyRoot, ":path", zFile);
                db_bind_int(&cpyRoot, ":branch", branchId);
                db_bind_int(&cpyRoot, ":rid", srcRid);
                db_step(&cpyRoot);
                db_reset(&cpyRoot);
................................................................................
    }
    db_finalize(&q);
  }else
  if( strncmp(g.argv[2], "svn", 3)==0 ){
    db_multi_exec(
       "CREATE TEMP TABLE xrevisions("
       " trev INTEGER, tbranch INT, trid INT, tparent INT DEFAULT 0,"
       " UNIQUE(tbranch, trev), UNIQUE(trid)"
       ");"

       "CREATE TEMP TABLE xfiles("
       " tpath TEXT, tbranch INT, tuuid TEXT, tperm TEXT,"
       " UNIQUE (tbranch, tpath) ON CONFLICT REPLACE"
       ");"
       "CREATE TEMP TABLE xbranches("
       " tid INTEGER PRIMARY KEY, tname TEXT, ttype INT,"
       " UNIQUE(tname, ttype)"







|
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
|
<
<
<
<
<

>
>
>
>
>
>




|
<
|







 







|

>













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

>







 







|







 







<
|
|
|
<
<
<
<
<







 







|







 







|

>







933
934
935
936
937
938
939
940
941
942
943
944
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
990
991

992
993
994
995
996
997
998
999
....
1005
1006
1007
1008
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
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
....
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
....
1286
1287
1288
1289
1290
1291
1292

1293
1294
1295





1296
1297
1298
1299
1300
1301
1302
....
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
....
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
                             " WHERE trev=%d AND tbranch=:branch", gsvn.rev);
  while( db_step(&getChanges)==SQLITE_ROW ){
    int branchId = db_column_int(&getChanges, 0);
    const char *zBranch = db_column_text(&getChanges, 1);
    int branchType = db_column_int(&getChanges, 2);
    int parentRid = db_column_int(&getChanges, 3);
    int mergeRid = parentRid;
    Manifest *pParentManifest = 0;
    ManifestFile *pParentFile = 0;
    int sameAsParent = 1;
    int parentBranch = 0;
    if( !bag_find(&gsvn.newBranches, branchId) ){
      parentRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions"
                            " WHERE trev<%d AND tbranch=%d",
                         gsvn.rev, branchId);
    }
    if( parentRid>0 ){
      pParentManifest = manifest_get(parentRid, CFTYPE_MANIFEST, 0);
      pParentFile = manifest_file_next(pParentManifest, 0);
      parentBranch = db_int(0, "SELECT tbranch FROM xrevisions WHERE trid=%d",
                            parentRid);
      if( parentBranch!=branchId && branchType!=SVN_TAG ){
        sameAsParent = 0;
      }
    }
    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);
    db_bind_int(&getFiles, ":branch", branchId);
    while( db_step(&getFiles)==SQLITE_ROW ){
      const char *zFile = db_column_text(&getFiles, 0);
      const char *zUuid = db_column_text(&getFiles, 1);
      const char *zPerm = db_column_text(&getFiles, 2);
      blob_appendf(&manifest, "F %F %s%s\n", zFile, zUuid, zPerm);
      if( sameAsParent ){
        if( !pParentFile
         || fossil_strcmp(pParentFile->zName,zFile)!=0
         || fossil_strcmp(pParentFile->zUuid,zUuid)!=0
         || fossil_strcmp(pParentFile->zPerm,zPerm)!=0
        ){
          sameAsParent = 0;
        }else{
          pParentFile = manifest_file_next(pParentManifest, 0);
        }





      }
    }
    if( pParentFile ){
      sameAsParent = 0;
    }
    db_reset(&getFiles);
    if( !sameAsParent ){
      if( parentRid>0 ){
        char *zParentUuid = rid_to_uuid(parentRid);
        if( parentRid==mergeRid || mergeRid==0){
          char *zParentBranch =
            db_text(0, "SELECT tname FROM xbranches WHERE tid=%d",

                    parentBranch
            );
          blob_appendf(&manifest, "P %s\n", zParentUuid);
          blob_appendf(&manifest, "T *branch * %F\n", zBranch);
          blob_appendf(&manifest, "T *sym-%F *\n", zBranch);
          blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev);
          blob_appendf(&manifest, "T -sym-%F *\n", zParentBranch);
          fossil_free(zParentBranch);
................................................................................
        }
        fossil_free(zParentUuid);
      }else{
        blob_appendf(&manifest, "T *branch * %F\n", zBranch);
        blob_appendf(&manifest, "T *sym-%F *\n", zBranch);
        blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev);
      }
    }else if( branchType==SVN_TAG ){
      char *zParentUuid = rid_to_uuid(parentRid);
      blob_reset(&manifest);
      blob_appendf(&manifest, "D %s\n", gsvn.zDate);
      blob_appendf(&manifest, "T +sym-%F %s\n", zBranch, zParentUuid);
      fossil_free(zParentUuid);
    }
    if( gsvn.zUser ){
      blob_appendf(&manifest, "U %F\n", gsvn.zUser);
    }else{
      const char *zUserOvrd = find_option("user-override",0,1);
      blob_appendf(&manifest, "U %F\n", zUserOvrd ? zUserOvrd : login_name());
    }
    md5sum_blob(&manifest, &mcksum);
    blob_appendf(&manifest, "Z %b\n", &mcksum);
    blob_reset(&mcksum);
    if( !sameAsParent ){
      int rid = content_put(&manifest);
      db_bind_int(&setRid, ":branch", branchId);
      db_bind_int(&setRid, ":rid", rid);
      db_step(&setRid);
      db_reset(&setRid);
    }else if( branchType==SVN_TAG ){
      content_put(&manifest);
      db_bind_int(&setRid, ":branch", branchId);
      db_bind_int(&setRid, ":rid", parentRid);
      db_step(&setRid);
      db_reset(&setRid);
    }else{
      db_multi_exec("DELETE FROM xrevisions WHERE tbranch=%d AND trev=%d",
                    branchId, gsvn.rev);
    }
    blob_reset(&manifest);
    manifest_destroy(pParentManifest);
  }
  db_reset(&getChanges);
  db_finalize(&setRid);
}

static u64 svn_get_varint(const char **pz){
  unsigned int v = 0;
................................................................................
    }else
    if( (zTemp = svn_find_header(rec, "Node-path")) ){ /* file/dir node */
      char *zFile;
      int branchType;
      int branchId = svn_parse_path(zTemp, &zFile, &branchType);
      char *zAction = svn_find_header(rec, "Node-action");
      char *zKind = svn_find_header(rec, "Node-kind");
      char *zPerm = svn_find_prop(rec, "svn:executable") ? " x" : 0;
      int deltaFlag = 0;
      int srcRev = 0;
      if( branchId==0 ){
        svn_free_rec(&rec);
        continue;
      }
      if( (zTemp = svn_find_header(rec, "Text-delta")) ){
................................................................................
          }else{
            fossil_fatal("Missing copyfrom-rev");
          }
          srcBranch = svn_parse_path(zSrcPath, &zSrcFile, &branchType);
          if( srcBranch==0 ){
            fossil_fatal("Copy from path outside the import paths");
          }

          srcRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions"
                             " WHERE trev<=%d AND tbranch=%d",
                          srcRev, srcBranch);





          if( srcRid>0 && srcBranch!=branchId ){
            db_bind_int(&addRev, ":branch", branchId);
            db_step(&addRev);
            db_reset(&addRev);
            db_bind_int(&revSrc, ":parent", srcRid);
            db_bind_int(&revSrc, ":rev", gsvn.rev);
            db_bind_int(&revSrc, ":branch", branchId);
................................................................................
            db_step(&revSrc);
            db_reset(&revSrc);
          }
        }
        if( zKind==0 ){
          fossil_fatal("Missing Node-kind");
        }else if( strncmp(zKind, "dir", 3)==0 ){
          if( zSrcPath ){
            if( srcRid>0 ){
              if( zSrcFile[0]==0 ){
                db_bind_text(&cpyRoot, ":path", zFile);
                db_bind_int(&cpyRoot, ":branch", branchId);
                db_bind_int(&cpyRoot, ":rid", srcRid);
                db_step(&cpyRoot);
                db_reset(&cpyRoot);
................................................................................
    }
    db_finalize(&q);
  }else
  if( strncmp(g.argv[2], "svn", 3)==0 ){
    db_multi_exec(
       "CREATE TEMP TABLE xrevisions("
       " trev INTEGER, tbranch INT, trid INT, tparent INT DEFAULT 0,"
       " UNIQUE(tbranch, trev)"
       ");"
       "CREATE INDEX temp.i_xrevisions ON xrevisions(trid);"
       "CREATE TEMP TABLE xfiles("
       " tpath TEXT, tbranch INT, tuuid TEXT, tperm TEXT,"
       " UNIQUE (tbranch, tpath) ON CONFLICT REPLACE"
       ");"
       "CREATE TEMP TABLE xbranches("
       " tid INTEGER PRIMARY KEY, tname TEXT, ttype INT,"
       " UNIQUE(tname, ttype)"