Fossil SCM
Fixed (wiki commit) to check for an existing page when the --mimetype flag is used (previously it only checked when that flag was not provided).
Commit
c0de97a1555c6397adaa2f03e48a89d916e37030a1c4b1ca5dfadff6f009ee75
Parent
be7c1bde92c8caa…
1 file changed
+20
-18
+20
-18
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -1495,10 +1495,11 @@ | ||
| 1495 | 1495 | || strncmp(g.argv[2],"create",n)==0 ){ |
| 1496 | 1496 | const char *zPageName; /* page name */ |
| 1497 | 1497 | Blob content; /* Input content */ |
| 1498 | 1498 | int rid = 0; |
| 1499 | 1499 | Manifest *pWiki = 0; /* Parsed wiki page content */ |
| 1500 | + const int isCreate = 'r'==g.argv[2][1] /* else "commit" */; | |
| 1500 | 1501 | const char *zMimeType = find_option("mimetype", "M", 1); |
| 1501 | 1502 | const char *zETime = find_option("technote", "t", 1); |
| 1502 | 1503 | const char *zTags = find_option("technote-tags", NULL, 1); |
| 1503 | 1504 | const char *zClr = find_option("technote-bgcolor", NULL, 1); |
| 1504 | 1505 | if( g.argc!=4 && g.argc!=5 ){ |
| @@ -1509,42 +1510,43 @@ | ||
| 1509 | 1510 | zPageName = g.argv[3]; |
| 1510 | 1511 | if( g.argc==4 ){ |
| 1511 | 1512 | blob_read_from_channel(&content, stdin, -1); |
| 1512 | 1513 | }else{ |
| 1513 | 1514 | blob_read_from_file(&content, g.argv[4], ExtFILE); |
| 1515 | + } | |
| 1516 | + if ( !zETime ){ | |
| 1517 | + rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x" | |
| 1518 | + " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'" | |
| 1519 | + " ORDER BY x.mtime DESC LIMIT 1", | |
| 1520 | + zPageName | |
| 1521 | + ); | |
| 1522 | + if( rid>0 ){ | |
| 1523 | + pWiki = manifest_get(rid, CFTYPE_WIKI, 0); | |
| 1524 | + } | |
| 1525 | + }else{ | |
| 1526 | + rid = wiki_technote_to_rid(zETime); | |
| 1527 | + if( rid>0 ){ | |
| 1528 | + pWiki = manifest_get(rid, CFTYPE_EVENT, 0); | |
| 1529 | + } | |
| 1514 | 1530 | } |
| 1515 | 1531 | if( !zMimeType || !*zMimeType ){ |
| 1516 | 1532 | /* Try to deduce the mime type based on the prior version. */ |
| 1517 | - if ( !zETime ){ | |
| 1518 | - rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x" | |
| 1519 | - " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'" | |
| 1520 | - " ORDER BY x.mtime DESC LIMIT 1", | |
| 1521 | - zPageName | |
| 1522 | - ); | |
| 1523 | - if( rid>0 && (pWiki = manifest_get(rid, CFTYPE_WIKI, 0))!=0 | |
| 1524 | - && (pWiki->zMimetype && *pWiki->zMimetype) ){ | |
| 1525 | - zMimeType = pWiki->zMimetype; | |
| 1526 | - } | |
| 1527 | - }else{ | |
| 1528 | - rid = wiki_technote_to_rid(zETime); | |
| 1529 | - if( rid>0 && (pWiki = manifest_get(rid, CFTYPE_EVENT, 0))!=0 | |
| 1530 | - && (pWiki->zMimetype && *pWiki->zMimetype) ){ | |
| 1531 | - zMimeType = pWiki->zMimetype; | |
| 1532 | - } | |
| 1533 | + if( pWiki!=0 && (pWiki->zMimetype && *pWiki->zMimetype) ){ | |
| 1534 | + zMimeType = pWiki->zMimetype; | |
| 1533 | 1535 | } |
| 1534 | 1536 | }else{ |
| 1535 | 1537 | zMimeType = wiki_filter_mimetypes(zMimeType); |
| 1536 | 1538 | } |
| 1537 | - if( g.argv[2][1]=='r' && rid>0 ){ | |
| 1539 | + if( isCreate && rid>0 ){ | |
| 1538 | 1540 | if ( !zETime ){ |
| 1539 | 1541 | fossil_fatal("wiki page %s already exists", zPageName); |
| 1540 | 1542 | }else{ |
| 1541 | 1543 | /* Creating a tech note with same timestamp is permitted |
| 1542 | 1544 | and should create a new tech note */ |
| 1543 | 1545 | rid = 0; |
| 1544 | 1546 | } |
| 1545 | - }else if( g.argv[2][1]=='o' && rid == 0 ){ | |
| 1547 | + }else if( !isCreate && rid == 0 ){ | |
| 1546 | 1548 | if ( !zETime ){ |
| 1547 | 1549 | fossil_fatal("no such wiki page: %s", zPageName); |
| 1548 | 1550 | }else{ |
| 1549 | 1551 | fossil_fatal("no such tech note: %s", zETime); |
| 1550 | 1552 | } |
| 1551 | 1553 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -1495,10 +1495,11 @@ | |
| 1495 | || strncmp(g.argv[2],"create",n)==0 ){ |
| 1496 | const char *zPageName; /* page name */ |
| 1497 | Blob content; /* Input content */ |
| 1498 | int rid = 0; |
| 1499 | Manifest *pWiki = 0; /* Parsed wiki page content */ |
| 1500 | const char *zMimeType = find_option("mimetype", "M", 1); |
| 1501 | const char *zETime = find_option("technote", "t", 1); |
| 1502 | const char *zTags = find_option("technote-tags", NULL, 1); |
| 1503 | const char *zClr = find_option("technote-bgcolor", NULL, 1); |
| 1504 | if( g.argc!=4 && g.argc!=5 ){ |
| @@ -1509,42 +1510,43 @@ | |
| 1509 | zPageName = g.argv[3]; |
| 1510 | if( g.argc==4 ){ |
| 1511 | blob_read_from_channel(&content, stdin, -1); |
| 1512 | }else{ |
| 1513 | blob_read_from_file(&content, g.argv[4], ExtFILE); |
| 1514 | } |
| 1515 | if( !zMimeType || !*zMimeType ){ |
| 1516 | /* Try to deduce the mime type based on the prior version. */ |
| 1517 | if ( !zETime ){ |
| 1518 | rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x" |
| 1519 | " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'" |
| 1520 | " ORDER BY x.mtime DESC LIMIT 1", |
| 1521 | zPageName |
| 1522 | ); |
| 1523 | if( rid>0 && (pWiki = manifest_get(rid, CFTYPE_WIKI, 0))!=0 |
| 1524 | && (pWiki->zMimetype && *pWiki->zMimetype) ){ |
| 1525 | zMimeType = pWiki->zMimetype; |
| 1526 | } |
| 1527 | }else{ |
| 1528 | rid = wiki_technote_to_rid(zETime); |
| 1529 | if( rid>0 && (pWiki = manifest_get(rid, CFTYPE_EVENT, 0))!=0 |
| 1530 | && (pWiki->zMimetype && *pWiki->zMimetype) ){ |
| 1531 | zMimeType = pWiki->zMimetype; |
| 1532 | } |
| 1533 | } |
| 1534 | }else{ |
| 1535 | zMimeType = wiki_filter_mimetypes(zMimeType); |
| 1536 | } |
| 1537 | if( g.argv[2][1]=='r' && rid>0 ){ |
| 1538 | if ( !zETime ){ |
| 1539 | fossil_fatal("wiki page %s already exists", zPageName); |
| 1540 | }else{ |
| 1541 | /* Creating a tech note with same timestamp is permitted |
| 1542 | and should create a new tech note */ |
| 1543 | rid = 0; |
| 1544 | } |
| 1545 | }else if( g.argv[2][1]=='o' && rid == 0 ){ |
| 1546 | if ( !zETime ){ |
| 1547 | fossil_fatal("no such wiki page: %s", zPageName); |
| 1548 | }else{ |
| 1549 | fossil_fatal("no such tech note: %s", zETime); |
| 1550 | } |
| 1551 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -1495,10 +1495,11 @@ | |
| 1495 | || strncmp(g.argv[2],"create",n)==0 ){ |
| 1496 | const char *zPageName; /* page name */ |
| 1497 | Blob content; /* Input content */ |
| 1498 | int rid = 0; |
| 1499 | Manifest *pWiki = 0; /* Parsed wiki page content */ |
| 1500 | const int isCreate = 'r'==g.argv[2][1] /* else "commit" */; |
| 1501 | const char *zMimeType = find_option("mimetype", "M", 1); |
| 1502 | const char *zETime = find_option("technote", "t", 1); |
| 1503 | const char *zTags = find_option("technote-tags", NULL, 1); |
| 1504 | const char *zClr = find_option("technote-bgcolor", NULL, 1); |
| 1505 | if( g.argc!=4 && g.argc!=5 ){ |
| @@ -1509,42 +1510,43 @@ | |
| 1510 | zPageName = g.argv[3]; |
| 1511 | if( g.argc==4 ){ |
| 1512 | blob_read_from_channel(&content, stdin, -1); |
| 1513 | }else{ |
| 1514 | blob_read_from_file(&content, g.argv[4], ExtFILE); |
| 1515 | } |
| 1516 | if ( !zETime ){ |
| 1517 | rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x" |
| 1518 | " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'" |
| 1519 | " ORDER BY x.mtime DESC LIMIT 1", |
| 1520 | zPageName |
| 1521 | ); |
| 1522 | if( rid>0 ){ |
| 1523 | pWiki = manifest_get(rid, CFTYPE_WIKI, 0); |
| 1524 | } |
| 1525 | }else{ |
| 1526 | rid = wiki_technote_to_rid(zETime); |
| 1527 | if( rid>0 ){ |
| 1528 | pWiki = manifest_get(rid, CFTYPE_EVENT, 0); |
| 1529 | } |
| 1530 | } |
| 1531 | if( !zMimeType || !*zMimeType ){ |
| 1532 | /* Try to deduce the mime type based on the prior version. */ |
| 1533 | if( pWiki!=0 && (pWiki->zMimetype && *pWiki->zMimetype) ){ |
| 1534 | zMimeType = pWiki->zMimetype; |
| 1535 | } |
| 1536 | }else{ |
| 1537 | zMimeType = wiki_filter_mimetypes(zMimeType); |
| 1538 | } |
| 1539 | if( isCreate && rid>0 ){ |
| 1540 | if ( !zETime ){ |
| 1541 | fossil_fatal("wiki page %s already exists", zPageName); |
| 1542 | }else{ |
| 1543 | /* Creating a tech note with same timestamp is permitted |
| 1544 | and should create a new tech note */ |
| 1545 | rid = 0; |
| 1546 | } |
| 1547 | }else if( !isCreate && rid == 0 ){ |
| 1548 | if ( !zETime ){ |
| 1549 | fossil_fatal("no such wiki page: %s", zPageName); |
| 1550 | }else{ |
| 1551 | fossil_fatal("no such tech note: %s", zETime); |
| 1552 | } |
| 1553 |