jcs
/amend
/amendments
/107
browser: Tweak menu language, fix bug in amendment exporting
We were passing a NULL pointer to SFPutFile instead of an empty
Pascal string, which has bad results on System 7. Now we will
supply "amendment_##.diff" as the default filename.
Also rename exporting functions to export an amendment instead of
a patch. The patch utility applies a diff, not a patch. But we're
exporting the whole amendment anyway.
jcs made amendment 107 over 2 years ago
--- amend.π.r Mon Sep 12 16:32:21 2022
+++ amend.π.r Thu Nov 10 09:42:11 2022
@@ -25,16 +25,15 @@ data 'MENU' (131) {
$"6570 6F0B 4164 6420 4669 6C65 2E2E 2E00" /* epo.Add File.... */
$"0000 0024 4469 7363 6172 6420 4368 616E" /* ...$Discard Chan */
$"6765 7320 746F 2053 656C 6563 7465 6420" /* ges to Selected */
- $"4669 6C65 732E 2E2E 0000 0000 0E41 7070" /* Files........App */
- $"6C79 2050 6174 6368 2E2E 2E00 0000 0000" /* ly Patch........ */
+ $"4669 6C65 732E 2E2E 0000 0000 0D41 7070" /* Files.......¬App */
+ $"6C79 2044 6966 662E 2E2E 0000 0000 00" /* ly Diff........ */
};
data 'MENU' (132) {
$"0084 0000 0000 0000 0000 FFFF FFFF 0941" /* .Ñ............∆A */
$"6D65 6E64 6D65 6E74 1045 6469 7420 4D65" /* mendment.Edit Me */
- $"7461 6461 7461 2E2E 2E00 0000 000F 4578" /* tadata........Ex */
- $"706F 7274 2050 6174 6368 2E2E 2E00 4500" /* port Patch....E. */
- $"0000" /* .. */
+ $"7461 6461 7461 2E2E 2E00 0000 0009 4578" /* tadata.......∆Ex */
+ $"706F 7274 2E2E 2E00 4500 0000" /* port....E... */
};
data 'MBAR' (128) {
--- amend.h Wed Aug 31 22:03:23 2022
+++ amend.h Thu Nov 10 09:30:17 2022
@@ -36,7 +36,7 @@
#define REPO_MENU_ID 131
#define REPO_MENU_ADD_FILE_ID 1
#define REPO_MENU_DISCARD_CHANGES_ID 2
-#define REPO_MENU_APPLY_PATCH_ID 3
+#define REPO_MENU_APPLY_DIFF_ID 3
#define AMENDMENT_MENU_ID 132
#define AMENDMENT_MENU_EDIT_ID 1
--- browser.c Mon Sep 12 16:18:15 2022
+++ browser.c Thu Nov 10 09:28:59 2022
@@ -90,12 +90,12 @@ browser_idle(struct focusable *focusable, EventRecord
browser_discard_changes(browser);
browser->state = BROWSER_STATE_IDLE;
break;
- case BROWSER_STATE_EXPORT_PATCH:
- browser_export_patch(browser);
+ case BROWSER_STATE_EXPORT_AMENDMENT:
+ browser_export_amendment(browser);
browser->state = BROWSER_STATE_IDLE;
break;
- case BROWSER_STATE_APPLY_PATCH:
- browser_apply_patch(browser);
+ case BROWSER_STATE_APPLY_DIFF:
+ browser_apply_diff(browser);
browser->state = BROWSER_STATE_IDLE;
break;
case BROWSER_STATE_EDIT_AMENDMENT:
@@ -446,12 +446,13 @@ browser_discard_changes(struct browser *browser)
}
void
-browser_export_patch(struct browser *browser)
+browser_export_amendment(struct browser *browser)
{
Cell selected = { 0 };
struct repo_amendment *amendment;
short error, len;
SFReply reply;
+ char filename[255];
if (LGetSelect(true, &selected, browser->amendment_list) == false)
return;
@@ -459,16 +460,21 @@ browser_export_patch(struct browser *browser)
len = sizeof(Ptr);
LGetCell(&amendment, &len, selected, browser->amendment_list);
- SFPutFile(centered_sfput_dialog(), "\pSave patch as:", NULL, NULL,
+ snprintf(filename, sizeof(filename), "amendment_%d.diff",
+ amendment->id);
+ CtoPstr(filename);
+
+ SFPutFile(centered_sfput_dialog(), "\pSave as:", filename, NULL,
&reply);
if (!reply.good)
return;
- repo_export_patch(browser->repo, amendment, reply.vRefNum, reply.fName);
+ repo_export_amendment(browser->repo, amendment, reply.vRefNum,
+ reply.fName);
}
void
-browser_apply_patch(struct browser *browser)
+browser_apply_diff(struct browser *browser)
{
SFReply reply;
@@ -535,7 +541,7 @@ browser_update_menu(struct browser *browser)
EnableItem(repo_menu, REPO_MENU_ADD_FILE_ID);
EnableItem(repo_menu, REPO_MENU_DISCARD_CHANGES_ID);
#if 0
- EnableItem(repo_menu, REPO_MENU_APPLY_PATCH_ID);
+ EnableItem(repo_menu, REPO_MENU_APPLY_DIFF_ID);
#endif
}
@@ -749,8 +755,8 @@ browser_handle_menu(struct focusable *focusable, short
case REPO_MENU_DISCARD_CHANGES_ID:
browser->state = BROWSER_STATE_DISCARD_CHANGES;
return true;
- case REPO_MENU_APPLY_PATCH_ID:
- browser->state = BROWSER_STATE_APPLY_PATCH;
+ case REPO_MENU_APPLY_DIFF_ID:
+ browser->state = BROWSER_STATE_APPLY_DIFF;
return true;
}
break;
@@ -760,7 +766,7 @@ browser_handle_menu(struct focusable *focusable, short
browser->state = BROWSER_STATE_EDIT_AMENDMENT;
return true;
case AMENDMENT_MENU_EXPORT_ID:
- browser->state = BROWSER_STATE_EXPORT_PATCH;
+ browser->state = BROWSER_STATE_EXPORT_AMENDMENT;
return true;
}
break;
--- browser.h Wed Aug 31 16:28:45 2022
+++ browser.h Thu Nov 10 09:28:21 2022
@@ -31,8 +31,8 @@ enum {
BROWSER_STATE_WAITING_FOR_COMMITTER,
BROWSER_STATE_REMOVE_FILE,
BROWSER_STATE_DISCARD_CHANGES,
- BROWSER_STATE_EXPORT_PATCH,
- BROWSER_STATE_APPLY_PATCH,
+ BROWSER_STATE_EXPORT_AMENDMENT,
+ BROWSER_STATE_APPLY_DIFF,
BROWSER_STATE_EDIT_AMENDMENT
};
@@ -54,11 +54,11 @@ void browser_update_titlebar(struct browser *browser);
void browser_show_amendment(struct browser *browser,
struct repo_amendment *amendment);
void browser_close_committer(struct browser *browser);
-void browser_export_patch(struct browser *browser);
+void browser_export_amendment(struct browser *browser);
short browser_is_all_files_selected(struct browser *browser);
short browser_selected_file_ids(struct browser *browser,
short **selected_files);
-void browser_apply_patch(struct browser *browser);
+void browser_apply_diff(struct browser *browser);
pascal void amendment_list_ldef(short message, Boolean selected,
Rect *cellRect, Cell theCell, short dataOffset, short dataLen,
--- committer.c Mon Sep 12 16:20:46 2022
+++ committer.c Thu Nov 10 09:31:29 2022
@@ -402,7 +402,7 @@ committer_update_menu(struct committer *committer)
DisableItem(repo_menu, REPO_MENU_ADD_FILE_ID);
DisableItem(repo_menu, REPO_MENU_DISCARD_CHANGES_ID);
- DisableItem(repo_menu, REPO_MENU_APPLY_PATCH_ID);
+ DisableItem(repo_menu, REPO_MENU_APPLY_DIFF_ID);
DisableItem(amendment_menu, AMENDMENT_MENU_EDIT_ID);
DisableItem(amendment_menu, AMENDMENT_MENU_EXPORT_ID);
--- editor.c Tue Sep 6 14:13:47 2022
+++ editor.c Thu Nov 10 09:32:40 2022
@@ -377,7 +377,7 @@ editor_update_menu(struct editor *editor)
DisableItem(repo_menu, REPO_MENU_ADD_FILE_ID);
DisableItem(repo_menu, REPO_MENU_DISCARD_CHANGES_ID);
- DisableItem(repo_menu, REPO_MENU_APPLY_PATCH_ID);
+ DisableItem(repo_menu, REPO_MENU_APPLY_DIFF_ID);
DisableItem(amendment_menu, AMENDMENT_MENU_EDIT_ID);
DisableItem(amendment_menu, AMENDMENT_MENU_EXPORT_ID);
--- main.c Mon Sep 12 16:15:05 2022
+++ main.c Thu Nov 10 09:33:36 2022
@@ -265,7 +265,7 @@ menu_defaults(void)
DisableItem(repo_menu, REPO_MENU_ADD_FILE_ID);
DisableItem(repo_menu, REPO_MENU_DISCARD_CHANGES_ID);
- DisableItem(repo_menu, REPO_MENU_APPLY_PATCH_ID);
+ DisableItem(repo_menu, REPO_MENU_APPLY_DIFF_ID);
DisableItem(amendment_menu, AMENDMENT_MENU_EDIT_ID);
DisableItem(amendment_menu, AMENDMENT_MENU_EXPORT_ID);
--- repo.c Mon Sep 12 15:57:38 2022
+++ repo.c Thu Nov 10 09:26:24 2022
@@ -879,7 +879,7 @@ repo_file_changed(struct repo *repo, struct repo_file
}
void
-repo_export_patch(struct repo *repo, struct repo_amendment *amendment,
+repo_export_amendment(struct repo *repo, struct repo_amendment *amendment,
short vrefnum, Str255 filename)
{
struct bile_object *bob;
@@ -918,7 +918,7 @@ repo_export_patch(struct repo *repo, struct repo_amend
error);
xfree(&buf);
- buf = xmalloc(bob->size, "repo_export_patch");
+ buf = xmalloc(bob->size, "repo_export_amendment");
size = bile_read_object(repo->bile, bob, buf, bob->size);
error = FSWrite(frefnum, &size, buf);
if (error)
--- repo.h Wed Aug 31 16:29:35 2022
+++ repo.h Thu Nov 10 09:26:04 2022
@@ -99,8 +99,8 @@ short repo_diff_file(struct repo *repo, struct repo_fi
short repo_file_changed(struct repo *repo, struct repo_file *file);
short repo_checkout_file(struct repo *repo, struct repo_file *file,
short vrefnum, Str255 filename);
-void repo_export_patch(struct repo *repo, struct repo_amendment *amendment,
- short vrefnum, Str255 filename);
+void repo_export_amendment(struct repo *repo,
+ struct repo_amendment *amendment, short vrefnum, Str255 filename);
void repo_amend(struct repo *repo, struct diffed_file *diffed_files,
short nfiles, short adds, short subs, char *author, Handle log,
short loglen, Handle diff, unsigned long difflen);