Fossil SCM
Add -ignore-tree to import command
Commit
10faea6e0f3deeba1e0734245c665ea55360eb26
Parent
d7b8b3e18328605…
1 file changed
+30
-1
+30
-1
| --- src/import.c | ||
| +++ src/import.c | ||
| @@ -767,10 +767,11 @@ | ||
| 767 | 767 | int lenTags; /* String length of zTags */ |
| 768 | 768 | Bag newBranches; /* Branches that were created in this revision */ |
| 769 | 769 | int revFlag; /* Add svn-rev-nn tags on every checkin */ |
| 770 | 770 | const char *zRevPre; /* Prepended to revision tag names */ |
| 771 | 771 | const char *zRevSuf; /* Appended to revision tag names */ |
| 772 | + const char **azIgnTree; /* NULL-terminated list of dirs to ignore */ | |
| 772 | 773 | } gsvn; |
| 773 | 774 | typedef struct { |
| 774 | 775 | char *zKey; |
| 775 | 776 | char *zVal; |
| 776 | 777 | } KeyVal; |
| @@ -1180,14 +1181,27 @@ | ||
| 1180 | 1181 | } |
| 1181 | 1182 | } |
| 1182 | 1183 | |
| 1183 | 1184 | /* |
| 1184 | 1185 | ** 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 | +*/ | |
| 1186 | 1188 | static int svn_parse_path(char *zPath, char **zFile, int *type){ |
| 1187 | 1189 | char *zBranch = 0; |
| 1188 | 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 | + } | |
| 1189 | 1203 | *type = SVN_UNKNOWN; |
| 1190 | 1204 | *zFile = 0; |
| 1191 | 1205 | if( gsvn.lenTrunk==0 ){ |
| 1192 | 1206 | zBranch = "trunk"; |
| 1193 | 1207 | *zFile = zPath; |
| @@ -1537,10 +1551,11 @@ | ||
| 1537 | 1551 | ** --base PATH Path to project root in repository |
| 1538 | 1552 | ** --flat The whole dump is a single branch |
| 1539 | 1553 | ** --rev-tags Tag each revision, implied by -i |
| 1540 | 1554 | ** --no-rev-tags Disables tagging effect of -i |
| 1541 | 1555 | ** --rename-rev PAT Rev tag names, default "svn-rev-%" |
| 1556 | +** --ignore-tree DIR Ignores subtree rooted at DIR | |
| 1542 | 1557 | ** |
| 1543 | 1558 | ** Common Options: |
| 1544 | 1559 | ** -i|--incremental allow importing into an existing repository |
| 1545 | 1560 | ** -f|--force overwrite repository if already exists |
| 1546 | 1561 | ** -q|--quiet omit progress output |
| @@ -1555,10 +1570,14 @@ | ||
| 1555 | 1570 | ** conflicts when using the --incremental option. |
| 1556 | 1571 | ** |
| 1557 | 1572 | ** The argument to --rename-* contains one "%" character to be replaced |
| 1558 | 1573 | ** with the original name. For example, "--rename-tag svn-%-tag" renames |
| 1559 | 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. | |
| 1560 | 1579 | ** |
| 1561 | 1580 | ** See also: export |
| 1562 | 1581 | */ |
| 1563 | 1582 | void import_cmd(void){ |
| 1564 | 1583 | char *zPassword; |
| @@ -1612,10 +1631,20 @@ | ||
| 1612 | 1631 | |
| 1613 | 1632 | if( svnFlag ){ |
| 1614 | 1633 | /* Get --svn related options here, so verify_all_options() fails when |
| 1615 | 1634 | * svn-only options are specified with --git |
| 1616 | 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 | + } | |
| 1617 | 1646 | zBase = find_option("base", 0, 1); |
| 1618 | 1647 | flatFlag = find_option("flat", 0, 0)!=0; |
| 1619 | 1648 | gsvn.zTrunk = find_option("trunk", 0, 1); |
| 1620 | 1649 | gsvn.zBranches = find_option("branches", 0, 1); |
| 1621 | 1650 | gsvn.zTags = find_option("tags", 0, 1); |
| 1622 | 1651 |
| --- 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 |