Differences From Artifact [27ecf5430e]:
- File src/import.c — part of check-in [b6b50b1244] at 2016-04-01 13:37:02 on branch trunk — Fix typos in comments. No changes to code. (user: mistachkin size: 53633) [more...]
To Artifact [0c01dc75d4]:
- File
src/import.c
— part of check-in
[c26213be47]
at
2016-05-14 21:41:35
on branch nick.lloyd-git-interop
— Add --import-marks and --export-marks options to 'fossil import' subcommand.
This allows one to save all git-generated marks following an import. Previously, performing an incremental import from git resulted in new commits being imported as orphans, and trying to perform an export to git at some later time resulted in git complaining of undefined marks. To remedy this, the format of the marks file is amended to include the rid, mark, and UUID of each commit. Now, fossil and git agree on the mapping between commits and marks, so updates in either direction can be performed easily. (user: nick.lloyd size: 55091)
| ︙ | |||
1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 | 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 | + + + | ** construct a new Fossil repository named by the NEW-REPOSITORY ** 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 (default) ** Options: ** --import-marks FILE Restore marks table from FILE ** --export-marks FILE Save marks table to FILE ** ** --svn Import from the svnadmin-dump file format. The default ** behaviour (unless overridden by --flat) 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: |
| ︙ | |||
1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 | 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 | + + + + + - - + + + |
*/
void import_cmd(void){
char *zPassword;
FILE *pIn;
Stmt q;
int forceFlag = find_option("force", "f", 0)!=0;
int svnFlag = find_option("svn", 0, 0)!=0;
int gitFlag = find_option("git", 0, 0)!=0;
int omitRebuild = find_option("no-rebuild",0,0)!=0;
int omitVacuum = find_option("no-vacuum",0,0)!=0;
/* Options common to all input formats */
int incrFlag = find_option("incremental", "i", 0)!=0;
/* Options for --svn only */
const char *zBase="";
int flatFlag=0;
/* Options for --git only */
const char *markfile_in;
const char *markfile_out;
if( svnFlag ){
/* Get --svn related options here, so verify_all_options() fail when svn
* only option are specify with --git
*/
zBase = find_option("base", 0, 1);
flatFlag = find_option("flat", 0, 0)!=0;
gsvn.zTrunk = find_option("trunk", 0, 1);
gsvn.zBranches = find_option("branches", 0, 1);
gsvn.zTags = find_option("tags", 0, 1);
gsvn.incrFlag = incrFlag;
|
| ︙ | |||
1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 | 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 | + + + |
if( gsvn.zTags[gsvn.lenTags-1]!='/' ){
gsvn.zTags = mprintf("%s/", gsvn.zTags);
gsvn.lenTags++;
}
}
svn_dump_import(pIn);
}else{
Bag blobs, vers;
bag_init(&blobs);
bag_init(&vers);
/* The following temp-tables are used to hold information needed for
** the import.
**
** The XMARK table provides a mapping from fast-import "marks" and symbols
** into artifact ids (UUIDs - the 40-byte hex SHA1 hash of artifacts).
** Given any valid fast-import symbol, the corresponding fossil rid and
** uuid can found by searching against the xmark.tname field.
|
| ︙ | |||
1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 | 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + |
** occurrence of the tag is the last until the import finishes.
*/
db_multi_exec(
"CREATE TEMP TABLE xmark(tname TEXT UNIQUE, trid INT, tuuid TEXT);"
"CREATE TEMP TABLE xbranch(tname TEXT UNIQUE, brnm TEXT);"
"CREATE TEMP TABLE xtag(tname TEXT UNIQUE, tcontent TEXT);"
);
if(markfile_in){
FILE *f = fossil_fopen(markfile_in, "r");
if(!f){
fossil_fatal("cannot open %s for reading\n", markfile_in);
}
if(import_marks(f, &blobs, NULL)<0){
fossil_fatal("error importing marks from file: %s\n", markfile_in);
}
fclose(f);
}
manifest_crosslink_begin();
git_fast_import(pIn);
db_prepare(&q, "SELECT tcontent FROM xtag");
while( db_step(&q)==SQLITE_ROW ){
Blob record;
db_ephemeral_blob(&q, 0, &record);
fast_insert_content(&record, 0, 0, 1);
import_reset(0);
}
db_finalize(&q);
if(markfile_out){
int rid;
Stmt q_marks;
db_prepare(&q_marks, "SELECT DISTINCT trid FROM xmark");
while( db_step(&q_marks)==SQLITE_ROW){
rid = db_column_int(&q_marks, 0);
if(db_int(0, "SELECT count(objid) FROM event WHERE objid=%d AND type='ci'", rid)==0){
if(bag_find(&blobs, rid)==0){
bag_insert(&blobs, rid);
}
}else{
bag_insert(&vers, rid);
}
}
db_finalize(&q_marks);
FILE* f = fossil_fopen(markfile_out, "w");
if(!f){
fossil_fatal("cannot open %s for writing\n", markfile_out);
}
export_marks(f, &blobs, &vers);
fclose(f);
bag_clear(&blobs);
bag_clear(&vers);
}
manifest_crosslink_end(MC_NONE);
}
verify_cancel();
db_end_transaction(0);
fossil_print(" \r");
if( omitRebuild ){
|
| ︙ |