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.

jan.nijtmans 2015-03-17 21:03 UTC trunk
Commit 12c54ad313648ce3c71d2115ddb877224d43ae73
2 files changed +30 -1 +6 -4
+30 -1
--- src/checkin.c
+++ src/checkin.c
@@ -1836,11 +1836,10 @@
18361836
" AND value=%Q", TAG_BRANCH, vid, sCiInfo.zBranch))
18371837
){
18381838
fossil_fatal("cannot commit against a closed leaf");
18391839
}
18401840
1841
- if( useCksum ) vfile_aggregate_checksum_disk(vid, &cksum1);
18421841
if( zComment ){
18431842
blob_zero(&comment);
18441843
blob_append(&comment, zComment, -1);
18451844
}else if( zComFile ){
18461845
blob_zero(&comment);
@@ -1869,15 +1868,45 @@
18691868
}else{
18701869
db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
18711870
db_end_transaction(0);
18721871
db_begin_transaction();
18731872
}
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
+ }
18741902
18751903
/* Step 1: Insert records for all modified files into the blob
18761904
** table. If there were arguments passed to this command, only
18771905
** the identified files are inserted (if they have been modified).
18781906
*/
1907
+ if( useCksum ) vfile_aggregate_checksum_disk(vid, &cksum1);
18791908
db_prepare(&q,
18801909
"SELECT id, %Q || pathname, mrid, %s, chnged, %s, %s FROM vfile "
18811910
"WHERE chnged==1 AND NOT deleted AND is_selected(id)",
18821911
g.zLocalRoot,
18831912
glob_expr("pathname", db_get("crnl-glob","")),
18841913
--- 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
+6 -4
--- src/db.c
+++ src/db.c
@@ -1666,10 +1666,11 @@
16661666
void create_repository_cmd(void){
16671667
char *zPassword;
16681668
const char *zTemplate; /* Repository from which to copy settings */
16691669
const char *zDate; /* Date of the initial check-in */
16701670
const char *zDefaultUser; /* Optional name of the default user */
1671
+ int makeServerCodes = find_option("docker", 0, 0)==0
16711672
16721673
zTemplate = find_option("template",0,1);
16731674
zDate = find_option("date-override",0,1);
16741675
zDefaultUser = find_option("admin-user","A",1);
16751676
/* We should be done with options.. */
@@ -1686,16 +1687,17 @@
16861687
db_create_repository(g.argv[2]);
16871688
db_open_repository(g.argv[2]);
16881689
db_open_config(0);
16891690
if( zTemplate ) db_attach(zTemplate, "settingSrc");
16901691
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);
16931693
db_end_transaction(0);
16941694
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
+ }
16971699
zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
16981700
fossil_print("admin-user: %s (initial password is \"%s\")\n",
16991701
g.zLogin, zPassword);
17001702
}
17011703
17021704
--- 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

Keyboard Shortcuts

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