Fossil SCM
Enhanced ability to deal with merges.
Commit
03dca8fca9bb629df30b17f80776138fbe8ac6e974fa04c865b3938914e427a6
Parent
4d82a8d1d01e8cc…
1 file changed
+25
-4
+25
-4
| --- src/patch.c | ||
| +++ src/patch.c | ||
| @@ -108,10 +108,11 @@ | ||
| 108 | 108 | ** Generate a binary patch file and store it into the file |
| 109 | 109 | ** named zOut. |
| 110 | 110 | */ |
| 111 | 111 | void patch_create(const char *zOut){ |
| 112 | 112 | int vid; |
| 113 | + | |
| 113 | 114 | if( file_isdir(zOut, ExtFILE)!=0 ){ |
| 114 | 115 | fossil_fatal("patch file already exists: %s", zOut); |
| 115 | 116 | } |
| 116 | 117 | add_content_sql_commands(g.db); |
| 117 | 118 | deltafunc_init(g.db); |
| @@ -160,17 +161,28 @@ | ||
| 160 | 161 | " FROM vfile WHERE deleted;" |
| 161 | 162 | ); |
| 162 | 163 | /* Changed files */ |
| 163 | 164 | db_multi_exec( |
| 164 | 165 | "INSERT INTO patch.chng(pathname,origname,hash,isexe,islink,delta)" |
| 165 | - " SELECT pathname, origname, blob.uuid, isexe, islink," | |
| 166 | + " SELECT pathname, nullif(origname,pathname), blob.uuid, isexe, islink," | |
| 166 | 167 | " mkdelta(blob.rid, %Q||pathname)" |
| 167 | 168 | " FROM vfile, blob" |
| 168 | 169 | " WHERE blob.rid=vfile.rid" |
| 169 | 170 | " AND NOT deleted AND (chnged OR origname<>pathname);", |
| 170 | 171 | g.zLocalRoot |
| 171 | 172 | ); |
| 173 | + | |
| 174 | + if( db_exists("SELECT 1 FROM localdb.vmerge WHERE id<=0") ){ | |
| 175 | + db_multi_exec( | |
| 176 | + "CREATE TABLE patch.patchmerge(type TEXT,mhash TEXT);\n" | |
| 177 | + "WITH tmap(id,type) AS (VALUES(0,'merge'),(-1,'cherrypick')," | |
| 178 | + "(-2,'backout'),(-4,'integrate'))" | |
| 179 | + "INSERT INTO patch.patchmerge(type,mhash)" | |
| 180 | + " SELECT tmap.type,vmerge.mhash FROM vmerge, tmap" | |
| 181 | + " WHERE tmap.id=vmerge.id;" | |
| 182 | + ); | |
| 183 | + } | |
| 172 | 184 | } |
| 173 | 185 | |
| 174 | 186 | /* |
| 175 | 187 | ** Attempt to load and validate a patchfile identified by the first |
| 176 | 188 | ** argument. |
| @@ -198,29 +210,38 @@ | ||
| 198 | 210 | */ |
| 199 | 211 | void patch_view(void){ |
| 200 | 212 | Stmt q; |
| 201 | 213 | db_prepare(&q, "SELECT value FROM patch.cfg WHERE key='baseline'"); |
| 202 | 214 | if( db_step(&q)==SQLITE_ROW ){ |
| 203 | - fossil_print("Patch against check-in %S\n", db_column_text(&q,0)); | |
| 215 | + fossil_print("%-10s %s\n", "BASELINE", db_column_text(&q,0)); | |
| 204 | 216 | }else{ |
| 205 | 217 | fossil_fatal("ERROR: Missing patch baseline"); |
| 206 | 218 | } |
| 207 | 219 | db_finalize(&q); |
| 220 | + if( db_table_exists("patch","patchmerge") ){ | |
| 221 | + db_prepare(&q, "SELECT upper(type),mhash FROM patchmerge"); | |
| 222 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 223 | + fossil_print("%-10s %s\n", | |
| 224 | + db_column_text(&q,0), | |
| 225 | + db_column_text(&q,1)); | |
| 226 | + } | |
| 227 | + db_finalize(&q); | |
| 228 | + } | |
| 208 | 229 | db_prepare(&q, |
| 209 | 230 | "SELECT pathname," |
| 210 | 231 | " hash IS NULL AND delta IS NOT NULL," |
| 211 | 232 | " delta IS NULL," |
| 212 | 233 | " origname" |
| 213 | 234 | " FROM patch.chng ORDER BY 1"); |
| 214 | 235 | while( db_step(&q)==SQLITE_ROW ){ |
| 215 | - const char *zClass = "CHANGED"; | |
| 236 | + const char *zClass = "EDIT"; | |
| 216 | 237 | const char *zName = db_column_text(&q,0); |
| 217 | 238 | const char *zOrigName = db_column_text(&q, 3); |
| 218 | 239 | if( db_column_int(&q, 1) && zOrigName==0 ){ |
| 219 | 240 | zClass = "NEW"; |
| 220 | 241 | }else if( db_column_int(&q, 2) ){ |
| 221 | - zClass = zOrigName==0 ? "DELETED" : 0; | |
| 242 | + zClass = zOrigName==0 ? "DELETE" : 0; | |
| 222 | 243 | } |
| 223 | 244 | if( zOrigName!=0 && zOrigName[0]!=0 ){ |
| 224 | 245 | fossil_print("%-10s %s -> %s\n", "RENAME",zOrigName,zName); |
| 225 | 246 | } |
| 226 | 247 | if( zClass ){ |
| 227 | 248 |
| --- src/patch.c | |
| +++ src/patch.c | |
| @@ -108,10 +108,11 @@ | |
| 108 | ** Generate a binary patch file and store it into the file |
| 109 | ** named zOut. |
| 110 | */ |
| 111 | void patch_create(const char *zOut){ |
| 112 | int vid; |
| 113 | if( file_isdir(zOut, ExtFILE)!=0 ){ |
| 114 | fossil_fatal("patch file already exists: %s", zOut); |
| 115 | } |
| 116 | add_content_sql_commands(g.db); |
| 117 | deltafunc_init(g.db); |
| @@ -160,17 +161,28 @@ | |
| 160 | " FROM vfile WHERE deleted;" |
| 161 | ); |
| 162 | /* Changed files */ |
| 163 | db_multi_exec( |
| 164 | "INSERT INTO patch.chng(pathname,origname,hash,isexe,islink,delta)" |
| 165 | " SELECT pathname, origname, blob.uuid, isexe, islink," |
| 166 | " mkdelta(blob.rid, %Q||pathname)" |
| 167 | " FROM vfile, blob" |
| 168 | " WHERE blob.rid=vfile.rid" |
| 169 | " AND NOT deleted AND (chnged OR origname<>pathname);", |
| 170 | g.zLocalRoot |
| 171 | ); |
| 172 | } |
| 173 | |
| 174 | /* |
| 175 | ** Attempt to load and validate a patchfile identified by the first |
| 176 | ** argument. |
| @@ -198,29 +210,38 @@ | |
| 198 | */ |
| 199 | void patch_view(void){ |
| 200 | Stmt q; |
| 201 | db_prepare(&q, "SELECT value FROM patch.cfg WHERE key='baseline'"); |
| 202 | if( db_step(&q)==SQLITE_ROW ){ |
| 203 | fossil_print("Patch against check-in %S\n", db_column_text(&q,0)); |
| 204 | }else{ |
| 205 | fossil_fatal("ERROR: Missing patch baseline"); |
| 206 | } |
| 207 | db_finalize(&q); |
| 208 | db_prepare(&q, |
| 209 | "SELECT pathname," |
| 210 | " hash IS NULL AND delta IS NOT NULL," |
| 211 | " delta IS NULL," |
| 212 | " origname" |
| 213 | " FROM patch.chng ORDER BY 1"); |
| 214 | while( db_step(&q)==SQLITE_ROW ){ |
| 215 | const char *zClass = "CHANGED"; |
| 216 | const char *zName = db_column_text(&q,0); |
| 217 | const char *zOrigName = db_column_text(&q, 3); |
| 218 | if( db_column_int(&q, 1) && zOrigName==0 ){ |
| 219 | zClass = "NEW"; |
| 220 | }else if( db_column_int(&q, 2) ){ |
| 221 | zClass = zOrigName==0 ? "DELETED" : 0; |
| 222 | } |
| 223 | if( zOrigName!=0 && zOrigName[0]!=0 ){ |
| 224 | fossil_print("%-10s %s -> %s\n", "RENAME",zOrigName,zName); |
| 225 | } |
| 226 | if( zClass ){ |
| 227 |
| --- src/patch.c | |
| +++ src/patch.c | |
| @@ -108,10 +108,11 @@ | |
| 108 | ** Generate a binary patch file and store it into the file |
| 109 | ** named zOut. |
| 110 | */ |
| 111 | void patch_create(const char *zOut){ |
| 112 | int vid; |
| 113 | |
| 114 | if( file_isdir(zOut, ExtFILE)!=0 ){ |
| 115 | fossil_fatal("patch file already exists: %s", zOut); |
| 116 | } |
| 117 | add_content_sql_commands(g.db); |
| 118 | deltafunc_init(g.db); |
| @@ -160,17 +161,28 @@ | |
| 161 | " FROM vfile WHERE deleted;" |
| 162 | ); |
| 163 | /* Changed files */ |
| 164 | db_multi_exec( |
| 165 | "INSERT INTO patch.chng(pathname,origname,hash,isexe,islink,delta)" |
| 166 | " SELECT pathname, nullif(origname,pathname), blob.uuid, isexe, islink," |
| 167 | " mkdelta(blob.rid, %Q||pathname)" |
| 168 | " FROM vfile, blob" |
| 169 | " WHERE blob.rid=vfile.rid" |
| 170 | " AND NOT deleted AND (chnged OR origname<>pathname);", |
| 171 | g.zLocalRoot |
| 172 | ); |
| 173 | |
| 174 | if( db_exists("SELECT 1 FROM localdb.vmerge WHERE id<=0") ){ |
| 175 | db_multi_exec( |
| 176 | "CREATE TABLE patch.patchmerge(type TEXT,mhash TEXT);\n" |
| 177 | "WITH tmap(id,type) AS (VALUES(0,'merge'),(-1,'cherrypick')," |
| 178 | "(-2,'backout'),(-4,'integrate'))" |
| 179 | "INSERT INTO patch.patchmerge(type,mhash)" |
| 180 | " SELECT tmap.type,vmerge.mhash FROM vmerge, tmap" |
| 181 | " WHERE tmap.id=vmerge.id;" |
| 182 | ); |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | /* |
| 187 | ** Attempt to load and validate a patchfile identified by the first |
| 188 | ** argument. |
| @@ -198,29 +210,38 @@ | |
| 210 | */ |
| 211 | void patch_view(void){ |
| 212 | Stmt q; |
| 213 | db_prepare(&q, "SELECT value FROM patch.cfg WHERE key='baseline'"); |
| 214 | if( db_step(&q)==SQLITE_ROW ){ |
| 215 | fossil_print("%-10s %s\n", "BASELINE", db_column_text(&q,0)); |
| 216 | }else{ |
| 217 | fossil_fatal("ERROR: Missing patch baseline"); |
| 218 | } |
| 219 | db_finalize(&q); |
| 220 | if( db_table_exists("patch","patchmerge") ){ |
| 221 | db_prepare(&q, "SELECT upper(type),mhash FROM patchmerge"); |
| 222 | while( db_step(&q)==SQLITE_ROW ){ |
| 223 | fossil_print("%-10s %s\n", |
| 224 | db_column_text(&q,0), |
| 225 | db_column_text(&q,1)); |
| 226 | } |
| 227 | db_finalize(&q); |
| 228 | } |
| 229 | db_prepare(&q, |
| 230 | "SELECT pathname," |
| 231 | " hash IS NULL AND delta IS NOT NULL," |
| 232 | " delta IS NULL," |
| 233 | " origname" |
| 234 | " FROM patch.chng ORDER BY 1"); |
| 235 | while( db_step(&q)==SQLITE_ROW ){ |
| 236 | const char *zClass = "EDIT"; |
| 237 | const char *zName = db_column_text(&q,0); |
| 238 | const char *zOrigName = db_column_text(&q, 3); |
| 239 | if( db_column_int(&q, 1) && zOrigName==0 ){ |
| 240 | zClass = "NEW"; |
| 241 | }else if( db_column_int(&q, 2) ){ |
| 242 | zClass = zOrigName==0 ? "DELETE" : 0; |
| 243 | } |
| 244 | if( zOrigName!=0 && zOrigName[0]!=0 ){ |
| 245 | fossil_print("%-10s %s -> %s\n", "RENAME",zOrigName,zName); |
| 246 | } |
| 247 | if( zClass ){ |
| 248 |