Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Attempting to rationalize the tagging and branching logic. The "branch" command has been resurrected and appears to work now. The "tag branch" command has been removed. Special tags "newbranch" and "closed" used to manage branches. New changes are not well-tested - use with caution. You must "rebuild" when upgrading through this version. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
b6e22e62cf26115617822c7940cec5d0 |
| User & Date: | drh 2009-01-20 16:51:19.000 |
References
|
2009-01-21
| ||
| 00:05 | Fix an SQL syntax error in the commit logic introduced by check-in [b6e22e62cf26115617822c7940cec5d0dc687184]. ... (check-in: f6d507179e user: drh tags: trunk) | |
Context
|
2009-01-20
| ||
| 22:21 | Add web-based branch color changer. Add the "branch list" command. Simplifications to color propagation logic. ... (check-in: b7f32a71ab user: drh tags: trunk) | |
| 16:51 | Attempting to rationalize the tagging and branching logic. The "branch" command has been resurrected and appears to work now. The "tag branch" command has been removed. Special tags "newbranch" and "closed" used to manage branches. New changes are not well-tested - use with caution. You must "rebuild" when upgrading through this version. ... (check-in: b6e22e62cf user: drh tags: trunk) | |
| 00:27 | Display a list of symbolic tags associated with each check-in on the timeline. ... (check-in: fbbd0318bd user: drh tags: trunk) | |
Changes
Changes to src/branch.c.
| ︙ | ︙ | |||
23 24 25 26 27 28 29 30 |
**
** This file contains code used to create new branches within a repository.
*/
#include "config.h"
#include "branch.h"
#include <assert.h>
void branch_new(void){
| > > > > > > | > > | | > > | > | > < < < < < < < | > > > > > > > > > > > > | | | > > > | < < > > | | > | | | | > | < < < < < < | > > < > > > > > > > > > > | > | | | > | > > | < < < > > | | | | | > > | | | | | | | < < | | | | > > | | | > | > | | < | | | < < < < < < < | < < < < < < < < < | | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
**
** This file contains code used to create new branches within a repository.
*/
#include "config.h"
#include "branch.h"
#include <assert.h>
/*
** fossil branch new BRANCH-NAME ?ORIGIN-CHECK-IN? ?-bgcolor COLOR?
** argv0 argv1 argv2 argv3 argv4
*/
void branch_new(void){
int rootid; /* RID of the root check-in - what we branch off of */
int brid; /* RID of the branch check-in */
int noSign; /* True if the branch is unsigned */
int i; /* Loop counter */
char *zUuid; /* Artifact ID of origin */
Stmt q; /* Generic query */
const char *zBranch; /* Name of the new branch */
char *zDate; /* Date that branch was created */
char *zComment; /* Check-in comment for the new branch */
const char *zColor; /* Color of the new branch */
Blob branch; /* manifest for the new branch */
Blob parent; /* root check-in manifest */
Manifest mParent; /* Parsed parent manifest */
Blob mcksum; /* Self-checksum on the manifest */
noSign = find_option("nosign","",0)!=0;
zColor = find_option("bgcolor","c",1);
verify_all_options();
if( g.argc<3 ){
usage("branch new BRANCH-NAME ?ROOT-CHECK-IN? ?-bgcolor COLOR?");
}
db_find_and_open_repository(1);
noSign = db_get_int("omitsign", 0)|noSign;
/* fossil branch new name */
zBranch = g.argv[3];
if( zBranch==0 || zBranch[0]==0 ){
fossil_panic("branch name cannot be empty");
}
if( db_exists(
"SELECT 1 FROM tagxref"
" WHERE tagtype>0"
" AND tagid=(SELECT tagid FROM tag WHERE tagname='sym-%s')",
zBranch)!=0 ){
fossil_fatal("branch \"%s\" already exists", zBranch);
}
user_select();
db_begin_transaction();
if( g.argc<5 ){
if( unsaved_changes() ){
fossil_fatal("there are uncommitted changes. please commit first");
}
rootid = db_lget_int("checkout", 0);
}else{
rootid = name_to_rid(g.argv[4]);
}
if( rootid==0 ){
fossil_fatal("unable to locate check-in off of which to branch");
}
/* Create a manifest for the new branch */
blob_zero(&branch);
zComment = mprintf("Create new branch named \"%h\"", zBranch);
blob_appendf(&branch, "C %F\n", zComment);
zDate = db_text(0, "SELECT datetime('now')");
zDate[10] = 'T';
blob_appendf(&branch, "D %s\n", zDate);
/* Copy all of the content from the parent into the branch */
content_get(rootid, &parent);
manifest_parse(&mParent, &parent);
if( mParent.type!=CFTYPE_MANIFEST ){
fossil_fatal("%s is not a valid check-in", g.argv[4]);
}
for(i=0; i<mParent.nFile; ++i){
if( mParent.aFile[i].zPerm[0] ){
blob_appendf(&branch, "F %F %s %s\n",
mParent.aFile[i].zName,
mParent.aFile[i].zUuid,
mParent.aFile[i].zPerm);
}else{
blob_appendf(&branch, "F %F %s\n",
mParent.aFile[i].zName,
mParent.aFile[i].zUuid);
}
}
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rootid);
blob_appendf(&branch, "P %s\n", zUuid);
blob_appendf(&branch, "R %s\n", mParent.zRepoCksum);
manifest_clear(&mParent);
/* Add the symbolic branch name and the "newbranch" tag to identify
** this as a new branch */
if( zColor!=0 ){
blob_appendf(&branch, "T *bgcolor * %F\n", zColor);
}
blob_appendf(&branch, "T *sym-%F *\n", zBranch);
blob_appendf(&branch, "T +newbranch *\n");
/* Cancel all other symbolic tags */
db_prepare(&q,
"SELECT tagname FROM tagxref, tag"
" WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid"
" AND tagtype>0 AND tagname GLOB 'sym-*'"
" ORDER BY tagname",
rootid);
while( db_step(&q)==SQLITE_ROW ){
const char *zTag = db_column_text(&q, 0);
blob_appendf(&branch, "T -%s *\n", zTag);
}
db_finalize(&q);
blob_appendf(&branch, "U %F\n", g.zLogin);
md5sum_blob(&branch, &mcksum);
blob_appendf(&branch, "Z %b\n", &mcksum);
if( !noSign && clearsign(&branch, &branch) ){
Blob ans;
blob_zero(&ans);
prompt_user("unable to sign manifest. continue [y/N]? ", &ans);
if( blob_str(&ans)[0]!='y' ){
db_end_transaction(1);
exit(1);
}
}
brid = content_put(&branch, 0, 0);
if( brid==0 ){
fossil_panic("trouble committing manifest: %s", g.zErrMsg);
}
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid);
if( manifest_crosslink(brid, &branch)==0 ){
fossil_panic("unable to install new manifest");
}
content_deltify(rootid, brid, 0);
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", brid);
printf("New branch: %s\n", zUuid);
if( g.argc==3 ){
printf(
"\n"
"Note: the local check-out has not been updated to the new\n"
" branch. To begin working on the new branch, do this:\n"
"\n"
" %s update %s\n",
g.argv[0], zBranch
);
}
/* Commit */
db_end_transaction(0);
/* Do an autosync push, if requested */
autosync(AUTOSYNC_PUSH);
}
/*
** COMMAND: branch
**
** Usage: %fossil branch SUBCOMMAND ... ?-R|--repository FILE?
**
** Run various subcommands on the branches of the open repository or
** of the repository identified by the -R or --repository option.
**
** %fossil branch new BRANCH-NAME ?ROOT-CHECK-IN? ?-bgcolor COLOR?
**
** Create a new branch BRANCH-NAME. You can optionally give
** a commit message and branch color.
**
** %fossil branch list
**
** List all branches
|
| ︙ | ︙ |
Changes to src/checkin.c.
| ︙ | ︙ | |||
342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
}
g.aCommitFile[ii-2] = iId;
blob_reset(&b);
}
g.aCommitFile[ii-2] = 0;
}
}
/*
** COMMAND: ci
** COMMAND: commit
**
** Usage: %fossil commit ?-m COMMENT? ?--nosign? ?FILE...?
**
| > > > > > > > > > > > > > > > > > > > | 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
}
g.aCommitFile[ii-2] = iId;
blob_reset(&b);
}
g.aCommitFile[ii-2] = 0;
}
}
/*
** Return true if the check-in with RID=rid has one or more child
** check-ins which are not tagged with "newbranch". In other words,
** return true if the check-in is not a leaf.
*/
int is_not_a_leaf(int rid){
return db_exists(
"SELECT 1 FROM plink"
" WHERE pid=%d"
" AND NOT EXIST("
"SELECT 1 FROM tagxref"
" WHERE tagxref.rid=plink.cid"
" AND tagxref.tagid=%d"
" AND tagxref.tagtype=1"
")",
rid, TAG_NEWBRANCH
);
}
/*
** COMMAND: ci
** COMMAND: commit
**
** Usage: %fossil commit ?-m COMMENT? ?--nosign? ?FILE...?
**
|
| ︙ | ︙ | |||
438 439 440 441 442 443 444 |
);
if( strlen(blob_str(&unmodified)) ){
fossil_panic("file %s has not changed", blob_str(&unmodified));
}
}
vid = db_lget_int("checkout", 0);
| | | | 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
);
if( strlen(blob_str(&unmodified)) ){
fossil_panic("file %s has not changed", blob_str(&unmodified));
}
}
vid = db_lget_int("checkout", 0);
if( is_not_a_leaf(vid) ){
wouldFork=1;
if( forceFlag==0 ){
fossil_fatal("would fork. \"update\" first or use -f or --force.");
}
}
vfile_aggregate_checksum_disk(vid, &cksum1);
if( zComment ){
blob_zero(&comment);
blob_append(&comment, zComment, -1);
}else{
|
| ︙ | ︙ |
Changes to src/descendants.c.
| ︙ | ︙ | |||
28 29 30 31 32 33 34 | #include "descendants.h" #include <assert.h> /* ** Create a temporary table named "leaves" if it does not ** already exist. Load this table with the RID of all | | | > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > < | > > | | > > | | > > > > > > > > > > > > > > > > > > > > > > > > | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
#include "descendants.h"
#include <assert.h>
/*
** Create a temporary table named "leaves" if it does not
** already exist. Load this table with the RID of all
** check-ins that are leaves which are decended from
** check-in iBase.
**
** A "leaf" is a check-in that has no children. For the purpose
** of finding leaves, children marked with the "newbranch" tag are
** not counted as children. For example:
**
**
** A -> B -> C -> D
** `-> E
**
** D and E are clearly leaves since they have no children. If
** D has the "newbranch" tag, then C is also a leaf since its only
** child is marked as a newbranch.
**
** The closeMode flag determines behavior associated with the "closed"
** tag:
**
** closeMode==0 Show all leaves regardless of the "closed" tag.
**
** closeMode==1 Show only leaves without the "closed" tag.
**
** closeMode==2 Show only leaves with the "closed" tag.
**
** The default behavior is to ignore closed leaves (closeMode==0). To
** Show all leaves, use closeMode==1. To show only closed leaves, use
** closeMode==2.
*/
void compute_leaves(int iBase, int closeMode){
Bag seen; /* Descendants seen */
Bag pending; /* Unpropagated descendants */
Stmt q; /* Query to find children of a check-in */
Stmt isBr; /* Query to check to see if a check-in starts a new branch */
Stmt ins; /* INSERT statement for a new record */
db_multi_exec(
"CREATE TEMP TABLE IF NOT EXISTS leaves("
" rid INTEGER PRIMARY KEY"
");"
"DELETE FROM leaves;"
);
bag_init(&seen);
bag_init(&pending);
if( iBase<=0 ){
iBase = db_int(0, "SELECT objid FROM event WHERE type='ci'"
" ORDER BY mtime LIMIT 1");
}
bag_insert(&pending, iBase);
db_prepare(&q, "SELECT cid FROM plink WHERE pid=:rid");
db_prepare(&isBr,
"SELECT 1 FROM tagxref WHERE rid=:rid AND tagid=%d AND tagtype=1",
TAG_NEWBRANCH
);
db_prepare(&ins, "INSERT OR IGNORE INTO leaves VALUES(:rid)");
while( bag_count(&pending) ){
int rid = bag_first(&pending);
int cnt = 0;
bag_remove(&pending, rid);
db_bind_int(&q, ":rid", rid);
while( db_step(&q)==SQLITE_ROW ){
int cid = db_column_int(&q, 0);
if( bag_insert(&seen, cid) ){
bag_insert(&pending, cid);
}
db_bind_int(&isBr, ":rid", cid);
if( db_step(&isBr)==SQLITE_DONE ){
cnt++;
}
db_reset(&isBr);
}
db_reset(&q);
if( cnt==0 ){
db_bind_int(&ins, ":rid", rid);
db_step(&ins);
db_reset(&ins);
}
}
db_finalize(&ins);
db_finalize(&isBr);
db_finalize(&q);
bag_clear(&pending);
bag_clear(&seen);
if( closeMode==1 ){
db_multi_exec(
"DELETE FROM leaves WHERE rid IN"
" (SELECT leaves.rid FROM leaves, tagxref"
" WHERE tagxref.rid=leaves.rid "
" AND tagxref.tagid=%d"
" AND tagxref.tagtype>0)",
TAG_CLOSED
);
}else if( closeMode==2 ){
db_multi_exec(
"DELETE FROM leaves WHERE rid NOT IN"
" (SELECT leaves.rid FROM leaves, tagxref"
" WHERE tagxref.rid=leaves.rid "
" AND tagxref.tagid=%d"
" AND tagxref.tagtype>0)",
TAG_CLOSED
);
}
}
/*
** Load the record ID rid and up to N-1 closest ancestors into
** the "ok" table.
*/
void compute_ancestors(int rid, int N){
|
| ︙ | ︙ | |||
144 145 146 147 148 149 150 |
db_must_be_within_tree();
if( g.argc==2 ){
base = db_lget_int("checkout", 0);
}else{
base = name_to_rid(g.argv[2]);
}
if( base==0 ) return;
| | | | > > | > > > | < > > > > > > > > > > > > > > > > > > > | < | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
db_must_be_within_tree();
if( g.argc==2 ){
base = db_lget_int("checkout", 0);
}else{
base = name_to_rid(g.argv[2]);
}
if( base==0 ) return;
compute_leaves(base, 0);
db_prepare(&q,
"%s"
" AND event.objid IN (SELECT rid FROM leaves)"
" ORDER BY event.mtime DESC",
timeline_query_for_tty()
);
print_timeline(&q, 20);
db_finalize(&q);
}
/*
** COMMAND: leaves
**
** Usage: %fossil leaves ?--all? ?--closed?
**
** Find leaves of all branches. By default show only open leaves.
** The --all flag causes all leaves (closed and open) to be shown.
** The --closed flag shows only closed leaves.
*/
void leaves_cmd(void){
Stmt q;
int showAll = find_option("all", 0, 0)!=0;
int showClosed = find_option("closed", 0, 0)!=0;
db_must_be_within_tree();
compute_leaves(0, showAll ? 0 : showClosed ? 2 : 1);
db_prepare(&q,
"%s"
" AND blob.rid IN leaves"
" ORDER BY event.mtime DESC",
timeline_query_for_tty()
);
print_timeline(&q, 2000);
db_finalize(&q);
}
/*
** WEBPAGE: leaves
**
** Find leaves of all branches.
*/
void leaves_page(void){
Stmt q;
int showAll = P("all")!=0;
int showClosed = P("closed")!=0;
login_check_credentials();
if( !g.okRead ){ login_needed(); return; }
if( !showAll ){
style_submenu_element("All", "All", "leaves?all");
}
if( !showClosed ){
style_submenu_element("Closed", "Closed", "leaves?closed");
}
if( showClosed || showAll ){
style_submenu_element("Open", "Open", "leaves");
}
style_header("Leaves");
login_anonymous_available();
compute_leaves(0, showAll ? 0 : showClosed ? 2 : 1);
if( showAll ){
@ <h1>All leaves, both open and closed</h1>
}else if( showClosed ){
@ <h1>Closed leaves only</h1>
}else{
@ <h1>All open leaves</h1>
}
db_prepare(&q,
"%s"
" AND blob.rid IN leaves"
" ORDER BY event.mtime DESC",
timeline_query_for_www()
);
www_print_timeline(&q);
db_finalize(&q);
@ <script>
@ function xin(id){
@ }
@ function xout(id){
@ }
@ </script>
style_footer();
}
|
Changes to src/info.c.
| ︙ | ︙ | |||
440 441 442 443 444 445 446 |
if( g.okHistory ){
@ <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a></li>
}else{
@ %h(zName)</li>
}
}
@ </ul>
| | | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
if( g.okHistory ){
@ <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a></li>
}else{
@ %h(zName)</li>
}
}
@ </ul>
compute_leaves(rid, 0);
showDescendants(rid, 2, "Descendants");
showLeaves();
showAncestors(rid, 2, "Ancestors");
style_footer();
}
/*
|
| ︙ | ︙ |
Changes to src/schema.c.
| ︙ | ︙ | |||
278 279 280 281 282 283 284 285 286 287 288 289 290 291 | @ ); @ INSERT INTO tag VALUES(1, 'bgcolor'); -- TAG_BGCOLOR @ INSERT INTO tag VALUES(2, 'comment'); -- TAG_COMMENT @ INSERT INTO tag VALUES(3, 'user'); -- TAG_USER @ INSERT INTO tag VALUES(4, 'hidden'); -- TAG_HIDDEN @ INSERT INTO tag VALUES(5, 'private'); -- TAG_PRIVATE @ INSERT INTO tag VALUES(6, 'cluster'); -- TAG_CLUSTER @ @ -- Assignments of tags to baselines. Note that we allow tags to @ -- have values assigned to them. So we are not really dealing with @ -- tags here. These are really properties. But we are going to @ -- keep calling them tags because in many cases the value is ignored. @ -- @ CREATE TABLE tagxref( | > > | 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | @ ); @ INSERT INTO tag VALUES(1, 'bgcolor'); -- TAG_BGCOLOR @ INSERT INTO tag VALUES(2, 'comment'); -- TAG_COMMENT @ INSERT INTO tag VALUES(3, 'user'); -- TAG_USER @ INSERT INTO tag VALUES(4, 'hidden'); -- TAG_HIDDEN @ INSERT INTO tag VALUES(5, 'private'); -- TAG_PRIVATE @ INSERT INTO tag VALUES(6, 'cluster'); -- TAG_CLUSTER @ INSERT INTO tag VALUES(7, 'newbranch'); -- TAG_NEWBRANCH @ INSERT INTO tag VALUES(8, 'closed'); -- TAG_CLOSED @ @ -- Assignments of tags to baselines. Note that we allow tags to @ -- have values assigned to them. So we are not really dealing with @ -- tags here. These are really properties. But we are going to @ -- keep calling them tags because in many cases the value is ignored. @ -- @ CREATE TABLE tagxref( |
| ︙ | ︙ | |||
329 330 331 332 333 334 335 336 337 | #if INTERFACE # define TAG_BGCOLOR 1 /* Set the background color for display */ # define TAG_COMMENT 2 /* The check-in comment */ # define TAG_USER 3 /* User who made a checking */ # define TAG_HIDDEN 4 /* Do not display or sync */ # define TAG_PRIVATE 5 /* Display but do not sync */ # define TAG_CLUSTER 6 /* A cluster */ #endif #if EXPORT_INTERFACE | > > | | 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | #if INTERFACE # define TAG_BGCOLOR 1 /* Set the background color for display */ # define TAG_COMMENT 2 /* The check-in comment */ # define TAG_USER 3 /* User who made a checking */ # define TAG_HIDDEN 4 /* Do not display or sync */ # define TAG_PRIVATE 5 /* Display but do not sync */ # define TAG_CLUSTER 6 /* A cluster */ # define TAG_NEWBRANCH 7 /* First check-in of a new named branch */ # define TAG_CLOSED 8 /* Do not display this check-in as a leaf */ #endif #if EXPORT_INTERFACE # define MAX_INT_TAG 8 /* The largest pre-assigned tag id */ #endif /* ** The schema for the locate FOSSIL database file found at the root ** of very check-out. This database contains the complete state of ** the checkout. */ |
| ︙ | ︙ |
Changes to src/tag.c.
| ︙ | ︙ | |||
244 245 246 247 248 249 250 251 | } zValue = g.argc==5 ? g.argv[4] : 0; db_begin_transaction(); tag_insert(zTag, tagtype, zValue, -1, 0.0, rid); db_end_transaction(0); } /* | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > | < < > | < < | | | | < > | | 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
}
zValue = g.argc==5 ? g.argv[4] : 0;
db_begin_transaction();
tag_insert(zTag, tagtype, zValue, -1, 0.0, rid);
db_end_transaction(0);
}
/*
** Add a control record to the repository that either creates
** or cancels a tag.
*/
static void tag_add_artifact(
const char *zPrefix, /* Prefix to prepend to tag name */
const char *zTagname, /* The tag to add or cancel */
const char *zObjName, /* Name of object attached to */
const char *zValue, /* Value for the tag. Might be NULL */
int tagtype /* 0:cancel 1:singleton 2:propagated */
){
int rid;
int nrid;
char *zDate;
Blob uuid;
Blob ctrl;
Blob cksum;
static const char zTagtype[] = { '-', '+', '*' };
assert( tagtype>=0 && tagtype<=2 );
user_select();
blob_zero(&uuid);
blob_append(&uuid, zObjName, -1);
if( name_to_uuid(&uuid, 9) ){
return;
}
rid = name_to_rid(blob_str(&uuid));
blob_zero(&ctrl);
#if 0
if( validate16(zTagname, strlen(zTagname)) ){
fossil_fatal(
"invalid tag name \"%s\" - might be confused with"
" a hexadecimal artifact ID",
zTagname
);
}
#endif
zDate = db_text(0, "SELECT datetime('now')");
zDate[10] = 'T';
blob_appendf(&ctrl, "D %s\n", zDate);
blob_appendf(&ctrl, "T %c%s%F %b",
zTagtype[tagtype], zPrefix, zTagname, &uuid);
if( tagtype>0 && zValue && zValue[0] ){
blob_appendf(&ctrl, " %F\n", zValue);
}else{
blob_appendf(&ctrl, "\n");
}
blob_appendf(&ctrl, "U %F\n", g.zLogin);
md5sum_blob(&ctrl, &cksum);
blob_appendf(&ctrl, "Z %b\n", &cksum);
|
| ︙ | ︙ | |||
367 368 369 370 371 372 373 | /* ** COMMAND: tag ** Usage: %fossil tag SUBCOMMAND ... ** ** Run various subcommands to control tags and properties ** | | | | | < < < < < < < < < | < < < < | | | | | | | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | /* ** COMMAND: tag ** Usage: %fossil tag SUBCOMMAND ... ** ** Run various subcommands to control tags and properties ** ** %fossil tag add ?--raw? ?--propagate? TAGNAME CHECK-IN ?VALUE? ** ** Add a new tag or property to CHECK-IN. The tag will ** be usable instead of a CHECK-IN in commands such as ** update and merge. If the --propagate flag is present, ** the tag value propages to all descendants of CHECK-IN ** ** %fossil tag cancel ?--raw? TAGNAME CHECK-IN ** ** Remove the tag TAGNAME from CHECK-IN, and also remove ** the propagation of the tag to any descendants. ** ** %fossil tag find ?--raw? TAGNAME ** ** List all check-ins that use TAGNAME ** ** %fossil tag list ?--raw? ?CHECK-IN? ** ** List all tags, or if CHECK-IN is supplied, list ** all tags and their values for CHECK-IN. ** ** The option --raw allows the manipulation of all types of tags ** used for various internal purposes in fossil. It also shows ** "cancel" tags for the "find" and "list" subcommands. You should ** not use this option to make changes unless you are sure what ** you are doing. ** |
| ︙ | ︙ | |||
423 424 425 426 427 428 429 |
** fossil update tag:decaf
**
** will assume that "decaf" is a tag/branch name.
**
*/
void tag_cmd(void){
int n;
| | | | < < < < | < | | < | < < < < < < < < < | < | | | | | | | > | | | | | > > > > > > > > > > > > > > > > > | | < | | | > > | | | | | > > < | < | < | | 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
** fossil update tag:decaf
**
** will assume that "decaf" is a tag/branch name.
**
*/
void tag_cmd(void){
int n;
int fRaw = find_option("raw","",0)!=0;
int fPropagate = find_option("propagate","",0)!=0;
const char *zPrefix = fRaw ? "" : "sym-";
db_find_and_open_repository(1);
if( g.argc<3 ){
goto tag_cmd_usage;
}
n = strlen(g.argv[2]);
if( n==0 ){
goto tag_cmd_usage;
}
if( strncmp(g.argv[2],"add",n)==0 ){
char *zValue;
if( g.argc!=5 && g.argc!=6 ){
usage("add ?--raw? ?--propagate? TAGNAME CHECK-IN ?VALUE?");
}
zValue = g.argc==6 ? g.argv[5] : 0;
tag_add_artifact(zPrefix, g.argv[3], g.argv[4], zValue, 1+fPropagate);
}else
if( strncmp(g.argv[2],"branch",n)==0 ){
fossil_fatal("the \"fossil tag branch\" command is discontinued\n"
"Use the \"fossil branch new\" command instead.");
}else
if( strncmp(g.argv[2],"cancel",n)==0 ){
if( g.argc!=5 ){
usage("cancel ?--raw? TAGNAME CHECK-IN");
}
tag_add_artifact(zPrefix, g.argv[3], g.argv[4], 0, 0);
}else
if( strncmp(g.argv[2],"find",n)==0 ){
Stmt q;
if( g.argc!=4 ){
usage("find ?--raw? TAGNAME");
}
if( fRaw ){
db_prepare(&q,
"SELECT blob.uuid FROM tagxref, blob"
" WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)"
" AND tagxref.tagtype>0"
" AND blob.rid=tagxref.rid",
g.argv[3]
);
while( db_step(&q)==SQLITE_ROW ){
printf("%s\n", db_column_text(&q, 0));
}
db_finalize(&q);
}else{
int tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'",
g.argv[3]);
if( tagid>0 ){
db_prepare(&q,
"%s"
" AND blob.rid IN ("
" SELECT rid FROM tagxref"
" WHERE tagtype>0 AND tagid=%d"
")"
" ORDER BY event.mtime DESC",
timeline_query_for_tty(), tagid
);
print_timeline(&q, 2000);
db_finalize(&q);
}
}
}else
if( strncmp(g.argv[2],"list",n)==0 ){
Stmt q;
if( g.argc==3 ){
db_prepare(&q,
"SELECT tagname FROM tag"
" WHERE EXISTS(SELECT 1 FROM tagxref"
" WHERE tagid=tag.tagid"
" AND tagtype>0)"
" ORDER BY tagname"
);
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
if( fRaw ){
printf("%s\n", zName);
}else if( strncmp(zName, "sym-", 4)==0 ){
printf("%s\n", &zName[4]);
}
}
db_finalize(&q);
}else if( g.argc==4 ){
int rid = name_to_rid(g.argv[3]);
db_prepare(&q,
"SELECT tagname, value FROM tagxref, tag"
" WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid"
" AND tagtype>%d"
" ORDER BY tagname",
rid,
fRaw ? -1 : 0
);
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
const char *zValue = db_column_text(&q, 1);
if( fRaw==0 ){
if( strncmp(zName, "sym-", 4)!=0 ) continue;
zName += 4;
}
if( zValue && zValue[0] ){
printf("%s=%s\n", zName, zValue);
}else{
printf("%s\n", zName);
}
}
db_finalize(&q);
}else{
usage("tag list ?CHECK-IN?");
}
}else
{
goto tag_cmd_usage;
}
/* Cleanup */
return;
tag_cmd_usage:
usage("add|cancel|find|list ...");
}
|
Changes to src/timeline.c.
| ︙ | ︙ | |||
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
if( zV2==0 ){
@ <a href="%s(g.zBaseURL)/diff?v2=%s(zV1)">[diff]</a>
}else{
@ <a href="%s(g.zBaseURL)/diff?v1=%s(zV1)&v2=%s(zV2)">[diff]</a>
}
}
}
/*
** Output a timeline in the web format given a query. The query
** should return these columns:
**
** 0. rid
** 1. UUID
| > > > > > > > > > > > > > > > > > > > > | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
if( zV2==0 ){
@ <a href="%s(g.zBaseURL)/diff?v2=%s(zV1)">[diff]</a>
}else{
@ <a href="%s(g.zBaseURL)/diff?v1=%s(zV1)&v2=%s(zV2)">[diff]</a>
}
}
}
/*
** Count the number of non-branch children for the given check-in.
** A non-branch child is a child that omits the "newbranch" tag.
*/
int count_nonbranch_children(int pid){
int nNonBranch;
nNonBranch = db_int(0,
"SELECT count(*) FROM plink"
" WHERE pid=%d"
" AND NOT EXISTS(SELECT 1 FROM tagxref"
" WHERE tagid=%d"
" AND rid=cid"
" AND tagtype>0"
" )",
pid, TAG_NEWBRANCH
);
return nNonBranch;
}
/*
** Output a timeline in the web format given a query. The query
** should return these columns:
**
** 0. rid
** 1. UUID
|
| ︙ | ︙ | |||
143 144 145 146 147 148 149 |
}
if( zType[0]=='c' ){
hyperlink_to_uuid_with_mouseover(zUuid, "xin", "xout", rid);
if( nParent>1 ){
@ <b>Merge</b>
}
if( nPChild>1 ){
| > | > > > | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
}
if( zType[0]=='c' ){
hyperlink_to_uuid_with_mouseover(zUuid, "xin", "xout", rid);
if( nParent>1 ){
@ <b>Merge</b>
}
if( nPChild>1 ){
if( count_nonbranch_children(rid)>1 ){
@ <b>Fork</b>
}else{
@ <b>Branch</b>
}
}
if( isLeaf ){
@ <b>Leaf</b>
}
}else{
hyperlink_to_uuid(zUuid);
}
|
| ︙ | ︙ | |||
545 546 547 548 549 550 551 552 553 554 555 556 557 558 |
if( g.localOpen ){
int rid = db_lget_int("checkout", 0);
zCurrentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
}
while( db_step(q)==SQLITE_ROW && nLine<=mxLine ){
const char *zId = db_column_text(q, 1);
const char *zDate = db_column_text(q, 2);
const char *zCom = db_column_text(q, 3);
int nChild = db_column_int(q, 4);
int nParent = db_column_int(q, 5);
char *zFree = 0;
int n = 0;
| > | 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 |
if( g.localOpen ){
int rid = db_lget_int("checkout", 0);
zCurrentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
}
while( db_step(q)==SQLITE_ROW && nLine<=mxLine ){
int rid = db_column_int(q, 0);
const char *zId = db_column_text(q, 1);
const char *zDate = db_column_text(q, 2);
const char *zCom = db_column_text(q, 3);
int nChild = db_column_int(q, 4);
int nParent = db_column_int(q, 5);
char *zFree = 0;
int n = 0;
|
| ︙ | ︙ | |||
569 570 571 572 573 574 575 |
printf("%.8s ", &zDate[11]);
zPrefix[0] = 0;
if( nParent>1 ){
sqlite3_snprintf(sizeof(zPrefix), zPrefix, "*MERGE* ");
n = strlen(zPrefix);
}
if( nChild>1 ){
| > > > > > > | | 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 |
printf("%.8s ", &zDate[11]);
zPrefix[0] = 0;
if( nParent>1 ){
sqlite3_snprintf(sizeof(zPrefix), zPrefix, "*MERGE* ");
n = strlen(zPrefix);
}
if( nChild>1 ){
const char *zBrType;
if( count_nonbranch_children(rid)>1 ){
zBrType = "*FORK* ";
}else{
zBrType = "*BRANCH* ";
}
sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], zBrType);
n = strlen(zPrefix);
}
if( zCurrentUuid && strcmp(zCurrentUuid,zId)==0 ){
sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* ");
n += strlen(zPrefix);
}
zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom);
|
| ︙ | ︙ |
Changes to src/update.c.
| ︙ | ︙ | |||
88 89 90 91 92 93 94 |
** By not giving a specific version, they are asking for the latest, thus
** pull to get the latest, then update.
*/
autosync(AUTOSYNC_PULL);
}
if( tid==0 ){
| | | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
** By not giving a specific version, they are asking for the latest, thus
** pull to get the latest, then update.
*/
autosync(AUTOSYNC_PULL);
}
if( tid==0 ){
compute_leaves(vid, 1);
if( !latestFlag && db_int(0, "SELECT count(*) FROM leaves")>1 ){
db_prepare(&q,
"%s "
" AND event.objid IN leaves"
" ORDER BY event.mtime DESC",
timeline_query_for_tty()
);
|
| ︙ | ︙ |