Fossil SCM
Filter branch ls output by user with check-ins on the branches.
Commit
d0f15a1b655b9a5fca41a08a70529cab08400b1b84af5e17002c20281b56ef70
Parent
9b10bf45755514b…
2 files changed
+27
-11
+1
-1
+27
-11
| --- src/branch.c | ||
| +++ src/branch.c | ||
| @@ -297,11 +297,12 @@ | ||
| 297 | 297 | */ |
| 298 | 298 | void branch_prepare_list_query( |
| 299 | 299 | Stmt *pQuery, |
| 300 | 300 | int brFlags, |
| 301 | 301 | const char *zBrNameGlob, |
| 302 | - int nLimitMRU | |
| 302 | + int nLimitMRU, | |
| 303 | + const char *zUser | |
| 303 | 304 | ){ |
| 304 | 305 | Blob sql; |
| 305 | 306 | blob_init(&sql, 0, 0); |
| 306 | 307 | brlist_create_temp_table(); |
| 307 | 308 | /* Ignore nLimitMRU if no chronological sort requested. */ |
| @@ -330,11 +331,16 @@ | ||
| 330 | 331 | break; |
| 331 | 332 | } |
| 332 | 333 | } |
| 333 | 334 | if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate"); |
| 334 | 335 | if( brFlags & BRL_MERGED ) blob_append_sql(&sql, " AND mergeto IS NOT NULL"); |
| 335 | - if(zBrNameGlob) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob); | |
| 336 | + if( zBrNameGlob ) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob); | |
| 337 | + if( zUser && zUser[0] ) blob_append_sql(&sql, | |
| 338 | + " AND EXISTS (SELECT 1 FROM event WHERE type='ci' AND (user=%Q OR euser=%Q)" | |
| 339 | + " AND objid in (SELECT rid FROM tagxref WHERE value=tmp_brlist.name))", | |
| 340 | + zUser, zUser | |
| 341 | + ); | |
| 336 | 342 | if( brFlags & BRL_ORDERBY_MTIME ){ |
| 337 | 343 | blob_append_sql(&sql, " ORDER BY -mtime"); |
| 338 | 344 | }else{ |
| 339 | 345 | blob_append_sql(&sql, " ORDER BY name COLLATE nocase"); |
| 340 | 346 | } |
| @@ -614,17 +620,19 @@ | ||
| 614 | 620 | ** > fossil branch lsh ?OPTIONS? ?LIMIT? |
| 615 | 621 | ** |
| 616 | 622 | ** List all branches. |
| 617 | 623 | ** |
| 618 | 624 | ** Options: |
| 619 | -** -a|--all List all branches. Default show only open branches | |
| 620 | -** -c|--closed List closed branches | |
| 621 | -** -m|--merged List branches merged into the current branch | |
| 622 | -** -M|--unmerged List branches not merged into the current branch | |
| 623 | -** -p List only private branches | |
| 624 | -** -r Reverse the sort order | |
| 625 | -** -t Show recently changed branches first | |
| 625 | +** -a|--all List all branches. Default show only open branches | |
| 626 | +** -c|--closed List closed branches | |
| 627 | +** -m|--merged List branches merged into the current branch | |
| 628 | +** -M|--unmerged List branches not merged into the current branch | |
| 629 | +** -p List only private branches | |
| 630 | +** -r Reverse the sort order | |
| 631 | +** -t Show recently changed branches first | |
| 632 | +** --username USER List only branches with check-ins by USER | |
| 633 | +** --self List only branches with check-ins by the default user | |
| 626 | 634 | ** |
| 627 | 635 | ** The current branch is marked with an asterisk. Private branches are |
| 628 | 636 | ** marked with a hash sign. |
| 629 | 637 | ** |
| 630 | 638 | ** If GLOB is given, show only branches matching the pattern. |
| @@ -692,19 +700,27 @@ | ||
| 692 | 700 | strcmp(zCmd, "lsh")==0 ){ |
| 693 | 701 | Stmt q; |
| 694 | 702 | int vid; |
| 695 | 703 | char *zCurrent = 0; |
| 696 | 704 | const char *zBrNameGlob = 0; |
| 705 | + const char *zUser = find_option("username",0,1); | |
| 697 | 706 | int nLimit = 0; |
| 698 | 707 | int brFlags = BRL_OPEN_ONLY; |
| 699 | 708 | if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH; |
| 700 | 709 | if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY; |
| 701 | 710 | if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME; |
| 702 | 711 | if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE; |
| 703 | 712 | if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE; |
| 704 | 713 | if( find_option("merged","m",0)!=0 ) brFlags |= BRL_MERGED; |
| 705 | 714 | if( find_option("unmerged","M",0)!=0 ) brFlags |= BRL_UNMERGED; |
| 715 | + if( find_option("self","0",0)!=0 ){ | |
| 716 | + if( zUser ){ | |
| 717 | + fossil_fatal("flags --username and --self are mutually exclusive"); | |
| 718 | + } | |
| 719 | + user_select(); | |
| 720 | + zUser = login_name(); | |
| 721 | + } | |
| 706 | 722 | |
| 707 | 723 | if ( (brFlags & BRL_MERGED) && (brFlags & BRL_UNMERGED) ){ |
| 708 | 724 | fossil_fatal("flags --merged and --unmerged are mutually exclusive"); |
| 709 | 725 | } |
| 710 | 726 | if( strcmp(zCmd, "lsh")==0 ){ |
| @@ -720,11 +736,11 @@ | ||
| 720 | 736 | if( g.localOpen ){ |
| 721 | 737 | vid = db_lget_int("checkout", 0); |
| 722 | 738 | zCurrent = db_text(0, "SELECT value FROM tagxref" |
| 723 | 739 | " WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH); |
| 724 | 740 | } |
| 725 | - branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit); | |
| 741 | + branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit, zUser); | |
| 726 | 742 | while( db_step(&q)==SQLITE_ROW ){ |
| 727 | 743 | const char *zBr = db_column_text(&q, 0); |
| 728 | 744 | int isPriv = zCurrent!=0 && db_column_int(&q, 1)==1; |
| 729 | 745 | const char *zMergeTo = db_column_text(&q, 2); |
| 730 | 746 | int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0; |
| @@ -922,11 +938,11 @@ | ||
| 922 | 938 | @ reopened).</li> |
| 923 | 939 | @ </ol> |
| 924 | 940 | style_sidebox_end(); |
| 925 | 941 | #endif |
| 926 | 942 | |
| 927 | - branch_prepare_list_query(&q, brFlags, 0, 0); | |
| 943 | + branch_prepare_list_query(&q, brFlags, 0, 0, 0); | |
| 928 | 944 | cnt = 0; |
| 929 | 945 | while( db_step(&q)==SQLITE_ROW ){ |
| 930 | 946 | const char *zBr = db_column_text(&q, 0); |
| 931 | 947 | if( cnt==0 ){ |
| 932 | 948 | if( colorTest ){ |
| 933 | 949 |
| --- src/branch.c | |
| +++ src/branch.c | |
| @@ -297,11 +297,12 @@ | |
| 297 | */ |
| 298 | void branch_prepare_list_query( |
| 299 | Stmt *pQuery, |
| 300 | int brFlags, |
| 301 | const char *zBrNameGlob, |
| 302 | int nLimitMRU |
| 303 | ){ |
| 304 | Blob sql; |
| 305 | blob_init(&sql, 0, 0); |
| 306 | brlist_create_temp_table(); |
| 307 | /* Ignore nLimitMRU if no chronological sort requested. */ |
| @@ -330,11 +331,16 @@ | |
| 330 | break; |
| 331 | } |
| 332 | } |
| 333 | if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate"); |
| 334 | if( brFlags & BRL_MERGED ) blob_append_sql(&sql, " AND mergeto IS NOT NULL"); |
| 335 | if(zBrNameGlob) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob); |
| 336 | if( brFlags & BRL_ORDERBY_MTIME ){ |
| 337 | blob_append_sql(&sql, " ORDER BY -mtime"); |
| 338 | }else{ |
| 339 | blob_append_sql(&sql, " ORDER BY name COLLATE nocase"); |
| 340 | } |
| @@ -614,17 +620,19 @@ | |
| 614 | ** > fossil branch lsh ?OPTIONS? ?LIMIT? |
| 615 | ** |
| 616 | ** List all branches. |
| 617 | ** |
| 618 | ** Options: |
| 619 | ** -a|--all List all branches. Default show only open branches |
| 620 | ** -c|--closed List closed branches |
| 621 | ** -m|--merged List branches merged into the current branch |
| 622 | ** -M|--unmerged List branches not merged into the current branch |
| 623 | ** -p List only private branches |
| 624 | ** -r Reverse the sort order |
| 625 | ** -t Show recently changed branches first |
| 626 | ** |
| 627 | ** The current branch is marked with an asterisk. Private branches are |
| 628 | ** marked with a hash sign. |
| 629 | ** |
| 630 | ** If GLOB is given, show only branches matching the pattern. |
| @@ -692,19 +700,27 @@ | |
| 692 | strcmp(zCmd, "lsh")==0 ){ |
| 693 | Stmt q; |
| 694 | int vid; |
| 695 | char *zCurrent = 0; |
| 696 | const char *zBrNameGlob = 0; |
| 697 | int nLimit = 0; |
| 698 | int brFlags = BRL_OPEN_ONLY; |
| 699 | if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH; |
| 700 | if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY; |
| 701 | if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME; |
| 702 | if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE; |
| 703 | if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE; |
| 704 | if( find_option("merged","m",0)!=0 ) brFlags |= BRL_MERGED; |
| 705 | if( find_option("unmerged","M",0)!=0 ) brFlags |= BRL_UNMERGED; |
| 706 | |
| 707 | if ( (brFlags & BRL_MERGED) && (brFlags & BRL_UNMERGED) ){ |
| 708 | fossil_fatal("flags --merged and --unmerged are mutually exclusive"); |
| 709 | } |
| 710 | if( strcmp(zCmd, "lsh")==0 ){ |
| @@ -720,11 +736,11 @@ | |
| 720 | if( g.localOpen ){ |
| 721 | vid = db_lget_int("checkout", 0); |
| 722 | zCurrent = db_text(0, "SELECT value FROM tagxref" |
| 723 | " WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH); |
| 724 | } |
| 725 | branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit); |
| 726 | while( db_step(&q)==SQLITE_ROW ){ |
| 727 | const char *zBr = db_column_text(&q, 0); |
| 728 | int isPriv = zCurrent!=0 && db_column_int(&q, 1)==1; |
| 729 | const char *zMergeTo = db_column_text(&q, 2); |
| 730 | int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0; |
| @@ -922,11 +938,11 @@ | |
| 922 | @ reopened).</li> |
| 923 | @ </ol> |
| 924 | style_sidebox_end(); |
| 925 | #endif |
| 926 | |
| 927 | branch_prepare_list_query(&q, brFlags, 0, 0); |
| 928 | cnt = 0; |
| 929 | while( db_step(&q)==SQLITE_ROW ){ |
| 930 | const char *zBr = db_column_text(&q, 0); |
| 931 | if( cnt==0 ){ |
| 932 | if( colorTest ){ |
| 933 |
| --- src/branch.c | |
| +++ src/branch.c | |
| @@ -297,11 +297,12 @@ | |
| 297 | */ |
| 298 | void branch_prepare_list_query( |
| 299 | Stmt *pQuery, |
| 300 | int brFlags, |
| 301 | const char *zBrNameGlob, |
| 302 | int nLimitMRU, |
| 303 | const char *zUser |
| 304 | ){ |
| 305 | Blob sql; |
| 306 | blob_init(&sql, 0, 0); |
| 307 | brlist_create_temp_table(); |
| 308 | /* Ignore nLimitMRU if no chronological sort requested. */ |
| @@ -330,11 +331,16 @@ | |
| 331 | break; |
| 332 | } |
| 333 | } |
| 334 | if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate"); |
| 335 | if( brFlags & BRL_MERGED ) blob_append_sql(&sql, " AND mergeto IS NOT NULL"); |
| 336 | if( zBrNameGlob ) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob); |
| 337 | if( zUser && zUser[0] ) blob_append_sql(&sql, |
| 338 | " AND EXISTS (SELECT 1 FROM event WHERE type='ci' AND (user=%Q OR euser=%Q)" |
| 339 | " AND objid in (SELECT rid FROM tagxref WHERE value=tmp_brlist.name))", |
| 340 | zUser, zUser |
| 341 | ); |
| 342 | if( brFlags & BRL_ORDERBY_MTIME ){ |
| 343 | blob_append_sql(&sql, " ORDER BY -mtime"); |
| 344 | }else{ |
| 345 | blob_append_sql(&sql, " ORDER BY name COLLATE nocase"); |
| 346 | } |
| @@ -614,17 +620,19 @@ | |
| 620 | ** > fossil branch lsh ?OPTIONS? ?LIMIT? |
| 621 | ** |
| 622 | ** List all branches. |
| 623 | ** |
| 624 | ** Options: |
| 625 | ** -a|--all List all branches. Default show only open branches |
| 626 | ** -c|--closed List closed branches |
| 627 | ** -m|--merged List branches merged into the current branch |
| 628 | ** -M|--unmerged List branches not merged into the current branch |
| 629 | ** -p List only private branches |
| 630 | ** -r Reverse the sort order |
| 631 | ** -t Show recently changed branches first |
| 632 | ** --username USER List only branches with check-ins by USER |
| 633 | ** --self List only branches with check-ins by the default user |
| 634 | ** |
| 635 | ** The current branch is marked with an asterisk. Private branches are |
| 636 | ** marked with a hash sign. |
| 637 | ** |
| 638 | ** If GLOB is given, show only branches matching the pattern. |
| @@ -692,19 +700,27 @@ | |
| 700 | strcmp(zCmd, "lsh")==0 ){ |
| 701 | Stmt q; |
| 702 | int vid; |
| 703 | char *zCurrent = 0; |
| 704 | const char *zBrNameGlob = 0; |
| 705 | const char *zUser = find_option("username",0,1); |
| 706 | int nLimit = 0; |
| 707 | int brFlags = BRL_OPEN_ONLY; |
| 708 | if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH; |
| 709 | if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY; |
| 710 | if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME; |
| 711 | if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE; |
| 712 | if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE; |
| 713 | if( find_option("merged","m",0)!=0 ) brFlags |= BRL_MERGED; |
| 714 | if( find_option("unmerged","M",0)!=0 ) brFlags |= BRL_UNMERGED; |
| 715 | if( find_option("self","0",0)!=0 ){ |
| 716 | if( zUser ){ |
| 717 | fossil_fatal("flags --username and --self are mutually exclusive"); |
| 718 | } |
| 719 | user_select(); |
| 720 | zUser = login_name(); |
| 721 | } |
| 722 | |
| 723 | if ( (brFlags & BRL_MERGED) && (brFlags & BRL_UNMERGED) ){ |
| 724 | fossil_fatal("flags --merged and --unmerged are mutually exclusive"); |
| 725 | } |
| 726 | if( strcmp(zCmd, "lsh")==0 ){ |
| @@ -720,11 +736,11 @@ | |
| 736 | if( g.localOpen ){ |
| 737 | vid = db_lget_int("checkout", 0); |
| 738 | zCurrent = db_text(0, "SELECT value FROM tagxref" |
| 739 | " WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH); |
| 740 | } |
| 741 | branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit, zUser); |
| 742 | while( db_step(&q)==SQLITE_ROW ){ |
| 743 | const char *zBr = db_column_text(&q, 0); |
| 744 | int isPriv = zCurrent!=0 && db_column_int(&q, 1)==1; |
| 745 | const char *zMergeTo = db_column_text(&q, 2); |
| 746 | int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0; |
| @@ -922,11 +938,11 @@ | |
| 938 | @ reopened).</li> |
| 939 | @ </ol> |
| 940 | style_sidebox_end(); |
| 941 | #endif |
| 942 | |
| 943 | branch_prepare_list_query(&q, brFlags, 0, 0, 0); |
| 944 | cnt = 0; |
| 945 | while( db_step(&q)==SQLITE_ROW ){ |
| 946 | const char *zBr = db_column_text(&q, 0); |
| 947 | if( cnt==0 ){ |
| 948 | if( colorTest ){ |
| 949 |
+1
-1
| --- src/json_branch.c | ||
| +++ src/json_branch.c | ||
| @@ -128,11 +128,11 @@ | ||
| 128 | 128 | cson_object_set(pay,"current",json_new_string(zCurrent)); |
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | |
| 133 | - branch_prepare_list_query(&q, branchListFlags, 0, 0); | |
| 133 | + branch_prepare_list_query(&q, branchListFlags, 0, 0, 0); /* Allow a user? */ | |
| 134 | 134 | cson_object_set(pay,"branches",listV); |
| 135 | 135 | while((SQLITE_ROW==db_step(&q))){ |
| 136 | 136 | cson_value * v = cson_sqlite3_column_to_value(q.pStmt,0); |
| 137 | 137 | if(v){ |
| 138 | 138 | cson_array_append(list,v); |
| 139 | 139 |
| --- src/json_branch.c | |
| +++ src/json_branch.c | |
| @@ -128,11 +128,11 @@ | |
| 128 | cson_object_set(pay,"current",json_new_string(zCurrent)); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | |
| 133 | branch_prepare_list_query(&q, branchListFlags, 0, 0); |
| 134 | cson_object_set(pay,"branches",listV); |
| 135 | while((SQLITE_ROW==db_step(&q))){ |
| 136 | cson_value * v = cson_sqlite3_column_to_value(q.pStmt,0); |
| 137 | if(v){ |
| 138 | cson_array_append(list,v); |
| 139 |
| --- src/json_branch.c | |
| +++ src/json_branch.c | |
| @@ -128,11 +128,11 @@ | |
| 128 | cson_object_set(pay,"current",json_new_string(zCurrent)); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | |
| 133 | branch_prepare_list_query(&q, branchListFlags, 0, 0, 0); /* Allow a user? */ |
| 134 | cson_object_set(pay,"branches",listV); |
| 135 | while((SQLITE_ROW==db_step(&q))){ |
| 136 | cson_value * v = cson_sqlite3_column_to_value(q.pStmt,0); |
| 137 | if(v){ |
| 138 | cson_array_append(list,v); |
| 139 |