Fossil SCM
Fix for "fossil new --docker" and for [http://www.mail-archive.com/fossil-users%40lists.fossil-scm.org/msg17644.html|Chisallapp: I have two trunks ?], while still guaranteeing the rid=1 initial empty commit.
Commit
12c54ad313648ce3c71d2115ddb877224d43ae73
Parent
f215075a47e34aa…
2 files changed
+30
-1
+6
-4
+30
-1
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -1836,11 +1836,10 @@ | ||
| 1836 | 1836 | " AND value=%Q", TAG_BRANCH, vid, sCiInfo.zBranch)) |
| 1837 | 1837 | ){ |
| 1838 | 1838 | fossil_fatal("cannot commit against a closed leaf"); |
| 1839 | 1839 | } |
| 1840 | 1840 | |
| 1841 | - if( useCksum ) vfile_aggregate_checksum_disk(vid, &cksum1); | |
| 1842 | 1841 | if( zComment ){ |
| 1843 | 1842 | blob_zero(&comment); |
| 1844 | 1843 | blob_append(&comment, zComment, -1); |
| 1845 | 1844 | }else if( zComFile ){ |
| 1846 | 1845 | blob_zero(&comment); |
| @@ -1869,15 +1868,45 @@ | ||
| 1869 | 1868 | }else{ |
| 1870 | 1869 | db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment); |
| 1871 | 1870 | db_end_transaction(0); |
| 1872 | 1871 | db_begin_transaction(); |
| 1873 | 1872 | } |
| 1873 | + | |
| 1874 | + /* Step 0: If the repository does not have any artifacts yet | |
| 1875 | + ** and a non-empty commit is being prepared, create an additional | |
| 1876 | + ** empty check-in for compatibility with fossil<1.28. This | |
| 1877 | + ** section can be removed when Fossil 1.27 is not used any more. | |
| 1878 | + */ | |
| 1879 | + | |
| 1880 | + if( !db_exists("SELECT 1 FROM blob") && db_exists("SELECT 1 FROM vfile")){ | |
| 1881 | + int rid; | |
| 1882 | + const char *zDate; | |
| 1883 | + Blob hash; | |
| 1884 | + blob_zero(&manifest); | |
| 1885 | + blob_appendf(&manifest, "C initial\\sempty\\scheck-in\n"); | |
| 1886 | + zDate = date_in_standard_format(sCiInfo.zDateOvrd ? sCiInfo.zDateOvrd : "now"); | |
| 1887 | + blob_appendf(&manifest, "D %s\n", zDate); | |
| 1888 | + md5sum_init(); | |
| 1889 | + /* The R-card is necessary here because without it | |
| 1890 | + * fossil versions earlier than versions 1.27 would | |
| 1891 | + * interpret this artifact as a "control". */ | |
| 1892 | + blob_appendf(&manifest, "R %s\n", md5sum_finish(0)); | |
| 1893 | + blob_appendf(&manifest, "T *branch * %F\n", sCiInfo.zBranch); | |
| 1894 | + blob_appendf(&manifest, "T *sym-%F *\n", sCiInfo.zBranch); | |
| 1895 | + blob_appendf(&manifest, "U %F\n", g.zLogin); | |
| 1896 | + md5sum_blob(&manifest, &hash); | |
| 1897 | + blob_appendf(&manifest, "Z %b\n", &hash); | |
| 1898 | + blob_reset(&hash); | |
| 1899 | + vid = content_put(&manifest); | |
| 1900 | + manifest_crosslink(vid, &manifest, MC_NONE); | |
| 1901 | + } | |
| 1874 | 1902 | |
| 1875 | 1903 | /* Step 1: Insert records for all modified files into the blob |
| 1876 | 1904 | ** table. If there were arguments passed to this command, only |
| 1877 | 1905 | ** the identified files are inserted (if they have been modified). |
| 1878 | 1906 | */ |
| 1907 | + if( useCksum ) vfile_aggregate_checksum_disk(vid, &cksum1); | |
| 1879 | 1908 | db_prepare(&q, |
| 1880 | 1909 | "SELECT id, %Q || pathname, mrid, %s, chnged, %s, %s FROM vfile " |
| 1881 | 1910 | "WHERE chnged==1 AND NOT deleted AND is_selected(id)", |
| 1882 | 1911 | g.zLocalRoot, |
| 1883 | 1912 | glob_expr("pathname", db_get("crnl-glob","")), |
| 1884 | 1913 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -1836,11 +1836,10 @@ | |
| 1836 | " AND value=%Q", TAG_BRANCH, vid, sCiInfo.zBranch)) |
| 1837 | ){ |
| 1838 | fossil_fatal("cannot commit against a closed leaf"); |
| 1839 | } |
| 1840 | |
| 1841 | if( useCksum ) vfile_aggregate_checksum_disk(vid, &cksum1); |
| 1842 | if( zComment ){ |
| 1843 | blob_zero(&comment); |
| 1844 | blob_append(&comment, zComment, -1); |
| 1845 | }else if( zComFile ){ |
| 1846 | blob_zero(&comment); |
| @@ -1869,15 +1868,45 @@ | |
| 1869 | }else{ |
| 1870 | db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment); |
| 1871 | db_end_transaction(0); |
| 1872 | db_begin_transaction(); |
| 1873 | } |
| 1874 | |
| 1875 | /* Step 1: Insert records for all modified files into the blob |
| 1876 | ** table. If there were arguments passed to this command, only |
| 1877 | ** the identified files are inserted (if they have been modified). |
| 1878 | */ |
| 1879 | db_prepare(&q, |
| 1880 | "SELECT id, %Q || pathname, mrid, %s, chnged, %s, %s FROM vfile " |
| 1881 | "WHERE chnged==1 AND NOT deleted AND is_selected(id)", |
| 1882 | g.zLocalRoot, |
| 1883 | glob_expr("pathname", db_get("crnl-glob","")), |
| 1884 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -1836,11 +1836,10 @@ | |
| 1836 | " AND value=%Q", TAG_BRANCH, vid, sCiInfo.zBranch)) |
| 1837 | ){ |
| 1838 | fossil_fatal("cannot commit against a closed leaf"); |
| 1839 | } |
| 1840 | |
| 1841 | if( zComment ){ |
| 1842 | blob_zero(&comment); |
| 1843 | blob_append(&comment, zComment, -1); |
| 1844 | }else if( zComFile ){ |
| 1845 | blob_zero(&comment); |
| @@ -1869,15 +1868,45 @@ | |
| 1868 | }else{ |
| 1869 | db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment); |
| 1870 | db_end_transaction(0); |
| 1871 | db_begin_transaction(); |
| 1872 | } |
| 1873 | |
| 1874 | /* Step 0: If the repository does not have any artifacts yet |
| 1875 | ** and a non-empty commit is being prepared, create an additional |
| 1876 | ** empty check-in for compatibility with fossil<1.28. This |
| 1877 | ** section can be removed when Fossil 1.27 is not used any more. |
| 1878 | */ |
| 1879 | |
| 1880 | if( !db_exists("SELECT 1 FROM blob") && db_exists("SELECT 1 FROM vfile")){ |
| 1881 | int rid; |
| 1882 | const char *zDate; |
| 1883 | Blob hash; |
| 1884 | blob_zero(&manifest); |
| 1885 | blob_appendf(&manifest, "C initial\\sempty\\scheck-in\n"); |
| 1886 | zDate = date_in_standard_format(sCiInfo.zDateOvrd ? sCiInfo.zDateOvrd : "now"); |
| 1887 | blob_appendf(&manifest, "D %s\n", zDate); |
| 1888 | md5sum_init(); |
| 1889 | /* The R-card is necessary here because without it |
| 1890 | * fossil versions earlier than versions 1.27 would |
| 1891 | * interpret this artifact as a "control". */ |
| 1892 | blob_appendf(&manifest, "R %s\n", md5sum_finish(0)); |
| 1893 | blob_appendf(&manifest, "T *branch * %F\n", sCiInfo.zBranch); |
| 1894 | blob_appendf(&manifest, "T *sym-%F *\n", sCiInfo.zBranch); |
| 1895 | blob_appendf(&manifest, "U %F\n", g.zLogin); |
| 1896 | md5sum_blob(&manifest, &hash); |
| 1897 | blob_appendf(&manifest, "Z %b\n", &hash); |
| 1898 | blob_reset(&hash); |
| 1899 | vid = content_put(&manifest); |
| 1900 | manifest_crosslink(vid, &manifest, MC_NONE); |
| 1901 | } |
| 1902 | |
| 1903 | /* Step 1: Insert records for all modified files into the blob |
| 1904 | ** table. If there were arguments passed to this command, only |
| 1905 | ** the identified files are inserted (if they have been modified). |
| 1906 | */ |
| 1907 | if( useCksum ) vfile_aggregate_checksum_disk(vid, &cksum1); |
| 1908 | db_prepare(&q, |
| 1909 | "SELECT id, %Q || pathname, mrid, %s, chnged, %s, %s FROM vfile " |
| 1910 | "WHERE chnged==1 AND NOT deleted AND is_selected(id)", |
| 1911 | g.zLocalRoot, |
| 1912 | glob_expr("pathname", db_get("crnl-glob","")), |
| 1913 |
M
src/db.c
+6
-4
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1666,10 +1666,11 @@ | ||
| 1666 | 1666 | void create_repository_cmd(void){ |
| 1667 | 1667 | char *zPassword; |
| 1668 | 1668 | const char *zTemplate; /* Repository from which to copy settings */ |
| 1669 | 1669 | const char *zDate; /* Date of the initial check-in */ |
| 1670 | 1670 | const char *zDefaultUser; /* Optional name of the default user */ |
| 1671 | + int makeServerCodes = find_option("docker", 0, 0)==0 | |
| 1671 | 1672 | |
| 1672 | 1673 | zTemplate = find_option("template",0,1); |
| 1673 | 1674 | zDate = find_option("date-override",0,1); |
| 1674 | 1675 | zDefaultUser = find_option("admin-user","A",1); |
| 1675 | 1676 | /* We should be done with options.. */ |
| @@ -1686,16 +1687,17 @@ | ||
| 1686 | 1687 | db_create_repository(g.argv[2]); |
| 1687 | 1688 | db_open_repository(g.argv[2]); |
| 1688 | 1689 | db_open_config(0); |
| 1689 | 1690 | if( zTemplate ) db_attach(zTemplate, "settingSrc"); |
| 1690 | 1691 | db_begin_transaction(); |
| 1691 | - if( zDate==0 ) zDate = "now"; | |
| 1692 | - db_initial_setup(zTemplate, zDate, zDefaultUser, 1); | |
| 1692 | + db_initial_setup(zTemplate, zDate, zDefaultUser, makeServerCodes); | |
| 1693 | 1693 | db_end_transaction(0); |
| 1694 | 1694 | if( zTemplate ) db_detach("settingSrc"); |
| 1695 | - fossil_print("project-id: %s\n", db_get("project-code", 0)); | |
| 1696 | - fossil_print("server-id: %s\n", db_get("server-code", 0)); | |
| 1695 | + if( makeServerCodes ){ | |
| 1696 | + fossil_print("project-id: %s\n", db_get("project-code", 0)); | |
| 1697 | + fossil_print("server-id: %s\n", db_get("server-code", 0)); | |
| 1698 | + } | |
| 1697 | 1699 | zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); |
| 1698 | 1700 | fossil_print("admin-user: %s (initial password is \"%s\")\n", |
| 1699 | 1701 | g.zLogin, zPassword); |
| 1700 | 1702 | } |
| 1701 | 1703 | |
| 1702 | 1704 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1666,10 +1666,11 @@ | |
| 1666 | void create_repository_cmd(void){ |
| 1667 | char *zPassword; |
| 1668 | const char *zTemplate; /* Repository from which to copy settings */ |
| 1669 | const char *zDate; /* Date of the initial check-in */ |
| 1670 | const char *zDefaultUser; /* Optional name of the default user */ |
| 1671 | |
| 1672 | zTemplate = find_option("template",0,1); |
| 1673 | zDate = find_option("date-override",0,1); |
| 1674 | zDefaultUser = find_option("admin-user","A",1); |
| 1675 | /* We should be done with options.. */ |
| @@ -1686,16 +1687,17 @@ | |
| 1686 | db_create_repository(g.argv[2]); |
| 1687 | db_open_repository(g.argv[2]); |
| 1688 | db_open_config(0); |
| 1689 | if( zTemplate ) db_attach(zTemplate, "settingSrc"); |
| 1690 | db_begin_transaction(); |
| 1691 | if( zDate==0 ) zDate = "now"; |
| 1692 | db_initial_setup(zTemplate, zDate, zDefaultUser, 1); |
| 1693 | db_end_transaction(0); |
| 1694 | if( zTemplate ) db_detach("settingSrc"); |
| 1695 | fossil_print("project-id: %s\n", db_get("project-code", 0)); |
| 1696 | fossil_print("server-id: %s\n", db_get("server-code", 0)); |
| 1697 | zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); |
| 1698 | fossil_print("admin-user: %s (initial password is \"%s\")\n", |
| 1699 | g.zLogin, zPassword); |
| 1700 | } |
| 1701 | |
| 1702 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1666,10 +1666,11 @@ | |
| 1666 | void create_repository_cmd(void){ |
| 1667 | char *zPassword; |
| 1668 | const char *zTemplate; /* Repository from which to copy settings */ |
| 1669 | const char *zDate; /* Date of the initial check-in */ |
| 1670 | const char *zDefaultUser; /* Optional name of the default user */ |
| 1671 | int makeServerCodes = find_option("docker", 0, 0)==0 |
| 1672 | |
| 1673 | zTemplate = find_option("template",0,1); |
| 1674 | zDate = find_option("date-override",0,1); |
| 1675 | zDefaultUser = find_option("admin-user","A",1); |
| 1676 | /* We should be done with options.. */ |
| @@ -1686,16 +1687,17 @@ | |
| 1687 | db_create_repository(g.argv[2]); |
| 1688 | db_open_repository(g.argv[2]); |
| 1689 | db_open_config(0); |
| 1690 | if( zTemplate ) db_attach(zTemplate, "settingSrc"); |
| 1691 | db_begin_transaction(); |
| 1692 | db_initial_setup(zTemplate, zDate, zDefaultUser, makeServerCodes); |
| 1693 | db_end_transaction(0); |
| 1694 | if( zTemplate ) db_detach("settingSrc"); |
| 1695 | if( makeServerCodes ){ |
| 1696 | fossil_print("project-id: %s\n", db_get("project-code", 0)); |
| 1697 | fossil_print("server-id: %s\n", db_get("server-code", 0)); |
| 1698 | } |
| 1699 | zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); |
| 1700 | fossil_print("admin-user: %s (initial password is \"%s\")\n", |
| 1701 | g.zLogin, zPassword); |
| 1702 | } |
| 1703 | |
| 1704 |