Fossil

Check-in [f67cb93f]
Login

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

Overview
Comment:Options to set trunk/branches/tags folder names and project repository root (filter). Various fixes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | svn-import
Files: files | file ages | folders
SHA1:f67cb93fa6612082c6bb4a901d38500bf2df7b8a
User & Date: baruch 2014-11-02 13:59:23
Context
2014-11-03
14:50
Fix bug when deleting whole folder check-in: 05537c6f user: baruch tags: svn-import
2014-11-02
13:59
Options to set trunk/branches/tags folder names and project repository root (filter). Various fixes check-in: f67cb93f user: baruch tags: svn-import
2014-11-01
21:44
revert mistake from last commit check-in: 59cc1242 user: baruch tags: svn-import
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/import.c.

723
724
725
726
727
728
729







730
731
732
733
734
735
736
...
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
...
932
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
....
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
....
1061
1062
1063
1064
1065
1066
1067

1068
1069
1070
1071
1072
1073
1074
....
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117

1118
1119
1120
1121
1122
1123
1124
....
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146






1147
1148
1149


1150
1151
1152



1153
1154
1155
1156
1157
1158





1159
1160
1161
1162
1163
1164
1165
....
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
....
1276
1277
1278
1279
1280
1281
1282
1283



1284




1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299

1300
1301



1302
1303
1304
1305
1306
1307
1308
....
1376
1377
1378
1379
1380
1381
1382





















