Fossil: Check-in [3327886918]

Fossil SCM

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

Overview
Comment:support for deleted files
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | svn-import
Files: files | file ages | folders
SHA1:332788691888bea6a139488b5e89f2861d7a8138
User & Date: baruch 2014-10-21 14:41:21
Context
2014-10-21
15:00
support copying files (no folders support yet) check-in: 0edbf144f3 user: baruch tags: svn-import
14:41
support for deleted files check-in: 3327886918 user: baruch tags: svn-import
12:32
prepare for svn branch importing check-in: bb1d783544 user: baruch tags: svn-import
Changes

Changes to src/import.c.

947
948
949
950
951
952
953

954
955
956
957
958
959
960
...
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
1002
1003
1004
1005
1006
1007

1008
1009
1010



1011
1012
1013
1014
1015
1016
1017
....
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
....
1133
1134
1135
1136
1137
1138
1139
1140

1141
1142
1143
1144
1145
1146
1147
static void svn_dump_import(FILE *pIn){
  SvnRecord rec;
  int ver;
  const char *zTemp;
  const char *zUuid;
  Stmt insRev;
  Stmt insFile;

  int rev = 0;

  /* version */
  if( svn_read_rec(pIn, &rec)
   && (zTemp = svn_find_header(rec, "SVN-fs-dump-format-version")) ){
    ver = atoi(zTemp);
    if( ver!=2 ){
................................................................................
  /* UUID */
  if( !svn_read_rec(pIn, &rec) || !(zUuid = svn_find_header(rec, "UUID")) ){
    fossil_fatal("Missing UUID!");
  }
  svn_free_rec(&rec);
  /* content */
  db_prepare(&insRev,
      "INSERT INTO xrevisions (trev, tuser, tmsg, ttime)"
      "VALUES(:rev, :user, :msg, :time)"
  );
  db_prepare(&insFile,
      "INSERT INTO xfiles (trev, tpath, trid, tperm)"
      "VALUES(:rev, :path, :rid, :perm)"
  );




  while( svn_read_rec(pIn, &rec) ){
    if( zTemp = svn_find_header(rec, "Revision-number") ){
      const char *zUser = svn_find_prop(rec, "svn:author");
      const char *zLog = svn_find_prop(rec, "svn:log");
      const char *zDate = svn_find_prop(rec, "svn:date");
      zDate = date_in_standard_format(zDate);
      rev = atoi(zTemp);
................................................................................
      db_bind_int(&insRev, ":rev", rev);
      db_bind_text(&insRev, ":user", zUser);
      db_bind_text(&insRev, ":msg", zLog);
      db_bind_text(&insRev, ":time", zDate);
      db_step(&insRev);
      db_reset(&insRev);
      fossil_free(zDate);





    }else
    if( zTemp = svn_find_header(rec, "Node-path") ){
      const char *zPath = zTemp;
      const char *zAction = svn_find_header(rec, "Node-action");
      const char *zKind = svn_find_header(rec, "Node-kind");
      const char *zSrcPath = svn_find_header(rec, "Node-copyfrom-path");
      const char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0;
      int srcRev = -1;
      int rid = 0;
      if( zKind && strncmp(zKind, "dir", 3)==0 ){
        svn_free_rec(&rec);
        continue;
      }

      zTemp = svn_find_header(rec, "Node-copyfrom-rev");
      if( zTemp ){
        srcRev = atoi(zTemp);



      }
      rid = content_put(&rec.content);
      if( strncmp(zAction, "add", 3)==0 ){
        db_bind_int(&insFile, ":rev", rev);
        db_bind_int(&insFile, ":rid", rid);
        db_bind_text(&insFile, ":path", zPath);
        db_bind_text(&insFile, ":perm", zPerm);
................................................................................
        db_bind_int(&insFile, ":rid", rid);
        db_bind_text(&insFile, ":path", zPath);
        db_bind_text(&insFile, ":perm", zPerm);
        db_step(&insFile);
        db_reset(&insFile);
      }else
      if( strncmp(zAction, "delete", 6)==0 ){




      }else
      if( strncmp(zAction, "replace", 7)==0 ){
      }else{
      }
    }else{
      fossil_fatal("Unknown record type");
    }
    svn_free_rec(&rec);
  }
  svn_create_manifests();
  db_finalize(&insRev);
  db_finalize(&insFile);

}

/*
** COMMAND: import
**
** Usage: %fossil import FORMAT ?OPTIONS? NEW-REPOSITORY ?INPUT-FILE?
**
................................................................................
  }else
  if( strncmp(g.argv[2], "svn", 3)==0 ){
    db_multi_exec(
       "CREATE TEMP TABLE xrevisions("
       " trev INT, tuser TEXT, tmsg TEXT, ttime DATETIME"
       ");"
       "CREATE TEMP TABLE xfiles("
       " trev INT, tpath TEXT, trid TEXT, tperm TEXT"

       ");"
    );

    svn_dump_import(pIn);
  }

  db_end_transaction(0);







>







 







|



|


>
>
>
>







 







>
>
>
>
>













>
|
|
|
>
>
>







 







>
>
>
>












>







 







|
>







947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
...
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
1002
1003
1004
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
....
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
....
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
static void svn_dump_import(FILE *pIn){
  SvnRecord rec;
  int ver;
  const char *zTemp;
  const char *zUuid;
  Stmt insRev;
  Stmt insFile;
  Stmt delFile;
  int rev = 0;

  /* version */
  if( svn_read_rec(pIn, &rec)
   && (zTemp = svn_find_header(rec, "SVN-fs-dump-format-version")) ){
    ver = atoi(zTemp);
    if( ver!=2 ){
................................................................................
  /* UUID */
  if( !svn_read_rec(pIn, &rec) || !(zUuid = svn_find_header(rec, "UUID")) ){
    fossil_fatal("Missing UUID!");
  }
  svn_free_rec(&rec);
  /* content */
  db_prepare(&insRev,
      "INSERT INTO xrevisions (trev, tuser, tmsg, ttime) "
      "VALUES(:rev, :user, :msg, :time)"
  );
  db_prepare(&insFile,
      "INSERT INTO xfiles (trev, tpath, trid, tperm) "
      "VALUES(:rev, :path, :rid, :perm)"
  );
  db_prepare(&delFile,
      "DELETE FROM xfiles "
      "WHERE trev=:rev AND (tpath=:path OR tpath GLOB :path || '/*')"
  );
  while( svn_read_rec(pIn, &rec) ){
    if( zTemp = svn_find_header(rec, "Revision-number") ){
      const char *zUser = svn_find_prop(rec, "svn:author");
      const char *zLog = svn_find_prop(rec, "svn:log");
      const char *zDate = svn_find_prop(rec, "svn:date");
      zDate = date_in_standard_format(zDate);
      rev = atoi(zTemp);
................................................................................
      db_bind_int(&insRev, ":rev", rev);
      db_bind_text(&insRev, ":user", zUser);
      db_bind_text(&insRev, ":msg", zLog);
      db_bind_text(&insRev, ":time", zDate);
      db_step(&insRev);
      db_reset(&insRev);
      fossil_free(zDate);
      if( rev>0 ){
        db_multi_exec("INSERT INTO xfiles (trev, tpath, trid, tperm) "
                      "SELECT %d, tpath, trid, tperm FROM xfiles "
                      "WHERE trev=%d", rev, rev-1);
      }
    }else
    if( zTemp = svn_find_header(rec, "Node-path") ){
      const char *zPath = zTemp;
      const char *zAction = svn_find_header(rec, "Node-action");
      const char *zKind = svn_find_header(rec, "Node-kind");
      const char *zSrcPath = svn_find_header(rec, "Node-copyfrom-path");
      const char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0;
      int srcRev = -1;
      int rid = 0;
      if( zKind && strncmp(zKind, "dir", 3)==0 ){
        svn_free_rec(&rec);
        continue;
      }
      if( zSrcPath ){
        zTemp = svn_find_header(rec, "Node-copyfrom-rev");
        if( zTemp ){
          srcRev = atoi(zTemp);
        }else{
          fossil_fatal("Missing copyfrom-rev");
        }
      }
      rid = content_put(&rec.content);
      if( strncmp(zAction, "add", 3)==0 ){
        db_bind_int(&insFile, ":rev", rev);
        db_bind_int(&insFile, ":rid", rid);
        db_bind_text(&insFile, ":path", zPath);
        db_bind_text(&insFile, ":perm", zPerm);
................................................................................
        db_bind_int(&insFile, ":rid", rid);
        db_bind_text(&insFile, ":path", zPath);
        db_bind_text(&insFile, ":perm", zPerm);
        db_step(&insFile);
        db_reset(&insFile);
      }else
      if( strncmp(zAction, "delete", 6)==0 ){
        db_bind_int(&delFile, ":rev", rev);
        db_bind_text(&delFile, ":path", zPath);
        db_step(&delFile);
        db_reset(&delFile);
      }else
      if( strncmp(zAction, "replace", 7)==0 ){
      }else{
      }
    }else{
      fossil_fatal("Unknown record type");
    }
    svn_free_rec(&rec);
  }
  svn_create_manifests();
  db_finalize(&insRev);
  db_finalize(&insFile);
  db_finalize(&delFile);
}

/*
** COMMAND: import
**
** Usage: %fossil import FORMAT ?OPTIONS? NEW-REPOSITORY ?INPUT-FILE?
**
................................................................................
  }else
  if( strncmp(g.argv[2], "svn", 3)==0 ){
    db_multi_exec(
       "CREATE TEMP TABLE xrevisions("
       " trev INT, tuser TEXT, tmsg TEXT, ttime DATETIME"
       ");"
       "CREATE TEMP TABLE xfiles("
       " trev INT, tpath TEXT, trid TEXT, tperm TEXT,"
       " UNIQUE (trev, tpath) ON CONFLICT REPLACE"
       ");"
    );

    svn_dump_import(pIn);
  }

  db_end_transaction(0);