Fossil SCM
Mark private branches in the CLI output of "fossil branch list", and output only those when "-p" is given. Clarify that private branches do not appear in a merge manifest.
Commit
cf04bcb2b112bbc8b6ccd5a0c36bfcb75c9c166ba80fa11341d70555c747b790
Parent
c34ca6299f09515…
2 files changed
+16
-6
+2
-1
+16
-6
| --- src/branch.c | ||
| +++ src/branch.c | ||
| @@ -233,10 +233,11 @@ | ||
| 233 | 233 | ** mtime Time of last checkin on this branch |
| 234 | 234 | ** isclosed True if the branch is closed |
| 235 | 235 | ** mergeto Another branch this branch was merged into |
| 236 | 236 | ** nckin Number of checkins on this branch |
| 237 | 237 | ** ckin Hash of the last checkin on this branch |
| 238 | +** isprivate True if the branch is private | |
| 238 | 239 | ** bgclr Background color for this branch |
| 239 | 240 | */ |
| 240 | 241 | static const char createBrlistQuery[] = |
| 241 | 242 | @ CREATE TEMP TABLE IF NOT EXISTS tmp_brlist AS |
| 242 | 243 | @ SELECT |
| @@ -252,11 +253,12 @@ | ||
| 252 | 253 | @ AND tagxref.rid=plink.cid |
| 253 | 254 | @ AND tagxref.tagid=(SELECT tagid FROM tag WHERE tagname='branch') |
| 254 | 255 | @ AND tagtype>0) AS mergeto, |
| 255 | 256 | @ count(*) AS nckin, |
| 256 | 257 | @ (SELECT uuid FROM blob WHERE rid=tagxref.rid) AS ckin, |
| 257 | -@ event.bgcolor AS bgclr | |
| 258 | +@ event.bgcolor AS bgclr, | |
| 259 | +@ EXISTS(SELECT 1 FROM private WHERE rid=tagxref.rid) AS isprivate | |
| 258 | 260 | @ FROM tagxref, tag, event |
| 259 | 261 | @ WHERE tagxref.tagid=tag.tagid |
| 260 | 262 | @ AND tagxref.tagtype>0 |
| 261 | 263 | @ AND tag.tagname='branch' |
| 262 | 264 | @ AND event.objid=tagxref.rid |
| @@ -277,10 +279,11 @@ | ||
| 277 | 279 | #define BRL_OPEN_ONLY 0x002 /* Show only open branches */ |
| 278 | 280 | #define BRL_BOTH 0x003 /* Show both open and closed branches */ |
| 279 | 281 | #define BRL_OPEN_CLOSED_MASK 0x003 |
| 280 | 282 | #define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/ |
| 281 | 283 | #define BRL_REVERSE 0x008 /* Reverse the sort order */ |
| 284 | +#define BRL_PRIVATE 0x010 /* Show only private branches */ | |
| 282 | 285 | |
| 283 | 286 | #endif /* INTERFACE */ |
| 284 | 287 | |
| 285 | 288 | /* |
| 286 | 289 | ** Prepare a query that will list branches. |
| @@ -294,27 +297,28 @@ | ||
| 294 | 297 | blob_init(&sql, 0, 0); |
| 295 | 298 | brlist_create_temp_table(); |
| 296 | 299 | switch( brFlags & BRL_OPEN_CLOSED_MASK ){ |
| 297 | 300 | case BRL_CLOSED_ONLY: { |
| 298 | 301 | blob_append_sql(&sql, |
| 299 | - "SELECT name FROM tmp_brlist WHERE isclosed" | |
| 302 | + "SELECT name, isprivate FROM tmp_brlist WHERE isclosed" | |
| 300 | 303 | ); |
| 301 | 304 | break; |
| 302 | 305 | } |
| 303 | 306 | case BRL_BOTH: { |
| 304 | 307 | blob_append_sql(&sql, |
| 305 | - "SELECT name FROM tmp_brlist WHERE 1" | |
| 308 | + "SELECT name, isprivate FROM tmp_brlist WHERE 1" | |
| 306 | 309 | ); |
| 307 | 310 | break; |
| 308 | 311 | } |
| 309 | 312 | case BRL_OPEN_ONLY: { |
| 310 | 313 | blob_append_sql(&sql, |
| 311 | - "SELECT name FROM tmp_brlist WHERE NOT isclosed" | |
| 314 | + "SELECT name, isprivate FROM tmp_brlist WHERE NOT isclosed" | |
| 312 | 315 | ); |
| 313 | 316 | break; |
| 314 | 317 | } |
| 315 | 318 | } |
| 319 | + if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate"); | |
| 316 | 320 | if(zBrNameGlob) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob); |
| 317 | 321 | if( brFlags & BRL_ORDERBY_MTIME ){ |
| 318 | 322 | blob_append_sql(&sql, " ORDER BY -mtime"); |
| 319 | 323 | }else{ |
| 320 | 324 | blob_append_sql(&sql, " ORDER BY name COLLATE nocase"); |
| @@ -585,14 +589,16 @@ | ||
| 585 | 589 | ** > fossil branch list|ls ?OPTIONS? ?GLOB? |
| 586 | 590 | ** |
| 587 | 591 | ** List all branches. Options: |
| 588 | 592 | ** -a|--all List all branches. Default show only open branches |
| 589 | 593 | ** -c|--closed List closed branches. |
| 594 | +** -p List only private branches. | |
| 590 | 595 | ** -r Reverse the sort order |
| 591 | 596 | ** -t Show recently changed branches first |
| 592 | 597 | ** |
| 593 | -** The current branch is marked with an asterisk. | |
| 598 | +** The current branch is marked with an asterisk. Private branches are | |
| 599 | +** marked with a hash sign. | |
| 594 | 600 | ** |
| 595 | 601 | ** If GLOB is given, show only branches matching the pattern. |
| 596 | 602 | ** |
| 597 | 603 | ** > fossil branch new BRANCH-NAME BASIS ?OPTIONS? |
| 598 | 604 | ** |
| @@ -655,10 +661,11 @@ | ||
| 655 | 661 | int brFlags = BRL_OPEN_ONLY; |
| 656 | 662 | if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH; |
| 657 | 663 | if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY; |
| 658 | 664 | if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME; |
| 659 | 665 | if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE; |
| 666 | + if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE; | |
| 660 | 667 | if( g.argc >= 4 ) zBrNameGlob = g.argv[3]; |
| 661 | 668 | |
| 662 | 669 | if( g.localOpen ){ |
| 663 | 670 | vid = db_lget_int("checkout", 0); |
| 664 | 671 | zCurrent = db_text(0, "SELECT value FROM tagxref" |
| @@ -665,12 +672,15 @@ | ||
| 665 | 672 | " WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH); |
| 666 | 673 | } |
| 667 | 674 | branch_prepare_list_query(&q, brFlags, zBrNameGlob); |
| 668 | 675 | while( db_step(&q)==SQLITE_ROW ){ |
| 669 | 676 | const char *zBr = db_column_text(&q, 0); |
| 677 | + int isPriv = zCurrent!=0 && db_column_int(&q, 1)==1; | |
| 670 | 678 | int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0; |
| 671 | - fossil_print("%s%s\n", (isCur ? "* " : " "), zBr); | |
| 679 | + fossil_print("%s%s%s\n", | |
| 680 | + ( (brFlags & BRL_PRIVATE) ? " " : ( isPriv ? "#" : " ") ), | |
| 681 | + (isCur ? "* " : " "), zBr); | |
| 672 | 682 | } |
| 673 | 683 | db_finalize(&q); |
| 674 | 684 | }else if( strncmp(zCmd,"new",n)==0 ){ |
| 675 | 685 | branch_new(); |
| 676 | 686 | }else if( strncmp(zCmd,"close",5)==0 ){ |
| 677 | 687 |
| --- src/branch.c | |
| +++ src/branch.c | |
| @@ -233,10 +233,11 @@ | |
| 233 | ** mtime Time of last checkin on this branch |
| 234 | ** isclosed True if the branch is closed |
| 235 | ** mergeto Another branch this branch was merged into |
| 236 | ** nckin Number of checkins on this branch |
| 237 | ** ckin Hash of the last checkin on this branch |
| 238 | ** bgclr Background color for this branch |
| 239 | */ |
| 240 | static const char createBrlistQuery[] = |
| 241 | @ CREATE TEMP TABLE IF NOT EXISTS tmp_brlist AS |
| 242 | @ SELECT |
| @@ -252,11 +253,12 @@ | |
| 252 | @ AND tagxref.rid=plink.cid |
| 253 | @ AND tagxref.tagid=(SELECT tagid FROM tag WHERE tagname='branch') |
| 254 | @ AND tagtype>0) AS mergeto, |
| 255 | @ count(*) AS nckin, |
| 256 | @ (SELECT uuid FROM blob WHERE rid=tagxref.rid) AS ckin, |
| 257 | @ event.bgcolor AS bgclr |
| 258 | @ FROM tagxref, tag, event |
| 259 | @ WHERE tagxref.tagid=tag.tagid |
| 260 | @ AND tagxref.tagtype>0 |
| 261 | @ AND tag.tagname='branch' |
| 262 | @ AND event.objid=tagxref.rid |
| @@ -277,10 +279,11 @@ | |
| 277 | #define BRL_OPEN_ONLY 0x002 /* Show only open branches */ |
| 278 | #define BRL_BOTH 0x003 /* Show both open and closed branches */ |
| 279 | #define BRL_OPEN_CLOSED_MASK 0x003 |
| 280 | #define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/ |
| 281 | #define BRL_REVERSE 0x008 /* Reverse the sort order */ |
| 282 | |
| 283 | #endif /* INTERFACE */ |
| 284 | |
| 285 | /* |
| 286 | ** Prepare a query that will list branches. |
| @@ -294,27 +297,28 @@ | |
| 294 | blob_init(&sql, 0, 0); |
| 295 | brlist_create_temp_table(); |
| 296 | switch( brFlags & BRL_OPEN_CLOSED_MASK ){ |
| 297 | case BRL_CLOSED_ONLY: { |
| 298 | blob_append_sql(&sql, |
| 299 | "SELECT name FROM tmp_brlist WHERE isclosed" |
| 300 | ); |
| 301 | break; |
| 302 | } |
| 303 | case BRL_BOTH: { |
| 304 | blob_append_sql(&sql, |
| 305 | "SELECT name FROM tmp_brlist WHERE 1" |
| 306 | ); |
| 307 | break; |
| 308 | } |
| 309 | case BRL_OPEN_ONLY: { |
| 310 | blob_append_sql(&sql, |
| 311 | "SELECT name FROM tmp_brlist WHERE NOT isclosed" |
| 312 | ); |
| 313 | break; |
| 314 | } |
| 315 | } |
| 316 | if(zBrNameGlob) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob); |
| 317 | if( brFlags & BRL_ORDERBY_MTIME ){ |
| 318 | blob_append_sql(&sql, " ORDER BY -mtime"); |
| 319 | }else{ |
| 320 | blob_append_sql(&sql, " ORDER BY name COLLATE nocase"); |
| @@ -585,14 +589,16 @@ | |
| 585 | ** > fossil branch list|ls ?OPTIONS? ?GLOB? |
| 586 | ** |
| 587 | ** List all branches. Options: |
| 588 | ** -a|--all List all branches. Default show only open branches |
| 589 | ** -c|--closed List closed branches. |
| 590 | ** -r Reverse the sort order |
| 591 | ** -t Show recently changed branches first |
| 592 | ** |
| 593 | ** The current branch is marked with an asterisk. |
| 594 | ** |
| 595 | ** If GLOB is given, show only branches matching the pattern. |
| 596 | ** |
| 597 | ** > fossil branch new BRANCH-NAME BASIS ?OPTIONS? |
| 598 | ** |
| @@ -655,10 +661,11 @@ | |
| 655 | int brFlags = BRL_OPEN_ONLY; |
| 656 | if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH; |
| 657 | if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY; |
| 658 | if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME; |
| 659 | if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE; |
| 660 | if( g.argc >= 4 ) zBrNameGlob = g.argv[3]; |
| 661 | |
| 662 | if( g.localOpen ){ |
| 663 | vid = db_lget_int("checkout", 0); |
| 664 | zCurrent = db_text(0, "SELECT value FROM tagxref" |
| @@ -665,12 +672,15 @@ | |
| 665 | " WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH); |
| 666 | } |
| 667 | branch_prepare_list_query(&q, brFlags, zBrNameGlob); |
| 668 | while( db_step(&q)==SQLITE_ROW ){ |
| 669 | const char *zBr = db_column_text(&q, 0); |
| 670 | int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0; |
| 671 | fossil_print("%s%s\n", (isCur ? "* " : " "), zBr); |
| 672 | } |
| 673 | db_finalize(&q); |
| 674 | }else if( strncmp(zCmd,"new",n)==0 ){ |
| 675 | branch_new(); |
| 676 | }else if( strncmp(zCmd,"close",5)==0 ){ |
| 677 |
| --- src/branch.c | |
| +++ src/branch.c | |
| @@ -233,10 +233,11 @@ | |
| 233 | ** mtime Time of last checkin on this branch |
| 234 | ** isclosed True if the branch is closed |
| 235 | ** mergeto Another branch this branch was merged into |
| 236 | ** nckin Number of checkins on this branch |
| 237 | ** ckin Hash of the last checkin on this branch |
| 238 | ** isprivate True if the branch is private |
| 239 | ** bgclr Background color for this branch |
| 240 | */ |
| 241 | static const char createBrlistQuery[] = |
| 242 | @ CREATE TEMP TABLE IF NOT EXISTS tmp_brlist AS |
| 243 | @ SELECT |
| @@ -252,11 +253,12 @@ | |
| 253 | @ AND tagxref.rid=plink.cid |
| 254 | @ AND tagxref.tagid=(SELECT tagid FROM tag WHERE tagname='branch') |
| 255 | @ AND tagtype>0) AS mergeto, |
| 256 | @ count(*) AS nckin, |
| 257 | @ (SELECT uuid FROM blob WHERE rid=tagxref.rid) AS ckin, |
| 258 | @ event.bgcolor AS bgclr, |
| 259 | @ EXISTS(SELECT 1 FROM private WHERE rid=tagxref.rid) AS isprivate |
| 260 | @ FROM tagxref, tag, event |
| 261 | @ WHERE tagxref.tagid=tag.tagid |
| 262 | @ AND tagxref.tagtype>0 |
| 263 | @ AND tag.tagname='branch' |
| 264 | @ AND event.objid=tagxref.rid |
| @@ -277,10 +279,11 @@ | |
| 279 | #define BRL_OPEN_ONLY 0x002 /* Show only open branches */ |
| 280 | #define BRL_BOTH 0x003 /* Show both open and closed branches */ |
| 281 | #define BRL_OPEN_CLOSED_MASK 0x003 |
| 282 | #define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/ |
| 283 | #define BRL_REVERSE 0x008 /* Reverse the sort order */ |
| 284 | #define BRL_PRIVATE 0x010 /* Show only private branches */ |
| 285 | |
| 286 | #endif /* INTERFACE */ |
| 287 | |
| 288 | /* |
| 289 | ** Prepare a query that will list branches. |
| @@ -294,27 +297,28 @@ | |
| 297 | blob_init(&sql, 0, 0); |
| 298 | brlist_create_temp_table(); |
| 299 | switch( brFlags & BRL_OPEN_CLOSED_MASK ){ |
| 300 | case BRL_CLOSED_ONLY: { |
| 301 | blob_append_sql(&sql, |
| 302 | "SELECT name, isprivate FROM tmp_brlist WHERE isclosed" |
| 303 | ); |
| 304 | break; |
| 305 | } |
| 306 | case BRL_BOTH: { |
| 307 | blob_append_sql(&sql, |
| 308 | "SELECT name, isprivate FROM tmp_brlist WHERE 1" |
| 309 | ); |
| 310 | break; |
| 311 | } |
| 312 | case BRL_OPEN_ONLY: { |
| 313 | blob_append_sql(&sql, |
| 314 | "SELECT name, isprivate FROM tmp_brlist WHERE NOT isclosed" |
| 315 | ); |
| 316 | break; |
| 317 | } |
| 318 | } |
| 319 | if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate"); |
| 320 | if(zBrNameGlob) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob); |
| 321 | if( brFlags & BRL_ORDERBY_MTIME ){ |
| 322 | blob_append_sql(&sql, " ORDER BY -mtime"); |
| 323 | }else{ |
| 324 | blob_append_sql(&sql, " ORDER BY name COLLATE nocase"); |
| @@ -585,14 +589,16 @@ | |
| 589 | ** > fossil branch list|ls ?OPTIONS? ?GLOB? |
| 590 | ** |
| 591 | ** List all branches. Options: |
| 592 | ** -a|--all List all branches. Default show only open branches |
| 593 | ** -c|--closed List closed branches. |
| 594 | ** -p List only private branches. |
| 595 | ** -r Reverse the sort order |
| 596 | ** -t Show recently changed branches first |
| 597 | ** |
| 598 | ** The current branch is marked with an asterisk. Private branches are |
| 599 | ** marked with a hash sign. |
| 600 | ** |
| 601 | ** If GLOB is given, show only branches matching the pattern. |
| 602 | ** |
| 603 | ** > fossil branch new BRANCH-NAME BASIS ?OPTIONS? |
| 604 | ** |
| @@ -655,10 +661,11 @@ | |
| 661 | int brFlags = BRL_OPEN_ONLY; |
| 662 | if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH; |
| 663 | if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY; |
| 664 | if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME; |
| 665 | if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE; |
| 666 | if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE; |
| 667 | if( g.argc >= 4 ) zBrNameGlob = g.argv[3]; |
| 668 | |
| 669 | if( g.localOpen ){ |
| 670 | vid = db_lget_int("checkout", 0); |
| 671 | zCurrent = db_text(0, "SELECT value FROM tagxref" |
| @@ -665,12 +672,15 @@ | |
| 672 | " WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH); |
| 673 | } |
| 674 | branch_prepare_list_query(&q, brFlags, zBrNameGlob); |
| 675 | while( db_step(&q)==SQLITE_ROW ){ |
| 676 | const char *zBr = db_column_text(&q, 0); |
| 677 | int isPriv = zCurrent!=0 && db_column_int(&q, 1)==1; |
| 678 | int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0; |
| 679 | fossil_print("%s%s%s\n", |
| 680 | ( (brFlags & BRL_PRIVATE) ? " " : ( isPriv ? "#" : " ") ), |
| 681 | (isCur ? "* " : " "), zBr); |
| 682 | } |
| 683 | db_finalize(&q); |
| 684 | }else if( strncmp(zCmd,"new",n)==0 ){ |
| 685 | branch_new(); |
| 686 | }else if( strncmp(zCmd,"close",5)==0 ){ |
| 687 |
+2
-1
| --- www/private.wiki | ||
| +++ www/private.wiki | ||
| @@ -31,11 +31,12 @@ | ||
| 31 | 31 | fossil update trunk |
| 32 | 32 | fossil merge private |
| 33 | 33 | fossil commit |
| 34 | 34 | </pre></blockquote> |
| 35 | 35 | |
| 36 | -The private branch remains private, but all of the changes associated with | |
| 36 | +The private branch remains private and is not recorded as a parent | |
| 37 | +in the merge manifest's P-card, but all of the changes associated with | |
| 37 | 38 | the private branch are now folded into the public branch and are hence |
| 38 | 39 | visible to other users of the project. |
| 39 | 40 | |
| 40 | 41 | A private branch created with Fossil version 1.30 or newer can also be |
| 41 | 42 | converted into a public branch using the <code>fossil publish</code> |
| 42 | 43 |
| --- www/private.wiki | |
| +++ www/private.wiki | |
| @@ -31,11 +31,12 @@ | |
| 31 | fossil update trunk |
| 32 | fossil merge private |
| 33 | fossil commit |
| 34 | </pre></blockquote> |
| 35 | |
| 36 | The private branch remains private, but all of the changes associated with |
| 37 | the private branch are now folded into the public branch and are hence |
| 38 | visible to other users of the project. |
| 39 | |
| 40 | A private branch created with Fossil version 1.30 or newer can also be |
| 41 | converted into a public branch using the <code>fossil publish</code> |
| 42 |
| --- www/private.wiki | |
| +++ www/private.wiki | |
| @@ -31,11 +31,12 @@ | |
| 31 | fossil update trunk |
| 32 | fossil merge private |
| 33 | fossil commit |
| 34 | </pre></blockquote> |
| 35 | |
| 36 | The private branch remains private and is not recorded as a parent |
| 37 | in the merge manifest's P-card, but all of the changes associated with |
| 38 | the private branch are now folded into the public branch and are hence |
| 39 | visible to other users of the project. |
| 40 | |
| 41 | A private branch created with Fossil version 1.30 or newer can also be |
| 42 | converted into a public branch using the <code>fossil publish</code> |
| 43 |