Differences From:
File
src/name.c
part of check-in
[d1c9938025]
- Change behavior of Fossil's tag handling.
- All subcommands of command tag prepends a prefix sym- infront of every
tag name passed to them. Tags beginning with sym- are special in
Fossil as they might serve as replacement of a UUID they are attached to.
Further, tag list will only list all tags beginning with sym- but
with that prefix removed during display as default.
All subcommands can get passed an option --raw, that prevent the
prepending of the prefix sym- in front of the tag name. tag list
will report all tags without removing any prefix if called with
option --raw.
- If a command takes a tag name that may be confused with a UUID,
the command did interpret that parameter as a UUID instead as a
tag name. Such tags might now be prefixed with a tag: to enforce
the command to take them as tag name instead of a UUID. For example:
fossil tag add abcde $uuid
:
fossil update tag:abcde
without the prefix tag: fossil would try to update to a UUID
beginning with abcde. If no such UUID was found, fossil will complain
and exit.
by
cle on
2008-07-27 18:35:06.
[view]
To:
File
src/name.c
part of check-in
[3984b1b2c1]
- Make the info web page handle symbolic tags as well as UUIDs. Start trying
to make the currently-disabled tagview page more useful.
by
eric on
2008-08-04 20:46:52.
[view]
@@ -45,9 +45,8 @@
int rc;
int sz;
sz = blob_size(pName);
if( sz>UUID_SIZE || sz<4 || !validate16(blob_buffer(pName), sz) ){
- Stmt q;
Blob uuid;
static const char prefix[] = "tag:";
static const int preflen = sizeof(prefix)-1;
const char *zName = blob_str(pName);
@@ -55,22 +54,9 @@
if( strncmp(zName, prefix, preflen)==0 ){
zName += preflen;
}
- db_prepare(&q,
- "SELECT (SELECT uuid FROM blob WHERE rid=objid)"
- " FROM tagxref JOIN event ON rid=objid"
- " WHERE tagid=(SELECT tagid FROM tag WHERE tagname='sym-'||%Q)"
- " AND tagtype>0"
- " AND value IS NULL"
- " ORDER BY event.mtime DESC",
- zName
- );
- blob_zero(&uuid);
- if( db_step(&q)==SQLITE_ROW ){
- db_column_blob(&q, 0, &uuid);
- }
- db_finalize(&q);
+ sym_tag_to_uuid(zName, &uuid);
if( blob_size(&uuid)==0 ){
fossil_error(iErrPriority, "not a valid object name: %s", zName);
blob_reset(&uuid);
return 1;
@@ -111,8 +97,44 @@
}else{
rc = 0;
}
return rc;
+}
+
+/*
+** This routine takes a name which might be a symbolic tag and
+** attempts to produce a UUID. The UUID (if any) is returned in the
+** blob pointed to by the second argument.
+**
+** Return as follows:
+** 0 Name is not a tag
+** 1 A single UUID was found
+** 2 More than one UUID was found, so this is presumably a
+** propagating tag. The return UUID is the most recent,
+** which is most likely to be the one wanted.
+*/
+int sym_tag_to_uuid(const char *pName, Blob *pUuid){
+ Stmt q;
+ int count = 0;
+ db_prepare(&q,
+ "SELECT (SELECT uuid FROM blob WHERE rid=objid)"
+ " FROM tagxref JOIN event ON rid=objid"
+ " WHERE tagid=(SELECT tagid FROM tag WHERE tagname='sym-'||%Q)"
+ " AND tagtype>0"
+ " AND value IS NULL"
+ " ORDER BY event.mtime DESC",
+ pName
+ );
+ blob_zero(pUuid);
+ while( db_step(&q)==SQLITE_ROW ){
+ count++;
+ if(count>1){
+ break;
+ }
+ db_column_blob(&q, 0, pUuid);
+ }
+ db_finalize(&q);
+ return count;
}
/*
** COMMAND: test-name-to-uuid