Fossil SCM

merged trunk

wolfgang 2010-09-29 16:01 wolfgangFormat2CSS_2 merge
Commit e2db682fa0ce4a98fcdd5874f24df2ca61ffcc66
--- src/checkin.c
+++ src/checkin.c
@@ -644,10 +644,22 @@
644644
** Autosync if autosync is enabled and this is not a private check-in.
645645
*/
646646
if( !g.markPrivate ){
647647
autosync(AUTOSYNC_PULL);
648648
}
649
+
650
+ /* Require confirmation to continue with the check-in if there is
651
+ ** clock skew
652
+ */
653
+ if( g.clockSkewSeen ){
654
+ Blob ans;
655
+ blob_zero(&ans);
656
+ prompt_user("continue in spite of time skew (y/N)? ", &ans);
657
+ if( blob_str(&ans)[0]!='y' ){
658
+ fossil_exit(1);
659
+ }
660
+ }
649661
650662
/* There are two ways this command may be executed. If there are
651663
** no arguments following the word "commit", then all modified files
652664
** in the checked out directory are committed. If one or more arguments
653665
** follows "commit", then only those files are committed.
654666
--- src/checkin.c
+++ src/checkin.c
@@ -644,10 +644,22 @@
644 ** Autosync if autosync is enabled and this is not a private check-in.
645 */
646 if( !g.markPrivate ){
647 autosync(AUTOSYNC_PULL);
648 }
 
 
 
 
 
 
 
 
 
 
 
 
649
650 /* There are two ways this command may be executed. If there are
651 ** no arguments following the word "commit", then all modified files
652 ** in the checked out directory are committed. If one or more arguments
653 ** follows "commit", then only those files are committed.
654
--- src/checkin.c
+++ src/checkin.c
@@ -644,10 +644,22 @@
644 ** Autosync if autosync is enabled and this is not a private check-in.
645 */
646 if( !g.markPrivate ){
647 autosync(AUTOSYNC_PULL);
648 }
649
650 /* Require confirmation to continue with the check-in if there is
651 ** clock skew
652 */
653 if( g.clockSkewSeen ){
654 Blob ans;
655 blob_zero(&ans);
656 prompt_user("continue in spite of time skew (y/N)? ", &ans);
657 if( blob_str(&ans)[0]!='y' ){
658 fossil_exit(1);
659 }
660 }
661
662 /* There are two ways this command may be executed. If there are
663 ** no arguments following the word "commit", then all modified files
664 ** in the checked out directory are committed. If one or more arguments
665 ** follows "commit", then only those files are committed.
666
+43
--- src/db.c
+++ src/db.c
@@ -1640,5 +1640,48 @@
16401640
}
16411641
}else{
16421642
usage("?PROPERTY? ?VALUE?");
16431643
}
16441644
}
1645
+
1646
+/*
1647
+** The input in a a timespan measured in days. Return a string which
1648
+** describes that timespan in units of seconds, minutes, hours, days,
1649
+** or years, depending on its duration.
1650
+*/
1651
+char *db_timespan_name(double rSpan){
1652
+ if( rSpan<0 ) rSpan = -rSpan;
1653
+ rSpan *= 24.0*3600.0; /* Convert units to seconds */
1654
+ if( rSpan<120.0 ){
1655
+ return sqlite3_mprintf("%.1f seconds", rSpan);
1656
+ }
1657
+ rSpan /= 60.0; /* Convert units to minutes */
1658
+ if( rSpan<90.0 ){
1659
+ return sqlite3_mprintf("%.1f minutes", rSpan);
1660
+ }
1661
+ rSpan /= 60.0; /* Convert units to hours */
1662
+ if( rSpan<=48.0 ){
1663
+ return sqlite3_mprintf("%.1f hours", rSpan);
1664
+ }
1665
+ rSpan /= 24.0; /* Convert units to days */
1666
+ if( rSpan<=365.0 ){
1667
+ return sqlite3_mprintf("%.1f days", rSpan);
1668
+ }
1669
+ rSpan /= 356.24; /* Convert units to years */
1670
+ return sqlite3_mprintf("%.1f years", rSpan);
1671
+}
1672
+
1673
+/*
1674
+** COMMAND: test-timespan
1675
+** %fossil test-timespan TIMESTAMP
1676
+**
1677
+** Print the approximate span of time from now to TIMESTAMP.
1678
+*/
1679
+void test_timespan_cmd(void){
1680
+ double rDiff;
1681
+ if( g.argc!=3 ) usage("TIMESTAMP");
1682
+ sqlite3_open(":memory:", &g.db);
1683
+ rDiff = db_double(0.0, "SELECT julianday('now') - julianday(%Q)", g.argv[2]);
1684
+ printf("Time differences: %s\n", db_timespan_name(rDiff));
1685
+ sqlite3_close(g.db);
1686
+ g.db = 0;
1687
+}
16451688
--- src/db.c
+++ src/db.c
@@ -1640,5 +1640,48 @@
1640 }
1641 }else{
1642 usage("?PROPERTY? ?VALUE?");
1643 }
1644 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1645
--- src/db.c
+++ src/db.c
@@ -1640,5 +1640,48 @@
1640 }
1641 }else{
1642 usage("?PROPERTY? ?VALUE?");
1643 }
1644 }
1645
1646 /*
1647 ** The input in a a timespan measured in days. Return a string which
1648 ** describes that timespan in units of seconds, minutes, hours, days,
1649 ** or years, depending on its duration.
1650 */
1651 char *db_timespan_name(double rSpan){
1652 if( rSpan<0 ) rSpan = -rSpan;
1653 rSpan *= 24.0*3600.0; /* Convert units to seconds */
1654 if( rSpan<120.0 ){
1655 return sqlite3_mprintf("%.1f seconds", rSpan);
1656 }
1657 rSpan /= 60.0; /* Convert units to minutes */
1658 if( rSpan<90.0 ){
1659 return sqlite3_mprintf("%.1f minutes", rSpan);
1660 }
1661 rSpan /= 60.0; /* Convert units to hours */
1662 if( rSpan<=48.0 ){
1663 return sqlite3_mprintf("%.1f hours", rSpan);
1664 }
1665 rSpan /= 24.0; /* Convert units to days */
1666 if( rSpan<=365.0 ){
1667 return sqlite3_mprintf("%.1f days", rSpan);
1668 }
1669 rSpan /= 356.24; /* Convert units to years */
1670 return sqlite3_mprintf("%.1f years", rSpan);
1671 }
1672
1673 /*
1674 ** COMMAND: test-timespan
1675 ** %fossil test-timespan TIMESTAMP
1676 **
1677 ** Print the approximate span of time from now to TIMESTAMP.
1678 */
1679 void test_timespan_cmd(void){
1680 double rDiff;
1681 if( g.argc!=3 ) usage("TIMESTAMP");
1682 sqlite3_open(":memory:", &g.db);
1683 rDiff = db_double(0.0, "SELECT julianday('now') - julianday(%Q)", g.argv[2]);
1684 printf("Time differences: %s\n", db_timespan_name(rDiff));
1685 sqlite3_close(g.db);
1686 g.db = 0;
1687 }
1688
+1
--- src/main.c
+++ src/main.c
@@ -83,10 +83,11 @@
8383
FILE *httpOut; /* Send HTTP output here */
8484
int xlinkClusterOnly; /* Set when cloning. Only process clusters */
8585
int fTimeFormat; /* 1 for UTC. 2 for localtime. 0 not yet selected */
8686
int *aCommitFile; /* Array of files to be committed */
8787
int markPrivate; /* All new artifacts are private if true */
88
+ int clockSkewSeen; /* True if clocks on client and server out of sync */
8889
8990
int urlIsFile; /* True if a "file:" url */
9091
int urlIsHttps; /* True if a "https:" url */
9192
int urlIsSsh; /* True if an "ssh:" url */
9293
char *urlName; /* Hostname for http: or filename for file: */
9394
--- src/main.c
+++ src/main.c
@@ -83,10 +83,11 @@
83 FILE *httpOut; /* Send HTTP output here */
84 int xlinkClusterOnly; /* Set when cloning. Only process clusters */
85 int fTimeFormat; /* 1 for UTC. 2 for localtime. 0 not yet selected */
86 int *aCommitFile; /* Array of files to be committed */
87 int markPrivate; /* All new artifacts are private if true */
 
