-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expect all file mode transitions to be represented by FileMode sections #93
base: main
Are you sure you want to change the base?
Conversation
c41f6e1
to
70b170e
Compare
/// The file's contents. | ||
pub contents: SelectedContents<'a>, | ||
} | ||
|
||
/// The contents of a file selected as part of the record operation. | ||
#[derive(Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] | ||
pub enum SelectedContents<'a> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be reduced to a Option<String>
at this point I feel like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose so although it means moving the binary/text handling stuff to the consumer side. You'd also need a wrapper struct if you still wanted a .push_str()
that turns it from None
to Some("...")
Oh also, could you maybe restore all those changed tests for now? Keeping this as minimal as possible for now would make it much easier to review/understand ^^ |
70b170e
to
258ee82
Compare
@30350n I've pushed a new version which removes the snapshot changes and updates the naming as you suggested. |
1df58ec
to
88a1027
Compare
@arxanas The tests were passing, but the changes were reverted in response to #93 (comment). If you'd like me to push the test changes again I'm happy to do so. |
Commit ff00611 includes the changes discussed in Discord to automatically select/deselect file mode changes and contents changes (e.g. automatically de-selecting a deletion if any of the removed lines are de-selected, since the file needs to exist to contain those lines). |
ff00611
to
e0dc9dd
Compare
e0dc9dd
to
273e88d
Compare
273e88d
to
4062a94
Compare
4062a94
to
2314d5f
Compare
Hi @jgilchrist and @30350n, thanks for working on this and sorry for the delay in reviewing. I appreciate all the thinking and coding you've done so far 🙏 Actionable itemsHere's my latest proposal based on an analysis from the perspective of interleaved deltas (see later):
In comparison to other proposals:
AnalysisThe mental models in
I think this is the non-obvious characterization of the
To categorize some existing data types as "snapshot" vs "diff":
Related ideasSome other things I'm thinking about to help clarify the design (but aren't necessarily relevant for this specific work):
Previous thoughtsBasically, I think I was wrong here: #62 (comment). The ultimate goal is that we should try to implement a snapshot-oriented model of
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking as "changes requested" to remove this from my review queue; you can request review again later.
Thanks for the detailed review @arxanas and no problem at all on the delay! I'll take a stab at your proposed changes over the next few days, I think everything is clear to me but I might pop up on Discord with a question or two as they come up! |
2314d5f
to
67c26cf
Compare
@arxanas I've taken a stab at your suggestions, and made the corresponding changes in the
This is done. I wasn't sure what to call the non-absent variant.
Done as part of the
This was already done as part of the previous changes (aside from 'unconditionally'), so I've kept the approach the same there, i.e. introducing |
51b4574
to
21e5b9b
Compare
11aab04
to
d6f8419
Compare
Self(0) | ||
} | ||
/// The default Unix permissions for files. | ||
pub const FILE_DEFAULT: FileMode = FileMode::Rwx(0o100644); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added this so that the tests that previously passed None
don't each have to dupe 100644
.
d6f8419
to
c7227b7
Compare
} | ||
} | ||
|
||
impl From<FileMode> for usize { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These didn't seem to be being used, either here, in the tests, or in jj
. Now that 0
isn't a sentinel value there isn't an infallible conversion to FileMode
anyway, so I've removed it. But if I'm missing something, I can add these back in.
let text = format!("File mode changed from {before} to {after}"); | ||
|
||
let text = match mode { | ||
// TODO: It would be nice to render this as 'file was created with mode x' but we don't have access |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arxanas Thoughts on this? It's not currently rendered this way so happy to leave this as is, but feels like this might improve the UX a bit.
c7227b7
to
0aea52a
Compare
An alternative approach to #92 for fixing various issues in
jj
.Based on a discussion from Discord where it was decided that
scm-record
should expect that any file mode transitions have aSection::FileMode
. This PR also implements UI/UX improvements inscm-record
such as auto-unselecting the file deletion mode transition if any of the deleted lines are un-selected, but that could be done as a follow-up if the approach works out.See #92 (comment) for some rationale regarding the removal of
SelectedContents::Absent
,.get_file_mode()
and the introduction ofSelectedChanges
.Note also that the internal consumers of
.get_selected_changes()
are not yet finished - for example,apply_changes
is not completely passing the tests yet. If there's agreement on the approach then I can update these too.