Fossil SCM

Add a warning to "fossil update" when a fork has occurred.

jan.nijtmans 2015-04-10 07:55 UTC trunk
Commit 32998a20f90bc6a235fde171d32a7499a4487055
2 files changed +25 -17 +3
+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
--- src/update.c
+++ src/update.c
@@ -560,10 +560,13 @@
560560
nOverwrite);
561561
}
562562
if( nMerge ){
563563
fossil_warning("WARNING: %d uncommitted prior merges", nMerge);
564564
}
565
+ if( fossil_find_nearest_fork(tid) ){
566
+ fossil_warning("WARNING: fork detected, please do a \"fossil merge\"");
567
+ }
565568
}
566569
567570
/*
568571
** Clean up the mid and pid VFILE entries. Then commit the changes.
569572
*/
570573
--- src/update.c
+++ src/update.c
@@ -560,10 +560,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
@@ -560,10 +560,13 @@
560 nOverwrite);
561 }
562 if( nMerge ){
563 fossil_warning("WARNING: %d uncommitted prior merges", nMerge);
564 }
565 if( fossil_find_nearest_fork(tid) ){
566 fossil_warning("WARNING: fork detected, please do a \"fossil merge\"");
567 }
568 }
569
570 /*
571 ** Clean up the mid and pid VFILE entries. Then commit the changes.
572 */
573

Keyboard Shortcuts

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