-
Notifications
You must be signed in to change notification settings - Fork 372
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
bookmark: Make bookmark {create, set, move}
unhide hidden commits
#5050
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,9 @@ pub fn cmd_bookmark_create( | |
let mut workspace_command = command.workspace_helper(ui)?; | ||
let target_commit = workspace_command | ||
.resolve_single_rev(ui, args.revision.as_ref().unwrap_or(&RevisionArg::AT))?; | ||
let repo = workspace_command.repo(); | ||
let view = workspace_command.repo().view(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: use |
||
let is_hidden = target_commit.is_hidden(repo.as_ref())?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, the repo seems like a better level to do it. I've updated my branch. I should also add tests for it in jj-lib. Or do you want to take my commit and add tests, @PhilipMetzger? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree, but it was the simplest way to implement it.
I in general agree with the direction we take here, so I probably should take over Martin's branch and drop the first commit, if it otherwise doesn't provide value. |
||
let bookmark_names = &args.names; | ||
for name in bookmark_names { | ||
if view.get_local_bookmark(name).is_present() { | ||
|
@@ -94,6 +96,11 @@ pub fn cmd_bookmark_create( | |
writeln!(ui.hint_default(), "Use -r to specify the target revision.")?; | ||
} | ||
|
||
// The commit was hidden, so make it visible again. | ||
if is_hidden { | ||
tx.repo_mut().add_head(&target_commit)?; | ||
} | ||
|
||
tx.finish( | ||
ui, | ||
format!( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -774,8 +774,8 @@ fn builtin_commit_methods<'repo>() -> CommitTemplateBuildMethodFnMap<'repo, Comm | |
function.expect_no_arguments()?; | ||
let repo = language.repo; | ||
let out_property = self_property.map(|commit| { | ||
let maybe_entries = repo.resolve_change_id(commit.change_id()); | ||
maybe_entries.map_or(true, |entries| !entries.contains(commit.id())) | ||
let value = commit.is_hidden(repo); | ||
value.unwrap_or_default() | ||
Comment on lines
+777
to
+778
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: inline |
||
}); | ||
Ok(L::wrap_boolean(out_property)) | ||
}, | ||
|
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 find "predecessor" a bit confusing the unhidden commit doesn't need to be a predecessor of the current commit, or a predecessor of any commit at all for that matter (maybe it was just abandoned).