Fossil SCM
Add additional metadata to patch files.
Commit
b9d5fa4d7b73e311803577cc6bcd5d0054c289f69f316fcf289f79efbc3ba312
Parent
7d6635542bac314…
1 file changed
+42
-1
+42
-1
| --- src/patch.c | ||
| +++ src/patch.c | ||
| @@ -29,10 +29,29 @@ | ||
| 29 | 29 | # undef popen |
| 30 | 30 | # define popen _popen |
| 31 | 31 | # undef pclose |
| 32 | 32 | # define pclose _pclose |
| 33 | 33 | #endif |
| 34 | + | |
| 35 | +/* | |
| 36 | +** Try to compute the name of the computer on which this process | |
| 37 | +** is running. | |
| 38 | +*/ | |
| 39 | +char *fossil_hostname(void){ | |
| 40 | + FILE *in; | |
| 41 | + char zBuf[200]; | |
| 42 | + in = popen("hostname","r"); | |
| 43 | + if( in ){ | |
| 44 | + size_t n = fread(zBuf, 1, sizeof(zBuf)-1, in); | |
| 45 | + while( n>0 && fossil_isspace(zBuf[n-1]) ){ n--; } | |
| 46 | + if( n<0 ) n = 0; | |
| 47 | + zBuf[n] = 0; | |
| 48 | + pclose(in); | |
| 49 | + return fossil_strdup(zBuf); | |
| 50 | + } | |
| 51 | + return 0; | |
| 52 | +} | |
| 34 | 53 | |
| 35 | 54 | /* |
| 36 | 55 | ** Flags passed from the main patch_cmd() routine into subfunctions used |
| 37 | 56 | ** to implement the various subcommands. |
| 38 | 57 | */ |
| @@ -127,10 +146,11 @@ | ||
| 127 | 146 | ** Generate a binary patch file and store it into the file |
| 128 | 147 | ** named zOut. |
| 129 | 148 | */ |
| 130 | 149 | void patch_create(const char *zOut, FILE *out){ |
| 131 | 150 | int vid; |
| 151 | + char *z; | |
| 132 | 152 | |
| 133 | 153 | if( zOut && file_isdir(zOut, ExtFILE)!=0 ){ |
| 134 | 154 | fossil_fatal("patch file already exists: %s", zOut); |
| 135 | 155 | } |
| 136 | 156 | add_content_sql_commands(g.db); |
| @@ -156,13 +176,34 @@ | ||
| 156 | 176 | " value ANY\n" |
| 157 | 177 | ");" |
| 158 | 178 | ); |
| 159 | 179 | vid = db_lget_int("checkout", 0); |
| 160 | 180 | vfile_check_signature(vid, CKSIG_ENOTFILE); |
| 181 | + user_select(); | |
| 161 | 182 | db_multi_exec( |
| 162 | 183 | "INSERT INTO patch.cfg(key,value)" |
| 163 | - "SELECT 'baseline',uuid FROM blob WHERE rid=%d", vid); | |
| 184 | + "SELECT 'baseline',uuid FROM blob WHERE rid=%d " | |
| 185 | + "UNION ALL" | |
| 186 | + " SELECT 'ckout',rtrim(%Q,'/')" | |
| 187 | + "UNION ALL" | |
| 188 | + " SELECT 'repo',%Q " | |
| 189 | + "UNION ALL" | |
| 190 | + " SELECT 'user',%Q " | |
| 191 | + "UNION ALL" | |
| 192 | + " SELECT 'date',julianday('now')" | |
| 193 | + "UNION ALL" | |
| 194 | + " SELECT 'project-code',value FROM repository.config" | |
| 195 | + " WHERE name='project-code' " | |
| 196 | + "UNION ALL" | |
| 197 | + " SELECT 'fossil-date',julianday('" MANIFEST_DATE "')" | |
| 198 | + ";", vid, g.zLocalRoot, g.zRepositoryName, g.zLogin); | |
| 199 | + z = fossil_hostname(); | |
| 200 | + if( z ){ | |
| 201 | + db_multi_exec( | |
| 202 | + "INSERT INTO patch.cfg(key,value)VALUES('hostname',%Q)", z); | |
| 203 | + fossil_free(z); | |
| 204 | + } | |
| 164 | 205 | |
| 165 | 206 | /* New files */ |
| 166 | 207 | db_multi_exec( |
| 167 | 208 | "INSERT INTO patch.chng(pathname,hash,isexe,islink,delta)" |
| 168 | 209 | " SELECT pathname, NULL, isexe, islink," |
| 169 | 210 |
| --- src/patch.c | |
| +++ src/patch.c | |
| @@ -29,10 +29,29 @@ | |
| 29 | # undef popen |
| 30 | # define popen _popen |
| 31 | # undef pclose |
| 32 | # define pclose _pclose |
| 33 | #endif |
| 34 | |
| 35 | /* |
| 36 | ** Flags passed from the main patch_cmd() routine into subfunctions used |
| 37 | ** to implement the various subcommands. |
| 38 | */ |
| @@ -127,10 +146,11 @@ | |
| 127 | ** Generate a binary patch file and store it into the file |
| 128 | ** named zOut. |
| 129 | */ |
| 130 | void patch_create(const char *zOut, FILE *out){ |
| 131 | int vid; |
| 132 | |
| 133 | if( zOut && file_isdir(zOut, ExtFILE)!=0 ){ |
| 134 | fossil_fatal("patch file already exists: %s", zOut); |
| 135 | } |
| 136 | add_content_sql_commands(g.db); |
| @@ -156,13 +176,34 @@ | |
| 156 | " value ANY\n" |
| 157 | ");" |
| 158 | ); |
| 159 | vid = db_lget_int("checkout", 0); |
| 160 | vfile_check_signature(vid, CKSIG_ENOTFILE); |
| 161 | db_multi_exec( |
| 162 | "INSERT INTO patch.cfg(key,value)" |
| 163 | "SELECT 'baseline',uuid FROM blob WHERE rid=%d", vid); |
| 164 | |
| 165 | /* New files */ |
| 166 | db_multi_exec( |
| 167 | "INSERT INTO patch.chng(pathname,hash,isexe,islink,delta)" |
| 168 | " SELECT pathname, NULL, isexe, islink," |
| 169 |
| --- src/patch.c | |
| +++ src/patch.c | |
| @@ -29,10 +29,29 @@ | |
| 29 | # undef popen |
| 30 | # define popen _popen |
| 31 | # undef pclose |
| 32 | # define pclose _pclose |
| 33 | #endif |
| 34 | |
| 35 | /* |
| 36 | ** Try to compute the name of the computer on which this process |
| 37 | ** is running. |
| 38 | */ |
| 39 | char *fossil_hostname(void){ |
| 40 | FILE *in; |
| 41 | char zBuf[200]; |
| 42 | in = popen("hostname","r"); |
| 43 | if( in ){ |
| 44 | size_t n = fread(zBuf, 1, sizeof(zBuf)-1, in); |
| 45 | while( n>0 && fossil_isspace(zBuf[n-1]) ){ n--; } |
| 46 | if( n<0 ) n = 0; |
| 47 | zBuf[n] = 0; |
| 48 | pclose(in); |
| 49 | return fossil_strdup(zBuf); |
| 50 | } |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | /* |
| 55 | ** Flags passed from the main patch_cmd() routine into subfunctions used |
| 56 | ** to implement the various subcommands. |
| 57 | */ |
| @@ -127,10 +146,11 @@ | |
| 146 | ** Generate a binary patch file and store it into the file |
| 147 | ** named zOut. |
| 148 | */ |
| 149 | void patch_create(const char *zOut, FILE *out){ |
| 150 | int vid; |
| 151 | char *z; |
| 152 | |
| 153 | if( zOut && file_isdir(zOut, ExtFILE)!=0 ){ |
| 154 | fossil_fatal("patch file already exists: %s", zOut); |
| 155 | } |
| 156 | add_content_sql_commands(g.db); |
| @@ -156,13 +176,34 @@ | |
| 176 | " value ANY\n" |
| 177 | ");" |
| 178 | ); |
| 179 | vid = db_lget_int("checkout", 0); |
| 180 | vfile_check_signature(vid, CKSIG_ENOTFILE); |
| 181 | user_select(); |
| 182 | db_multi_exec( |
| 183 | "INSERT INTO patch.cfg(key,value)" |
| 184 | "SELECT 'baseline',uuid FROM blob WHERE rid=%d " |
| 185 | "UNION ALL" |
| 186 | " SELECT 'ckout',rtrim(%Q,'/')" |
| 187 | "UNION ALL" |
| 188 | " SELECT 'repo',%Q " |
| 189 | "UNION ALL" |
| 190 | " SELECT 'user',%Q " |
| 191 | "UNION ALL" |
| 192 | " SELECT 'date',julianday('now')" |
| 193 | "UNION ALL" |
| 194 | " SELECT 'project-code',value FROM repository.config" |
| 195 | " WHERE name='project-code' " |
| 196 | "UNION ALL" |
| 197 | " SELECT 'fossil-date',julianday('" MANIFEST_DATE "')" |
| 198 | ";", vid, g.zLocalRoot, g.zRepositoryName, g.zLogin); |
| 199 | z = fossil_hostname(); |
| 200 | if( z ){ |
| 201 | db_multi_exec( |
| 202 | "INSERT INTO patch.cfg(key,value)VALUES('hostname',%Q)", z); |
| 203 | fossil_free(z); |
| 204 | } |
| 205 | |
| 206 | /* New files */ |
| 207 | db_multi_exec( |
| 208 | "INSERT INTO patch.chng(pathname,hash,isexe,islink,delta)" |
| 209 | " SELECT pathname, NULL, isexe, islink," |
| 210 |