88
89 int urlIsFile; /* True if a "file:" url */
90 int urlIsHttps; /* True if a "https:" url */
91 int urlIsSsh; /* True if an "ssh:" url */
92 char *urlName; /* Hostname for http: or filename for file: */
93
--- src/main.c
+++ src/main.c
@@ -83,10 +83,11 @@
83 FILE *httpOut; /* Send HTTP output here */
84 int xlinkClusterOnly; /* Set when cloning. Only process clusters */
85 int fTimeFormat; /* 1 for UTC. 2 for localtime. 0 not yet selected */
86 int *aCommitFile; /* Array of files to be committed */
87 int markPrivate; /* All new artifacts are private if true */
88 int clockSkewSeen; /* True if clocks on client and server out of sync */
89
90 int urlIsFile; /* True if a "file:" url */
91 int urlIsHttps; /* True if a "https:" url */
92 int urlIsSsh; /* True if an "ssh:" url */
93 char *urlName; /* Hostname for http: or filename for file: */
94
+19 -1
--- src/xfer.c
+++ src/xfer.c
@@ -476,11 +476,11 @@
476476
** But if we do (because of a bug) now is a good time to delete them. */
477477
db_multi_exec(
478478
"DELETE FROM unclustered WHERE rid IN (SELECT rid FROM private)"
479479
);
480480
481
- nUncl = db_int(0, "SELECT count(*) FROM unclustered"
481
+ nUncl = db_int(0, "SELECT count(*) FROM unclustered /*scan*/"
482482
" WHERE NOT EXISTS(SELECT 1 FROM phantom"
483483
" WHERE rid=unclustered.rid)");
484484
if( nUncl<100 ){
485485
return;
486486
}
@@ -593,10 +593,11 @@
593593
int deltaFlag = 0;
594594
int isClone = 0;
595595
int nGimme = 0;
596596
int size;
597597
int recvConfig = 0;
598
+ char *zNow;
598599
599600
if( strcmp(PD("REQUEST_METHOD","POST"),"POST") ){
600601
fossil_redirect_home();
601602
}
602603
memset(&xfer, 0, sizeof(xfer));
@@ -610,10 +611,12 @@
610611
611612
db_begin_transaction();
612613
db_multi_exec(
613614
"CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);"
614615
);
616
+ zNow = db_text(0, "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%S', 'now')");
617
+ @ # timestamp %s(zNow)
615618
manifest_crosslink_begin();
616619
while( blob_line(xfer.pIn, &xfer.line) ){
617620
if( blob_buffer(&xfer.line)[0]=='#' ) continue;
618621
xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
619622
@@ -1082,10 +1085,25 @@
10821085
go = 0;
10831086
10841087
/* Process the reply that came back from the server */
10851088
while( blob_line(&recv, &xfer.line) ){
10861089
if( blob_buffer(&xfer.line)[0]=='#' ){
1090
+ const char *zLine = blob_buffer(&xfer.line);
1091
+ if( memcmp(zLine, "# timestamp ", 12)==0 ){
1092
+ char zTime[20];
1093
+ double rDiff;
1094
+ sqlite3_snprintf(sizeof(zTime), zTime, "%.19s", &zLine[12]);
1095
+ rDiff = db_double(9e99, "SELECT julianday('%q') - julianday('now')",
1096
+ zTime);
1097
+ if( rDiff<0.0 ) rDiff = -rDiff;
1098
+ if( rDiff>9e98 ) rDiff = 0.0;
1099
+ if( (rDiff*24.0*3600.0)>=60.0 ){
1100
+ fossil_warning("*** time skew *** server time differs by %s",
1101
+ db_timespan_name(rDiff));
1102
+ g.clockSkewSeen = 1;
1103
+ }
1104
+ }
10871105
continue;
10881106
}
10891107
xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
10901108
nCardRcvd++;
10911109
if( !g.cgiOutput && !g.fQuiet ){
10921110
--- src/xfer.c
+++ src/xfer.c
@@ -476,11 +476,11 @@
476 ** But if we do (because of a bug) now is a good time to delete them. */
477 db_multi_exec(
478 "DELETE FROM unclustered WHERE rid IN (SELECT rid FROM private)"
479 );
480
481 nUncl = db_int(0, "SELECT count(*) FROM unclustered"
482 " WHERE NOT EXISTS(SELECT 1 FROM phantom"
483 " WHERE rid=unclustered.rid)");
484 if( nUncl<100 ){
485 return;
486 }
@@ -593,10 +593,11 @@
593 int deltaFlag = 0;
594 int isClone = 0;
595 int nGimme = 0;
596 int size;
597 int recvConfig = 0;
 
598
599 if( strcmp(PD("REQUEST_METHOD","POST"),"POST") ){
600 fossil_redirect_home();
601 }
602 memset(&xfer, 0, sizeof(xfer));
@@ -610,10 +611,12 @@
610
611 db_begin_transaction();
612 db_multi_exec(
613 "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);"
614 );
 
 
615 manifest_crosslink_begin();
616 while( blob_line(xfer.pIn, &xfer.line) ){
617 if( blob_buffer(&xfer.line)[0]=='#' ) continue;
618 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
619
@@ -1082,10 +1085,25 @@
1082 go = 0;
1083
1084 /* Process the reply that came back from the server */
1085 while( blob_line(&recv, &xfer.line) ){
1086 if( blob_buffer(&xfer.line)[0]=='#' ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1087 continue;
1088 }
1089 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
1090 nCardRcvd++;
1091 if( !g.cgiOutput && !g.fQuiet ){
1092
--- src/xfer.c
+++ src/xfer.c
@@ -476,11 +476,11 @@
476 ** But if we do (because of a bug) now is a good time to delete them. */
477 db_multi_exec(
478 "DELETE FROM unclustered WHERE rid IN (SELECT rid FROM private)"
479 );
480
481 nUncl = db_int(0, "SELECT count(*) FROM unclustered /*scan*/"
482 " WHERE NOT EXISTS(SELECT 1 FROM phantom"
483 " WHERE rid=unclustered.rid)");
484 if( nUncl<100 ){
485 return;
486 }
@@ -593,10 +593,11 @@
593 int deltaFlag = 0;
594 int isClone = 0;
595 int nGimme = 0;
596 int size;
597 int recvConfig = 0;
598 char *zNow;
599
600 if( strcmp(PD("REQUEST_METHOD","POST"),"POST") ){
601 fossil_redirect_home();
602 }
603 memset(&xfer, 0, sizeof(xfer));
@@ -610,10 +611,12 @@
611
612 db_begin_transaction();
613 db_multi_exec(
614 "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);"
615 );
616 zNow = db_text(0, "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%S', 'now')");
617 @ # timestamp %s(zNow)
618 manifest_crosslink_begin();
619 while( blob_line(xfer.pIn, &xfer.line) ){
620 if( blob_buffer(&xfer.line)[0]=='#' ) continue;
621 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
622
@@ -1082,10 +1085,25 @@
1085 go = 0;
1086
1087 /* Process the reply that came back from the server */
1088 while( blob_line(&recv, &xfer.line) ){
1089 if( blob_buffer(&xfer.line)[0]=='#' ){
1090 const char *zLine = blob_buffer(&xfer.line);
1091 if( memcmp(zLine, "# timestamp ", 12)==0 ){
1092 char zTime[20];
1093 double rDiff;
1094 sqlite3_snprintf(sizeof(zTime), zTime, "%.19s", &zLine[12]);
1095 rDiff = db_double(9e99, "SELECT julianday('%q') - julianday('now')",
1096 zTime);
1097 if( rDiff<0.0 ) rDiff = -rDiff;
1098 if( rDiff>9e98 ) rDiff = 0.0;
1099 if( (rDiff*24.0*3600.0)>=60.0 ){
1100 fossil_warning("*** time skew *** server time differs by %s",
1101 db_timespan_name(rDiff));
1102 g.clockSkewSeen = 1;
1103 }
1104 }
1105 continue;
1106 }
1107 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
1108 nCardRcvd++;
1109 if( !g.cgiOutput && !g.fQuiet ){
1110

Keyboard Shortcuts

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