Dmitry Gutov [2022-08-30 18:26:41] wrote:
On 30.08.2022 18:16, Stefan Monnier wrote:
I can look into adapting this approach for other VCS if nobody beats me to
it. As long as we fundamentally agree on the behavior.
Fine by me. I'll just mention that I think we should be careful to make
sure no info is lost if Emacs crashes in the middle of the operation.
File contents' backups should remain somewhere in /tmp, *shrug*.
It might take some effort to find them, though.
We could do something like:
run-the-vcs-diff-on-the FILES >VC-pending-changes
patch -R <VC-pending-changes
...do the vc-checkin-patch...
patch <VC-pending-changes
rm VC-pending-changes
or (closer to Git's behavior):
tar -cf VC-pending-changes.tar FILES
vc-revert FILES
...do the vc-checkin-patch...
tar xf VC-pending-changes.tar
rm VC-pending-changes.tar
I think it's hard to implement this with even more safety somehow.
I'm just worried that the uncommmitted changes we need to temporarily
remove are the rare parts that contain information that's not yet
duplicated in the VCS's data, so if we only store it in an Emacs buffer
it's vulnerable to an Emacs crash (which is something that *does*
happen, especially for us poor souls who run with experimental code and
with all assertions enabled :-).