Fossil SCM

Enhance the --detail option on the "merge" command to show the specific check-in that is being merged in and the baseline of the merge.

drh 2012-02-03 15:05 trunk
Commit 68d84047c0a4dcce7264d12bd324d334ea5371f7
1 file changed +37 -1
+37 -1
--- src/merge.c
+++ src/merge.c
@@ -20,10 +20,43 @@
2020
*/
2121
#include "config.h"
2222
#include "merge.h"
2323
#include <assert.h>
2424
25
+/*
26
+** Print information about a particular check-in.
27
+*/
28
+void print_checkin_description(int rid, int indent, const char *zLabel){
29
+ Stmt q;
30
+ db_prepare(&q,
31
+ "SELECT datetime(mtime,'localtime'),"
32
+ " coalesce(euser,user), coalesce(ecomment,comment),"
33
+ " (SELECT uuid FROM blob WHERE rid=%d),"
34
+ " (SELECT group_concat(substr(tagname,5), ', ') FROM tag, tagxref"
35
+ " WHERE tagname GLOB 'sym-*' AND tag.tagid=tagxref.tagid"
36
+ " AND tagxref.rid=%d AND tagxref.tagtype>0)"
37
+ " FROM event WHERE objid=%d", rid, rid, rid);
38
+ if( db_step(&q)==SQLITE_ROW ){
39
+ const char *zTagList = db_column_text(&q, 4);
40
+ char *zCom;
41
+ if( zTagList && zTagList[0] ){
42
+ zCom = mprintf("%s (%s)", db_column_text(&q, 2), zTagList);
43
+ }else{
44
+ zCom = mprintf("%s", db_column_text(&q,2));
45
+ }
46
+ fossil_print("%-*s [%S] by %s on %s\n%*s",
47
+ indent-1, zLabel,
48
+ db_column_text(&q, 3),
49
+ db_column_text(&q, 1),
50
+ db_column_text(&q, 0),
51
+ indent, "");
52
+ comment_print(zCom, indent, 78);
53
+ fossil_free(zCom);
54
+ }
55
+ db_finalize(&q);
56
+}
57
+
2558
2659
/*
2760
** COMMAND: merge
2861
**
2962
** Usage: %fossil merge ?OPTIONS? VERSION
@@ -116,11 +149,10 @@
116149
fossil_fatal("not a version: %s", zPivot);
117150
}
118151
if( pickFlag ){
119152
fossil_fatal("incompatible options: --cherrypick & --baseline");
120153
}
121
- /* pickFlag = 1; // Using --baseline is really like doing a cherrypick */
122154
}else if( pickFlag || backoutFlag ){
123155
pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid);
124156
if( pid<=0 ){
125157
fossil_fatal("cannot find an ancestor for %s", g.argv[2]);
126158
}
@@ -144,10 +176,14 @@
144176
mid = t;
145177
}
146178
if( !is_a_version(pid) ){
147179
fossil_fatal("not a version: record #%d", pid);
148180
}
181
+ if( detailFlag ){
182
+ print_checkin_description(mid, 12, "merge-from:");
183
+ print_checkin_description(pid, 12, "baseline:");
184
+ }
149185
vfile_check_signature(vid, 1, 0);
150186
db_begin_transaction();
151187
if( !nochangeFlag ) undo_begin();
152188
load_vfile_from_rid(mid);
153189
load_vfile_from_rid(pid);
154190
--- src/merge.c
+++ src/merge.c
@@ -20,10 +20,43 @@
20 */
21 #include "config.h"
22 #include "merge.h"
23 #include <assert.h>
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
26 /*
27 ** COMMAND: merge
28 **
29 ** Usage: %fossil merge ?OPTIONS? VERSION
@@ -116,11 +149,10 @@
116 fossil_fatal("not a version: %s", zPivot);
117 }
118 if( pickFlag ){
119 fossil_fatal("incompatible options: --cherrypick & --baseline");
120 }
121 /* pickFlag = 1; // Using --baseline is really like doing a cherrypick */
122 }else if( pickFlag || backoutFlag ){
123 pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid);
124 if( pid<=0 ){
125 fossil_fatal("cannot find an ancestor for %s", g.argv[2]);
126 }
@@ -144,10 +176,14 @@
144 mid = t;
145 }
146 if( !is_a_version(pid) ){
147 fossil_fatal("not a version: record #%d", pid);
148 }
 
 
 
 
149 vfile_check_signature(vid, 1, 0);
150 db_begin_transaction();
151 if( !nochangeFlag ) undo_begin();
152 load_vfile_from_rid(mid);
153 load_vfile_from_rid(pid);
154
--- src/merge.c
+++ src/merge.c
@@ -20,10 +20,43 @@
20 */
21 #include "config.h"
22 #include "merge.h"
23 #include <assert.h>
24
25 /*
26 ** Print information about a particular check-in.
27 */
28 void print_checkin_description(int rid, int indent, const char *zLabel){
29 Stmt q;
30 db_prepare(&q,
31 "SELECT datetime(mtime,'localtime'),"
32 " coalesce(euser,user), coalesce(ecomment,comment),"
33 " (SELECT uuid FROM blob WHERE rid=%d),"
34 " (SELECT group_concat(substr(tagname,5), ', ') FROM tag, tagxref"
35 " WHERE tagname GLOB 'sym-*' AND tag.tagid=tagxref.tagid"
36 " AND tagxref.rid=%d AND tagxref.tagtype>0)"
37 " FROM event WHERE objid=%d", rid, rid, rid);
38 if( db_step(&q)==SQLITE_ROW ){
39 const char *zTagList = db_column_text(&q, 4);
40 char *zCom;
41 if( zTagList && zTagList[0] ){
42 zCom = mprintf("%s (%s)", db_column_text(&q, 2), zTagList);
43 }else{
44 zCom = mprintf("%s", db_column_text(&q,2));
45 }
46 fossil_print("%-*s [%S] by %s on %s\n%*s",
47 indent-1, zLabel,
48 db_column_text(&q, 3),
49 db_column_text(&q, 1),
50 db_column_text(&q, 0),
51 indent, "");
52 comment_print(zCom, indent, 78);
53 fossil_free(zCom);
54 }
55 db_finalize(&q);
56 }
57
58
59 /*
60 ** COMMAND: merge
61 **
62 ** Usage: %fossil merge ?OPTIONS? VERSION
@@ -116,11 +149,10 @@
149 fossil_fatal("not a version: %s", zPivot);
150 }
151 if( pickFlag ){
152 fossil_fatal("incompatible options: --cherrypick & --baseline");
153 }
 
154 }else if( pickFlag || backoutFlag ){
155 pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid);
156 if( pid<=0 ){
157 fossil_fatal("cannot find an ancestor for %s", g.argv[2]);
158 }
@@ -144,10 +176,14 @@
176 mid = t;
177 }
178 if( !is_a_version(pid) ){
179 fossil_fatal("not a version: record #%d", pid);
180 }
181 if( detailFlag ){
182 print_checkin_description(mid, 12, "merge-from:");
183 print_checkin_description(pid, 12, "baseline:");
184 }
185 vfile_check_signature(vid, 1, 0);
186 db_begin_transaction();
187 if( !nochangeFlag ) undo_begin();
188 load_vfile_from_rid(mid);
189 load_vfile_from_rid(pid);
190

Keyboard Shortcuts

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