Fossil SCM
Add the new subcommand `fossil branch lsh' to list the most recently modified branches.
Commit
fc8e5750d7b05e78565b6d9a1f5d7c94c52e86a6a7d60cca9e49be78e611c964
Parent
ad0aac2fdeb1c12…
1 file changed
+55
-10
+55
-10
| --- src/branch.c | ||
| +++ src/branch.c | ||
| @@ -289,31 +289,51 @@ | ||
| 289 | 289 | ** Prepare a query that will list branches. |
| 290 | 290 | ** |
| 291 | 291 | ** If (which<0) then the query pulls only closed branches. If |
| 292 | 292 | ** (which>0) then the query pulls all (closed and opened) |
| 293 | 293 | ** branches. Else the query pulls currently-opened branches. |
| 294 | +** | |
| 295 | +** If the BRL_ORDERBY_MTIME flag is set and nLimitMRU ("Limit Most Recently Used | |
| 296 | +** style") is a non-zero number, the result is limited to nLimitMRU entries, and | |
| 297 | +** the BRL_REVERSE flag is applied in an outer query after processing the limit, | |
| 298 | +** so that it's possible to generate short lists with the most recently modified | |
| 299 | +** branches sorted chronologically in either direction, as does the "branch lsh" | |
| 300 | +** command. | |
| 301 | +** For other cases, the outer query is also generated, but works as a no-op. The | |
| 302 | +** code to build the outer query is marked with *//* OUTER QUERY *//* comments. | |
| 294 | 303 | */ |
| 295 | -void branch_prepare_list_query(Stmt *pQuery, int brFlags, const char *zBrNameGlob){ | |
| 304 | +void branch_prepare_list_query( | |
| 305 | + Stmt *pQuery, | |
| 306 | + int brFlags, | |
| 307 | + const char *zBrNameGlob, | |
| 308 | + int nLimitMRU | |
| 309 | +){ | |
| 296 | 310 | Blob sql; |
| 297 | 311 | blob_init(&sql, 0, 0); |
| 298 | 312 | brlist_create_temp_table(); |
| 313 | + /* Ignore nLimitMRU if no chronological sort requested. */ | |
| 314 | + if( (brFlags & BRL_ORDERBY_MTIME)==0 ) nLimitMRU = 0; | |
| 315 | + /* Undocumented: invert negative values for nLimitMRU, so that command-line | |
| 316 | + ** arguments similar to `head -5' with "option numbers" are possible. */ | |
| 317 | + if( nLimitMRU<0 ) nLimitMRU = -nLimitMRU; | |
| 318 | + blob_append_sql(&sql,"SELECT name, isprivate FROM ("); /* OUTER QUERY */ | |
| 299 | 319 | switch( brFlags & BRL_OPEN_CLOSED_MASK ){ |
| 300 | 320 | case BRL_CLOSED_ONLY: { |
| 301 | 321 | blob_append_sql(&sql, |
| 302 | - "SELECT name, isprivate FROM tmp_brlist WHERE isclosed" | |
| 322 | + "SELECT name, isprivate, mtime FROM tmp_brlist WHERE isclosed" | |
| 303 | 323 | ); |
| 304 | 324 | break; |
| 305 | 325 | } |
| 306 | 326 | case BRL_BOTH: { |
| 307 | 327 | blob_append_sql(&sql, |
| 308 | - "SELECT name, isprivate FROM tmp_brlist WHERE 1" | |
| 328 | + "SELECT name, isprivate, mtime FROM tmp_brlist WHERE 1" | |
| 309 | 329 | ); |
| 310 | 330 | break; |
| 311 | 331 | } |
| 312 | 332 | case BRL_OPEN_ONLY: { |
| 313 | 333 | blob_append_sql(&sql, |
| 314 | - "SELECT name, isprivate FROM tmp_brlist WHERE NOT isclosed" | |
| 334 | + "SELECT name, isprivate, mtime FROM tmp_brlist WHERE NOT isclosed" | |
| 315 | 335 | ); |
| 316 | 336 | break; |
| 317 | 337 | } |
| 318 | 338 | } |
| 319 | 339 | if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate"); |
| @@ -321,13 +341,20 @@ | ||
| 321 | 341 | if( brFlags & BRL_ORDERBY_MTIME ){ |
| 322 | 342 | blob_append_sql(&sql, " ORDER BY -mtime"); |
| 323 | 343 | }else{ |
| 324 | 344 | blob_append_sql(&sql, " ORDER BY name COLLATE nocase"); |
| 325 | 345 | } |
| 326 | - if( brFlags & BRL_REVERSE ){ | |
| 346 | + if( brFlags & BRL_REVERSE && !nLimitMRU ){ | |
| 327 | 347 | blob_append_sql(&sql," DESC"); |
| 328 | 348 | } |
| 349 | + if( nLimitMRU ){ | |
| 350 | + blob_append_sql(&sql," LIMIT %d",nLimitMRU); | |
| 351 | + } | |
| 352 | + blob_append_sql(&sql,")"); /* OUTER QUERY */ | |
| 353 | + if( brFlags & BRL_REVERSE && nLimitMRU ){ | |
| 354 | + blob_append_sql(&sql," ORDER BY mtime"); /* OUTER QUERY */ | |
| 355 | + } | |
| 329 | 356 | db_prepare_blob(pQuery, &sql); |
| 330 | 357 | blob_reset(&sql); |
| 331 | 358 | } |
| 332 | 359 | |
| 333 | 360 | /* |
| @@ -585,10 +612,11 @@ | ||
| 585 | 612 | ** > fossil branch info BRANCH-NAME |
| 586 | 613 | ** |
| 587 | 614 | ** Print information about a branch |
| 588 | 615 | ** |
| 589 | 616 | ** > fossil branch list|ls ?OPTIONS? ?GLOB? |
| 617 | +** > fossil branch lsh ?OPTIONS? ?LIMIT? | |
| 590 | 618 | ** |
| 591 | 619 | ** List all branches. Options: |
| 592 | 620 | ** -a|--all List all branches. Default show only open branches |
| 593 | 621 | ** -c|--closed List closed branches. |
| 594 | 622 | ** -p List only private branches. |
| @@ -597,10 +625,15 @@ | ||
| 597 | 625 | ** |
| 598 | 626 | ** The current branch is marked with an asterisk. Private branches are |
| 599 | 627 | ** marked with a hash sign. |
| 600 | 628 | ** |
| 601 | 629 | ** If GLOB is given, show only branches matching the pattern. |
| 630 | +** | |
| 631 | +** The "lsh" variant of this subcommand shows recently changed branches, | |
| 632 | +** and accepts an optional LIMIT argument (defaults to 5) to cap output, | |
| 633 | +** but no GLOB argument. All other options are supported, with -t being | |
| 634 | +** an implied no-op. | |
| 602 | 635 | ** |
| 603 | 636 | ** > fossil branch new BRANCH-NAME BASIS ?OPTIONS? |
| 604 | 637 | ** |
| 605 | 638 | ** Create a new branch BRANCH-NAME off of check-in BASIS. |
| 606 | 639 | ** Supported options for this subcommand include: |
| @@ -651,29 +684,41 @@ | ||
| 651 | 684 | "SELECT datetime(mtime,toLocal()) FROM event" |
| 652 | 685 | " WHERE objid=%d", rid); |
| 653 | 686 | fossil_print("%s: open as of %s on %.16s\n", zBrName, zDate, zUuid); |
| 654 | 687 | } |
| 655 | 688 | } |
| 656 | - }else if( (strncmp(zCmd,"list",n)==0)||(strncmp(zCmd, "ls", n)==0) ){ | |
| 689 | + }else if( strncmp(zCmd,"list",n)==0 || | |
| 690 | + strncmp(zCmd, "ls", n)==0 || | |
| 691 | + strcmp(zCmd, "lsh")==0 ){ | |
| 657 | 692 | Stmt q; |
| 658 | 693 | int vid; |
| 659 | 694 | char *zCurrent = 0; |
| 660 | 695 | const char *zBrNameGlob = 0; |
| 696 | + int nLimit = 0; | |
| 661 | 697 | int brFlags = BRL_OPEN_ONLY; |
| 662 | 698 | if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH; |
| 663 | 699 | if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY; |
| 664 | 700 | if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME; |
| 665 | 701 | if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE; |
| 666 | 702 | if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE; |
| 667 | - if( g.argc >= 4 ) zBrNameGlob = g.argv[3]; | |
| 703 | + | |
| 704 | + if( strcmp(zCmd, "lsh")==0 ){ | |
| 705 | + nLimit = 5; | |
| 706 | + if( g.argc>4 || (g.argc==4 && (nLimit = atoi(g.argv[3]))==0) ){ | |
| 707 | + fossil_fatal("the lsh subcommand allows one optional numeric argument"); | |
| 708 | + } | |
| 709 | + brFlags |= BRL_ORDERBY_MTIME; | |
| 710 | + }else{ | |
| 711 | + if( g.argc >= 4 ) zBrNameGlob = g.argv[3]; | |
| 712 | + } | |
| 668 | 713 | |
| 669 | 714 | if( g.localOpen ){ |
| 670 | 715 | vid = db_lget_int("checkout", 0); |
| 671 | 716 | zCurrent = db_text(0, "SELECT value FROM tagxref" |
| 672 | 717 | " WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH); |
| 673 | 718 | } |
| 674 | - branch_prepare_list_query(&q, brFlags, zBrNameGlob); | |
| 719 | + branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit); | |
| 675 | 720 | while( db_step(&q)==SQLITE_ROW ){ |
| 676 | 721 | const char *zBr = db_column_text(&q, 0); |
| 677 | 722 | int isPriv = zCurrent!=0 && db_column_int(&q, 1)==1; |
| 678 | 723 | int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0; |
| 679 | 724 | fossil_print("%s%s%s\n", |
| @@ -703,11 +748,11 @@ | ||
| 703 | 748 | usage("branch unhide branch-name(s)..."); |
| 704 | 749 | } |
| 705 | 750 | branch_cmd_hide(3,0); |
| 706 | 751 | }else{ |
| 707 | 752 | fossil_fatal("branch subcommand should be one of: " |
| 708 | - "close current hide info list ls new reopen unhide"); | |
| 753 | + "close current hide info list ls lsh new reopen unhide"); | |
| 709 | 754 | } |
| 710 | 755 | } |
| 711 | 756 | |
| 712 | 757 | /* |
| 713 | 758 | ** This is the new-style branch-list page that shows the branch names |
| @@ -862,11 +907,11 @@ | ||
| 862 | 907 | @ reopened).</li> |
| 863 | 908 | @ </ol> |
| 864 | 909 | style_sidebox_end(); |
| 865 | 910 | #endif |
| 866 | 911 | |
| 867 | - branch_prepare_list_query(&q, brFlags, 0); | |
| 912 | + branch_prepare_list_query(&q, brFlags, 0, 0); | |
| 868 | 913 | cnt = 0; |
| 869 | 914 | while( db_step(&q)==SQLITE_ROW ){ |
| 870 | 915 | const char *zBr = db_column_text(&q, 0); |
| 871 | 916 | if( cnt==0 ){ |
| 872 | 917 | if( colorTest ){ |
| 873 | 918 |
| --- src/branch.c | |
| +++ src/branch.c | |
| @@ -289,31 +289,51 @@ | |
| 289 | ** Prepare a query that will list branches. |
| 290 | ** |
| 291 | ** If (which<0) then the query pulls only closed branches. If |
| 292 | ** (which>0) then the query pulls all (closed and opened) |
| 293 | ** branches. Else the query pulls currently-opened branches. |
| 294 | */ |
| 295 | void branch_prepare_list_query(Stmt *pQuery, int brFlags, const char *zBrNameGlob){ |
| 296 | Blob sql; |
| 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"); |
| @@ -321,13 +341,20 @@ | |
| 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"); |
| 325 | } |
| 326 | if( brFlags & BRL_REVERSE ){ |
| 327 | blob_append_sql(&sql," DESC"); |
| 328 | } |
| 329 | db_prepare_blob(pQuery, &sql); |
| 330 | blob_reset(&sql); |
| 331 | } |
| 332 | |
| 333 | /* |
| @@ -585,10 +612,11 @@ | |
| 585 | ** > fossil branch info BRANCH-NAME |
| 586 | ** |
| 587 | ** Print information about a branch |
| 588 | ** |
| 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. |
| @@ -597,10 +625,15 @@ | |
| 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 | ** |
| 605 | ** Create a new branch BRANCH-NAME off of check-in BASIS. |
| 606 | ** Supported options for this subcommand include: |
| @@ -651,29 +684,41 @@ | |
| 651 | "SELECT datetime(mtime,toLocal()) FROM event" |
| 652 | " WHERE objid=%d", rid); |
| 653 | fossil_print("%s: open as of %s on %.16s\n", zBrName, zDate, zUuid); |
| 654 | } |
| 655 | } |
| 656 | }else if( (strncmp(zCmd,"list",n)==0)||(strncmp(zCmd, "ls", n)==0) ){ |
| 657 | Stmt q; |
| 658 | int vid; |
| 659 | char *zCurrent = 0; |
| 660 | const char *zBrNameGlob = 0; |
| 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" |
| 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", |
| @@ -703,11 +748,11 @@ | |
| 703 | usage("branch unhide branch-name(s)..."); |
| 704 | } |
| 705 | branch_cmd_hide(3,0); |
| 706 | }else{ |
| 707 | fossil_fatal("branch subcommand should be one of: " |
| 708 | "close current hide info list ls new reopen unhide"); |
| 709 | } |
| 710 | } |
| 711 | |
| 712 | /* |
| 713 | ** This is the new-style branch-list page that shows the branch names |
| @@ -862,11 +907,11 @@ | |
| 862 | @ reopened).</li> |
| 863 | @ </ol> |
| 864 | style_sidebox_end(); |
| 865 | #endif |
| 866 | |
| 867 | branch_prepare_list_query(&q, brFlags, 0); |
| 868 | cnt = 0; |
| 869 | while( db_step(&q)==SQLITE_ROW ){ |
| 870 | const char *zBr = db_column_text(&q, 0); |
| 871 | if( cnt==0 ){ |
| 872 | if( colorTest ){ |
| 873 |
| --- src/branch.c | |
| +++ src/branch.c | |
| @@ -289,31 +289,51 @@ | |
| 289 | ** Prepare a query that will list branches. |
| 290 | ** |
| 291 | ** If (which<0) then the query pulls only closed branches. If |
| 292 | ** (which>0) then the query pulls all (closed and opened) |
| 293 | ** branches. Else the query pulls currently-opened branches. |
| 294 | ** |
| 295 | ** If the BRL_ORDERBY_MTIME flag is set and nLimitMRU ("Limit Most Recently Used |
| 296 | ** style") is a non-zero number, the result is limited to nLimitMRU entries, and |
| 297 | ** the BRL_REVERSE flag is applied in an outer query after processing the limit, |
| 298 | ** so that it's possible to generate short lists with the most recently modified |
| 299 | ** branches sorted chronologically in either direction, as does the "branch lsh" |
| 300 | ** command. |
| 301 | ** For other cases, the outer query is also generated, but works as a no-op. The |
| 302 | ** code to build the outer query is marked with *//* OUTER QUERY *//* comments. |
| 303 | */ |
| 304 | void branch_prepare_list_query( |
| 305 | Stmt *pQuery, |
| 306 | int brFlags, |
| 307 | const char *zBrNameGlob, |
| 308 | int nLimitMRU |
| 309 | ){ |
| 310 | Blob sql; |
| 311 | blob_init(&sql, 0, 0); |
| 312 | brlist_create_temp_table(); |
| 313 | /* Ignore nLimitMRU if no chronological sort requested. */ |
| 314 | if( (brFlags & BRL_ORDERBY_MTIME)==0 ) nLimitMRU = 0; |
| 315 | /* Undocumented: invert negative values for nLimitMRU, so that command-line |
| 316 | ** arguments similar to `head -5' with "option numbers" are possible. */ |
| 317 | if( nLimitMRU<0 ) nLimitMRU = -nLimitMRU; |
| 318 | blob_append_sql(&sql,"SELECT name, isprivate FROM ("); /* OUTER QUERY */ |
| 319 | switch( brFlags & BRL_OPEN_CLOSED_MASK ){ |
| 320 | case BRL_CLOSED_ONLY: { |
| 321 | blob_append_sql(&sql, |
| 322 | "SELECT name, isprivate, mtime FROM tmp_brlist WHERE isclosed" |
| 323 | ); |
| 324 | break; |
| 325 | } |
| 326 | case BRL_BOTH: { |
| 327 | blob_append_sql(&sql, |
| 328 | "SELECT name, isprivate, mtime FROM tmp_brlist WHERE 1" |
| 329 | ); |
| 330 | break; |
| 331 | } |
| 332 | case BRL_OPEN_ONLY: { |
| 333 | blob_append_sql(&sql, |
| 334 | "SELECT name, isprivate, mtime FROM tmp_brlist WHERE NOT isclosed" |
| 335 | ); |
| 336 | break; |
| 337 | } |
| 338 | } |
| 339 | if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate"); |
| @@ -321,13 +341,20 @@ | |
| 341 | if( brFlags & BRL_ORDERBY_MTIME ){ |
| 342 | blob_append_sql(&sql, " ORDER BY -mtime"); |
| 343 | }else{ |
| 344 | blob_append_sql(&sql, " ORDER BY name COLLATE nocase"); |
| 345 | } |
| 346 | if( brFlags & BRL_REVERSE && !nLimitMRU ){ |
| 347 | blob_append_sql(&sql," DESC"); |
| 348 | } |
| 349 | if( nLimitMRU ){ |
| 350 | blob_append_sql(&sql," LIMIT %d",nLimitMRU); |
| 351 | } |
| 352 | blob_append_sql(&sql,")"); /* OUTER QUERY */ |
| 353 | if( brFlags & BRL_REVERSE && nLimitMRU ){ |
| 354 | blob_append_sql(&sql," ORDER BY mtime"); /* OUTER QUERY */ |
| 355 | } |
| 356 | db_prepare_blob(pQuery, &sql); |
| 357 | blob_reset(&sql); |
| 358 | } |
| 359 | |
| 360 | /* |
| @@ -585,10 +612,11 @@ | |
| 612 | ** > fossil branch info BRANCH-NAME |
| 613 | ** |
| 614 | ** Print information about a branch |
| 615 | ** |
| 616 | ** > fossil branch list|ls ?OPTIONS? ?GLOB? |
| 617 | ** > fossil branch lsh ?OPTIONS? ?LIMIT? |
| 618 | ** |
| 619 | ** List all branches. Options: |
| 620 | ** -a|--all List all branches. Default show only open branches |
| 621 | ** -c|--closed List closed branches. |
| 622 | ** -p List only private branches. |
| @@ -597,10 +625,15 @@ | |
| 625 | ** |
| 626 | ** The current branch is marked with an asterisk. Private branches are |
| 627 | ** marked with a hash sign. |
| 628 | ** |
| 629 | ** If GLOB is given, show only branches matching the pattern. |
| 630 | ** |
| 631 | ** The "lsh" variant of this subcommand shows recently changed branches, |
| 632 | ** and accepts an optional LIMIT argument (defaults to 5) to cap output, |
| 633 | ** but no GLOB argument. All other options are supported, with -t being |
| 634 | ** an implied no-op. |
| 635 | ** |
| 636 | ** > fossil branch new BRANCH-NAME BASIS ?OPTIONS? |
| 637 | ** |
| 638 | ** Create a new branch BRANCH-NAME off of check-in BASIS. |
| 639 | ** Supported options for this subcommand include: |
| @@ -651,29 +684,41 @@ | |
| 684 | "SELECT datetime(mtime,toLocal()) FROM event" |
| 685 | " WHERE objid=%d", rid); |
| 686 | fossil_print("%s: open as of %s on %.16s\n", zBrName, zDate, zUuid); |
| 687 | } |
| 688 | } |
| 689 | }else if( strncmp(zCmd,"list",n)==0 || |
| 690 | strncmp(zCmd, "ls", n)==0 || |
| 691 | strcmp(zCmd, "lsh")==0 ){ |
| 692 | Stmt q; |
| 693 | int vid; |
| 694 | char *zCurrent = 0; |
| 695 | const char *zBrNameGlob = 0; |
| 696 | int nLimit = 0; |
| 697 | int brFlags = BRL_OPEN_ONLY; |
| 698 | if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH; |
| 699 | if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY; |
| 700 | if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME; |
| 701 | if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE; |
| 702 | if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE; |
| 703 | |
| 704 | if( strcmp(zCmd, "lsh")==0 ){ |
| 705 | nLimit = 5; |
| 706 | if( g.argc>4 || (g.argc==4 && (nLimit = atoi(g.argv[3]))==0) ){ |
| 707 | fossil_fatal("the lsh subcommand allows one optional numeric argument"); |
| 708 | } |
| 709 | brFlags |= BRL_ORDERBY_MTIME; |
| 710 | }else{ |
| 711 | if( g.argc >= 4 ) zBrNameGlob = g.argv[3]; |
| 712 | } |
| 713 | |
| 714 | if( g.localOpen ){ |
| 715 | vid = db_lget_int("checkout", 0); |
| 716 | zCurrent = db_text(0, "SELECT value FROM tagxref" |
| 717 | " WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH); |
| 718 | } |
| 719 | branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit); |
| 720 | while( db_step(&q)==SQLITE_ROW ){ |
| 721 | const char *zBr = db_column_text(&q, 0); |
| 722 | int isPriv = zCurrent!=0 && db_column_int(&q, 1)==1; |
| 723 | int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0; |
| 724 | fossil_print("%s%s%s\n", |
| @@ -703,11 +748,11 @@ | |
| 748 | usage("branch unhide branch-name(s)..."); |
| 749 | } |
| 750 | branch_cmd_hide(3,0); |
| 751 | }else{ |
| 752 | fossil_fatal("branch subcommand should be one of: " |
| 753 | "close current hide info list ls lsh new reopen unhide"); |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | /* |
| 758 | ** This is the new-style branch-list page that shows the branch names |
| @@ -862,11 +907,11 @@ | |
| 907 | @ reopened).</li> |
| 908 | @ </ol> |
| 909 | style_sidebox_end(); |
| 910 | #endif |
| 911 | |
| 912 | branch_prepare_list_query(&q, brFlags, 0, 0); |
| 913 | cnt = 0; |
| 914 | while( db_step(&q)==SQLITE_ROW ){ |
| 915 | const char *zBr = db_column_text(&q, 0); |
| 916 | if( cnt==0 ){ |
| 917 | if( colorTest ){ |
| 918 |