| | @@ -36,18 +36,21 @@ |
| 36 | 36 | */ |
| 37 | 37 | static void status_report(Blob *report, const char *zPrefix){ |
| 38 | 38 | Stmt q; |
| 39 | 39 | int nPrefix = strlen(zPrefix); |
| 40 | 40 | db_prepare(&q, |
| 41 | | - "SELECT pathname, deleted, chnged, rid FROM vfile " |
| 42 | | - "WHERE file_is_selected(id) AND (chnged OR deleted OR rid=0) ORDER BY 1" |
| 41 | + "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)" |
| 42 | + " FROM vfile " |
| 43 | + " WHERE file_is_selected(id)" |
| 44 | + " AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1" |
| 43 | 45 | ); |
| 44 | 46 | while( db_step(&q)==SQLITE_ROW ){ |
| 45 | 47 | const char *zPathname = db_column_text(&q,0); |
| 46 | 48 | int isDeleted = db_column_int(&q, 1); |
| 47 | 49 | int isChnged = db_column_int(&q,2); |
| 48 | 50 | int isNew = db_column_int(&q,3)==0; |
| 51 | + int isRenamed = db_column_int(&q,4); |
| 49 | 52 | char *zFullName = mprintf("%s/%s", g.zLocalRoot, zPathname); |
| 50 | 53 | blob_append(report, zPrefix, nPrefix); |
| 51 | 54 | if( isDeleted ){ |
| 52 | 55 | blob_appendf(report, "DELETED %s\n", zPathname); |
| 53 | 56 | }else if( access(zFullName, 0) ){ |
| | @@ -58,12 +61,14 @@ |
| 58 | 61 | blob_appendf(report, "DELETED %s\n", zPathname); |
| 59 | 62 | }else if( isChnged==2 ){ |
| 60 | 63 | blob_appendf(report, "UPDATED_BY_MERGE %s\n", zPathname); |
| 61 | 64 | }else if( isChnged==3 ){ |
| 62 | 65 | blob_appendf(report, "ADDED_BY_MERGE %s\n", zPathname); |
| 63 | | - }else{ |
| 66 | + }else if( isChnged==1 ){ |
| 64 | 67 | blob_appendf(report, "EDITED %s\n", zPathname); |
| 68 | + }else if( isRenamed ){ |
| 69 | + blob_appendf(report, "RENAMED %s\n", zPathname); |
| 65 | 70 | } |
| 66 | 71 | free(zFullName); |
| 67 | 72 | } |
| 68 | 73 | db_finalize(&q); |
| 69 | 74 | db_prepare(&q, "SELECT uuid FROM vmerge JOIN blob ON merge=rid" |
| | @@ -127,26 +132,32 @@ |
| 127 | 132 | Stmt q; |
| 128 | 133 | |
| 129 | 134 | db_must_be_within_tree(); |
| 130 | 135 | vid = db_lget_int("checkout", 0); |
| 131 | 136 | vfile_check_signature(vid); |
| 132 | | - db_prepare(&q, "SELECT pathname, deleted, rid, chnged FROM vfile" |
| 133 | | - " ORDER BY 1"); |
| 137 | + db_prepare(&q, |
| 138 | + "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)" |
| 139 | + " FROM vfile" |
| 140 | + " ORDER BY 1" |
| 141 | + ); |
| 134 | 142 | while( db_step(&q)==SQLITE_ROW ){ |
| 135 | 143 | const char *zPathname = db_column_text(&q,0); |
| 136 | 144 | int isDeleted = db_column_int(&q, 1); |
| 137 | 145 | int isNew = db_column_int(&q,2)==0; |
| 138 | 146 | int chnged = db_column_int(&q,3); |
| 147 | + int renamed = db_column_int(&q,4); |
| 139 | 148 | char *zFullName = mprintf("%s/%s", g.zLocalRoot, zPathname); |
| 140 | 149 | if( isNew ){ |
| 141 | 150 | printf("ADDED %s\n", zPathname); |
| 142 | 151 | }else if( access(zFullName, 0) ){ |
| 143 | 152 | printf("MISSING %s\n", zPathname); |
| 144 | 153 | }else if( isDeleted ){ |
| 145 | 154 | printf("DELETED %s\n", zPathname); |
| 146 | 155 | }else if( chnged ){ |
| 147 | 156 | printf("EDITED %s\n", zPathname); |
| 157 | + }else if( renamed ){ |
| 158 | + printf("RENAMED %s\n", zPathname); |
| 148 | 159 | }else{ |
| 149 | 160 | printf("UNCHANGED %s\n", zPathname); |
| 150 | 161 | } |
| 151 | 162 | free(zFullName); |
| 152 | 163 | } |
| | @@ -480,28 +491,35 @@ |
| 480 | 491 | blob_appendf(&manifest, "C %F\n", blob_str(&comment)); |
| 481 | 492 | zDate = db_text(0, "SELECT datetime('now')"); |
| 482 | 493 | zDate[10] = 'T'; |
| 483 | 494 | blob_appendf(&manifest, "D %s\n", zDate); |
| 484 | 495 | db_prepare(&q, |
| 485 | | - "SELECT pathname, uuid FROM vfile JOIN blob ON vfile.mrid=blob.rid" |
| 496 | + "SELECT pathname, uuid, origname" |
| 497 | + " FROM vfile JOIN blob ON vfile.mrid=blob.rid" |
| 486 | 498 | " WHERE NOT deleted AND vfile.vid=%d" |
| 487 | 499 | " ORDER BY 1", vid); |
| 488 | 500 | blob_zero(&filename); |
| 489 | 501 | blob_appendf(&filename, "%s/", g.zLocalRoot); |
| 490 | 502 | nBasename = blob_size(&filename); |
| 491 | 503 | while( db_step(&q)==SQLITE_ROW ){ |
| 492 | 504 | const char *zName = db_column_text(&q, 0); |
| 493 | 505 | const char *zUuid = db_column_text(&q, 1); |
| 506 | + const char *zOrig = db_column_text(&q, 2); |
| 494 | 507 | const char *zPerm; |
| 495 | 508 | blob_append(&filename, zName, -1); |
| 496 | 509 | if( file_isexe(blob_str(&filename)) ){ |
| 497 | 510 | zPerm = " x"; |
| 498 | 511 | }else{ |
| 499 | 512 | zPerm = ""; |
| 500 | 513 | } |
| 501 | 514 | blob_resize(&filename, nBasename); |
| 502 | | - blob_appendf(&manifest, "F %F %s%s\n", zName, zUuid, zPerm); |
| 515 | + if( zOrig==0 || strcmp(zOrig,zName)==0 ){ |
| 516 | + blob_appendf(&manifest, "F %F %s%s\n", zName, zUuid, zPerm); |
| 517 | + }else{ |
| 518 | + if( zPerm[0]==0 ){ zPerm = " w"; } |
| 519 | + blob_appendf(&manifest, "F %F %s%s %F\n", zName, zUuid, zPerm, zOrig); |
| 520 | + } |
| 503 | 521 | } |
| 504 | 522 | blob_reset(&filename); |
| 505 | 523 | db_finalize(&q); |
| 506 | 524 | zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid); |
| 507 | 525 | blob_appendf(&manifest, "P %s", zUuid); |
| | @@ -557,11 +575,12 @@ |
| 557 | 575 | /* Update the vfile and vmerge tables */ |
| 558 | 576 | db_multi_exec( |
| 559 | 577 | "DELETE FROM vfile WHERE (vid!=%d OR deleted) AND file_is_selected(id);" |
| 560 | 578 | "DELETE FROM vmerge WHERE file_is_selected(id) OR id=0;" |
| 561 | 579 | "UPDATE vfile SET vid=%d;" |
| 562 | | - "UPDATE vfile SET rid=mrid, chnged=0, deleted=0 WHERE file_is_selected(id);" |
| 580 | + "UPDATE vfile SET rid=mrid, chnged=0, deleted=0, origname=NULL" |
| 581 | + " WHERE file_is_selected(id);" |
| 563 | 582 | , vid, nvid |
| 564 | 583 | ); |
| 565 | 584 | db_lset_int("checkout", nvid); |
| 566 | 585 | |
| 567 | 586 | /* Verify that the repository checksum matches the expected checksum |
| | @@ -791,11 +810,11 @@ |
| 791 | 810 | ** least one. |
| 792 | 811 | */ |
| 793 | 812 | |
| 794 | 813 | blob_appendf(&manifest, "P"); |
| 795 | 814 | for (i=0;i<zParentCount;i++) { |
| 796 | | - char* zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", zParents [i]); |
| 815 | + char* zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", zParents[i]); |
| 797 | 816 | blob_appendf(&manifest, " %s", zUuid); |
| 798 | 817 | free(zUuid); |
| 799 | 818 | } |
| 800 | 819 | blob_appendf(&manifest, "\n"); |
| 801 | 820 | |
| 802 | 821 | |