Fossil SCM

Better fork detection on [/help?cmd=import|fossil update], [/help?cmd=import|fossil status] and related commands.

jan.nijtmans 2015-04-13 08:29 trunk merge
Commit 5c40f8565e9a3f93590f251e6e0fd9805cb36b85
+14 -7
--- src/info.c
+++ src/info.c
@@ -48,12 +48,14 @@
4848
**
4949
** * The UUID
5050
** * The record ID
5151
** * mtime and ctime
5252
** * who signed it
53
+**
54
+** Returns 1 when a fork was found.
5355
*/
54
-void show_common_info(
56
+int show_common_info(
5557
int rid, /* The rid for the check-in to display info for */
5658
const char *zUuidName, /* Name of the UUID */
5759
int showComment, /* True to show the check-in comment */
5860
int showFamily /* True to show parents and children */
5961
){
@@ -60,10 +62,11 @@
6062
Stmt q;
6163
char *zComment = 0;
6264
char *zTags;
6365
char *zDate;
6466
char *zUuid;
67
+ int isFork = 0;
6568
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
6669
if( zUuid ){
6770
zDate = db_text(0,
6871
"SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d",
6972
rid
@@ -111,17 +114,20 @@
111114
}
112115
db_finalize(&q);
113116
}
114117
if( zUuid ){
115118
fossil_print("%-13s ", "leaf:");
116
- if(is_a_leaf(rid)){
117
- if(db_int(0, "SELECT 1 FROM tagxref AS tx"
118
- " WHERE tx.rid=%d"
119
- " AND tx.tagid=%d"
120
- " AND tx.tagtype>0",
121
- rid, TAG_CLOSED)){
119
+ if( is_a_leaf(rid) ){
120
+ if( db_int(0, "SELECT 1 FROM tagxref AS tx"
121
+ " WHERE tx.rid=%d"
122
+ " AND tx.tagid=%d"
123
+ " AND tx.tagtype>0",
124
+ rid, TAG_CLOSED)){
122125
fossil_print("%s\n", "closed");
126
+ }else if( fossil_find_nearest_fork(rid) ){
127
+ fossil_print("%s\n", "fork");
128
+ isFork = 1;
123129
}else{
124130
fossil_print("%s\n", "open");
125131
}
126132
}else{
127133
fossil_print("no\n");
@@ -135,10 +141,11 @@
135141
if( zComment ){
136142
fossil_print("comment: ");
137143
comment_print(zComment, 0, 14, -1, g.comFmtFlags);
138144
free(zComment);
139145
}
146
+ return isFork;
140147
}
141148
142149
/*
143150
** Print information about the URLs used to access a repository and
144151
** checkouts in a repository.
145152
--- src/info.c
+++ src/info.c
@@ -48,12 +48,14 @@
48 **
49 ** * The UUID
50 ** * The record ID
51 ** * mtime and ctime
52 ** * who signed it
 
 
53 */
54 void show_common_info(
55 int rid, /* The rid for the check-in to display info for */
56 const char *zUuidName, /* Name of the UUID */
57 int showComment, /* True to show the check-in comment */
58 int showFamily /* True to show parents and children */
59 ){
@@ -60,10 +62,11 @@
60 Stmt q;
61 char *zComment = 0;
62 char *zTags;
63 char *zDate;
64 char *zUuid;
 
65 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
66 if( zUuid ){
67 zDate = db_text(0,
68 "SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d",
69 rid
@@ -111,17 +114,20 @@
111 }
112 db_finalize(&q);
113 }
114 if( zUuid ){
115 fossil_print("%-13s ", "leaf:");
116 if(is_a_leaf(rid)){
117 if(db_int(0, "SELECT 1 FROM tagxref AS tx"
118 " WHERE tx.rid=%d"
119 " AND tx.tagid=%d"
120 " AND tx.tagtype>0",
121 rid, TAG_CLOSED)){
122 fossil_print("%s\n", "closed");
 
 
 
123 }else{
124 fossil_print("%s\n", "open");
125 }
126 }else{
127 fossil_print("no\n");
@@ -135,10 +141,11 @@
135 if( zComment ){
136 fossil_print("comment: ");
137 comment_print(zComment, 0, 14, -1, g.comFmtFlags);
138 free(zComment);
139 }
 
140 }
141
142 /*
143 ** Print information about the URLs used to access a repository and
144 ** checkouts in a repository.
145
--- src/info.c
+++ src/info.c
@@ -48,12 +48,14 @@
48 **
49 ** * The UUID
50 ** * The record ID
51 ** * mtime and ctime
52 ** * who signed it
53 **
54 ** Returns 1 when a fork was found.
55 */
56 int show_common_info(
57 int rid, /* The rid for the check-in to display info for */
58 const char *zUuidName, /* Name of the UUID */
59 int showComment, /* True to show the check-in comment */
60 int showFamily /* True to show parents and children */
61 ){
@@ -60,10 +62,11 @@
62 Stmt q;
63 char *zComment = 0;
64 char *zTags;
65 char *zDate;
66 char *zUuid;
67 int isFork = 0;
68 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
69 if( zUuid ){
70 zDate = db_text(0,
71 "SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d",
72 rid
@@ -111,17 +114,20 @@
114 }
115 db_finalize(&q);
116 }
117 if( zUuid ){
118 fossil_print("%-13s ", "leaf:");
119 if( is_a_leaf(rid) ){
120 if( db_int(0, "SELECT 1 FROM tagxref AS tx"
121 " WHERE tx.rid=%d"
122 " AND tx.tagid=%d"
123 " AND tx.tagtype>0",
124 rid, TAG_CLOSED)){
125 fossil_print("%s\n", "closed");
126 }else if( fossil_find_nearest_fork(rid) ){
127 fossil_print("%s\n", "fork");
128 isFork = 1;
129 }else{
130 fossil_print("%s\n", "open");
131 }
132 }else{
133 fossil_print("no\n");
@@ -135,10 +141,11 @@
141 if( zComment ){
142 fossil_print("comment: ");
143 comment_print(zComment, 0, 14, -1, g.comFmtFlags);
144 free(zComment);
145 }
146 return isFork;
147 }
148
149 /*
150 ** Print information about the URLs used to access a repository and
151 ** checkouts in a repository.
152
+25 -17
--- src/merge.c
+++ src/merge.c
@@ -53,10 +53,34 @@
5353
fossil_free(zCom);
5454
}
5555
db_finalize(&q);
5656
}
5757
58
+
59
+/* Pick the most recent leaf that is (1) not equal to vid and (2)
60
+** has not already been merged into vid and (3) the leaf is not
61
+** closed and (4) the leaf is in the same branch as vid.
62
+*/
63
+int fossil_find_nearest_fork(int vid){
64
+ return db_int(0,
65
+ "SELECT leaf.rid"
66
+ " FROM leaf, event"
67
+ " WHERE leaf.rid=event.objid"
68
+ " AND leaf.rid!=%d" /* Constraint (1) */
69
+ " AND leaf.rid NOT IN (SELECT merge FROM vmerge)" /* Constraint (2) */
70
+ " AND NOT EXISTS(SELECT 1 FROM tagxref" /* Constraint (3) */
71
+ " WHERE rid=leaf.rid"
72
+ " AND tagid=%d"
73
+ " AND tagtype>0)"
74
+ " AND (SELECT value FROM tagxref" /* Constraint (4) */
75
+ " WHERE tagid=%d AND rid=%d AND tagtype>0) ="
76
+ " (SELECT value FROM tagxref"
77
+ " WHERE tagid=%d AND rid=leaf.rid AND tagtype>0)"
78
+ " ORDER BY event.mtime DESC LIMIT 1",
79
+ vid, TAG_CLOSED, TAG_BRANCH, vid, TAG_BRANCH
80
+ );
81
+}
5882
5983
/*
6084
** COMMAND: merge
6185
**
6286
** Usage: %fossil merge ?OPTIONS? ?VERSION?
@@ -172,27 +196,11 @@
172196
*/
173197
Stmt q;
174198
if( pickFlag || backoutFlag || integrateFlag){
175199
fossil_fatal("cannot use --backout, --cherrypick or --integrate with a fork merge");
176200
}
177
- mid = db_int(0,
178
- "SELECT leaf.rid"
179
- " FROM leaf, event"
180
- " WHERE leaf.rid=event.objid"
181
- " AND leaf.rid!=%d" /* Constraint (1) */
182
- " AND leaf.rid NOT IN (SELECT merge FROM vmerge)" /* Constraint (2) */
183
- " AND NOT EXISTS(SELECT 1 FROM tagxref" /* Constraint (3) */
184
- " WHERE rid=leaf.rid"
185
- " AND tagid=%d"
186
- " AND tagtype>0)"
187
- " AND (SELECT value FROM tagxref" /* Constraint (4) */
188
- " WHERE tagid=%d AND rid=%d AND tagtype>0) ="
189
- " (SELECT value FROM tagxref"
190
- " WHERE tagid=%d AND rid=leaf.rid AND tagtype>0)"
191
- " ORDER BY event.mtime DESC LIMIT 1",
192
- vid, TAG_CLOSED, TAG_BRANCH, vid, TAG_BRANCH
193
- );
201
+ mid = fossil_find_nearest_fork(vid);
194202
if( mid==0 ){
195203
fossil_fatal("no unmerged forks of branch \"%s\"",
196204
db_text(0, "SELECT value FROM tagxref"
197205
" WHERE tagid=%d AND rid=%d AND tagtype>0",
198206
TAG_BRANCH, vid)
199207
--- src/merge.c
+++ src/merge.c
@@ -53,10 +53,34 @@
53 fossil_free(zCom);
54 }
55 db_finalize(&q);
56 }
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
59 /*
60 ** COMMAND: merge
61 **
62 ** Usage: %fossil merge ?OPTIONS? ?VERSION?
@@ -172,27 +196,11 @@
172 */
173 Stmt q;
174 if( pickFlag || backoutFlag || integrateFlag){
175 fossil_fatal("cannot use --backout, --cherrypick or --integrate with a fork merge");
176 }
177 mid = db_int(0,
178 "SELECT leaf.rid"
179 " FROM leaf, event"
180 " WHERE leaf.rid=event.objid"
181 " AND leaf.rid!=%d" /* Constraint (1) */
182 " AND leaf.rid NOT IN (SELECT merge FROM vmerge)" /* Constraint (2) */
183 " AND NOT EXISTS(SELECT 1 FROM tagxref" /* Constraint (3) */
184 " WHERE rid=leaf.rid"
185 " AND tagid=%d"
186 " AND tagtype>0)"
187 " AND (SELECT value FROM tagxref" /* Constraint (4) */
188 " WHERE tagid=%d AND rid=%d AND tagtype>0) ="
189 " (SELECT value FROM tagxref"
190 " WHERE tagid=%d AND rid=leaf.rid AND tagtype>0)"
191 " ORDER BY event.mtime DESC LIMIT 1",
192 vid, TAG_CLOSED, TAG_BRANCH, vid, TAG_BRANCH
193 );
194 if( mid==0 ){
195 fossil_fatal("no unmerged forks of branch \"%s\"",
196 db_text(0, "SELECT value FROM tagxref"
197 " WHERE tagid=%d AND rid=%d AND tagtype>0",
198 TAG_BRANCH, vid)
199
--- src/merge.c
+++ src/merge.c
@@ -53,10 +53,34 @@
53 fossil_free(zCom);
54 }
55 db_finalize(&q);
56 }
57
58
59 /* Pick the most recent leaf that is (1) not equal to vid and (2)
60 ** has not already been merged into vid and (3) the leaf is not
61 ** closed and (4) the leaf is in the same branch as vid.
62 */
63 int fossil_find_nearest_fork(int vid){
64 return db_int(0,
65 "SELECT leaf.rid"
66 " FROM leaf, event"
67 " WHERE leaf.rid=event.objid"
68 " AND leaf.rid!=%d" /* Constraint (1) */
69 " AND leaf.rid NOT IN (SELECT merge FROM vmerge)" /* Constraint (2) */
70 " AND NOT EXISTS(SELECT 1 FROM tagxref" /* Constraint (3) */
71 " WHERE rid=leaf.rid"
72 " AND tagid=%d"
73 " AND tagtype>0)"
74 " AND (SELECT value FROM tagxref" /* Constraint (4) */
75 " WHERE tagid=%d AND rid=%d AND tagtype>0) ="
76 " (SELECT value FROM tagxref"
77 " WHERE tagid=%d AND rid=leaf.rid AND tagtype>0)"
78 " ORDER BY event.mtime DESC LIMIT 1",
79 vid, TAG_CLOSED, TAG_BRANCH, vid, TAG_BRANCH
80 );
81 }
82
83 /*
84 ** COMMAND: merge
85 **
86 ** Usage: %fossil merge ?OPTIONS? ?VERSION?
@@ -172,27 +196,11 @@
196 */
197 Stmt q;
198 if( pickFlag || backoutFlag || integrateFlag){
199 fossil_fatal("cannot use --backout, --cherrypick or --integrate with a fork merge");
200 }
201 mid = fossil_find_nearest_fork(vid);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202 if( mid==0 ){
203 fossil_fatal("no unmerged forks of branch \"%s\"",
204 db_text(0, "SELECT value FROM tagxref"
205 " WHERE tagid=%d AND rid=%d AND tagtype>0",
206 TAG_BRANCH, vid)
207
+6 -2
--- src/update.c
+++ src/update.c
@@ -121,10 +121,11 @@
121121
int nOverwrite = 0; /* Number of unmanaged files overwritten */
122122
int nUpdate = 0; /* Number of changes of any kind */
123123
int width; /* Width of printed comment lines */
124124
Stmt mtimeXfer; /* Statement to transfer mtimes */
125125
const char *zWidth; /* Width option string value */
126
+ int isFork;
126127
127128
if( !internalUpdate ){
128129
undo_capture_command_line();
129130
url_proxy_options();
130131
}
@@ -518,14 +519,14 @@
518519
}
519520
db_finalize(&q);
520521
db_finalize(&mtimeXfer);
521522
fossil_print("%.79c\n",'-');
522523
if( nUpdate==0 ){
523
- show_common_info(tid, "checkout:", 1, 0);
524
+ isFork = show_common_info(tid, "checkout:", 1, 0);
524525
fossil_print("%-13s None. Already up-to-date\n", "changes:");
525526
}else{
526
- show_common_info(tid, "updated-to:", 1, 0);
527
+ isFork = show_common_info(tid, "updated-to:", 1, 0);
527528
fossil_print("%-13s %d file%s modified.\n", "changes:",
528529
nUpdate, nUpdate>1 ? "s" : "");
529530
}
530531
531532
/* Report on conflicts
@@ -560,10 +561,13 @@
560561
nOverwrite);
561562
}
562563
if( nMerge ){
563564
fossil_warning("WARNING: %d uncommitted prior merges", nMerge);
564565
}
566
+ if( isFork ){
567
+ fossil_warning("WARNING: fork detected, please do a \"fossil merge\"");
568
+ }
565569
}
566570
567571
/*
568572
** Clean up the mid and pid VFILE entries. Then commit the changes.
569573
*/
570574
--- src/update.c
+++ src/update.c
@@ -121,10 +121,11 @@
121 int nOverwrite = 0; /* Number of unmanaged files overwritten */
122 int nUpdate = 0; /* Number of changes of any kind */
123 int width; /* Width of printed comment lines */
124 Stmt mtimeXfer; /* Statement to transfer mtimes */
125 const char *zWidth; /* Width option string value */
 
126
127 if( !internalUpdate ){
128 undo_capture_command_line();
129 url_proxy_options();
130 }
@@ -518,14 +519,14 @@
518 }
519 db_finalize(&q);
520 db_finalize(&mtimeXfer);
521 fossil_print("%.79c\n",'-');
522 if( nUpdate==0 ){
523 show_common_info(tid, "checkout:", 1, 0);
524 fossil_print("%-13s None. Already up-to-date\n", "changes:");
525 }else{
526 show_common_info(tid, "updated-to:", 1, 0);
527 fossil_print("%-13s %d file%s modified.\n", "changes:",
528 nUpdate, nUpdate>1 ? "s" : "");
529 }
530
531 /* Report on conflicts
@@ -560,10 +561,13 @@
560 nOverwrite);
561 }
562 if( nMerge ){
563 fossil_warning("WARNING: %d uncommitted prior merges", nMerge);
564 }
 
 
 
565 }
566
567 /*
568 ** Clean up the mid and pid VFILE entries. Then commit the changes.
569 */
570
--- src/update.c
+++ src/update.c
@@ -121,10 +121,11 @@
121 int nOverwrite = 0; /* Number of unmanaged files overwritten */
122 int nUpdate = 0; /* Number of changes of any kind */
123 int width; /* Width of printed comment lines */
124 Stmt mtimeXfer; /* Statement to transfer mtimes */
125 const char *zWidth; /* Width option string value */
126 int isFork;
127
128 if( !internalUpdate ){
129 undo_capture_command_line();
130 url_proxy_options();
131 }
@@ -518,14 +519,14 @@
519 }
520 db_finalize(&q);
521 db_finalize(&mtimeXfer);
522 fossil_print("%.79c\n",'-');
523 if( nUpdate==0 ){
524 isFork = show_common_info(tid, "checkout:", 1, 0);
525 fossil_print("%-13s None. Already up-to-date\n", "changes:");
526 }else{
527 isFork = show_common_info(tid, "updated-to:", 1, 0);
528 fossil_print("%-13s %d file%s modified.\n", "changes:",
529 nUpdate, nUpdate>1 ? "s" : "");
530 }
531
532 /* Report on conflicts
@@ -560,10 +561,13 @@
561 nOverwrite);
562 }
563 if( nMerge ){
564 fossil_warning("WARNING: %d uncommitted prior merges", nMerge);
565 }
566 if( isFork ){
567 fossil_warning("WARNING: fork detected, please do a \"fossil merge\"");
568 }
569 }
570
571 /*
572 ** Clean up the mid and pid VFILE entries. Then commit the changes.
573 */
574
--- www/changes.wiki
+++ www/changes.wiki
@@ -9,10 +9,12 @@
99
* Fix some obscure issues with TH1 expression processing.
1010
* Fix titles in search results for documents that are not wiki, markdown,
1111
or HTML.
1212
* Formally translate TH1 to Tcl return codes and vice-versa, where
1313
necessary, in the Tcl integration subsystem.
14
+ * Better fork detection on [/help?cmd=import|fossil update],
15
+ [/help?cmd=import|fossil status] and related commands.
1416
1517
<h2>Changes for Version 1.32 (2015-03-14)</h2>
1618
* When creating a new repository using [/help?cmd=init|fossil init], ensure
1719
that the new repository is fully compatible with historical versions of
1820
Fossil by having a valid manifest as RID 1.
1921
--- www/changes.wiki
+++ www/changes.wiki
@@ -9,10 +9,12 @@
9 * Fix some obscure issues with TH1 expression processing.
10 * Fix titles in search results for documents that are not wiki, markdown,
11 or HTML.
12 * Formally translate TH1 to Tcl return codes and vice-versa, where
13 necessary, in the Tcl integration subsystem.
 
 
14
15 <h2>Changes for Version 1.32 (2015-03-14)</h2>
16 * When creating a new repository using [/help?cmd=init|fossil init], ensure
17 that the new repository is fully compatible with historical versions of
18 Fossil by having a valid manifest as RID 1.
19
--- www/changes.wiki
+++ www/changes.wiki
@@ -9,10 +9,12 @@
9 * Fix some obscure issues with TH1 expression processing.
10 * Fix titles in search results for documents that are not wiki, markdown,
11 or HTML.
12 * Formally translate TH1 to Tcl return codes and vice-versa, where
13 necessary, in the Tcl integration subsystem.
14 * Better fork detection on [/help?cmd=import|fossil update],
15 [/help?cmd=import|fossil status] and related commands.
16
17 <h2>Changes for Version 1.32 (2015-03-14)</h2>
18 * When creating a new repository using [/help?cmd=init|fossil init], ensure
19 that the new repository is fully compatible with historical versions of
20 Fossil by having a valid manifest as RID 1.
21
--- www/changes.wiki
+++ www/changes.wiki
@@ -9,10 +9,12 @@
99
* Fix some obscure issues with TH1 expression processing.
1010
* Fix titles in search results for documents that are not wiki, markdown,
1111
or HTML.
1212
* Formally translate TH1 to Tcl return codes and vice-versa, where
1313
necessary, in the Tcl integration subsystem.
14
+ * Better fork detection on [/help?cmd=import|fossil update],
15
+ [/help?cmd=import|fossil status] and related commands.
1416
1517
<h2>Changes for Version 1.32 (2015-03-14)</h2>
1618
* When creating a new repository using [/help?cmd=init|fossil init], ensure
1719
that the new repository is fully compatible with historical versions of
1820
Fossil by having a valid manifest as RID 1.
1921
--- www/changes.wiki
+++ www/changes.wiki
@@ -9,10 +9,12 @@
9 * Fix some obscure issues with TH1 expression processing.
10 * Fix titles in search results for documents that are not wiki, markdown,
11 or HTML.
12 * Formally translate TH1 to Tcl return codes and vice-versa, where
13 necessary, in the Tcl integration subsystem.
 
 
14
15 <h2>Changes for Version 1.32 (2015-03-14)</h2>
16 * When creating a new repository using [/help?cmd=init|fossil init], ensure
17 that the new repository is fully compatible with historical versions of
18 Fossil by having a valid manifest as RID 1.
19
--- www/changes.wiki
+++ www/changes.wiki
@@ -9,10 +9,12 @@
9 * Fix some obscure issues with TH1 expression processing.
10 * Fix titles in search results for documents that are not wiki, markdown,
11 or HTML.
12 * Formally translate TH1 to Tcl return codes and vice-versa, where
13 necessary, in the Tcl integration subsystem.
14 * Better fork detection on [/help?cmd=import|fossil update],
15 [/help?cmd=import|fossil status] and related commands.
16
17 <h2>Changes for Version 1.32 (2015-03-14)</h2>
18 * When creating a new repository using [/help?cmd=init|fossil init], ensure
19 that the new repository is fully compatible with historical versions of
20 Fossil by having a valid manifest as RID 1.
21

Keyboard Shortcuts

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