Fossil SCM

merge in filter-branch-ls-by-user

preben 2023-09-29 13:33 trunk merge
Commit d6cdd955e133ebb78f7fe735f6abbd7fc11f6eda6bb5264a2a2a442d62559025
3 files changed +77 -13 +77 -13 +1 -1
+77 -13
--- src/branch.c
+++ src/branch.c
@@ -278,10 +278,11 @@
278278
#define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/
279279
#define BRL_REVERSE 0x008 /* Reverse the sort order */
280280
#define BRL_PRIVATE 0x010 /* Show only private branches */
281281
#define BRL_MERGED 0x020 /* Show only merged branches */
282282
#define BRL_UNMERGED 0x040 /* Show only unmerged branches */
283
+#define BRL_LIST_USERS 0x080 /* Populate list of users participating */
283284
284285
#endif /* INTERFACE */
285286
286287
/*
287288
** Prepare a query that will list branches.
@@ -297,21 +298,38 @@
297298
*/
298299
void branch_prepare_list_query(
299300
Stmt *pQuery,
300301
int brFlags,
301302
const char *zBrNameGlob,
302
- int nLimitMRU
303
+ int nLimitMRU,
304
+ const char *zUser
303305
){
304306
Blob sql;
305307
blob_init(&sql, 0, 0);
306308
brlist_create_temp_table();
307309
/* Ignore nLimitMRU if no chronological sort requested. */
308310
if( (brFlags & BRL_ORDERBY_MTIME)==0 ) nLimitMRU = 0;
309311
/* Undocumented: invert negative values for nLimitMRU, so that command-line
310312
** arguments similar to `head -5' with "option numbers" are possible. */
311313
if( nLimitMRU<0 ) nLimitMRU = -nLimitMRU;
312
- blob_append_sql(&sql,"SELECT name, isprivate, mergeto FROM ("); /* OUTER QUERY */
314
+ /* OUTER QUERY */
315
+ blob_append_sql(&sql,"SELECT name, isprivate, mergeto,");
316
+ if( brFlags & BRL_LIST_USERS ){
317
+ blob_append_sql(&sql,
318
+ " (SELECT group_concat(user) FROM ("
319
+ " SELECT DISTINCT * FROM ("
320
+ " SELECT coalesce(euser,user) AS user"
321
+ " FROM event"
322
+ " WHERE type='ci' AND objid IN ("
323
+ " SELECT rid FROM tagxref WHERE value=name)"
324
+ " ORDER BY 1)))"
325
+ );
326
+ }else{
327
+ blob_append_sql(&sql, " NULL");
328
+ }
329
+ blob_append_sql(&sql," FROM (");
330
+ /* INNER QUERY */
313331
switch( brFlags & BRL_OPEN_CLOSED_MASK ){
314332
case BRL_CLOSED_ONLY: {
315333
blob_append_sql(&sql,
316334
"SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE isclosed"
317335
);
@@ -330,11 +348,16 @@
330348
break;
331349
}
332350
}
333351
if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate");
334352
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);
353
+ if( zBrNameGlob ) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob);
354
+ if( zUser && zUser[0] ) blob_append_sql(&sql,
355
+ " AND EXISTS (SELECT 1 FROM event WHERE type='ci' AND (user=%Q OR euser=%Q)"
356
+ " AND objid in (SELECT rid FROM tagxref WHERE value=tmp_brlist.name))",
357
+ zUser, zUser
358
+ );
336359
if( brFlags & BRL_ORDERBY_MTIME ){
337360
blob_append_sql(&sql, " ORDER BY -mtime");
338361
}else{
339362
blob_append_sql(&sql, " ORDER BY name COLLATE nocase");
340363
}
@@ -614,17 +637,20 @@
614637
** > fossil branch lsh ?OPTIONS? ?LIMIT?
615638
**
616639
** List all branches.
617640
**
618641
** 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
642
+** -a|--all List all branches. Default show only open branches
643
+** -c|--closed List closed branches
644
+** -m|--merged List branches merged into the current branch
645
+** -M|--unmerged List branches not merged into the current branch
646
+** -p List only private branches
647
+** -r Reverse the sort order
648
+** -t Show recently changed branches first
649
+** --self List only branches where you participate
650
+** --username USER List only branches where USER participate
651
+** --users N List up to N users partipiating
626652
**
627653
** The current branch is marked with an asterisk. Private branches are
628654
** marked with a hash sign.
629655
**
630656
** If GLOB is given, show only branches matching the pattern.
@@ -689,26 +715,42 @@
689715
}
690716
}else if( strncmp(zCmd,"list",n)==0 ||
691717
strncmp(zCmd, "ls", n)==0 ||
692718
strcmp(zCmd, "lsh")==0 ){
693719
Stmt q;
720
+ Blob txt = empty_blob;
694721
int vid;
695722
char *zCurrent = 0;
696723
const char *zBrNameGlob = 0;
724
+ const char *zUser = find_option("username",0,1);
725
+ const char *zUsersOpt = find_option("users",0,1);
726
+ int nUsers = zUsersOpt ? atoi(zUsersOpt) : 0;
697727
int nLimit = 0;
698728
int brFlags = BRL_OPEN_ONLY;
699729
if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH;
700730
if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY;
701731
if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME;
702732
if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE;
703733
if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE;
704734
if( find_option("merged","m",0)!=0 ) brFlags |= BRL_MERGED;
705735
if( find_option("unmerged","M",0)!=0 ) brFlags |= BRL_UNMERGED;
736
+ if( find_option("self",0,0)!=0 ){
737
+ if( zUser ){
738
+ fossil_fatal("flags --username and --self are mutually exclusive");
739
+ }
740
+ user_select();
741
+ zUser = login_name();
742
+ }
743
+ verify_all_options();
706744
707745
if ( (brFlags & BRL_MERGED) && (brFlags & BRL_UNMERGED) ){
708746
fossil_fatal("flags --merged and --unmerged are mutually exclusive");
709747
}
748
+ if( zUsersOpt ){
749
+ if( nUsers <= 0) fossil_fatal("With --users, N must be positive");
750
+ brFlags |= BRL_LIST_USERS;
751
+ }
710752
if( strcmp(zCmd, "lsh")==0 ){
711753
nLimit = 5;
712754
if( g.argc>4 || (g.argc==4 && (nLimit = atoi(g.argv[3]))==0) ){
713755
fossil_fatal("the lsh subcommand allows one optional numeric argument");
714756
}
@@ -720,26 +762,48 @@
720762
if( g.localOpen ){
721763
vid = db_lget_int("checkout", 0);
722764
zCurrent = db_text(0, "SELECT value FROM tagxref"
723765
" WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH);
724766
}
725
- branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit);
767
+ branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit, zUser);
768
+ blob_init(&txt, 0, 0);
726769
while( db_step(&q)==SQLITE_ROW ){
727770
const char *zBr = db_column_text(&q, 0);
728771
int isPriv = db_column_int(&q, 1)==1;
729772
const char *zMergeTo = db_column_text(&q, 2);
730773
int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0;
774
+ const char *zUsers = db_column_text(&q, 3);
731775
if( (brFlags & BRL_MERGED) && fossil_strcmp(zCurrent,zMergeTo)!=0 ){
732776
continue;
733777
}
734778
if( (brFlags & BRL_UNMERGED) && (fossil_strcmp(zCurrent,zMergeTo)==0
735779
|| isCur) ){
736780
continue;
737781
}
738
- fossil_print("%s%s%s\n",
782
+ blob_appendf(&txt, "%s%s%s",
739783
( (brFlags & BRL_PRIVATE) ? " " : ( isPriv ? "#" : " ") ),
740784
(isCur ? "* " : " "), zBr);
785
+ if( nUsers ){
786
+ char c;
787
+ const char *cp;
788
+ const char *pComma = 0;
789
+ int commas = 0;
790
+ for( cp = zUsers; ( c = *cp ) != 0; cp++ ){
791
+ if( c == ',' ){
792
+ commas++;
793
+ if( commas == nUsers ) pComma = cp;
794
+ }
795
+ }
796
+ if( pComma ){
797
+ blob_appendf(&txt, " (%.*s,... %i more)",
798
+ pComma - zUsers, zUsers, commas + 1 - nUsers);
799
+ }else{
800
+ blob_appendf(&txt, " (%s)", zUsers);
801
+ }
802
+ }
803
+ fossil_print("%s\n", blob_str(&txt));
804
+ blob_reset(&txt);
741805
}
742806
db_finalize(&q);
743807
}else if( strncmp(zCmd,"new",n)==0 ){
744808
branch_new();
745809
}else if( strncmp(zCmd,"close",5)==0 ){
@@ -922,11 +986,11 @@
922986
@ reopened).</li>
923987
@ </ol>
924988
style_sidebox_end();
925989
#endif
926990
927
- branch_prepare_list_query(&q, brFlags, 0, 0);
991
+ branch_prepare_list_query(&q, brFlags, 0, 0, 0);
928992
cnt = 0;
929993
while( db_step(&q)==SQLITE_ROW ){
930994
const char *zBr = db_column_text(&q, 0);
931995
if( cnt==0 ){
932996
if( colorTest ){
933997
--- src/branch.c
+++ src/branch.c
@@ -278,10 +278,11 @@
278 #define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/
279 #define BRL_REVERSE 0x008 /* Reverse the sort order */
280 #define BRL_PRIVATE 0x010 /* Show only private branches */
281 #define BRL_MERGED 0x020 /* Show only merged branches */
282 #define BRL_UNMERGED 0x040 /* Show only unmerged branches */
 
283
284 #endif /* INTERFACE */
285
286 /*
287 ** Prepare a query that will list branches.
@@ -297,21 +298,38 @@
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. */
308 if( (brFlags & BRL_ORDERBY_MTIME)==0 ) nLimitMRU = 0;
309 /* Undocumented: invert negative values for nLimitMRU, so that command-line
310 ** arguments similar to `head -5' with "option numbers" are possible. */
311 if( nLimitMRU<0 ) nLimitMRU = -nLimitMRU;
312 blob_append_sql(&sql,"SELECT name, isprivate, mergeto FROM ("); /* OUTER QUERY */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313 switch( brFlags & BRL_OPEN_CLOSED_MASK ){
314 case BRL_CLOSED_ONLY: {
315 blob_append_sql(&sql,
316 "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE isclosed"
317 );
@@ -330,11 +348,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 +637,20 @@
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.
@@ -689,26 +715,42 @@
689 }
690 }else if( strncmp(zCmd,"list",n)==0 ||
691 strncmp(zCmd, "ls", n)==0 ||
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 ){
711 nLimit = 5;
712 if( g.argc>4 || (g.argc==4 && (nLimit = atoi(g.argv[3]))==0) ){
713 fossil_fatal("the lsh subcommand allows one optional numeric argument");
714 }
@@ -720,26 +762,48 @@
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 = 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;
 
731 if( (brFlags & BRL_MERGED) && fossil_strcmp(zCurrent,zMergeTo)!=0 ){
732 continue;
733 }
734 if( (brFlags & BRL_UNMERGED) && (fossil_strcmp(zCurrent,zMergeTo)==0
735 || isCur) ){
736 continue;
737 }
738 fossil_print("%s%s%s\n",
739 ( (brFlags & BRL_PRIVATE) ? " " : ( isPriv ? "#" : " ") ),
740 (isCur ? "* " : " "), zBr);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
741 }
742 db_finalize(&q);
743 }else if( strncmp(zCmd,"new",n)==0 ){
744 branch_new();
745 }else if( strncmp(zCmd,"close",5)==0 ){
@@ -922,11 +986,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
@@ -278,10 +278,11 @@
278 #define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/
279 #define BRL_REVERSE 0x008 /* Reverse the sort order */
280 #define BRL_PRIVATE 0x010 /* Show only private branches */
281 #define BRL_MERGED 0x020 /* Show only merged branches */
282 #define BRL_UNMERGED 0x040 /* Show only unmerged branches */
283 #define BRL_LIST_USERS 0x080 /* Populate list of users participating */
284
285 #endif /* INTERFACE */
286
287 /*
288 ** Prepare a query that will list branches.
@@ -297,21 +298,38 @@
298 */
299 void branch_prepare_list_query(
300 Stmt *pQuery,
301 int brFlags,
302 const char *zBrNameGlob,
303 int nLimitMRU,
304 const char *zUser
305 ){
306 Blob sql;
307 blob_init(&sql, 0, 0);
308 brlist_create_temp_table();
309 /* Ignore nLimitMRU if no chronological sort requested. */
310 if( (brFlags & BRL_ORDERBY_MTIME)==0 ) nLimitMRU = 0;
311 /* Undocumented: invert negative values for nLimitMRU, so that command-line
312 ** arguments similar to `head -5' with "option numbers" are possible. */
313 if( nLimitMRU<0 ) nLimitMRU = -nLimitMRU;
314 /* OUTER QUERY */
315 blob_append_sql(&sql,"SELECT name, isprivate, mergeto,");
316 if( brFlags & BRL_LIST_USERS ){
317 blob_append_sql(&sql,
318 " (SELECT group_concat(user) FROM ("
319 " SELECT DISTINCT * FROM ("
320 " SELECT coalesce(euser,user) AS user"
321 " FROM event"
322 " WHERE type='ci' AND objid IN ("
323 " SELECT rid FROM tagxref WHERE value=name)"
324 " ORDER BY 1)))"
325 );
326 }else{
327 blob_append_sql(&sql, " NULL");
328 }
329 blob_append_sql(&sql," FROM (");
330 /* INNER QUERY */
331 switch( brFlags & BRL_OPEN_CLOSED_MASK ){
332 case BRL_CLOSED_ONLY: {
333 blob_append_sql(&sql,
334 "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE isclosed"
335 );
@@ -330,11 +348,16 @@
348 break;
349 }
350 }
351 if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate");
352 if( brFlags & BRL_MERGED ) blob_append_sql(&sql, " AND mergeto IS NOT NULL");
353 if( zBrNameGlob ) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob);
354 if( zUser && zUser[0] ) blob_append_sql(&sql,
355 " AND EXISTS (SELECT 1 FROM event WHERE type='ci' AND (user=%Q OR euser=%Q)"
356 " AND objid in (SELECT rid FROM tagxref WHERE value=tmp_brlist.name))",
357 zUser, zUser
358 );
359 if( brFlags & BRL_ORDERBY_MTIME ){
360 blob_append_sql(&sql, " ORDER BY -mtime");
361 }else{
362 blob_append_sql(&sql, " ORDER BY name COLLATE nocase");
363 }
@@ -614,17 +637,20 @@
637 ** > fossil branch lsh ?OPTIONS? ?LIMIT?
638 **
639 ** List all branches.
640 **
641 ** Options:
642 ** -a|--all List all branches. Default show only open branches
643 ** -c|--closed List closed branches
644 ** -m|--merged List branches merged into the current branch
645 ** -M|--unmerged List branches not merged into the current branch
646 ** -p List only private branches
647 ** -r Reverse the sort order
648 ** -t Show recently changed branches first
649 ** --self List only branches where you participate
650 ** --username USER List only branches where USER participate
651 ** --users N List up to N users partipiating
652 **
653 ** The current branch is marked with an asterisk. Private branches are
654 ** marked with a hash sign.
655 **
656 ** If GLOB is given, show only branches matching the pattern.
@@ -689,26 +715,42 @@
715 }
716 }else if( strncmp(zCmd,"list",n)==0 ||
717 strncmp(zCmd, "ls", n)==0 ||
718 strcmp(zCmd, "lsh")==0 ){
719 Stmt q;
720 Blob txt = empty_blob;
721 int vid;
722 char *zCurrent = 0;
723 const char *zBrNameGlob = 0;
724 const char *zUser = find_option("username",0,1);
725 const char *zUsersOpt = find_option("users",0,1);
726 int nUsers = zUsersOpt ? atoi(zUsersOpt) : 0;
727 int nLimit = 0;
728 int brFlags = BRL_OPEN_ONLY;
729 if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH;
730 if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY;
731 if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME;
732 if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE;
733 if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE;
734 if( find_option("merged","m",0)!=0 ) brFlags |= BRL_MERGED;
735 if( find_option("unmerged","M",0)!=0 ) brFlags |= BRL_UNMERGED;
736 if( find_option("self",0,0)!=0 ){
737 if( zUser ){
738 fossil_fatal("flags --username and --self are mutually exclusive");
739 }
740 user_select();
741 zUser = login_name();
742 }
743 verify_all_options();
744
745 if ( (brFlags & BRL_MERGED) && (brFlags & BRL_UNMERGED) ){
746 fossil_fatal("flags --merged and --unmerged are mutually exclusive");
747 }
748 if( zUsersOpt ){
749 if( nUsers <= 0) fossil_fatal("With --users, N must be positive");
750 brFlags |= BRL_LIST_USERS;
751 }
752 if( strcmp(zCmd, "lsh")==0 ){
753 nLimit = 5;
754 if( g.argc>4 || (g.argc==4 && (nLimit = atoi(g.argv[3]))==0) ){
755 fossil_fatal("the lsh subcommand allows one optional numeric argument");
756 }
@@ -720,26 +762,48 @@
762 if( g.localOpen ){
763 vid = db_lget_int("checkout", 0);
764 zCurrent = db_text(0, "SELECT value FROM tagxref"
765 " WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH);
766 }
767 branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit, zUser);
768 blob_init(&txt, 0, 0);
769 while( db_step(&q)==SQLITE_ROW ){
770 const char *zBr = db_column_text(&q, 0);
771 int isPriv = db_column_int(&q, 1)==1;
772 const char *zMergeTo = db_column_text(&q, 2);
773 int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0;
774 const char *zUsers = db_column_text(&q, 3);
775 if( (brFlags & BRL_MERGED) && fossil_strcmp(zCurrent,zMergeTo)!=0 ){
776 continue;
777 }
778 if( (brFlags & BRL_UNMERGED) && (fossil_strcmp(zCurrent,zMergeTo)==0
779 || isCur) ){
780 continue;
781 }
782 blob_appendf(&txt, "%s%s%s",
783 ( (brFlags & BRL_PRIVATE) ? " " : ( isPriv ? "#" : " ") ),
784 (isCur ? "* " : " "), zBr);
785 if( nUsers ){
786 char c;
787 const char *cp;
788 const char *pComma = 0;
789 int commas = 0;
790 for( cp = zUsers; ( c = *cp ) != 0; cp++ ){
791 if( c == ',' ){
792 commas++;
793 if( commas == nUsers ) pComma = cp;
794 }
795 }
796 if( pComma ){
797 blob_appendf(&txt, " (%.*s,... %i more)",
798 pComma - zUsers, zUsers, commas + 1 - nUsers);
799 }else{
800 blob_appendf(&txt, " (%s)", zUsers);
801 }
802 }
803 fossil_print("%s\n", blob_str(&txt));
804 blob_reset(&txt);
805 }
806 db_finalize(&q);
807 }else if( strncmp(zCmd,"new",n)==0 ){
808 branch_new();
809 }else if( strncmp(zCmd,"close",5)==0 ){
@@ -922,11 +986,11 @@
986 @ reopened).</li>
987 @ </ol>
988 style_sidebox_end();
989 #endif
990
991 branch_prepare_list_query(&q, brFlags, 0, 0, 0);
992 cnt = 0;
993 while( db_step(&q)==SQLITE_ROW ){
994 const char *zBr = db_column_text(&q, 0);
995 if( cnt==0 ){
996 if( colorTest ){
997
+77 -13
--- src/branch.c
+++ src/branch.c
@@ -278,10 +278,11 @@
278278
#define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/
279279
#define BRL_REVERSE 0x008 /* Reverse the sort order */
280280
#define BRL_PRIVATE 0x010 /* Show only private branches */
281281
#define BRL_MERGED 0x020 /* Show only merged branches */
282282
#define BRL_UNMERGED 0x040 /* Show only unmerged branches */
283
+#define BRL_LIST_USERS 0x080 /* Populate list of users participating */
283284
284285
#endif /* INTERFACE */
285286
286287
/*
287288
** Prepare a query that will list branches.
@@ -297,21 +298,38 @@
297298
*/
298299
void branch_prepare_list_query(
299300
Stmt *pQuery,
300301
int brFlags,
301302
const char *zBrNameGlob,
302
- int nLimitMRU
303
+ int nLimitMRU,
304
+ const char *zUser
303305
){
304306
Blob sql;
305307
blob_init(&sql, 0, 0);
306308
brlist_create_temp_table();
307309
/* Ignore nLimitMRU if no chronological sort requested. */
308310
if( (brFlags & BRL_ORDERBY_MTIME)==0 ) nLimitMRU = 0;
309311
/* Undocumented: invert negative values for nLimitMRU, so that command-line
310312
** arguments similar to `head -5' with "option numbers" are possible. */
311313
if( nLimitMRU<0 ) nLimitMRU = -nLimitMRU;
312
- blob_append_sql(&sql,"SELECT name, isprivate, mergeto FROM ("); /* OUTER QUERY */
314
+ /* OUTER QUERY */
315
+ blob_append_sql(&sql,"SELECT name, isprivate, mergeto,");
316
+ if( brFlags & BRL_LIST_USERS ){
317
+ blob_append_sql(&sql,
318
+ " (SELECT group_concat(user) FROM ("
319
+ " SELECT DISTINCT * FROM ("
320
+ " SELECT coalesce(euser,user) AS user"
321
+ " FROM event"
322
+ " WHERE type='ci' AND objid IN ("
323
+ " SELECT rid FROM tagxref WHERE value=name)"
324
+ " ORDER BY 1)))"
325
+ );
326
+ }else{
327
+ blob_append_sql(&sql, " NULL");
328
+ }
329
+ blob_append_sql(&sql," FROM (");
330
+ /* INNER QUERY */
313331
switch( brFlags & BRL_OPEN_CLOSED_MASK ){
314332
case BRL_CLOSED_ONLY: {
315333
blob_append_sql(&sql,
316334
"SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE isclosed"
317335
);
@@ -330,11 +348,16 @@
330348
break;
331349
}
332350
}
333351
if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate");
334352
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);
353
+ if( zBrNameGlob ) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob);
354
+ if( zUser && zUser[0] ) blob_append_sql(&sql,
355
+ " AND EXISTS (SELECT 1 FROM event WHERE type='ci' AND (user=%Q OR euser=%Q)"
356
+ " AND objid in (SELECT rid FROM tagxref WHERE value=tmp_brlist.name))",
357
+ zUser, zUser
358
+ );
336359
if( brFlags & BRL_ORDERBY_MTIME ){
337360
blob_append_sql(&sql, " ORDER BY -mtime");
338361
}else{
339362
blob_append_sql(&sql, " ORDER BY name COLLATE nocase");
340363
}
@@ -614,17 +637,20 @@
614637
** > fossil branch lsh ?OPTIONS? ?LIMIT?
615638
**
616639
** List all branches.
617640
**
618641
** 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
642
+** -a|--all List all branches. Default show only open branches
643
+** -c|--closed List closed branches
644
+** -m|--merged List branches merged into the current branch
645
+** -M|--unmerged List branches not merged into the current branch
646
+** -p List only private branches
647
+** -r Reverse the sort order
648
+** -t Show recently changed branches first
649
+** --self List only branches where you participate
650
+** --username USER List only branches where USER participate
651
+** --users N List up to N users partipiating
626652
**
627653
** The current branch is marked with an asterisk. Private branches are
628654
** marked with a hash sign.
629655
**
630656
** If GLOB is given, show only branches matching the pattern.
@@ -689,26 +715,42 @@
689715
}
690716
}else if( strncmp(zCmd,"list",n)==0 ||
691717
strncmp(zCmd, "ls", n)==0 ||
692718
strcmp(zCmd, "lsh")==0 ){
693719
Stmt q;
720
+ Blob txt = empty_blob;
694721
int vid;
695722
char *zCurrent = 0;
696723
const char *zBrNameGlob = 0;
724
+ const char *zUser = find_option("username",0,1);
725
+ const char *zUsersOpt = find_option("users",0,1);
726
+ int nUsers = zUsersOpt ? atoi(zUsersOpt) : 0;
697727
int nLimit = 0;
698728
int brFlags = BRL_OPEN_ONLY;
699729
if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH;
700730
if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY;
701731
if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME;
702732
if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE;
703733
if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE;
704734
if( find_option("merged","m",0)!=0 ) brFlags |= BRL_MERGED;
705735
if( find_option("unmerged","M",0)!=0 ) brFlags |= BRL_UNMERGED;
736
+ if( find_option("self",0,0)!=0 ){
737
+ if( zUser ){
738
+ fossil_fatal("flags --username and --self are mutually exclusive");
739
+ }
740
+ user_select();
741
+ zUser = login_name();
742
+ }
743
+ verify_all_options();
706744
707745
if ( (brFlags & BRL_MERGED) && (brFlags & BRL_UNMERGED) ){
708746
fossil_fatal("flags --merged and --unmerged are mutually exclusive");
709747
}
748
+ if( zUsersOpt ){
749
+ if( nUsers <= 0) fossil_fatal("With --users, N must be positive");
750
+ brFlags |= BRL_LIST_USERS;
751
+ }
710752
if( strcmp(zCmd, "lsh")==0 ){
711753
nLimit = 5;
712754
if( g.argc>4 || (g.argc==4 && (nLimit = atoi(g.argv[3]))==0) ){
713755
fossil_fatal("the lsh subcommand allows one optional numeric argument");
714756
}
@@ -720,26 +762,48 @@
720762
if( g.localOpen ){
721763
vid = db_lget_int("checkout", 0);
722764
zCurrent = db_text(0, "SELECT value FROM tagxref"
723765
" WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH);
724766
}
725
- branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit);
767
+ branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit, zUser);
768
+ blob_init(&txt, 0, 0);
726769
while( db_step(&q)==SQLITE_ROW ){
727770
const char *zBr = db_column_text(&q, 0);
728771
int isPriv = db_column_int(&q, 1)==1;
729772
const char *zMergeTo = db_column_text(&q, 2);
730773
int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0;
774
+ const char *zUsers = db_column_text(&q, 3);
731775
if( (brFlags & BRL_MERGED) && fossil_strcmp(zCurrent,zMergeTo)!=0 ){
732776
continue;
733777
}
734778
if( (brFlags & BRL_UNMERGED) && (fossil_strcmp(zCurrent,zMergeTo)==0
735779
|| isCur) ){
736780
continue;
737781
}
738
- fossil_print("%s%s%s\n",
782
+ blob_appendf(&txt, "%s%s%s",
739783
( (brFlags & BRL_PRIVATE) ? " " : ( isPriv ? "#" : " ") ),
740784
(isCur ? "* " : " "), zBr);
785
+ if( nUsers ){
786
+ char c;
787
+ const char *cp;
788
+ const char *pComma = 0;
789
+ int commas = 0;
790
+ for( cp = zUsers; ( c = *cp ) != 0; cp++ ){
791
+ if( c == ',' ){
792
+ commas++;
793
+ if( commas == nUsers ) pComma = cp;
794
+ }
795
+ }
796
+ if( pComma ){
797
+ blob_appendf(&txt, " (%.*s,... %i more)",
798
+ pComma - zUsers, zUsers, commas + 1 - nUsers);
799
+ }else{
800
+ blob_appendf(&txt, " (%s)", zUsers);
801
+ }
802
+ }
803
+ fossil_print("%s\n", blob_str(&txt));
804
+ blob_reset(&txt);
741805
}
742806
db_finalize(&q);
743807
}else if( strncmp(zCmd,"new",n)==0 ){
744808
branch_new();
745809
}else if( strncmp(zCmd,"close",5)==0 ){
@@ -922,11 +986,11 @@
922986
@ reopened).</li>
923987
@ </ol>
924988
style_sidebox_end();
925989
#endif
926990
927
- branch_prepare_list_query(&q, brFlags, 0, 0);
991
+ branch_prepare_list_query(&q, brFlags, 0, 0, 0);
928992
cnt = 0;
929993
while( db_step(&q)==SQLITE_ROW ){
930994
const char *zBr = db_column_text(&q, 0);
931995
if( cnt==0 ){
932996
if( colorTest ){
933997
--- src/branch.c
+++ src/branch.c
@@ -278,10 +278,11 @@
278 #define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/
279 #define BRL_REVERSE 0x008 /* Reverse the sort order */
280 #define BRL_PRIVATE 0x010 /* Show only private branches */
281 #define BRL_MERGED 0x020 /* Show only merged branches */
282 #define BRL_UNMERGED 0x040 /* Show only unmerged branches */
 
283
284 #endif /* INTERFACE */
285
286 /*
287 ** Prepare a query that will list branches.
@@ -297,21 +298,38 @@
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. */
308 if( (brFlags & BRL_ORDERBY_MTIME)==0 ) nLimitMRU = 0;
309 /* Undocumented: invert negative values for nLimitMRU, so that command-line
310 ** arguments similar to `head -5' with "option numbers" are possible. */
311 if( nLimitMRU<0 ) nLimitMRU = -nLimitMRU;
312 blob_append_sql(&sql,"SELECT name, isprivate, mergeto FROM ("); /* OUTER QUERY */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313 switch( brFlags & BRL_OPEN_CLOSED_MASK ){
314 case BRL_CLOSED_ONLY: {
315 blob_append_sql(&sql,
316 "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE isclosed"
317 );
@@ -330,11 +348,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 +637,20 @@
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.
@@ -689,26 +715,42 @@
689 }
690 }else if( strncmp(zCmd,"list",n)==0 ||
691 strncmp(zCmd, "ls", n)==0 ||
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 ){
711 nLimit = 5;
712 if( g.argc>4 || (g.argc==4 && (nLimit = atoi(g.argv[3]))==0) ){
713 fossil_fatal("the lsh subcommand allows one optional numeric argument");
714 }
@@ -720,26 +762,48 @@
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 = 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;
 
731 if( (brFlags & BRL_MERGED) && fossil_strcmp(zCurrent,zMergeTo)!=0 ){
732 continue;
733 }
734 if( (brFlags & BRL_UNMERGED) && (fossil_strcmp(zCurrent,zMergeTo)==0
735 || isCur) ){
736 continue;
737 }
738 fossil_print("%s%s%s\n",
739 ( (brFlags & BRL_PRIVATE) ? " " : ( isPriv ? "#" : " ") ),
740 (isCur ? "* " : " "), zBr);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
741 }
742 db_finalize(&q);
743 }else if( strncmp(zCmd,"new",n)==0 ){
744 branch_new();
745 }else if( strncmp(zCmd,"close",5)==0 ){
@@ -922,11 +986,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
@@ -278,10 +278,11 @@
278 #define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/
279 #define BRL_REVERSE 0x008 /* Reverse the sort order */
280 #define BRL_PRIVATE 0x010 /* Show only private branches */
281 #define BRL_MERGED 0x020 /* Show only merged branches */
282 #define BRL_UNMERGED 0x040 /* Show only unmerged branches */
283 #define BRL_LIST_USERS 0x080 /* Populate list of users participating */
284
285 #endif /* INTERFACE */
286
287 /*
288 ** Prepare a query that will list branches.
@@ -297,21 +298,38 @@
298 */
299 void branch_prepare_list_query(
300 Stmt *pQuery,
301 int brFlags,
302 const char *zBrNameGlob,
303 int nLimitMRU,
304 const char *zUser
305 ){
306 Blob sql;
307 blob_init(&sql, 0, 0);
308 brlist_create_temp_table();
309 /* Ignore nLimitMRU if no chronological sort requested. */
310 if( (brFlags & BRL_ORDERBY_MTIME)==0 ) nLimitMRU = 0;
311 /* Undocumented: invert negative values for nLimitMRU, so that command-line
312 ** arguments similar to `head -5' with "option numbers" are possible. */
313 if( nLimitMRU<0 ) nLimitMRU = -nLimitMRU;
314 /* OUTER QUERY */
315 blob_append_sql(&sql,"SELECT name, isprivate, mergeto,");
316 if( brFlags & BRL_LIST_USERS ){
317 blob_append_sql(&sql,
318 " (SELECT group_concat(user) FROM ("
319 " SELECT DISTINCT * FROM ("
320 " SELECT coalesce(euser,user) AS user"
321 " FROM event"
322 " WHERE type='ci' AND objid IN ("
323 " SELECT rid FROM tagxref WHERE value=name)"
324 " ORDER BY 1)))"
325 );
326 }else{
327 blob_append_sql(&sql, " NULL");
328 }
329 blob_append_sql(&sql," FROM (");
330 /* INNER QUERY */
331 switch( brFlags & BRL_OPEN_CLOSED_MASK ){
332 case BRL_CLOSED_ONLY: {
333 blob_append_sql(&sql,
334 "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE isclosed"
335 );
@@ -330,11 +348,16 @@
348 break;
349 }
350 }
351 if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate");
352 if( brFlags & BRL_MERGED ) blob_append_sql(&sql, " AND mergeto IS NOT NULL");
353 if( zBrNameGlob ) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob);
354 if( zUser && zUser[0] ) blob_append_sql(&sql,
355 " AND EXISTS (SELECT 1 FROM event WHERE type='ci' AND (user=%Q OR euser=%Q)"
356 " AND objid in (SELECT rid FROM tagxref WHERE value=tmp_brlist.name))",
357 zUser, zUser
358 );
359 if( brFlags & BRL_ORDERBY_MTIME ){
360 blob_append_sql(&sql, " ORDER BY -mtime");
361 }else{
362 blob_append_sql(&sql, " ORDER BY name COLLATE nocase");
363 }
@@ -614,17 +637,20 @@
637 ** > fossil branch lsh ?OPTIONS? ?LIMIT?
638 **
639 ** List all branches.
640 **
641 ** Options:
642 ** -a|--all List all branches. Default show only open branches
643 ** -c|--closed List closed branches
644 ** -m|--merged List branches merged into the current branch
645 ** -M|--unmerged List branches not merged into the current branch
646 ** -p List only private branches
647 ** -r Reverse the sort order
648 ** -t Show recently changed branches first
649 ** --self List only branches where you participate
650 ** --username USER List only branches where USER participate
651 ** --users N List up to N users partipiating
652 **
653 ** The current branch is marked with an asterisk. Private branches are
654 ** marked with a hash sign.
655 **
656 ** If GLOB is given, show only branches matching the pattern.
@@ -689,26 +715,42 @@
715 }
716 }else if( strncmp(zCmd,"list",n)==0 ||
717 strncmp(zCmd, "ls", n)==0 ||
718 strcmp(zCmd, "lsh")==0 ){
719 Stmt q;
720 Blob txt = empty_blob;
721 int vid;
722 char *zCurrent = 0;
723 const char *zBrNameGlob = 0;
724 const char *zUser = find_option("username",0,1);
725 const char *zUsersOpt = find_option("users",0,1);
726 int nUsers = zUsersOpt ? atoi(zUsersOpt) : 0;
727 int nLimit = 0;
728 int brFlags = BRL_OPEN_ONLY;
729 if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH;
730 if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY;
731 if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME;
732 if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE;
733 if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE;
734 if( find_option("merged","m",0)!=0 ) brFlags |= BRL_MERGED;
735 if( find_option("unmerged","M",0)!=0 ) brFlags |= BRL_UNMERGED;
736 if( find_option("self",0,0)!=0 ){
737 if( zUser ){
738 fossil_fatal("flags --username and --self are mutually exclusive");
739 }
740 user_select();
741 zUser = login_name();
742 }
743 verify_all_options();
744
745 if ( (brFlags & BRL_MERGED) && (brFlags & BRL_UNMERGED) ){
746 fossil_fatal("flags --merged and --unmerged are mutually exclusive");
747 }
748 if( zUsersOpt ){
749 if( nUsers <= 0) fossil_fatal("With --users, N must be positive");
750 brFlags |= BRL_LIST_USERS;
751 }
752 if( strcmp(zCmd, "lsh")==0 ){
753 nLimit = 5;
754 if( g.argc>4 || (g.argc==4 && (nLimit = atoi(g.argv[3]))==0) ){
755 fossil_fatal("the lsh subcommand allows one optional numeric argument");
756 }
@@ -720,26 +762,48 @@
762 if( g.localOpen ){
763 vid = db_lget_int("checkout", 0);
764 zCurrent = db_text(0, "SELECT value FROM tagxref"
765 " WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH);
766 }
767 branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit, zUser);
768 blob_init(&txt, 0, 0);
769 while( db_step(&q)==SQLITE_ROW ){
770 const char *zBr = db_column_text(&q, 0);
771 int isPriv = db_column_int(&q, 1)==1;
772 const char *zMergeTo = db_column_text(&q, 2);
773 int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0;
774 const char *zUsers = db_column_text(&q, 3);
775 if( (brFlags & BRL_MERGED) && fossil_strcmp(zCurrent,zMergeTo)!=0 ){
776 continue;
777 }
778 if( (brFlags & BRL_UNMERGED) && (fossil_strcmp(zCurrent,zMergeTo)==0
779 || isCur) ){
780 continue;
781 }
782 blob_appendf(&txt, "%s%s%s",
783 ( (brFlags & BRL_PRIVATE) ? " " : ( isPriv ? "#" : " ") ),
784 (isCur ? "* " : " "), zBr);
785 if( nUsers ){
786 char c;
787 const char *cp;
788 const char *pComma = 0;
789 int commas = 0;
790 for( cp = zUsers; ( c = *cp ) != 0; cp++ ){
791 if( c == ',' ){
792 commas++;
793 if( commas == nUsers ) pComma = cp;
794 }
795 }
796 if( pComma ){
797 blob_appendf(&txt, " (%.*s,... %i more)",
798 pComma - zUsers, zUsers, commas + 1 - nUsers);
799 }else{
800 blob_appendf(&txt, " (%s)", zUsers);
801 }
802 }
803 fossil_print("%s\n", blob_str(&txt));
804 blob_reset(&txt);
805 }
806 db_finalize(&q);
807 }else if( strncmp(zCmd,"new",n)==0 ){
808 branch_new();
809 }else if( strncmp(zCmd,"close",5)==0 ){
@@ -922,11 +986,11 @@
986 @ reopened).</li>
987 @ </ol>
988 style_sidebox_end();
989 #endif
990
991 branch_prepare_list_query(&q, brFlags, 0, 0, 0);
992 cnt = 0;
993 while( db_step(&q)==SQLITE_ROW ){
994 const char *zBr = db_column_text(&q, 0);
995 if( cnt==0 ){
996 if( colorTest ){
997
--- src/json_branch.c
+++ src/json_branch.c
@@ -128,11 +128,11 @@
128128
cson_object_set(pay,"current",json_new_string(zCurrent));
129129
}
130130
}
131131
132132
133
- branch_prepare_list_query(&q, branchListFlags, 0, 0);
133
+ branch_prepare_list_query(&q, branchListFlags, 0, 0, 0); /* Allow a user? */
134134
cson_object_set(pay,"branches",listV);
135135
while((SQLITE_ROW==db_step(&q))){
136136
cson_value * v = cson_sqlite3_column_to_value(q.pStmt,0);
137137
if(v){
138138
cson_array_append(list,v);
139139
--- 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

Keyboard Shortcuts

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