Fossil SCM

Restore the ability to amend a comment both with and without an interactive editor. If the edit happens outside a working check-out then use a suitable TMP directory.

andybradford 2017-06-02 02:23 trunk merge
Commit 1fff403a686adaef44302cea6f27bca1aaadb2d989f8d97bc32178f48d6c974c
3 files changed +8 -4 +8 -3 +1 -1
+8 -4
--- src/checkin.c
+++ src/checkin.c
@@ -1202,14 +1202,18 @@
12021202
"# Type \".\" on a line by itself when you are done:\n", -1);
12031203
zFile = mprintf("-");
12041204
}else{
12051205
Blob fname;
12061206
blob_zero(&fname);
1207
- assert( g.zLocalRoot!=0 );
1208
- file_relative_name(g.zLocalRoot, &fname, 1);
1209
- zFile = db_text(0, "SELECT '%qci-comment-'||hex(randomblob(6))||'.txt'",
1210
- blob_str(&fname));
1207
+ if( g.zLocalRoot!=0 ){
1208
+ file_relative_name(g.zLocalRoot, &fname, 1);
1209
+ zFile = db_text(0, "SELECT '%qci-comment-'||hex(randomblob(6))||'.txt'",
1210
+ blob_str(&fname));
1211
+ }else{
1212
+ file_tempname(&fname, "ci-comment");
1213
+ zFile = mprintf("%s", blob_str(&fname));
1214
+ }
12111215
blob_reset(&fname);
12121216
}
12131217
#if defined(_WIN32)
12141218
blob_add_cr(pPrompt);
12151219
#endif
12161220
--- src/checkin.c
+++ src/checkin.c
@@ -1202,14 +1202,18 @@
1202 "# Type \".\" on a line by itself when you are done:\n", -1);
1203 zFile = mprintf("-");
1204 }else{
1205 Blob fname;
1206 blob_zero(&fname);
1207 assert( g.zLocalRoot!=0 );
1208 file_relative_name(g.zLocalRoot, &fname, 1);
1209 zFile = db_text(0, "SELECT '%qci-comment-'||hex(randomblob(6))||'.txt'",
1210 blob_str(&fname));
 
 
 
 
1211 blob_reset(&fname);
1212 }
1213 #if defined(_WIN32)
1214 blob_add_cr(pPrompt);
1215 #endif
1216
--- src/checkin.c
+++ src/checkin.c
@@ -1202,14 +1202,18 @@
1202 "# Type \".\" on a line by itself when you are done:\n", -1);
1203 zFile = mprintf("-");
1204 }else{
1205 Blob fname;
1206 blob_zero(&fname);
1207 if( g.zLocalRoot!=0 ){
1208 file_relative_name(g.zLocalRoot, &fname, 1);
1209 zFile = db_text(0, "SELECT '%qci-comment-'||hex(randomblob(6))||'.txt'",
1210 blob_str(&fname));
1211 }else{
1212 file_tempname(&fname, "ci-comment");
1213 zFile = mprintf("%s", blob_str(&fname));
1214 }
1215 blob_reset(&fname);
1216 }
1217 #if defined(_WIN32)
1218 blob_add_cr(pPrompt);
1219 #endif
1220
+8 -3
--- src/file.c
+++ src/file.c
@@ -799,10 +799,11 @@
799799
** If the slash parameter is non-zero, the trailing slash, if any,
800800
** is retained.
801801
*/
802802
int file_simplify_name(char *z, int n, int slash){
803803
int i = 1, j;
804
+ assert( z!=0 );
804805
if( n<0 ) n = strlen(z);
805806
806807
/* On windows and cygwin convert all \ characters to /
807808
* and remove extended path prefix if present */
808809
#if defined(_WIN32) || defined(__CYGWIN__)
@@ -1388,11 +1389,12 @@
13881389
0, /* TEMP */
13891390
0, /* TMP */
13901391
".",
13911392
};
13921393
#else
1393
- static const char *const azDirs[] = {
1394
+ static const char *azDirs[] = {
1395
+ 0, /* TMPDIR */
13941396
"/var/tmp",
13951397
"/usr/tmp",
13961398
"/tmp",
13971399
"/temp",
13981400
".",
@@ -1414,12 +1416,13 @@
14141416
azDirs[0] = fossil_path_to_utf8(zTmpPath);
14151417
}
14161418
14171419
azDirs[1] = fossil_getenv("TEMP");
14181420
azDirs[2] = fossil_getenv("TMP");
1421
+#else
1422
+ azDirs[0] = fossil_getenv("TMPDIR");
14191423
#endif
1420
-
14211424
14221425
for(i=0; i<count(azDirs); i++){
14231426
if( azDirs[i]==0 ) continue;
14241427
if( !file_isdir(azDirs[i]) ) continue;
14251428
zDir = azDirs[i];
@@ -1432,17 +1435,19 @@
14321435
sqlite3_randomness(15, zRand);
14331436
for(i=0; i<15; i++){
14341437
zRand[i] = (char)zChars[ ((unsigned char)zRand[i])%(sizeof(zChars)-1) ];
14351438
}
14361439
zRand[15] = 0;
1437
- blob_appendf(pBuf, "%s/%s.%s", zDir, zPrefix ? zPrefix : "", zRand);
1440
+ blob_appendf(pBuf, "%s/%s-%s.txt", zDir, zPrefix ? zPrefix : "", zRand);
14381441
}while( file_size(blob_str(pBuf))>=0 );
14391442
14401443
#if defined(_WIN32)
14411444
fossil_path_free((char *)azDirs[0]);
14421445
fossil_path_free((char *)azDirs[1]);
14431446
fossil_path_free((char *)azDirs[2]);
1447
+#else
1448
+ fossil_path_free((char *)azDirs[0]);
14441449
#endif
14451450
}
14461451
14471452
14481453
/*
14491454
--- src/file.c
+++ src/file.c
@@ -799,10 +799,11 @@
799 ** If the slash parameter is non-zero, the trailing slash, if any,
800 ** is retained.
801 */
802 int file_simplify_name(char *z, int n, int slash){
803 int i = 1, j;
 
804 if( n<0 ) n = strlen(z);
805
806 /* On windows and cygwin convert all \ characters to /
807 * and remove extended path prefix if present */
808 #if defined(_WIN32) || defined(__CYGWIN__)
@@ -1388,11 +1389,12 @@
1388 0, /* TEMP */
1389 0, /* TMP */
1390 ".",
1391 };
1392 #else
1393 static const char *const azDirs[] = {
 
1394 "/var/tmp",
1395 "/usr/tmp",
1396 "/tmp",
1397 "/temp",
1398 ".",
@@ -1414,12 +1416,13 @@
1414 azDirs[0] = fossil_path_to_utf8(zTmpPath);
1415 }
1416
1417 azDirs[1] = fossil_getenv("TEMP");
1418 azDirs[2] = fossil_getenv("TMP");
 
 
1419 #endif
1420
1421
1422 for(i=0; i<count(azDirs); i++){
1423 if( azDirs[i]==0 ) continue;
1424 if( !file_isdir(azDirs[i]) ) continue;
1425 zDir = azDirs[i];
@@ -1432,17 +1435,19 @@
1432 sqlite3_randomness(15, zRand);
1433 for(i=0; i<15; i++){
1434 zRand[i] = (char)zChars[ ((unsigned char)zRand[i])%(sizeof(zChars)-1) ];
1435 }
1436 zRand[15] = 0;
1437 blob_appendf(pBuf, "%s/%s.%s", zDir, zPrefix ? zPrefix : "", zRand);
1438 }while( file_size(blob_str(pBuf))>=0 );
1439
1440 #if defined(_WIN32)
1441 fossil_path_free((char *)azDirs[0]);
1442 fossil_path_free((char *)azDirs[1]);
1443 fossil_path_free((char *)azDirs[2]);
 
 
1444 #endif
1445 }
1446
1447
1448 /*
1449
--- src/file.c
+++ src/file.c
@@ -799,10 +799,11 @@
799 ** If the slash parameter is non-zero, the trailing slash, if any,
800 ** is retained.
801 */
802 int file_simplify_name(char *z, int n, int slash){
803 int i = 1, j;
804 assert( z!=0 );
805 if( n<0 ) n = strlen(z);
806
807 /* On windows and cygwin convert all \ characters to /
808 * and remove extended path prefix if present */
809 #if defined(_WIN32) || defined(__CYGWIN__)
@@ -1388,11 +1389,12 @@
1389 0, /* TEMP */
1390 0, /* TMP */
1391 ".",
1392 };
1393 #else
1394 static const char *azDirs[] = {
1395 0, /* TMPDIR */
1396 "/var/tmp",
1397 "/usr/tmp",
1398 "/tmp",
1399 "/temp",
1400 ".",
@@ -1414,12 +1416,13 @@
1416 azDirs[0] = fossil_path_to_utf8(zTmpPath);
1417 }
1418
1419 azDirs[1] = fossil_getenv("TEMP");
1420 azDirs[2] = fossil_getenv("TMP");
1421 #else
1422 azDirs[0] = fossil_getenv("TMPDIR");
1423 #endif
 
