Fossil SCM
Begin making infrastructure changes to support doing a diff between two independently edited check-outs.
Commit
b10cb2b536a92f49ea4da9bbcc74423c6cb0c0808f33ab062731c92234344cd3
Parent
02eb97d801a899f…
1 file changed
+30
-13
+30
-13
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -960,10 +960,33 @@ | ||
| 960 | 960 | fossil_free(zFullName); |
| 961 | 961 | blob_reset(&content); |
| 962 | 962 | } |
| 963 | 963 | db_finalize(&q); |
| 964 | 964 | } |
| 965 | + | |
| 966 | +/* | |
| 967 | +** Fetch the content for pFile into pContent. pContent is assumed to be | |
| 968 | +** uninitialized. | |
| 969 | +** | |
| 970 | +** This routine accepts non-standard ManifestFile records where the | |
| 971 | +** ManifestFile.zUuid is an absolute pathname rather than an artifact | |
| 972 | +** hash. When zUuid is a pathname, the content of the file at that pathname | |
| 973 | +** is read directly from disk. | |
| 974 | +*/ | |
| 975 | +static void diff_fetch_manifest_entry( | |
| 976 | + ManifestFile *pFile, | |
| 977 | + Blob *pContent | |
| 978 | +){ | |
| 979 | + if( pFile==0){ | |
| 980 | + blob_zero(pContent); | |
| 981 | + }else if( file_is_absolute_path(pFile->zUuid) ){ | |
| 982 | + blob_read_from_file(pContent, pFile->zUuid, ExtFILE); | |
| 983 | + }else{ | |
| 984 | + int rid = uuid_to_rid(pFile->zUuid, 0); | |
| 985 | + content_get(rid, pContent); | |
| 986 | + } | |
| 987 | +} | |
| 965 | 988 | |
| 966 | 989 | /* |
| 967 | 990 | ** Show the difference between two files identified by ManifestFile |
| 968 | 991 | ** entries. |
| 969 | 992 | ** |
| @@ -971,18 +994,22 @@ | ||
| 971 | 994 | ** command zDiffCmd to do the diffing. |
| 972 | 995 | ** |
| 973 | 996 | ** When using an external diff program, zBinGlob contains the GLOB patterns |
| 974 | 997 | ** for file names to treat as binary. If fIncludeBinary is zero, these files |
| 975 | 998 | ** will be skipped in addition to files that may contain binary content. |
| 999 | +** | |
| 1000 | +** This routine accepts non-standard ManifestFile records where the | |
| 1001 | +** ManifestFile.zUuid is an absolute pathname rather than an artifact | |
| 1002 | +** hash. When zUuid is a pathname, the content of the file at that pathname | |
| 1003 | +** is read directly from disk. | |
| 976 | 1004 | */ |
| 977 | 1005 | static void diff_manifest_entry( |
| 978 | 1006 | struct ManifestFile *pFrom, |
| 979 | 1007 | struct ManifestFile *pTo, |
| 980 | 1008 | DiffConfig *pCfg |
| 981 | 1009 | ){ |
| 982 | 1010 | Blob f1, f2; |
| 983 | - int rid; | |
| 984 | 1011 | const char *zName; |
| 985 | 1012 | if( pFrom ){ |
| 986 | 1013 | zName = pFrom->zName; |
| 987 | 1014 | }else if( pTo ){ |
| 988 | 1015 | zName = pTo->zName; |
| @@ -989,22 +1016,12 @@ | ||
| 989 | 1016 | }else{ |
| 990 | 1017 | zName = DIFF_NO_NAME; |
| 991 | 1018 | } |
| 992 | 1019 | if( pCfg->diffFlags & DIFF_BRIEF ) return; |
| 993 | 1020 | diff_print_index(zName, pCfg, 0); |
| 994 | - if( pFrom ){ | |
| 995 | - rid = uuid_to_rid(pFrom->zUuid, 0); | |
| 996 | - content_get(rid, &f1); | |
| 997 | - }else{ | |
| 998 | - blob_zero(&f1); | |
| 999 | - } | |
| 1000 | - if( pTo ){ | |
| 1001 | - rid = uuid_to_rid(pTo->zUuid, 0); | |
| 1002 | - content_get(rid, &f2); | |
| 1003 | - }else{ | |
| 1004 | - blob_zero(&f2); | |
| 1005 | - } | |
| 1021 | + diff_fetch_manifest_entry(pFrom, &f1); | |
| 1022 | + diff_fetch_manifest_entry(pTo, &f2); | |
| 1006 | 1023 | diff_file_mem(&f1, &f2, zName, pCfg); |
| 1007 | 1024 | blob_reset(&f1); |
| 1008 | 1025 | blob_reset(&f2); |
| 1009 | 1026 | } |
| 1010 | 1027 | |
| 1011 | 1028 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -960,10 +960,33 @@ | |
| 960 | fossil_free(zFullName); |
| 961 | blob_reset(&content); |
| 962 | } |
| 963 | db_finalize(&q); |
| 964 | } |
| 965 | |
| 966 | /* |
| 967 | ** Show the difference between two files identified by ManifestFile |
| 968 | ** entries. |
| 969 | ** |
| @@ -971,18 +994,22 @@ | |
| 971 | ** command zDiffCmd to do the diffing. |
| 972 | ** |
| 973 | ** When using an external diff program, zBinGlob contains the GLOB patterns |
| 974 | ** for file names to treat as binary. If fIncludeBinary is zero, these files |
| 975 | ** will be skipped in addition to files that may contain binary content. |
| 976 | */ |
| 977 | static void diff_manifest_entry( |
| 978 | struct ManifestFile *pFrom, |
| 979 | struct ManifestFile *pTo, |
| 980 | DiffConfig *pCfg |
| 981 | ){ |
| 982 | Blob f1, f2; |
| 983 | int rid; |
| 984 | const char *zName; |
| 985 | if( pFrom ){ |
| 986 | zName = pFrom->zName; |
| 987 | }else if( pTo ){ |
| 988 | zName = pTo->zName; |
| @@ -989,22 +1016,12 @@ | |
| 989 | }else{ |
| 990 | zName = DIFF_NO_NAME; |
| 991 | } |
| 992 | if( pCfg->diffFlags & DIFF_BRIEF ) return; |
| 993 | diff_print_index(zName, pCfg, 0); |
| 994 | if( pFrom ){ |
| 995 | rid = uuid_to_rid(pFrom->zUuid, 0); |
| 996 | content_get(rid, &f1); |
| 997 | }else{ |
| 998 | blob_zero(&f1); |
| 999 | } |
| 1000 | if( pTo ){ |
| 1001 | rid = uuid_to_rid(pTo->zUuid, 0); |
| 1002 | content_get(rid, &f2); |
| 1003 | }else{ |
| 1004 | blob_zero(&f2); |
| 1005 | } |
| 1006 | diff_file_mem(&f1, &f2, zName, pCfg); |
| 1007 | blob_reset(&f1); |
| 1008 | blob_reset(&f2); |
| 1009 | } |
| 1010 | |
| 1011 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -960,10 +960,33 @@ | |
| 960 | fossil_free(zFullName); |
| 961 | blob_reset(&content); |
| 962 | } |
| 963 | db_finalize(&q); |
| 964 | } |
| 965 | |
| 966 | /* |
| 967 | ** Fetch the content for pFile into pContent. pContent is assumed to be |
| 968 | ** uninitialized. |
| 969 | ** |
| 970 | ** This routine accepts non-standard ManifestFile records where the |
| 971 | ** ManifestFile.zUuid is an absolute pathname rather than an artifact |
| 972 | ** hash. When zUuid is a pathname, the content of the file at that pathname |
| 973 | ** is read directly from disk. |
| 974 | */ |
| 975 | static void diff_fetch_manifest_entry( |
| 976 | ManifestFile *pFile, |
| 977 | Blob *pContent |
| 978 | ){ |
| 979 | if( pFile==0){ |
| 980 | blob_zero(pContent); |
| 981 | }else if( file_is_absolute_path(pFile->zUuid) ){ |
| 982 | blob_read_from_file(pContent, pFile->zUuid, ExtFILE); |
| 983 | }else{ |
| 984 | int rid = uuid_to_rid(pFile->zUuid, 0); |
| 985 | content_get(rid, pContent); |
| 986 | } |
| 987 | } |
| 988 | |
| 989 | /* |
| 990 | ** Show the difference between two files identified by ManifestFile |
| 991 | ** entries. |
| 992 | ** |
| @@ -971,18 +994,22 @@ | |
| 994 | ** command zDiffCmd to do the diffing. |
| 995 | ** |
| 996 | ** When using an external diff program, zBinGlob contains the GLOB patterns |
| 997 | ** for file names to treat as binary. If fIncludeBinary is zero, these files |
| 998 | ** will be skipped in addition to files that may contain binary content. |
| 999 | ** |
| 1000 | ** This routine accepts non-standard ManifestFile records where the |
| 1001 | ** ManifestFile.zUuid is an absolute pathname rather than an artifact |
| 1002 | ** hash. When zUuid is a pathname, the content of the file at that pathname |
| 1003 | ** is read directly from disk. |
| 1004 | */ |
| 1005 | static void diff_manifest_entry( |
| 1006 | struct ManifestFile *pFrom, |
| 1007 | struct ManifestFile *pTo, |
| 1008 | DiffConfig *pCfg |
| 1009 | ){ |
| 1010 | Blob f1, f2; |
| 1011 | const char *zName; |
| 1012 | if( pFrom ){ |
| 1013 | zName = pFrom->zName; |
| 1014 | }else if( pTo ){ |
| 1015 | zName = pTo->zName; |
| @@ -989,22 +1016,12 @@ | |
| 1016 | }else{ |
| 1017 | zName = DIFF_NO_NAME; |
| 1018 | } |
| 1019 | if( pCfg->diffFlags & DIFF_BRIEF ) return; |
| 1020 | diff_print_index(zName, pCfg, 0); |
| 1021 | diff_fetch_manifest_entry(pFrom, &f1); |
| 1022 | diff_fetch_manifest_entry(pTo, &f2); |
| 1023 | diff_file_mem(&f1, &f2, zName, pCfg); |
| 1024 | blob_reset(&f1); |
| 1025 | blob_reset(&f2); |
| 1026 | } |
| 1027 | |
| 1028 |