Fossil SCM
Add an option to the 'timeline' command to display only items on a specific branch.
Commit
32b11546c830e3285a0322c7469c550d6f96f8667fc0b0ae42ffb6163acc7043
Parent
a791d5e8058b328…
1 file changed
+34
-2
+34
-2
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -3108,10 +3108,12 @@ | ||
| 3108 | 3108 | ** (westward) or "+HH:MM" (eastward). Either no timezone suffix or "Z" |
| 3109 | 3109 | ** means UTC. |
| 3110 | 3110 | ** |
| 3111 | 3111 | ** |
| 3112 | 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 | |
| 3113 | 3115 | ** -F|--format Entry format. Values "oneline", "medium", and "full" |
| 3114 | 3116 | ** get mapped to the full options below. Otherwise a |
| 3115 | 3117 | ** string which can contain these placeholders: |
| 3116 | 3118 | ** %n newline |
| 3117 | 3119 | ** %% a raw % |
| @@ -3125,20 +3127,18 @@ | ||
| 3125 | 3127 | ** %p phase: zero or more of *CURRENT*, *MERGE*, |
| 3126 | 3128 | ** *FORK*, *UNPUBLISHED*, *LEAF*, *BRANCH* |
| 3127 | 3129 | ** --oneline Show only short hash and comment for each entry |
| 3128 | 3130 | ** --medium Medium-verbose entry formatting |
| 3129 | 3131 | ** --full Extra verbose entry formatting |
| 3130 | -** | |
| 3131 | 3132 | ** -n|--limit N If N is positive, output the first N entries. If |
| 3132 | 3133 | ** N is negative, output the first -N lines. If N is |
| 3133 | 3134 | ** zero, no limit. Default is -20 meaning 20 lines. |
| 3134 | 3135 | ** --offset P skip P changes |
| 3135 | 3136 | ** -p|--path PATH Output items affecting PATH only. |
| 3136 | 3137 | ** PATH can be a file or a sub directory. |
| 3137 | 3138 | ** -R REPO_FILE Specifies the repository db to use. Default is |
| 3138 | 3139 | ** the current checkout's repository. |
| 3139 | - | |
| 3140 | 3140 | ** --sql Show the SQL used to generate the timeline |
| 3141 | 3141 | ** -t|--type TYPE Output items from the given types only, such as: |
| 3142 | 3142 | ** ci = file commits only |
| 3143 | 3143 | ** e = technical notes only |
| 3144 | 3144 | ** f = forum posts only |
| @@ -3167,10 +3167,11 @@ | ||
| 3167 | 3167 | int mode = TIMELINE_MODE_NONE; |
| 3168 | 3168 | int verboseFlag = 0 ; |
| 3169 | 3169 | int iOffset; |
| 3170 | 3170 | const char *zFilePattern = 0; |
| 3171 | 3171 | const char *zFormat = 0; |
| 3172 | + const char *zBr = 0; | |
| 3172 | 3173 | Blob treeName; |
| 3173 | 3174 | int showSql = 0; |
| 3174 | 3175 | |
| 3175 | 3176 | verboseFlag = find_option("verbose","v", 0)!=0; |
| 3176 | 3177 | if( !verboseFlag){ |
| @@ -3180,10 +3181,20 @@ | ||
| 3180 | 3181 | zLimit = find_option("limit","n",1); |
| 3181 | 3182 | zWidth = find_option("width","W",1); |
| 3182 | 3183 | zType = find_option("type","t",1); |
| 3183 | 3184 | zFilePattern = find_option("path","p",1); |
| 3184 | 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 | + } | |
| 3185 | 3196 | if( find_option("oneline",0,0)!= 0 || fossil_strcmp(zFormat,"oneline")==0 ) |
| 3186 | 3197 | zFormat = "%h %c"; |
| 3187 | 3198 | if( find_option("medium",0,0)!= 0 || fossil_strcmp(zFormat,"medium")==0 ) |
| 3188 | 3199 | zFormat = "Commit: %h%nDate: %d%nAuthor: %a%nComment: %c%n"; |
| 3189 | 3200 | if( find_option("full",0,0)!= 0 || fossil_strcmp(zFormat,"full")==0 ) |
| @@ -3325,10 +3336,31 @@ | ||
| 3325 | 3336 | " OR lower(name) GLOB lower('%q/*'))", |
| 3326 | 3337 | blob_str(&treeName), blob_str(&treeName)); |
| 3327 | 3338 | } |
| 3328 | 3339 | blob_append(&sql, ")", -1); |
| 3329 | 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 | + } | |
| 3330 | 3362 | blob_append_sql(&sql, "\nORDER BY event.mtime DESC"); |
| 3331 | 3363 | if( iOffset>0 ){ |
| 3332 | 3364 | /* Don't handle LIMIT here, otherwise print_timeline() |
| 3333 | 3365 | * will not determine the end-marker correctly! */ |
| 3334 | 3366 | blob_append_sql(&sql, "\n LIMIT -1 OFFSET %d", iOffset); |
| 3335 | 3367 |
| --- 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 |