1424
1425 for(i=0; i<count(azDirs); i++){
1426 if( azDirs[i]==0 ) continue;
1427 if( !file_isdir(azDirs[i]) ) continue;
1428 zDir = azDirs[i];
@@ -1432,17 +1435,19 @@
1435 sqlite3_randomness(15, zRand);
1436 for(i=0; i<15; i++){
1437 zRand[i] = (char)zChars[ ((unsigned char)zRand[i])%(sizeof(zChars)-1) ];
1438 }
1439 zRand[15] = 0;
1440 blob_appendf(pBuf, "%s/%s-%s.txt", zDir, zPrefix ? zPrefix : "", zRand);
1441 }while( file_size(blob_str(pBuf))>=0 );
1442
1443 #if defined(_WIN32)
1444 fossil_path_free((char *)azDirs[0]);
1445 fossil_path_free((char *)azDirs[1]);
1446 fossil_path_free((char *)azDirs[2]);
1447 #else
1448 fossil_path_free((char *)azDirs[0]);
1449 #endif
1450 }
1451
1452
1453 /*
1454
+1 -1
--- src/info.c
+++ src/info.c
@@ -2946,11 +2946,11 @@
29462946
pzNewTags = find_repeatable_option("tag",0,&nTags);
29472947
pzCancelTags = find_repeatable_option("cancel",0,&nCancels);
29482948
fClose = find_option("close",0,0)!=0;
29492949
fHide = find_option("hide",0,0)!=0;
29502950
zChngTime = find_option("chngtime",0,1);
2951
- db_must_be_within_tree();
2951
+ db_find_and_open_repository(0,0);
29522952
user_select();
29532953
verify_all_options();
29542954
if( g.argc<3 || g.argc>=4 ) usage(AMEND_USAGE_STMT);
29552955
rid = name_to_typed_rid(g.argv[2], "ci");
29562956
if( rid==0 && !is_a_version(rid) ) fossil_fatal("no such check-in");
29572957
--- src/info.c
+++ src/info.c
@@ -2946,11 +2946,11 @@
2946 pzNewTags = find_repeatable_option("tag",0,&nTags);
2947 pzCancelTags = find_repeatable_option("cancel",0,&nCancels);
2948 fClose = find_option("close",0,0)!=0;
2949 fHide = find_option("hide",0,0)!=0;
2950 zChngTime = find_option("chngtime",0,1);
2951 db_must_be_within_tree();
2952 user_select();
2953 verify_all_options();
2954 if( g.argc<3 || g.argc>=4 ) usage(AMEND_USAGE_STMT);
2955 rid = name_to_typed_rid(g.argv[2], "ci");
2956 if( rid==0 && !is_a_version(rid) ) fossil_fatal("no such check-in");
2957
--- src/info.c
+++ src/info.c
@@ -2946,11 +2946,11 @@
2946 pzNewTags = find_repeatable_option("tag",0,&nTags);
2947 pzCancelTags = find_repeatable_option("cancel",0,&nCancels);
2948 fClose = find_option("close",0,0)!=0;
2949 fHide = find_option("hide",0,0)!=0;
2950 zChngTime = find_option("chngtime",0,1);
2951 db_find_and_open_repository(0,0);
2952 user_select();
2953 verify_all_options();
2954 if( g.argc<3 || g.argc>=4 ) usage(AMEND_USAGE_STMT);
2955 rid = name_to_typed_rid(g.argv[2], "ci");
2956 if( rid==0 && !is_a_version(rid) ) fossil_fatal("no such check-in");
2957

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button