Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add a new `-h' option to `fossil branch ls' to list the "hot" (first few recently modified) branches. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | ls-hot-branches |
| Files: | files | file ages | folders |
| SHA3-256: |
fe299ee400d06551774b874e158819d0 |
| User & Date: | florian 2022-07-31 10:47:00.000 |
Context
|
2022-08-02
| ||
| 10:27 | Refactor the `-h' option to its own `lsh' subcommand sibling to `list|ls' to reuse their infrastructure and flags. To produce useful output with the `-r' option, the SQL query to generate the branch list is LIMIT'ed in an inner query, and then ORDER'ed again in an outer query. ... (check-in: dbd6efe2d8 user: florian tags: ls-hot-branches) | |
|
2022-07-31
| ||
| 10:47 | Add a new `-h' option to `fossil branch ls' to list the "hot" (first few recently modified) branches. ... (check-in: fe299ee400 user: florian tags: ls-hot-branches) | |
|
2022-07-30
| ||
| 20:33 | login-group command: corrected help text for 'join' option to include REPO and extended code to allow REPO to optionally be passed on as -R REPO. Resolves issue reported in [forum:240b6d856a3dd4b5|forum post 240b6d856a3dd4b5]. ... (check-in: 769a7651e4 user: stephan tags: trunk) | |
Changes
Changes to src/branch.c.
| ︙ | ︙ | |||
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | #define BRL_CLOSED_ONLY 0x001 /* Show only closed branches */ #define BRL_OPEN_ONLY 0x002 /* Show only open branches */ #define BRL_BOTH 0x003 /* Show both open and closed branches */ #define BRL_OPEN_CLOSED_MASK 0x003 #define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/ #define BRL_REVERSE 0x008 /* Reverse the sort order */ #define BRL_PRIVATE 0x010 /* Show only private branches */ #endif /* INTERFACE */ /* ** Prepare a query that will list branches. ** ** If (which<0) then the query pulls only closed branches. If ** (which>0) then the query pulls all (closed and opened) ** branches. Else the query pulls currently-opened branches. */ | > | > > > > > | 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
#define BRL_CLOSED_ONLY 0x001 /* Show only closed branches */
#define BRL_OPEN_ONLY 0x002 /* Show only open branches */
#define BRL_BOTH 0x003 /* Show both open and closed branches */
#define BRL_OPEN_CLOSED_MASK 0x003
#define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/
#define BRL_REVERSE 0x008 /* Reverse the sort order */
#define BRL_PRIVATE 0x010 /* Show only private branches */
#define BRL_LIMIT 0x020 /* Limit entries to specified number */
#endif /* INTERFACE */
/*
** Prepare a query that will list branches.
**
** If (which<0) then the query pulls only closed branches. If
** (which>0) then the query pulls all (closed and opened)
** branches. Else the query pulls currently-opened branches.
*/
void branch_prepare_list_query(
Stmt *pQuery,
int brFlags,
const char *zBrNameGlob,
int nLimit
){
Blob sql;
blob_init(&sql, 0, 0);
brlist_create_temp_table();
switch( brFlags & BRL_OPEN_CLOSED_MASK ){
case BRL_CLOSED_ONLY: {
blob_append_sql(&sql,
"SELECT name, isprivate FROM tmp_brlist WHERE isclosed"
|
| ︙ | ︙ | |||
322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
blob_append_sql(&sql, " ORDER BY -mtime");
}else{
blob_append_sql(&sql, " ORDER BY name COLLATE nocase");
}
if( brFlags & BRL_REVERSE ){
blob_append_sql(&sql," DESC");
}
db_prepare_blob(pQuery, &sql);
blob_reset(&sql);
}
/*
** If the branch named in the argument is open, return a RID for one of
** the open leaves of that branch. If the branch does not exists or is
| > > > | 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
blob_append_sql(&sql, " ORDER BY -mtime");
}else{
blob_append_sql(&sql, " ORDER BY name COLLATE nocase");
}
if( brFlags & BRL_REVERSE ){
blob_append_sql(&sql," DESC");
}
if( brFlags & BRL_LIMIT && nLimit>0 ){
blob_append_sql(&sql," LIMIT %d",nLimit);
}
db_prepare_blob(pQuery, &sql);
blob_reset(&sql);
}
/*
** If the branch named in the argument is open, return a RID for one of
** the open leaves of that branch. If the branch does not exists or is
|
| ︙ | ︙ | |||
590 591 592 593 594 595 596 597 598 599 600 | ** ** List all branches. Options: ** -a|--all List all branches. Default show only open branches ** -c|--closed List closed branches. ** -p List only private branches. ** -r Reverse the sort order ** -t Show recently changed branches first ** ** The current branch is marked with an asterisk. Private branches are ** marked with a hash sign. ** | > | > > | 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | ** ** List all branches. Options: ** -a|--all List all branches. Default show only open branches ** -c|--closed List closed branches. ** -p List only private branches. ** -r Reverse the sort order ** -t Show recently changed branches first ** -h ?N? Show N recently changed branches (or 5 if N omitted) ** ** The current branch is marked with an asterisk. Private branches are ** marked with a hash sign. ** ** If GLOB is given, show only branches matching the pattern. With the ** -h option set, no GLOB argument is allowed, but an (optional) number ** of entries to output. ** ** > fossil branch new BRANCH-NAME BASIS ?OPTIONS? ** ** Create a new branch BRANCH-NAME off of check-in BASIS. ** Supported options for this subcommand include: ** --private branch is private (i.e., remains local) ** --bgcolor COLOR use COLOR instead of automatic background |
| ︙ | ︙ | |||
654 655 656 657 658 659 660 661 662 663 664 665 666 |
}
}
}else if( (strncmp(zCmd,"list",n)==0)||(strncmp(zCmd, "ls", n)==0) ){
Stmt q;
int vid;
char *zCurrent = 0;
const char *zBrNameGlob = 0;
int brFlags = BRL_OPEN_ONLY;
if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH;
if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY;
if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME;
if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE;
if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE;
| > > > | > > > > > > | | 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 |
}
}
}else if( (strncmp(zCmd,"list",n)==0)||(strncmp(zCmd, "ls", n)==0) ){
Stmt q;
int vid;
char *zCurrent = 0;
const char *zBrNameGlob = 0;
int nLimit = 5;
int brFlags = BRL_OPEN_ONLY;
if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH;
if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY;
if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME;
if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE;
if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE;
if( find_option("h",0,0)!=0 ) brFlags |= BRL_LIMIT;
if( (brFlags & BRL_LIMIT)==0 ){
if( g.argc >= 4 ) zBrNameGlob = g.argv[3];
}else{
if( g.argc>4 || g.argc==4 && (nLimit = atoi(g.argv[3]))==0 ){
fossil_fatal("only one numeric or no argument allowed following -h");
}
brFlags |= BRL_ORDERBY_MTIME;
}
if( g.localOpen ){
vid = db_lget_int("checkout", 0);
zCurrent = db_text(0, "SELECT value FROM tagxref"
" WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH);
}
branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit);
while( db_step(&q)==SQLITE_ROW ){
const char *zBr = db_column_text(&q, 0);
int isPriv = zCurrent!=0 && db_column_int(&q, 1)==1;
int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0;
fossil_print("%s%s%s\n",
( (brFlags & BRL_PRIVATE) ? " " : ( isPriv ? "#" : " ") ),
(isCur ? "* " : " "), zBr);
|
| ︙ | ︙ | |||
860 861 862 863 864 865 866 | @ closed leaves</a></div>. @ Closed branches are fixed and do not change (unless they are first @ reopened).</li> @ </ol> style_sidebox_end(); #endif | | | 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 |
@ closed leaves</a></div>.
@ Closed branches are fixed and do not change (unless they are first
@ reopened).</li>
@ </ol>
style_sidebox_end();
#endif
branch_prepare_list_query(&q, brFlags, 0, 0);
cnt = 0;
while( db_step(&q)==SQLITE_ROW ){
const char *zBr = db_column_text(&q, 0);
if( cnt==0 ){
if( colorTest ){
@ <h2>Default background colors for all branches:</h2>
}else if( showClosed ){
|
| ︙ | ︙ |