Fossil SCM

Add an option to the 'timeline' command to display only items on a specific branch.

danield 2022-05-11 20:51 trunk
Commit 32b11546c830e3285a0322c7469c550d6f96f8667fc0b0ae42ffb6163acc7043
1 file changed +34 -2
+34 -2
--- src/timeline.c
+++ src/timeline.c
@@ -3108,10 +3108,12 @@
31083108
** (westward) or "+HH:MM" (eastward). Either no timezone suffix or "Z"
31093109
** means UTC.
31103110
**
31113111
**
31123112
** Options:
3113
+** -b|--branch BRANCH Show only items on the branch named BRANCH
3114
+** -c|--current-branch Show only items on the current branch
31133115
** -F|--format Entry format. Values "oneline", "medium", and "full"
31143116
** get mapped to the full options below. Otherwise a
31153117
** string which can contain these placeholders:
31163118
** %n newline
31173119
** %% a raw %
@@ -3125,20 +3127,18 @@
31253127
** %p phase: zero or more of *CURRENT*, *MERGE*,
31263128
** *FORK*, *UNPUBLISHED*, *LEAF*, *BRANCH*
31273129
** --oneline Show only short hash and comment for each entry
31283130
** --medium Medium-verbose entry formatting
31293131
** --full Extra verbose entry formatting
3130
-**
31313132
** -n|--limit N If N is positive, output the first N entries. If
31323133
** N is negative, output the first -N lines. If N is
31333134
** zero, no limit. Default is -20 meaning 20 lines.
31343135
** --offset P skip P changes
31353136
** -p|--path PATH Output items affecting PATH only.
31363137
** PATH can be a file or a sub directory.
31373138
** -R REPO_FILE Specifies the repository db to use. Default is
31383139
** the current checkout's repository.
3139
-
31403140
** --sql Show the SQL used to generate the timeline
31413141
** -t|--type TYPE Output items from the given types only, such as:
31423142
** ci = file commits only
31433143
** e = technical notes only
31443144
** f = forum posts only
@@ -3167,10 +3167,11 @@
31673167
int mode = TIMELINE_MODE_NONE;
31683168
int verboseFlag = 0 ;
31693169
int iOffset;
31703170
const char *zFilePattern = 0;
31713171
const char *zFormat = 0;
3172
+ const char *zBr = 0;
31723173
Blob treeName;
31733174
int showSql = 0;
31743175
31753176
verboseFlag = find_option("verbose","v", 0)!=0;
31763177
if( !verboseFlag){
@@ -3180,10 +3181,20 @@
31803181
zLimit = find_option("limit","n",1);
31813182
zWidth = find_option("width","W",1);
31823183
zType = find_option("type","t",1);
31833184
zFilePattern = find_option("path","p",1);
31843185
zFormat = find_option("format","F",1);
3186
+ zBr = find_option("branch","b",1);
3187
+ if( find_option("current-branch","c",0)!=0 ){
3188
+ if( !g.localOpen ){
3189
+ fossil_fatal("not within an open checkout");
3190
+ }else{
3191
+ int vid = db_lget_int("checkout", 0);
3192
+ zBr = db_text(0, "SELECT value FROM tagxref WHERE rid=%d AND tagid=%d",
3193
+ vid, TAG_BRANCH);
3194
+ }
3195
+ }
31853196
if( find_option("oneline",0,0)!= 0 || fossil_strcmp(zFormat,"oneline")==0 )
31863197
zFormat = "%h %c";
31873198
if( find_option("medium",0,0)!= 0 || fossil_strcmp(zFormat,"medium")==0 )
31883199
zFormat = "Commit: %h%nDate: %d%nAuthor: %a%nComment: %c%n";
31893200
if( find_option("full",0,0)!= 0 || fossil_strcmp(zFormat,"full")==0 )
@@ -3325,10 +3336,31 @@
33253336
" OR lower(name) GLOB lower('%q/*'))",
33263337
blob_str(&treeName), blob_str(&treeName));
33273338
}
33283339
blob_append(&sql, ")", -1);
33293340
}
3341
+ if( zBr ){
3342
+ blob_append_sql(&sql,
3343
+ "\n AND blob.rid IN (\n" /* Commits */
3344
+ " SELECT rid FROM tagxref NATURAL JOIN tag\n"
3345
+ " WHERE tagtype>0 AND tagname='sym-%q'\n"
3346
+ " UNION\n" /* Tags */
3347
+ " SELECT srcid FROM tagxref WHERE origid IN (\n"
3348
+ " SELECT rid FROM tagxref NATURAL JOIN tag\n"
3349
+ " WHERE tagname='sym-%q')\n"
3350
+ " UNION\n" /* Branch wikis */
3351
+ " SELECT objid FROM event WHERE comment LIKE '_branch/%q'\n"
3352
+ " UNION\n" /* Checkin wikis */
3353
+ " SELECT e.objid FROM event e\n"
3354
+ " INNER JOIN blob b ON b.uuid=substr(e.comment, 10)\n"
3355
+ " AND e.comment LIKE '_checkin/%%'\n"
3356
+ " LEFT JOIN tagxref tx ON tx.rid=b.rid AND tx.tagid=%d\n"
3357
+ " WHERE tx.value='%q'\n"
3358
+ ")\n" /* No merge closures */
3359
+ " AND (tagxref.value IS NULL OR tagxref.value='%q')",
3360
+ zBr, zBr, zBr, TAG_BRANCH, zBr, zBr);
3361
+ }
33303362
blob_append_sql(&sql, "\nORDER BY event.mtime DESC");
33313363
if( iOffset>0 ){
33323364
/* Don't handle LIMIT here, otherwise print_timeline()
33333365
* will not determine the end-marker correctly! */
33343366
blob_append_sql(&sql, "\n LIMIT -1 OFFSET %d", iOffset);
33353367
--- src/timeline.c
+++ src/timeline.c
@@ -3108,10 +3108,12 @@
3108 ** (westward) or "+HH:MM" (eastward). Either no timezone suffix or "Z"
3109 ** means UTC.
3110 **
3111 **
3112 ** Options:
 
 
3113 ** -F|--format Entry format. Values "oneline", "medium", and "full"
3114 ** get mapped to the full options below. Otherwise a
3115 ** string which can contain these placeholders:
3116 ** %n newline
3117 ** %% a raw %
@@ -3125,20 +3127,18 @@
3125 ** %p phase: zero or more of *CURRENT*, *MERGE*,
3126 ** *FORK*, *UNPUBLISHED*, *LEAF*, *BRANCH*
3127 ** --oneline Show only short hash and comment for each entry
3128 ** --medium Medium-verbose entry formatting
3129 ** --full Extra verbose entry formatting
3130 **
3131 ** -n|--limit N If N is positive, output the first N entries. If
3132 ** N is negative, output the first -N lines. If N is
3133 ** zero, no limit. Default is -20 meaning 20 lines.
3134 ** --offset P skip P changes
3135 ** -p|--path PATH Output items affecting PATH only.
3136 ** PATH can be a file or a sub directory.
3137 ** -R REPO_FILE Specifies the repository db to use. Default is
3138 ** the current checkout's repository.
3139
3140 ** --sql Show the SQL used to generate the timeline
3141 ** -t|--type TYPE Output items from the given types only, such as:
3142 ** ci = file commits only
3143 ** e = technical notes only
3144 ** f = forum posts only
@@ -3167,10 +3167,11 @@
3167 int mode = TIMELINE_MODE_NONE;
3168 int verboseFlag = 0 ;
3169 int iOffset;
3170 const char *zFilePattern = 0;
3171 const char *zFormat = 0;
 
3172 Blob treeName;
3173 int showSql = 0;
3174
3175 verboseFlag = find_option("verbose","v", 0)!=0;
3176 if( !verboseFlag){
@@ -3180,10 +3181,20 @@
3180 zLimit = find_option("limit","n",1);
3181 zWidth = find_option("width","W",1);
3182 zType = find_option("type","t",1);
3183 zFilePattern = find_option("path","p",1);
3184 zFormat = find_option("format","F",1);
 
 
 
 
 
 
 
 
 
 
3185 if( find_option("oneline",0,0)!= 0 || fossil_strcmp(zFormat,"oneline")==0 )
3186 zFormat = "%h %c";
3187 if( find_option("medium",0,0)!= 0 || fossil_strcmp(zFormat,"medium")==0 )
3188 zFormat = "Commit: %h%nDate: %d%nAuthor: %a%nComment: %c%n";
3189 if( find_option("full",0,0)!= 0 || fossil_strcmp(zFormat,"full")==0 )
@@ -3325,10 +3336,31 @@
3325 " OR lower(name) GLOB lower('%q/*'))",
3326 blob_str(&treeName), blob_str(&treeName));
3327 }
3328 blob_append(&sql, ")", -1);
3329 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3330 blob_append_sql(&sql, "\nORDER BY event.mtime DESC");
3331 if( iOffset>0 ){
3332 /* Don't handle LIMIT here, otherwise print_timeline()
3333 * will not determine the end-marker correctly! */
3334 blob_append_sql(&sql, "\n LIMIT -1 OFFSET %d", iOffset);
3335
--- src/timeline.c
+++ src/timeline.c
@@ -3108,10 +3108,12 @@
3108 ** (westward) or "+HH:MM" (eastward). Either no timezone suffix or "Z"
3109 ** means UTC.
3110 **
3111 **
3112 ** Options:
3113 ** -b|--branch BRANCH Show only items on the branch named BRANCH
3114 ** -c|--current-branch Show only items on the current branch
3115 ** -F|--format Entry format. Values "oneline", "medium", and "full"
3116 ** get mapped to the full options below. Otherwise a
3117 ** string which can contain these placeholders:
3118 ** %n newline
3119 ** %% a raw %
@@ -3125,20 +3127,18 @@
3127 ** %p phase: zero or more of *CURRENT*, *MERGE*,
3128 ** *FORK*, *UNPUBLISHED*, *LEAF*, *BRANCH*
3129 ** --oneline Show only short hash and comment for each entry
3130 ** --medium Medium-verbose entry formatting
3131 ** --full Extra verbose entry formatting
 
3132 ** -n|--limit N If N is positive, output the first N entries. If
3133 ** N is negative, output the first -N lines. If N is
3134 ** zero, no limit. Default is -20 meaning 20 lines.
3135 ** --offset P skip P changes
3136 ** -p|--path PATH Output items affecting PATH only.
3137 ** PATH can be a file or a sub directory.
3138 ** -R REPO_FILE Specifies the repository db to use. Default is
3139 ** the current checkout's repository.
 
3140 ** --sql Show the SQL used to generate the timeline
3141 ** -t|--type TYPE Output items from the given types only, such as:
3142 ** ci = file commits only
3143 ** e = technical notes only
3144 ** f = forum posts only
@@ -3167,10 +3167,11 @@
3167 int mode = TIMELINE_MODE_NONE;
3168 int verboseFlag = 0 ;
3169 int iOffset;
3170 const char *zFilePattern = 0;
3171 const char *zFormat = 0;
3172 const char *zBr = 0;
3173 Blob treeName;
3174 int showSql = 0;
3175
3176 verboseFlag = find_option("verbose","v", 0)!=0;
3177 if( !verboseFlag){
@@ -3180,10 +3181,20 @@
3181 zLimit = find_option("limit","n",1);
3182 zWidth = find_option("width","W",1);
3183 zType = find_option("type","t",1);
3184 zFilePattern = find_option("path","p",1);
3185 zFormat = find_option("format","F",1);
3186 zBr = find_option("branch","b",1);
3187 if( find_option("current-branch","c",0)!=0 ){
3188 if( !g.localOpen ){
3189 fossil_fatal("not within an open checkout");
3190 }else{
3191 int vid = db_lget_int("checkout", 0);
3192 zBr = db_text(0, "SELECT value FROM tagxref WHERE rid=%d AND tagid=%d",
3193 vid, TAG_BRANCH);
3194 }
3195 }
3196 if( find_option("oneline",0,0)!= 0 || fossil_strcmp(zFormat,"oneline")==0 )
3197 zFormat = "%h %c";
3198 if( find_option("medium",0,0)!= 0 || fossil_strcmp(zFormat,"medium")==0 )
3199 zFormat = "Commit: %h%nDate: %d%nAuthor: %a%nComment: %c%n";
3200 if( find_option("full",0,0)!= 0 || fossil_strcmp(zFormat,"full")==0 )
@@ -3325,10 +3336,31 @@
3336 " OR lower(name) GLOB lower('%q/*'))",
3337 blob_str(&treeName), blob_str(&treeName));
3338 }
3339 blob_append(&sql, ")", -1);
3340 }
3341 if( zBr ){
3342 blob_append_sql(&sql,
3343 "\n AND blob.rid IN (\n" /* Commits */
3344 " SELECT rid FROM tagxref NATURAL JOIN tag\n"
3345 " WHERE tagtype>0 AND tagname='sym-%q'\n"
3346 " UNION\n" /* Tags */
3347 " SELECT srcid FROM tagxref WHERE origid IN (\n"
3348 " SELECT rid FROM tagxref NATURAL JOIN tag\n"
3349 " WHERE tagname='sym-%q')\n"
3350 " UNION\n" /* Branch wikis */
3351 " SELECT objid FROM event WHERE comment LIKE '_branch/%q'\n"
3352 " UNION\n" /* Checkin wikis */
3353 " SELECT e.objid FROM event e\n"
3354 " INNER JOIN blob b ON b.uuid=substr(e.comment, 10)\n"
3355 " AND e.comment LIKE '_checkin/%%'\n"
3356 " LEFT JOIN tagxref tx ON tx.rid=b.rid AND tx.tagid=%d\n"
3357 " WHERE tx.value='%q'\n"
3358 ")\n" /* No merge closures */
3359 " AND (tagxref.value IS NULL OR tagxref.value='%q')",
3360 zBr, zBr, zBr, TAG_BRANCH, zBr, zBr);
3361 }
3362 blob_append_sql(&sql, "\nORDER BY event.mtime DESC");
3363 if( iOffset>0 ){
3364 /* Don't handle LIMIT here, otherwise print_timeline()
3365 * will not determine the end-marker correctly! */
3366 blob_append_sql(&sql, "\n LIMIT -1 OFFSET %d", iOffset);
3367

Keyboard Shortcuts

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