Fossil SCM

Add -ignore-tree to import command

andygoth 2016-05-14 04:29 andygoth-svn-import
Commit 10faea6e0f3deeba1e0734245c665ea55360eb26
1 file changed +30 -1
+30 -1
--- src/import.c
+++ src/import.c
@@ -767,10 +767,11 @@
767767
int lenTags; /* String length of zTags */
768768
Bag newBranches; /* Branches that were created in this revision */
769769
int revFlag; /* Add svn-rev-nn tags on every checkin */
770770
const char *zRevPre; /* Prepended to revision tag names */
771771
const char *zRevSuf; /* Appended to revision tag names */
772
+ const char **azIgnTree; /* NULL-terminated list of dirs to ignore */
772773
} gsvn;
773774
typedef struct {
774775
char *zKey;
775776
char *zVal;
776777
} KeyVal;
@@ -1180,14 +1181,27 @@
11801181
}
11811182
}
11821183
11831184
/*
11841185
** Extract the branch or tag that the given path is on. Return the branch ID.
1185
- */
1186
+** Return 0 if not a branch, tag, or trunk, or if ignored by --ignore-tree.
1187
+*/
11861188
static int svn_parse_path(char *zPath, char **zFile, int *type){
11871189
char *zBranch = 0;
11881190
int branchId = 0;
1191
+ if( gsvn.azIgnTree ){
1192
+ const char **pzIgnTree;
1193
+ unsigned nPath = strlen(zPath);
1194
+ for( pzIgnTree = gsvn.azIgnTree; *pzIgnTree; ++pzIgnTree ){
1195
+ const char *zIgn = *pzIgnTree;
1196
+ int nIgn = strlen(zIgn);
1197
+ if( strncmp(zPath, zIgn, nIgn) == 0
1198
+ && ( nPath == nIgn || (nPath > nIgn && zPath[nIgn] == '/')) ){
1199
+ return 0;
1200
+ }
1201
+ }
1202
+ }
11891203
*type = SVN_UNKNOWN;
11901204
*zFile = 0;
11911205
if( gsvn.lenTrunk==0 ){
11921206
zBranch = "trunk";
11931207
*zFile = zPath;
@@ -1537,10 +1551,11 @@
15371551
** --base PATH Path to project root in repository
15381552
** --flat The whole dump is a single branch
15391553
** --rev-tags Tag each revision, implied by -i
15401554
** --no-rev-tags Disables tagging effect of -i
15411555
** --rename-rev PAT Rev tag names, default "svn-rev-%"
1556
+** --ignore-tree DIR Ignores subtree rooted at DIR
15421557
**
15431558
** Common Options:
15441559
** -i|--incremental allow importing into an existing repository
15451560
** -f|--force overwrite repository if already exists
15461561
** -q|--quiet omit progress output
@@ -1555,10 +1570,14 @@
15551570
** conflicts when using the --incremental option.
15561571
**
15571572
** The argument to --rename-* contains one "%" character to be replaced
15581573
** with the original name. For example, "--rename-tag svn-%-tag" renames
15591574
** the tag called "release" to "svn-release-tag".
1575
+**
1576
+** --ignore-tree is useful for importing Subversion repositories which
1577
+** move branches to subdirectories of "branches/deleted" instead of
1578
+** deleting them. It can be supplied multiple times if necessary.
15601579
**
15611580
** See also: export
15621581
*/
15631582
void import_cmd(void){
15641583
char *zPassword;
@@ -1612,10 +1631,20 @@
16121631
16131632
if( svnFlag ){
16141633
/* Get --svn related options here, so verify_all_options() fails when
16151634
* svn-only options are specified with --git
16161635
*/
1636
+ const char *zIgnTree;
1637
+ unsigned nIgnTree = 0;
1638
+ while( (zIgnTree = find_option("ignore-tree", 0, 1)) ){
1639
+ if ( *zIgnTree ){
1640
+ gsvn.azIgnTree = fossil_realloc(gsvn.azIgnTree,
1641
+ sizeof(*gsvn.azIgnTree) * (nIgnTree + 2));
1642
+ gsvn.azIgnTree[nIgnTree++] = zIgnTree;
1643
+ gsvn.azIgnTree[nIgnTree] = 0;
1644
+ }
1645
+ }
16171646
zBase = find_option("base", 0, 1);
16181647
flatFlag = find_option("flat", 0, 0)!=0;
16191648
gsvn.zTrunk = find_option("trunk", 0, 1);
16201649
gsvn.zBranches = find_option("branches", 0, 1);
16211650
gsvn.zTags = find_option("tags", 0, 1);
16221651
--- src/import.c
+++ src/import.c
@@ -767,10 +767,11 @@
767 int lenTags; /* String length of zTags */
768 Bag newBranches; /* Branches that were created in this revision */
769 int revFlag; /* Add svn-rev-nn tags on every checkin */
770 const char *zRevPre; /* Prepended to revision tag names */
771 const char *zRevSuf; /* Appended to revision tag names */
 
772 } gsvn;
773 typedef struct {
774 char *zKey;
775 char *zVal;
776 } KeyVal;
@@ -1180,14 +1181,27 @@
1180 }
1181 }
1182
1183 /*
1184 ** Extract the branch or tag that the given path is on. Return the branch ID.
1185 */
 
1186 static int svn_parse_path(char *zPath, char **zFile, int *type){
1187 char *zBranch = 0;
1188 int branchId = 0;
 
 
 
 
 
 
 
 
 
 
 
 
1189 *type = SVN_UNKNOWN;
1190 *zFile = 0;
1191 if( gsvn.lenTrunk==0 ){
1192 zBranch = "trunk";
1193 *zFile = zPath;
@@ -1537,10 +1551,11 @@
1537 ** --base PATH Path to project root in repository
1538 ** --flat The whole dump is a single branch
1539 ** --rev-tags Tag each revision, implied by -i
1540 ** --no-rev-tags Disables tagging effect of -i
1541 ** --rename-rev PAT Rev tag names, default "svn-rev-%"
 
1542 **
1543 ** Common Options:
1544 ** -i|--incremental allow importing into an existing repository
1545 ** -f|--force overwrite repository if already exists
1546 ** -q|--quiet omit progress output
@@ -1555,10 +1570,14 @@
1555 ** conflicts when using the --incremental option.
1556 **
1557 ** The argument to --rename-* contains one "%" character to be replaced
1558 ** with the original name. For example, "--rename-tag svn-%-tag" renames
1559 ** the tag called "release" to "svn-release-tag".
 
 
 
 
1560 **
1561 ** See also: export
1562 */
1563 void import_cmd(void){
1564 char *zPassword;
@@ -1612,10 +1631,20 @@
1612
1613 if( svnFlag ){
1614 /* Get --svn related options here, so verify_all_options() fails when
1615 * svn-only options are specified with --git
1616 */
 
 
 
 
 
 
 
 
 
 
1617 zBase = find_option("base", 0, 1);
1618 flatFlag = find_option("flat", 0, 0)!=0;
1619 gsvn.zTrunk = find_option("trunk", 0, 1);
1620 gsvn.zBranches = find_option("branches", 0, 1);
1621 gsvn.zTags = find_option("tags", 0, 1);
1622
--- src/import.c
+++ src/import.c
@@ -767,10 +767,11 @@
767 int lenTags; /* String length of zTags */
768 Bag newBranches; /* Branches that were created in this revision */
769 int revFlag; /* Add svn-rev-nn tags on every checkin */
770 const char *zRevPre; /* Prepended to revision tag names */
771 const char *zRevSuf; /* Appended to revision tag names */
772 const char **azIgnTree; /* NULL-terminated list of dirs to ignore */
773 } gsvn;
774 typedef struct {
775 char *zKey;
776 char *zVal;
777 } KeyVal;
@@ -1180,14 +1181,27 @@
1181 }
1182 }
1183
1184 /*
1185 ** Extract the branch or tag that the given path is on. Return the branch ID.
1186 ** Return 0 if not a branch, tag, or trunk, or if ignored by --ignore-tree.
1187 */
1188 static int svn_parse_path(char *zPath, char **zFile, int *type){
1189 char *zBranch = 0;
1190 int branchId = 0;
1191 if( gsvn.azIgnTree ){
1192 const char **pzIgnTree;
1193 unsigned nPath = strlen(zPath);
1194 for( pzIgnTree = gsvn.azIgnTree; *pzIgnTree; ++pzIgnTree ){
1195 const char *zIgn = *pzIgnTree;
1196 int nIgn = strlen(zIgn);
1197 if( strncmp(zPath, zIgn, nIgn) == 0
1198 && ( nPath == nIgn || (nPath > nIgn && zPath[nIgn] == '/')) ){
1199 return 0;
1200 }
1201 }
1202 }
1203 *type = SVN_UNKNOWN;
1204 *zFile = 0;
1205 if( gsvn.lenTrunk==0 ){
1206 zBranch = "trunk";
1207 *zFile = zPath;
@@ -1537,10 +1551,11 @@
1551 ** --base PATH Path to project root in repository
1552 ** --flat The whole dump is a single branch
1553 ** --rev-tags Tag each revision, implied by -i
1554 ** --no-rev-tags Disables tagging effect of -i
1555 ** --rename-rev PAT Rev tag names, default "svn-rev-%"
1556 ** --ignore-tree DIR Ignores subtree rooted at DIR
1557 **
1558 ** Common Options:
1559 ** -i|--incremental allow importing into an existing repository
1560 ** -f|--force overwrite repository if already exists
1561 ** -q|--quiet omit progress output
@@ -1555,10 +1570,14 @@
1570 ** conflicts when using the --incremental option.
1571 **
1572 ** The argument to --rename-* contains one "%" character to be replaced
1573 ** with the original name. For example, "--rename-tag svn-%-tag" renames
1574 ** the tag called "release" to "svn-release-tag".
1575 **
1576 ** --ignore-tree is useful for importing Subversion repositories which
1577 ** move branches to subdirectories of "branches/deleted" instead of
1578 ** deleting them. It can be supplied multiple times if necessary.
1579 **
1580 ** See also: export
1581 */
1582 void import_cmd(void){
1583 char *zPassword;
@@ -1612,10 +1631,20 @@
1631
1632 if( svnFlag ){
1633 /* Get --svn related options here, so verify_all_options() fails when
1634 * svn-only options are specified with --git
1635 */
1636 const char *zIgnTree;
1637 unsigned nIgnTree = 0;
1638 while( (zIgnTree = find_option("ignore-tree", 0, 1)) ){
1639 if ( *zIgnTree ){
1640 gsvn.azIgnTree = fossil_realloc(gsvn.azIgnTree,
1641 sizeof(*gsvn.azIgnTree) * (nIgnTree + 2));
1642 gsvn.azIgnTree[nIgnTree++] = zIgnTree;
1643 gsvn.azIgnTree[nIgnTree] = 0;
1644 }
1645 }
1646 zBase = find_option("base", 0, 1);
1647 flatFlag = find_option("flat", 0, 0)!=0;
1648 gsvn.zTrunk = find_option("trunk", 0, 1);
1649 gsvn.zBranches = find_option("branches", 0, 1);
1650 gsvn.zTags = find_option("tags", 0, 1);
1651

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button