Fossil SCM
Add a button to review a list of hashes to shun. As discussed in [forum:1d54d9965c7e4c00], fossil may accept 40 byte abbreviated hashes from command output, when the intention is to shun the real 64 byte hash.
Commit
d5c8235cdc1a69c399e892b01f7050a491d6813481067138ad39e262729667e7
Parent
e03200e54543046…
1 file changed
+61
-1
+61
-1
| --- src/shun.c | ||
| +++ src/shun.c | ||
| @@ -47,10 +47,11 @@ | ||
| 47 | 47 | int cnt = 0; |
| 48 | 48 | const char *zUuid = P("uuid"); |
| 49 | 49 | const char *zShun = P("shun"); |
| 50 | 50 | const char *zAccept = P("accept"); |
| 51 | 51 | const char *zRcvid = P("rcvid"); |
| 52 | + int reviewList = P("review")!=0; | |
| 52 | 53 | int nRcvid = 0; |
| 53 | 54 | int numRows = 3; |
| 54 | 55 | char *zCanonical = 0; |
| 55 | 56 | |
| 56 | 57 | login_check_credentials(); |
| @@ -85,11 +86,11 @@ | ||
| 85 | 86 | } |
| 86 | 87 | zCanonical[j+1] = zCanonical[j] = 0; |
| 87 | 88 | p = zCanonical; |
| 88 | 89 | while( *p ){ |
| 89 | 90 | int nUuid = strlen(p); |
| 90 | - if( !hname_validate(p, nUuid) ){ | |
| 91 | + if( !(reviewList || hname_validate(p, nUuid)) ){ | |
| 91 | 92 | @ <p class="generalError">Error: Bad artifact IDs.</p> |
| 92 | 93 | fossil_free(zCanonical); |
| 93 | 94 | zCanonical = 0; |
| 94 | 95 | break; |
| 95 | 96 | }else{ |
| @@ -155,10 +156,63 @@ | ||
| 155 | 156 | } |
| 156 | 157 | @ have been shunned. They will no longer be pushed. |
| 157 | 158 | @ They will be removed from the repository the next time the repository |
| 158 | 159 | @ is rebuilt using the <b>fossil rebuild</b> command-line</p> |
| 159 | 160 | } |
| 161 | + if( zUuid && reviewList ){ | |
| 162 | + const char *p; | |
| 163 | + int nTotal = 0; | |
| 164 | + int nOk = 0; | |
| 165 | + @ <table class="shun-review"><tbody><tr><td> | |
| 166 | + for( p = zUuid ; *p ; p += strlen(p)+1 ){ | |
| 167 | + int rid = symbolic_name_to_rid(p, 0); | |
| 168 | + nTotal++; | |
| 169 | + if( rid < 0 ){ | |
| 170 | + @ Ambiguous<br> | |
| 171 | + }else if( rid == 0 ){ | |
| 172 | + if( !hname_validate(p, strlen(p)) ){ | |
| 173 | + @ Bad artifact<br> | |
| 174 | + }else if(db_int(0, "SELECT 1 FROM shun WHERE uuid=%Q", p)){ | |
| 175 | + @ Already shunned<br> | |
| 176 | + }else{ | |
| 177 | + @ Unknown<br> | |
| 178 | + } | |
| 179 | + }else{ | |
| 180 | + char *zCmpUuid = db_text(0, | |
| 181 | + "SELECT uuid" | |
| 182 | + " FROM blob, rcvfrom" | |
| 183 | + " WHERE rid=%d" | |
| 184 | + " AND rcvfrom.rcvid=blob.rcvid", | |
| 185 | + rid); | |
| 186 | + if( fossil_strcmp(p, zCmpUuid)==0 ){ | |
| 187 | + nOk++; | |
| 188 | + @ OK</br> | |
| 189 | + }else{ | |
| 190 | + @ Abbreviated<br> | |
| 191 | + } | |
| 192 | + } | |
| 193 | + } | |
| 194 | + @ </td><td> | |
| 195 | + for( p = zUuid ; *p ; p += strlen(p)+1 ){ | |
| 196 | + int rid = symbolic_name_to_rid(p, 0); | |
| 197 | + if( rid > 0 ){ | |
| 198 | + @ <a href="%R/artifact/%s(p)">%s(p)</a><br> | |
| 199 | + }else{ | |
| 200 | + @ %s(p)<br> | |
| 201 | + } | |
| 202 | + } | |
| 203 | + @ </td></tr></tbody></table> | |
| 204 | + @ <p class="shunned"> | |
| 205 | + if( nOk < nTotal){ | |
| 206 | + @ <b>Warning:</b> Not all artifacts | |
| 207 | + }else if( nTotal==1 ){ | |
| 208 | + @ The artifact is present and | |
| 209 | + }else{ | |
| 210 | + @ All %i(nOk) artifacts are present and | |
| 211 | + } | |
| 212 | + @ can be shunned with its hash above.</p> | |
| 213 | + } | |
| 160 | 214 | if( zRcvid ){ |
| 161 | 215 | nRcvid = atoi(zRcvid); |
| 162 | 216 | numRows = db_int(0, "SELECT min(count(), 10) FROM blob WHERE rcvid=%d", |
| 163 | 217 | nRcvid); |
| 164 | 218 | } |
| @@ -196,13 +250,19 @@ | ||
| 196 | 250 | while( db_step(&q)==SQLITE_ROW ){ |
| 197 | 251 | @ %s(db_column_text(&q, 0)) |
| 198 | 252 | } |
| 199 | 253 | db_finalize(&q); |
| 200 | 254 | } |
| 255 | + }else if( zUuid && reviewList ){ | |
| 256 | + const char *p; | |
| 257 | + for( p = zUuid ; *p ; p += strlen(p)+1 ){ | |
| 258 | + @ %s(p) | |
| 259 | + } | |
| 201 | 260 | } |
| 202 | 261 | @ </textarea> |
| 203 | 262 | @ <input type="submit" name="add" value="Shun"> |
| 263 | + @ <input type="submit" name="review" value="Review"> | |
| 204 | 264 | @ </div></form> |
| 205 | 265 | @ </blockquote> |
| 206 | 266 | @ |
| 207 | 267 | @ <a name="delshun"></a> |
| 208 | 268 | @ <p>Enter the UUIDs of previously shunned artifacts to cause them to be |
| 209 | 269 |
| --- src/shun.c | |
| +++ src/shun.c | |
| @@ -47,10 +47,11 @@ | |
| 47 | int cnt = 0; |
| 48 | const char *zUuid = P("uuid"); |
| 49 | const char *zShun = P("shun"); |
| 50 | const char *zAccept = P("accept"); |
| 51 | const char *zRcvid = P("rcvid"); |
| 52 | int nRcvid = 0; |
| 53 | int numRows = 3; |
| 54 | char *zCanonical = 0; |
| 55 | |
| 56 | login_check_credentials(); |
| @@ -85,11 +86,11 @@ | |
| 85 | } |
| 86 | zCanonical[j+1] = zCanonical[j] = 0; |
| 87 | p = zCanonical; |
| 88 | while( *p ){ |
| 89 | int nUuid = strlen(p); |
| 90 | if( !hname_validate(p, nUuid) ){ |
| 91 | @ <p class="generalError">Error: Bad artifact IDs.</p> |
| 92 | fossil_free(zCanonical); |
| 93 | zCanonical = 0; |
| 94 | break; |
| 95 | }else{ |
| @@ -155,10 +156,63 @@ | |
| 155 | } |
| 156 | @ have been shunned. They will no longer be pushed. |
| 157 | @ They will be removed from the repository the next time the repository |
| 158 | @ is rebuilt using the <b>fossil rebuild</b> command-line</p> |
| 159 | } |
| 160 | if( zRcvid ){ |
| 161 | nRcvid = atoi(zRcvid); |
| 162 | numRows = db_int(0, "SELECT min(count(), 10) FROM blob WHERE rcvid=%d", |
| 163 | nRcvid); |
| 164 | } |
| @@ -196,13 +250,19 @@ | |
| 196 | while( db_step(&q)==SQLITE_ROW ){ |
| 197 | @ %s(db_column_text(&q, 0)) |
| 198 | } |
| 199 | db_finalize(&q); |
| 200 | } |
| 201 | } |
| 202 | @ </textarea> |
| 203 | @ <input type="submit" name="add" value="Shun"> |
| 204 | @ </div></form> |
| 205 | @ </blockquote> |
| 206 | @ |
| 207 | @ <a name="delshun"></a> |
| 208 | @ <p>Enter the UUIDs of previously shunned artifacts to cause them to be |
| 209 |
| --- src/shun.c | |
| +++ src/shun.c | |
| @@ -47,10 +47,11 @@ | |
| 47 | int cnt = 0; |
| 48 | const char *zUuid = P("uuid"); |
| 49 | const char *zShun = P("shun"); |
| 50 | const char *zAccept = P("accept"); |
| 51 | const char *zRcvid = P("rcvid"); |
| 52 | int reviewList = P("review")!=0; |
| 53 | int nRcvid = 0; |
| 54 | int numRows = 3; |
| 55 | char *zCanonical = 0; |
| 56 | |
| 57 | login_check_credentials(); |
| @@ -85,11 +86,11 @@ | |
| 86 | } |
| 87 | zCanonical[j+1] = zCanonical[j] = 0; |
| 88 | p = zCanonical; |
| 89 | while( *p ){ |
| 90 | int nUuid = strlen(p); |
| 91 | if( !(reviewList || hname_validate(p, nUuid)) ){ |
| 92 | @ <p class="generalError">Error: Bad artifact IDs.</p> |
| 93 | fossil_free(zCanonical); |
| 94 | zCanonical = 0; |
| 95 | break; |
| 96 | }else{ |
| @@ -155,10 +156,63 @@ | |
| 156 | } |
| 157 | @ have been shunned. They will no longer be pushed. |
| 158 | @ They will be removed from the repository the next time the repository |
| 159 | @ is rebuilt using the <b>fossil rebuild</b> command-line</p> |
| 160 | } |
| 161 | if( zUuid && reviewList ){ |
| 162 | const char *p; |
| 163 | int nTotal = 0; |
| 164 | int nOk = 0; |
| 165 | @ <table class="shun-review"><tbody><tr><td> |
| 166 | for( p = zUuid ; *p ; p += strlen(p)+1 ){ |
| 167 | int rid = symbolic_name_to_rid(p, 0); |
| 168 | nTotal++; |
| 169 | if( rid < 0 ){ |
| 170 | @ Ambiguous<br> |
| 171 | }else if( rid == 0 ){ |
| 172 | if( !hname_validate(p, strlen(p)) ){ |
| 173 | @ Bad artifact<br> |
| 174 | }else if(db_int(0, "SELECT 1 FROM shun WHERE uuid=%Q", p)){ |
| 175 | @ Already shunned<br> |
| 176 | }else{ |
| 177 | @ Unknown<br> |
| 178 | } |
| 179 | }else{ |
| 180 | char *zCmpUuid = db_text(0, |
| 181 | "SELECT uuid" |
| 182 | " FROM blob, rcvfrom" |
| 183 | " WHERE rid=%d" |
| 184 | " AND rcvfrom.rcvid=blob.rcvid", |
| 185 | rid); |
| 186 | if( fossil_strcmp(p, zCmpUuid)==0 ){ |
| 187 | nOk++; |
| 188 | @ OK</br> |
| 189 | }else{ |
| 190 | @ Abbreviated<br> |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | @ </td><td> |
| 195 | for( p = zUuid ; *p ; p += strlen(p)+1 ){ |
| 196 | int rid = symbolic_name_to_rid(p, 0); |
| 197 | if( rid > 0 ){ |
| 198 | @ <a href="%R/artifact/%s(p)">%s(p)</a><br> |
| 199 | }else{ |
| 200 | @ %s(p)<br> |
| 201 | } |
| 202 | } |
| 203 | @ </td></tr></tbody></table> |
| 204 | @ <p class="shunned"> |
| 205 | if( nOk < nTotal){ |
| 206 | @ <b>Warning:</b> Not all artifacts |
| 207 | }else if( nTotal==1 ){ |
| 208 | @ The artifact is present and |
| 209 | }else{ |
| 210 | @ All %i(nOk) artifacts are present and |
| 211 | } |
| 212 | @ can be shunned with its hash above.</p> |
| 213 | } |
| 214 | if( zRcvid ){ |
| 215 | nRcvid = atoi(zRcvid); |
| 216 | numRows = db_int(0, "SELECT min(count(), 10) FROM blob WHERE rcvid=%d", |
| 217 | nRcvid); |
| 218 | } |
| @@ -196,13 +250,19 @@ | |
| 250 | while( db_step(&q)==SQLITE_ROW ){ |
| 251 | @ %s(db_column_text(&q, 0)) |
| 252 | } |
| 253 | db_finalize(&q); |
| 254 | } |
| 255 | }else if( zUuid && reviewList ){ |
| 256 | const char *p; |
| 257 | for( p = zUuid ; *p ; p += strlen(p)+1 ){ |
| 258 | @ %s(p) |
| 259 | } |
| 260 | } |
| 261 | @ </textarea> |
| 262 | @ <input type="submit" name="add" value="Shun"> |
| 263 | @ <input type="submit" name="review" value="Review"> |
| 264 | @ </div></form> |
| 265 | @ </blockquote> |
| 266 | @ |
| 267 | @ <a name="delshun"></a> |
| 268 | @ <p>Enter the UUIDs of previously shunned artifacts to cause them to be |
| 269 |