Fossil SCM

Update the "checkin" command so that the template check-in message contains a comment that shows the branch tags that will be associated with the new check-in.

drh 2009-12-17 14:51 trunk
Commit 6df39e37f2094628ecdda8f3575deabfa63c5fa9
2 files changed +22 -2 +19 -6
+22 -2
--- src/checkin.c
+++ src/checkin.c
@@ -261,12 +261,26 @@
261261
** editor specified in the global_config table or either
262262
** the VISUAL or EDITOR environment variable.
263263
**
264264
** Store the final commit comment in pComment. pComment is assumed
265265
** to be uninitialized - any prior content is overwritten.
266
+**
267
+** zInit is the text of the most recent failed attempt to check in
268
+** this same change. Use zInit to reinitialize the check-in comment
269
+** so that the user does not have to retype.
270
+**
271
+** zBranch is the name of a new branch that this check-in is forced into.
272
+** zBranch might be NULL or an empty string if no forcing occurs.
273
+**
274
+** parent_rid is the recordid of the parent check-in.
266275
*/
267
-static void prepare_commit_comment(Blob *pComment, char *zInit){
276
+static void prepare_commit_comment(
277
+ Blob *pComment,
278
+ char *zInit,
279
+ const char *zBranch,
280
+ int parent_rid
281
+){
268282
const char *zEditor;
269283
char *zCmd;
270284
char *zFile;
271285
Blob text, line;
272286
char *zComment;
@@ -276,10 +290,16 @@
276290
"\n"
277291
"# Enter comments on this check-in. Lines beginning with # are ignored.\n"
278292
"# The check-in comment follows wiki formatting rules.\n"
279293
"#\n", -1
280294
);
295
+ if( zBranch && zBranch[0] ){
296
+ blob_appendf(&text, "# tags: %s\n#\n", zBranch);
297
+ }else{
298
+ char *zTags = info_tags_of_checkin(parent_rid);
299
+ if( zTags ) blob_appendf(&text, "# tags: %z\n#\n", zTags);
300
+ }
281301
if( g.markPrivate ){
282302
blob_append(&text,
283303
"# PRIVATE BRANCH: This check-in will be private and will not sync to\n"
284304
"# repositories.\n"
285305
"#\n", -1
@@ -558,11 +578,11 @@
558578
}else if( zCommentFile ){
559579
blob_zero(&comment);
560580
blob_read_from_file(&comment, zCommentFile);
561581
}else{
562582
char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'");
563
- prepare_commit_comment(&comment, zInit);
583
+ prepare_commit_comment(&comment, zInit, zBranch, vid);
564584
free(zInit);
565585
}
566586
if( blob_size(&comment)==0 ){
567587
Blob ans;
568588
blob_zero(&ans);
569589
--- src/checkin.c
+++ src/checkin.c
@@ -261,12 +261,26 @@
261 ** editor specified in the global_config table or either
262 ** the VISUAL or EDITOR environment variable.
263 **
264 ** Store the final commit comment in pComment. pComment is assumed
265 ** to be uninitialized - any prior content is overwritten.
 
 
 
 
 
 
 
 
 
266 */
267 static void prepare_commit_comment(Blob *pComment, char *zInit){
 
 
 
 
 
268 const char *zEditor;
269 char *zCmd;
270 char *zFile;
271 Blob text, line;
272 char *zComment;
@@ -276,10 +290,16 @@
276 "\n"
277 "# Enter comments on this check-in. Lines beginning with # are ignored.\n"
278 "# The check-in comment follows wiki formatting rules.\n"
279 "#\n", -1
280 );
 
 
 
 
 
 
281 if( g.markPrivate ){
282 blob_append(&text,
283 "# PRIVATE BRANCH: This check-in will be private and will not sync to\n"
284 "# repositories.\n"
285 "#\n", -1
@@ -558,11 +578,11 @@
558 }else if( zCommentFile ){
559 blob_zero(&comment);
560 blob_read_from_file(&comment, zCommentFile);
561 }else{
562 char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'");
563 prepare_commit_comment(&comment, zInit);
564 free(zInit);
565 }
566 if( blob_size(&comment)==0 ){
567 Blob ans;
568 blob_zero(&ans);
569
--- src/checkin.c
+++ src/checkin.c
@@ -261,12 +261,26 @@
261 ** editor specified in the global_config table or either
262 ** the VISUAL or EDITOR environment variable.
263 **
264 ** Store the final commit comment in pComment. pComment is assumed
265 ** to be uninitialized - any prior content is overwritten.
266 **
267 ** zInit is the text of the most recent failed attempt to check in
268 ** this same change. Use zInit to reinitialize the check-in comment
269 ** so that the user does not have to retype.
270 **
271 ** zBranch is the name of a new branch that this check-in is forced into.
272 ** zBranch might be NULL or an empty string if no forcing occurs.
273 **
274 ** parent_rid is the recordid of the parent check-in.
275 */
276 static void prepare_commit_comment(
277 Blob *pComment,
278 char *zInit,
279 const char *zBranch,
280 int parent_rid
281 ){
282 const char *zEditor;
283 char *zCmd;
284 char *zFile;
285 Blob text, line;
286 char *zComment;
@@ -276,10 +290,16 @@
290 "\n"
291 "# Enter comments on this check-in. Lines beginning with # are ignored.\n"
292 "# The check-in comment follows wiki formatting rules.\n"
293 "#\n", -1
294 );
295 if( zBranch && zBranch[0] ){
296 blob_appendf(&text, "# tags: %s\n#\n", zBranch);
297 }else{
298 char *zTags = info_tags_of_checkin(parent_rid);
299 if( zTags ) blob_appendf(&text, "# tags: %z\n#\n", zTags);
300 }
301 if( g.markPrivate ){
302 blob_append(&text,
303 "# PRIVATE BRANCH: This check-in will be private and will not sync to\n"
304 "# repositories.\n"
305 "#\n", -1
@@ -558,11 +578,11 @@
578 }else if( zCommentFile ){
579 blob_zero(&comment);
580 blob_read_from_file(&comment, zCommentFile);
581 }else{
582 char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'");
583 prepare_commit_comment(&comment, zInit, zBranch, vid);
584 free(zInit);
585 }
586 if( blob_size(&comment)==0 ){
587 Blob ans;
588 blob_zero(&ans);
589
+19 -6
--- src/info.c
+++ src/info.c
@@ -27,10 +27,28 @@
2727
*/
2828
#include "config.h"
2929
#include "info.h"
3030
#include <assert.h>
3131
32
+/*
33
+** Return a string (in memory obtained from malloc) holding a
34
+** comma-separated list of tags that apply to check-in with
35
+** record-id rid.
36
+**
37
+** Return NULL if there are no such tags.
38
+*/
39
+char *info_tags_of_checkin(int rid){
40
+ char *zTags;
41
+ zTags = db_text(0, "SELECT group_concat(substr(tagname, 5), ', ')"
42
+ " FROM tagxref, tag"
43
+ " WHERE tagxref.rid=%d AND tagxref.tagtype>0"
44
+ " AND tag.tagid=tagxref.tagid"
45
+ " AND tag.tagname GLOB 'sym-*'",
46
+ rid);
47
+ return zTags;
48
+}
49
+
3250
3351
/*
3452
** Print common information about a particular record.
3553
**
3654
** * The UUID
@@ -77,16 +95,11 @@
7795
);
7896
printf("child: %s %s\n", zUuid, zDate);
7997
free(zDate);
8098
}
8199
db_finalize(&q);
82
- zTags = db_text(0, "SELECT group_concat(substr(tagname, 5), ', ')"
83
- " FROM tagxref, tag"
84
- " WHERE tagxref.rid=%d AND tagxref.tagtype>0"
85
- " AND tag.tagid=tagxref.tagid"
86
- " AND tag.tagname GLOB 'sym-*'",
87
- rid);
100
+ zTags = info_tags_of_checkin(rid);
88101
if( zTags && zTags[0] ){
89102
printf("tags: %s\n", zTags);
90103
}
91104
free(zTags);
92105
if( zComment ){
93106
--- src/info.c
+++ src/info.c
@@ -27,10 +27,28 @@
27 */
28 #include "config.h"
29 #include "info.h"
30 #include <assert.h>
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
33 /*
34 ** Print common information about a particular record.
35 **
36 ** * The UUID
@@ -77,16 +95,11 @@
77 );
78 printf("child: %s %s\n", zUuid, zDate);
79 free(zDate);
80 }
81 db_finalize(&q);
82 zTags = db_text(0, "SELECT group_concat(substr(tagname, 5), ', ')"
83 " FROM tagxref, tag"
84 " WHERE tagxref.rid=%d AND tagxref.tagtype>0"
85 " AND tag.tagid=tagxref.tagid"
86 " AND tag.tagname GLOB 'sym-*'",
87 rid);
88 if( zTags && zTags[0] ){
89 printf("tags: %s\n", zTags);
90 }
91 free(zTags);
92 if( zComment ){
93
--- src/info.c
+++ src/info.c
@@ -27,10 +27,28 @@
27 */
28 #include "config.h"
29 #include "info.h"
30 #include <assert.h>
31
32 /*
33 ** Return a string (in memory obtained from malloc) holding a
34 ** comma-separated list of tags that apply to check-in with
35 ** record-id rid.
36 **
37 ** Return NULL if there are no such tags.
38 */
39 char *info_tags_of_checkin(int rid){
40 char *zTags;
41 zTags = db_text(0, "SELECT group_concat(substr(tagname, 5), ', ')"
42 " FROM tagxref, tag"
43 " WHERE tagxref.rid=%d AND tagxref.tagtype>0"
44 " AND tag.tagid=tagxref.tagid"
45 " AND tag.tagname GLOB 'sym-*'",
46 rid);
47 return zTags;
48 }
49
50
51 /*
52 ** Print common information about a particular record.
53 **
54 ** * The UUID
@@ -77,16 +95,11 @@
95 );
96 printf("child: %s %s\n", zUuid, zDate);
97 free(zDate);
98 }
99 db_finalize(&q);
100 zTags = info_tags_of_checkin(rid);
 
 
 
 
 
101 if( zTags && zTags[0] ){
102 printf("tags: %s\n", zTags);
103 }
104 free(zTags);
105 if( zComment ){
106

Keyboard Shortcuts

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