1383
1384
1385
1386
1387
1388
1389
  int rev;                    /* SVN revision number */
  int parent;                 /* SVN revision number of parent check-in */
  char *zBranch;              /* Name of a branch for a commit */
  char *zDate;                /* Date/time stamp */
  char *zUser;                /* User name */
  char *zComment;             /* Comment of a commit */
  int flatFlag;               /* True if whole repo is a single file tree */







} gsvn;
typedef struct {
  const char *zKey;
  const char *zVal;
} KeyVal;
typedef struct {
  KeyVal *aHeaders;
................................................................................
static void svn_create_manifest(
){
  Blob manifest;
  static Stmt insRev;
  static Stmt qParent;
  static Stmt qFiles;
  static Stmt qTags;
  char zFilter[200];
  int nFilter;
  int rid;
  const char *zParentBranch = 0;
  Blob mcksum;

  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, tbranch FROM xrevisions "
                              "WHERE trev=:rev");
  db_static_prepare(&qFiles, "SELECT tpath, trid, tperm FROM xfiles "
                             "WHERE tpath GLOB :filter ORDER BY tpath");
  db_static_prepare(&qTags, "SELECT ttag FROM xtags WHERE trev=:rev");
  if( db_int(0, "SELECT 1 FROM xfiles LIMIT 1")==0 ){ return; }
  if( !gsvn.flatFlag ){
    if( gsvn.zBranch==0 || gsvn.zBranch[0]=='\0' ){ return; }
    if( gsvn.parent<0 ){
      gsvn.parent = db_int(-1, "SELECT ifnull(max(trev),-1) FROM xrevisions "
                               "WHERE tbranch=%Q", gsvn.zBranch);
    }
    db_bind_int(&insRev, ":rev", gsvn.rev);
    db_bind_text(&insRev, ":branch", gsvn.zBranch);
    db_bind_int(&insRev, ":rid", 0);
................................................................................
  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);

  if( strncmp(gsvn.zBranch, "trunk", 5)==0 ){
    memcpy(zFilter, "trunk/*", 8);
    nFilter = 6;
  }else{
    sqlite3_snprintf(sizeof(zFilter), zFilter, "branches/%s/*", gsvn.zBranch);
    nFilter = strlen(zFilter)-1;
  }
  db_bind_text(&qFiles, ":filter", zFilter);

  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);
  }

  if( gsvn.parent>=0 ){
    const char *zParentUuid;
    db_bind_int(&qParent, ":rev", gsvn.parent);
    db_step(&qParent);
    zParentUuid = db_column_text(&qParent, 0);
    blob_appendf(&manifest, "P %s\n", zParentUuid);
    if( !gsvn.flatFlag ){
................................................................................
  if( blob_size(pDiff)<4 || memcmp(zDiff, "SVN", 4)!=0 ){
    fossil_fatal("Invalid svndiff0 format");
  }
  zDiff += 4;
  blob_zero(pOut);
  while( zDiff<(blob_buffer(pDiff)+blob_size(pDiff)) ){
    u64 offSrc = svn_get_varint(&zDiff);
    u64 lenSrc = svn_get_varint(&zDiff);
    u64 lenOut = svn_get_varint(&zDiff);
    u64 lenInst = svn_get_varint(&zDiff);
    u64 lenData = svn_get_varint(&zDiff);
    const char *zInst = zDiff;
    const char *zData = zInst+lenInst;
    u64 lenOld = blob_size(pOut);
    blob_resize(pOut, lenOut+lenOld);
................................................................................
  SvnRecord rec;
  int ver;
  const char *zTemp;
  const char *zUuid;
  Stmt addHist;
  Stmt insTag;
  Stmt cpyPath;


  /* version */
  if( svn_read_rec(pIn, &rec)
   && (zTemp = svn_find_header(rec, "SVN-fs-dump-format-version")) ){
    ver = atoi(zTemp);
    if( ver!=2 && ver!=3 ){
      fossil_fatal("Unknown svn-dump format version: %d", ver);
................................................................................
    " SELECT :rev, :path||substr(tpath, length(:srcpath)+1), trid, tperm"
    " FROM xsrc WHERE tpath>:srcpath||'/' AND tpath<:srcpath||0"
  );
  gsvn.rev = -1;
  while( svn_read_rec(pIn, &rec) ){
    if( (zTemp = svn_find_header(rec, "Revision-number")) ){ /* revision node */
      /* finish previous revision */
      if( gsvn.rev>=0 ){
        svn_create_manifest();
        fossil_free(gsvn.zUser);
        fossil_free(gsvn.zComment);
        fossil_free(gsvn.zDate);
        fossil_free(gsvn.zBranch);
      }
      /* 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.parent = -1;
      gsvn.zBranch = 0;

      fossil_print("\rImporting SVN revision: %d", gsvn.rev);
      db_bind_int(&addHist, ":rev", gsvn.rev);
      db_bind_int(&cpyPath, ":rev", gsvn.rev);
    }else
    if( (zTemp = svn_find_header(rec, "Node-path")) ){ /* file/dir node */
      const char *zPath = zTemp;
      const char *zAction = svn_find_header(rec, "Node-action");
................................................................................
        if( zTemp ){
          srcRev = atoi(zTemp);
        }else{
          fossil_fatal("Missing copyfrom-rev");
        }
      }
      if( !gsvn.flatFlag ){
        if( strncmp(zPath, "branches/", 9)==0 ){
          int nBranch;
          zTemp = zPath+9;
          while( *zTemp && *zTemp!='/' ){ zTemp++; }
          nBranch = zTemp-zPath+9;






          gsvn.zBranch = fossil_malloc(nBranch+1);
          memcpy(gsvn.zBranch, zPath+9, nBranch);
          gsvn.zBranch[nBranch] = '\0';


        }else
        if( strncmp(zPath, "trunk/", 6)==0 ){
          gsvn.zBranch = mprintf("trunk");



        }else
        if( strncmp(zPath, "tags/", 5)!=0
         && strcmp(zPath, "branches")!=0
         && strcmp(zPath, "trunk")!=0
         && strcmp(zPath, "tags")!=0){
          fossil_fatal("Write outside repository layout: %s", zPath);





        }
      }
      if( strncmp(zAction, "delete", 6)==0
       || strncmp(zAction, "replace", 7)==0 )
      {
        db_bind_null(&addHist, ":rid");
        db_bind_text(&addHist, ":path", zPath);
................................................................................
          if( zSrcPath ){
            db_bind_int(&cpyPath, ":srcrev", srcRev);
            db_bind_text(&cpyPath, ":path", zPath);
            db_bind_text(&cpyPath, ":srcpath", zSrcPath);
            db_step(&cpyPath);
            db_reset(&cpyPath);
            if( !gsvn.flatFlag ){
              if( strncmp(zPath, "branches/", 9)==0 ){
                zTemp = zPath+9+strlen(gsvn.zBranch);
                if( *zTemp==0 ){
                  gsvn.parent = srcRev;
                }
              }else if( strncmp(zPath, "tags/", 5)==0 ){
                zTemp = zPath+5;
                db_bind_int(&insTag, ":rev", srcRev);
                db_bind_text(&insTag, ":tag", zTemp);
                db_step(&insTag);
                db_reset(&insTag);
              }
            }
          }
................................................................................
** argument.  If no input file is supplied the interchange format
** data is read from standard input.
**
** The following formats are currently understood by this command
**
**   git          Import from the git-fast-export file format
**
**   svn          Import from the svnadmin-dump file format



**                Options:




**                  --flat  The whole dump is a single branch. The default
**                          is to use the trunk/branches/tags svn layout
**
** The --incremental option allows an existing repository to be extended
** with new content.
**
** Options:
**   --incremental  allow importing into an existing repository
**
** See also: export
*/
void import_cmd(void){
  char *zPassword;
  FILE *pIn;
  Stmt q;

  int forceFlag = find_option("force", "f", 0)!=0;
  int incrFlag = find_option("incremental", "i", 0)!=0;



  gsvn.flatFlag = find_option("flat", 0, 0)!=0;

  verify_all_options();
  if( g.argc!=4  && g.argc!=5 ){
    usage("FORMAT REPOSITORY-NAME");
  }
  if( g.argc==5 ){
................................................................................
       "CREATE TEMP TRIGGER xfilesaddtrig AFTER INSERT ON xhist FOR EACH ROW"
       " WHEN new.trid NOTNULL BEGIN INSERT INTO xfiles(tpath,trid,tperm)"
       " VALUES(new.tpath, new.trid, new.tperm); END;"
       "CREATE TEMP TABLE xtags("
       " trev INT, ttag TEXT"
       ");"
    );





















    svn_dump_import(pIn);
  }

  verify_cancel();
  db_end_transaction(0);
  db_begin_transaction();
  fossil_print("Rebuilding repository meta-data...\n");







>
>
>
>
>
>
>







 







|













<

<







 







>
|
<
|

|
<

|
>









>







 







|







 







>







 







|













>







 







|
|
|

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

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







 







|
|



|
|







 







|
>
>
>

>
>
>
>
|
<













>


>
>
>







 







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







723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
...
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921

922

923
924
925
926
927
928
929
...
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
....
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
....
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
....
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
....
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172





1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
....
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
....
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311

1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
....
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
  int rev;                    /* SVN revision number */
  int parent;                 /* SVN revision number of parent check-in */
  char *zBranch;              /* Name of a branch for a commit */
  char *zDate;                /* Date/time stamp */
  char *zUser;                /* User name */
  char *zComment;             /* Comment of a commit */
  int flatFlag;               /* True if whole repo is a single file tree */
  const char *zTrunk;         /* Name of trunk folder in repo root */
  int lenTrunk;               /* String length of zTrunk */
  const char *zBranches;      /* Name of branches folder in repo root */
  int lenBranches;            /* String length of zBranches */
  const char *zTags;          /* Name of tags folder in repo root */
  int lenTags;                /* String length of zTags */
  Blob filter;                /* Path to repo root */
} gsvn;
typedef struct {
  const char *zKey;
  const char *zVal;
} KeyVal;
typedef struct {
  KeyVal *aHeaders;
................................................................................
static void svn_create_manifest(
){
  Blob manifest;
  static Stmt insRev;
  static Stmt qParent;
  static Stmt qFiles;
  static Stmt qTags;
  int nBaseFilter;
  int nFilter;
  int rid;
  const char *zParentBranch = 0;
  Blob mcksum;

  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, tbranch FROM xrevisions "
                              "WHERE trev=:rev");
  db_static_prepare(&qFiles, "SELECT tpath, trid, tperm FROM xfiles "
                             "WHERE tpath GLOB :filter ORDER BY tpath");
  db_static_prepare(&qTags, "SELECT ttag FROM xtags WHERE trev=:rev");

  if( !gsvn.flatFlag ){

    if( gsvn.parent<0 ){
      gsvn.parent = db_int(-1, "SELECT ifnull(max(trev),-1) FROM xrevisions "
                               "WHERE tbranch=%Q", gsvn.zBranch);
    }
    db_bind_int(&insRev, ":rev", gsvn.rev);
    db_bind_text(&insRev, ":branch", gsvn.zBranch);
    db_bind_int(&insRev, ":rid", 0);
................................................................................
  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);
  nBaseFilter = blob_size(&gsvn.filter);
  if( strcmp(gsvn.zBranch, gsvn.zTrunk)==0 ){

    blob_appendf(&gsvn.filter, "%s*", gsvn.zTrunk);
  }else{
    blob_appendf(&gsvn.filter, "%s%s/*", gsvn.zBranches, gsvn.zBranch);

  }
  db_bind_text(&qFiles, ":filter", blob_str(&gsvn.filter));
  nFilter = blob_size(&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.parent>=0 ){
    const char *zParentUuid;
    db_bind_int(&qParent, ":rev", gsvn.parent);
    db_step(&qParent);
    zParentUuid = db_column_text(&qParent, 0);
    blob_appendf(&manifest, "P %s\n", zParentUuid);
    if( !gsvn.flatFlag ){
................................................................................
  if( blob_size(pDiff)<4 || memcmp(zDiff, "SVN", 4)!=0 ){
    fossil_fatal("Invalid svndiff0 format");
  }
  zDiff += 4;
  blob_zero(pOut);
  while( zDiff<(blob_buffer(pDiff)+blob_size(pDiff)) ){
    u64 offSrc = svn_get_varint(&zDiff);
    /*u64 lenSrc =*/ svn_get_varint(&zDiff);
    u64 lenOut = svn_get_varint(&zDiff);
    u64 lenInst = svn_get_varint(&zDiff);
    u64 lenData = svn_get_varint(&zDiff);
    const char *zInst = zDiff;
    const char *zData = zInst+lenInst;
    u64 lenOld = blob_size(pOut);
    blob_resize(pOut, lenOut+lenOld);
................................................................................
  SvnRecord rec;
  int ver;
  const char *zTemp;
  const char *zUuid;
  Stmt addHist;
  Stmt insTag;
  Stmt cpyPath;
  int bHasFiles;

  /* version */
  if( svn_read_rec(pIn, &rec)
   && (zTemp = svn_find_header(rec, "SVN-fs-dump-format-version")) ){
    ver = atoi(zTemp);
    if( ver!=2 && ver!=3 ){
      fossil_fatal("Unknown svn-dump format version: %d", ver);
................................................................................
    " SELECT :rev, :path||substr(tpath, length(:srcpath)+1), trid, tperm"
    " FROM xsrc WHERE tpath>:srcpath||'/' AND tpath<:srcpath||0"
  );
  gsvn.rev = -1;
  while( svn_read_rec(pIn, &rec) ){
    if( (zTemp = svn_find_header(rec, "Revision-number")) ){ /* revision node */
      /* finish previous revision */
      if( bHasFiles ){
        svn_create_manifest();
        fossil_free(gsvn.zUser);
        fossil_free(gsvn.zComment);
        fossil_free(gsvn.zDate);
        fossil_free(gsvn.zBranch);
      }
      /* 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.parent = -1;
      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
    if( (zTemp = svn_find_header(rec, "Node-path")) ){ /* file/dir node */
      const char *zPath = zTemp;
      const char *zAction = svn_find_header(rec, "Node-action");
................................................................................
        if( zTemp ){
          srcRev = atoi(zTemp);
        }else{
          fossil_fatal("Missing copyfrom-rev");
        }
      }
      if( !gsvn.flatFlag ){
        if( strncmp(zPath, gsvn.zBranches, gsvn.lenBranches)==0 ){
          int lenBranch;
          zTemp = zPath+gsvn.lenBranches;
          while( *zTemp && *zTemp!='/' ){ zTemp++; }
          lenBranch = zTemp-zPath-gsvn.lenBranches;
          zTemp = zPath+gsvn.lenBranches;
          if( gsvn.zBranch!=0 ){
            if( strncmp(zTemp, gsvn.zBranch, lenBranch)!=0 ){
              fossil_fatal("Commit to multiple branches");
            }
          }else{
            gsvn.zBranch = fossil_malloc(lenBranch+1);
            memcpy(gsvn.zBranch, zTemp, lenBranch);
            gsvn.zBranch[lenBranch] = '\0';
            bHasFiles = 1;
          }
        }else
        if( strncmp(zPath, gsvn.zTrunk, gsvn.lenTrunk)==0 ){
          if( gsvn.zBranch!=0 ){
            if( strncmp(gsvn.zTrunk, gsvn.zBranch, gsvn.lenTrunk-1)!=0 ){
              fossil_fatal("Commit to multiple branches");
            }
          }else{





            gsvn.zBranch = fossil_malloc(gsvn.lenTrunk);
            memcpy(gsvn.zBranch, gsvn.zTrunk, gsvn.lenTrunk-1);
            gsvn.zBranch[gsvn.lenTrunk-1] = '\0';
            bHasFiles = 1;
          }
        }
      }
      if( strncmp(zAction, "delete", 6)==0
       || strncmp(zAction, "replace", 7)==0 )
      {
        db_bind_null(&addHist, ":rid");
        db_bind_text(&addHist, ":path", zPath);
................................................................................
          if( zSrcPath ){
            db_bind_int(&cpyPath, ":srcrev", srcRev);
            db_bind_text(&cpyPath, ":path", zPath);
            db_bind_text(&cpyPath, ":srcpath", zSrcPath);
            db_step(&cpyPath);
            db_reset(&cpyPath);
            if( !gsvn.flatFlag ){
              if( strncmp(zPath, gsvn.zBranches, gsvn.lenBranches)==0 ){
                zTemp = zPath+gsvn.lenBranches+strlen(gsvn.zBranch);
                if( *zTemp==0 ){
                  gsvn.parent = srcRev;
                }
              }else if( strncmp(zPath, gsvn.zTags, gsvn.lenTags)==0 ){
                zTemp = zPath+gsvn.lenTags;
                db_bind_int(&insTag, ":rev", srcRev);
                db_bind_text(&insTag, ":tag", zTemp);
                db_step(&insTag);
                db_reset(&insTag);
              }
            }
          }
................................................................................
** argument.  If no input file is supplied the interchange format
** data is read from standard input.
**
** The following formats are currently understood by this command
**
**   git          Import from the git-fast-export file format
**
**   svn          Import from the svnadmin-dump file format. The default
**                behaviour is to treat 3 folders in the SVN root as special,
**                following the common layout of SVN repositories. These are
**                (by default) trunk/, branches/ and tags/
**                Options:
**                  --trunk FOLDER     Name of trunk folder
**                  --branches FOLDER  Name of branches folder
**                  --tags FOLDER      Name of tags folder
**                  --fiter PATH       Path to project root in repository
**                  --flat             The whole dump is a single branch

**
** The --incremental option allows an existing repository to be extended
** with new content.
**
** Options:
**   --incremental  allow importing into an existing repository
**
** See also: export
*/
void import_cmd(void){
  char *zPassword;
  FILE *pIn;
  Stmt q;
  const char *zFilter = find_option("filter", 0, 1);
  int forceFlag = find_option("force", "f", 0)!=0;
  int incrFlag = find_option("incremental", "i", 0)!=0;
  gsvn.zTrunk = find_option("trunk", 0, 1);
  gsvn.zBranches = find_option("branches", 0, 1);
  gsvn.zTags = find_option("tags", 0, 1);
  gsvn.flatFlag = find_option("flat", 0, 0)!=0;

  verify_all_options();
  if( g.argc!=4  && g.argc!=5 ){
    usage("FORMAT REPOSITORY-NAME");
  }
  if( g.argc==5 ){
................................................................................
       "CREATE TEMP TRIGGER xfilesaddtrig AFTER INSERT ON xhist FOR EACH ROW"
       " WHEN new.trid NOTNULL BEGIN INSERT INTO xfiles(tpath,trid,tperm)"
       " VALUES(new.tpath, new.trid, new.tperm); END;"
       "CREATE TEMP TABLE xtags("
       " trev INT, ttag TEXT"
       ");"
    );
    if( gsvn.zTrunk==0 ){ gsvn.zTrunk = "trunk/"; }
    if( gsvn.zBranches==0 ){ gsvn.zBranches = "branches/"; }
    if( gsvn.zTags==0 ){ gsvn.zTags = "tags/"; }
    gsvn.lenTrunk = strlen(gsvn.zTrunk);
    gsvn.lenBranches = strlen(gsvn.zBranches);
    gsvn.lenTags = strlen(gsvn.zTags);
    if( gsvn.zTrunk[gsvn.lenTrunk-1]!='/' ){
      gsvn.zTrunk = mprintf("%s/", gsvn.zTrunk);
      gsvn.lenTrunk++;
    }
    if( gsvn.zBranches[gsvn.lenBranches-1]!='/' ){
      gsvn.zBranches = mprintf("%s/", gsvn.zBranches);
      gsvn.lenBranches++;
    }
    if( gsvn.zTags[gsvn.lenTags-1]!='/' ){
      gsvn.zTags = mprintf("%s/", gsvn.zTags);
      gsvn.lenTags++;
    }
    if( zFilter==0 ){ zFilter = ""; }
    blob_zero(&gsvn.filter);
    blob_set(&gsvn.filter, zFilter);
    svn_dump_import(pIn);
  }

  verify_cancel();
  db_end_transaction(0);
  db_begin_transaction();
  fossil_print("Rebuilding repository meta-data...\n");