| b69ab31 | | | 1 | /** |
| b69ab31 | | | 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| b69ab31 | | | 3 | * |
| b69ab31 | | | 4 | * This source code is licensed under the MIT license found in the |
| b69ab31 | | | 5 | * LICENSE file in the root directory of this source tree. |
| b69ab31 | | | 6 | */ |
| b69ab31 | | | 7 | |
| b69ab31 | | | 8 | import type React from 'react'; |
| b69ab31 | | | 9 | import type {ISLCommandName} from './ISLShortcuts'; |
| b69ab31 | | | 10 | |
| b69ab31 | | | 11 | import {isMac} from 'isl-components/OperatingSystem'; |
| b69ab31 | | | 12 | import {atom} from 'jotai'; |
| b69ab31 | | | 13 | import {useCallback} from 'react'; |
| b69ab31 | | | 14 | import {commitMode} from './CommitInfoView/CommitInfoState'; |
| b69ab31 | | | 15 | import {useCommand} from './ISLShortcuts'; |
| b69ab31 | | | 16 | import {useSelectAllCommitsShortcut} from './SelectAllCommits'; |
| b69ab31 | | | 17 | import {successionTracker} from './SuccessionTracker'; |
| b69ab31 | | | 18 | import {YOU_ARE_HERE_VIRTUAL_COMMIT} from './dag/virtualCommit'; |
| b69ab31 | | | 19 | import {islDrawerState} from './drawerState'; |
| b69ab31 | | | 20 | import {findPublicBaseAncestor} from './getCommitTree'; |
| b69ab31 | | | 21 | import {t} from './i18n'; |
| b69ab31 | | | 22 | import {readAtom, useAtomHas, writeAtom} from './jotaiUtils'; |
| b69ab31 | | | 23 | import {BulkRebaseOperation} from './operations/BulkRebaseOperation'; |
| b69ab31 | | | 24 | import {HideOperation} from './operations/HideOperation'; |
| b69ab31 | | | 25 | import {RebaseOperation} from './operations/RebaseOperation'; |
| b69ab31 | | | 26 | import {operationBeingPreviewed, useRunOperation} from './operationsState'; |
| b69ab31 | | | 27 | import platform from './platform'; |
| b69ab31 | | | 28 | import {dagWithPreviews} from './previews'; |
| b69ab31 | | | 29 | import {latestDag} from './serverAPIState'; |
| b69ab31 | | | 30 | import {latestSuccessorUnlessExplicitlyObsolete} from './successionUtils'; |
| b69ab31 | | | 31 | import {exactRevset, type CommitInfo, type Hash} from './types'; |
| b69ab31 | | | 32 | import {firstOfIterable, registerCleanup} from './utils'; |
| b69ab31 | | | 33 | |
| b69ab31 | | | 34 | /** |
| b69ab31 | | | 35 | * The name of the key to toggle individual selection. |
| b69ab31 | | | 36 | * On Windows / Linux, it is Ctrl. On Mac, it is Command. |
| b69ab31 | | | 37 | */ |
| b69ab31 | | | 38 | export const individualToggleKey: 'metaKey' | 'ctrlKey' = isMac ? 'metaKey' : 'ctrlKey'; |
| b69ab31 | | | 39 | |
| b69ab31 | | | 40 | /** |
| b69ab31 | | | 41 | * See {@link selectedCommitInfos} |
| b69ab31 | | | 42 | * Note: it is possible to be selecting a commit that stops being rendered, and thus has no associated commit info. |
| b69ab31 | | | 43 | * Prefer to use `selectedCommitInfos` to get the subset of the selection that is visible. |
| b69ab31 | | | 44 | */ |
| b69ab31 | | | 45 | export const selectedCommits = atom(new Set<Hash>()); |
| b69ab31 | | | 46 | |
| b69ab31 | | | 47 | /** |
| b69ab31 | | | 48 | * Commit that is currently being actioned on (i.e., from the context menu). |
| b69ab31 | | | 49 | * This is a temporary visual state separate from selection. |
| b69ab31 | | | 50 | */ |
| b69ab31 | | | 51 | export const actioningCommit = atom<Hash | null>(null); |
| b69ab31 | | | 52 | registerCleanup( |
| b69ab31 | | | 53 | selectedCommits, |
| b69ab31 | | | 54 | successionTracker.onSuccessions(successions => { |
| b69ab31 | | | 55 | let value = readAtom(selectedCommits); |
| b69ab31 | | | 56 | let changed = false; |
| b69ab31 | | | 57 | |
| b69ab31 | | | 58 | for (const [oldHash, newHash] of successions) { |
| b69ab31 | | | 59 | if (value?.has(oldHash)) { |
| b69ab31 | | | 60 | if (!changed) { |
| b69ab31 | | | 61 | changed = true; |
| b69ab31 | | | 62 | value = new Set(value); |
| b69ab31 | | | 63 | } |
| b69ab31 | | | 64 | value.delete(oldHash); |
| b69ab31 | | | 65 | value.add(newHash); |
| b69ab31 | | | 66 | } |
| b69ab31 | | | 67 | } |
| b69ab31 | | | 68 | if (changed) { |
| b69ab31 | | | 69 | writeAtom(selectedCommits, value); |
| b69ab31 | | | 70 | } |
| b69ab31 | | | 71 | }), |
| b69ab31 | | | 72 | import.meta.hot, |
| b69ab31 | | | 73 | ); |
| b69ab31 | | | 74 | |
| b69ab31 | | | 75 | const previouslySelectedCommit = atom<undefined | string>(undefined); |
| b69ab31 | | | 76 | |
| b69ab31 | | | 77 | /** |
| b69ab31 | | | 78 | * Clicking on commits will select them in the UI. |
| b69ab31 | | | 79 | * Selected commits can be acted on in bulk, and appear in the commit info sidebar for editing / details. |
| b69ab31 | | | 80 | * Invariant: Selected commits are non-public. |
| b69ab31 | | | 81 | * |
| b69ab31 | | | 82 | * See {@link selectedCommits} for setting underlying storage |
| b69ab31 | | | 83 | */ |
| b69ab31 | | | 84 | export const selectedCommitInfos = atom(get => { |
| b69ab31 | | | 85 | const selected = get(selectedCommits); |
| b69ab31 | | | 86 | const dag = get(dagWithPreviews); |
| b69ab31 | | | 87 | return [...selected].flatMap(h => { |
| b69ab31 | | | 88 | const info = dag.get(h); |
| b69ab31 | | | 89 | return info === undefined ? [] : [info]; |
| b69ab31 | | | 90 | }); |
| b69ab31 | | | 91 | }); |
| b69ab31 | | | 92 | |
| b69ab31 | | | 93 | export function useCommitSelection(hash: string): { |
| b69ab31 | | | 94 | isSelected: boolean; |
| b69ab31 | | | 95 | onClickToSelect: ( |
| b69ab31 | | | 96 | _e: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>, |
| b69ab31 | | | 97 | ) => unknown; |
| b69ab31 | | | 98 | overrideSelection: (newSelected: Array<Hash>) => void; |
| b69ab31 | | | 99 | } { |
| b69ab31 | | | 100 | const isSelected = useAtomHas(selectedCommits, hash); |
| b69ab31 | | | 101 | const onClickToSelect = useCallback( |
| b69ab31 | | | 102 | (e: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => { |
| b69ab31 | | | 103 | // previews won't change a commit from draft -> public, so we don't need |
| b69ab31 | | | 104 | // to use previews here |
| b69ab31 | | | 105 | const dag = readAtom(latestDag); |
| ab83ad3 | | | 106 | if (hash === YOU_ARE_HERE_VIRTUAL_COMMIT.hash) { |
| ab83ad3 | | | 107 | // don't bother selecting virtual commits |
| b69ab31 | | | 108 | return; |
| b69ab31 | | | 109 | } |
| b69ab31 | | | 110 | writeAtom(selectedCommits, last => { |
| b69ab31 | | | 111 | if (e.shiftKey) { |
| b69ab31 | | | 112 | const previouslySelected = readAtom(previouslySelectedCommit); |
| b69ab31 | | | 113 | if (previouslySelected != null) { |
| b69ab31 | | | 114 | let slice: Array<Hash> | null = null; |
| b69ab31 | | | 115 | const dag = readAtom(dagWithPreviews); |
| b69ab31 | | | 116 | // Prefer dag range for shift selection. |
| b69ab31 | | | 117 | const range = dag |
| b69ab31 | | | 118 | .range(hash, previouslySelected) |
| b69ab31 | | | 119 | .union(dag.range(previouslySelected, hash)); |
| b69ab31 | | | 120 | if (range.size > 0) { |
| b69ab31 | | | 121 | slice = range.toArray(); |
| b69ab31 | | | 122 | } else { |
| b69ab31 | | | 123 | // Fall back to displayed (flatten) range. |
| b69ab31 | | | 124 | const [sortIndex, sorted] = dag.defaultSortAscIndex(); |
| b69ab31 | | | 125 | const prevIdx = sortIndex.get(previouslySelected); |
| b69ab31 | | | 126 | const nextIdx = sortIndex.get(hash); |
| b69ab31 | | | 127 | if (prevIdx != null && nextIdx != null) { |
| b69ab31 | | | 128 | const [fromIdx, toIdx] = |
| b69ab31 | | | 129 | prevIdx > nextIdx ? [nextIdx, prevIdx] : [prevIdx, nextIdx]; |
| b69ab31 | | | 130 | slice = sorted.slice(fromIdx, toIdx + 1); |
| b69ab31 | | | 131 | } |
| b69ab31 | | | 132 | } |
| b69ab31 | | | 133 | if (slice != null) { |
| ab83ad3 | | | 134 | return new Set([...last, ...slice]); |
| b69ab31 | | | 135 | } |
| b69ab31 | | | 136 | } |
| b69ab31 | | | 137 | // Holding shift, but we don't have a previous selected commit. |
| b69ab31 | | | 138 | // Fall through to treat it like a normal click. |
| b69ab31 | | | 139 | } |
| b69ab31 | | | 140 | |
| b69ab31 | | | 141 | const individualToggle = e[individualToggleKey]; |
| b69ab31 | | | 142 | |
| b69ab31 | | | 143 | const selected = new Set(last); |
| b69ab31 | | | 144 | if (selected.has(hash)) { |
| b69ab31 | | | 145 | // multiple selected, then click an existing selected: |
| b69ab31 | | | 146 | // if cmd, unselect just that one commit |
| b69ab31 | | | 147 | // if not cmd, reset selection to just that one commit |
| b69ab31 | | | 148 | // only one selected, then click on it |
| b69ab31 | | | 149 | // if cmd, unselect it |
| b69ab31 | | | 150 | // it not cmd, unselect it |
| b69ab31 | | | 151 | if (!individualToggle && selected.size > 1) { |
| b69ab31 | | | 152 | // only select this commit |
| b69ab31 | | | 153 | selected.clear(); |
| b69ab31 | | | 154 | selected.add(hash); |
| b69ab31 | | | 155 | } else { |
| b69ab31 | | | 156 | // unselect |
| b69ab31 | | | 157 | selected.delete(hash); |
| b69ab31 | | | 158 | writeAtom(previouslySelectedCommit, undefined); |
| b69ab31 | | | 159 | } |
| b69ab31 | | | 160 | } else { |
| b69ab31 | | | 161 | if (!individualToggle) { |
| b69ab31 | | | 162 | // clear if not holding cmd key |
| b69ab31 | | | 163 | selected.clear(); |
| b69ab31 | | | 164 | } |
| b69ab31 | | | 165 | selected.add(hash); |
| b69ab31 | | | 166 | } |
| b69ab31 | | | 167 | return selected; |
| b69ab31 | | | 168 | }); |
| b69ab31 | | | 169 | writeAtom(previouslySelectedCommit, hash); |
| b69ab31 | | | 170 | }, |
| b69ab31 | | | 171 | [hash], |
| b69ab31 | | | 172 | ); |
| b69ab31 | | | 173 | |
| b69ab31 | | | 174 | const overrideSelection = useCallback( |
| b69ab31 | | | 175 | (newSelected: Array<Hash>) => { |
| b69ab31 | | | 176 | // previews won't change a commit from draft -> public, so we don't need |
| b69ab31 | | | 177 | // to use previews here |
| b69ab31 | | | 178 | const dag = readAtom(latestDag); |
| ab83ad3 | | | 179 | writeAtom(selectedCommits, new Set(newSelected)); |
| b69ab31 | | | 180 | }, |
| b69ab31 | | | 181 | [hash], |
| b69ab31 | | | 182 | ); |
| b69ab31 | | | 183 | |
| b69ab31 | | | 184 | return {isSelected, onClickToSelect, overrideSelection}; |
| b69ab31 | | | 185 | } |
| b69ab31 | | | 186 | |
| b69ab31 | | | 187 | /** A richer version of `useCommitSelection`, provides extra handlers like `onDoubleClickToShowDrawer`. */ |
| b69ab31 | | | 188 | export function useCommitCallbacks(commit: CommitInfo): { |
| b69ab31 | | | 189 | isSelected: boolean; |
| b69ab31 | | | 190 | onClickToSelect: ( |
| b69ab31 | | | 191 | _e: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>, |
| b69ab31 | | | 192 | ) => unknown; |
| b69ab31 | | | 193 | onDoubleClickToShowDrawer: () => void; |
| b69ab31 | | | 194 | } { |
| b69ab31 | | | 195 | const {isSelected, onClickToSelect, overrideSelection} = useCommitSelection(commit.hash); |
| b69ab31 | | | 196 | const onDoubleClickToShowDrawer = useCallback(() => { |
| b69ab31 | | | 197 | // Select the commit if it was deselected. |
| b69ab31 | | | 198 | if (!isSelected) { |
| b69ab31 | | | 199 | if (commit.hash === YOU_ARE_HERE_VIRTUAL_COMMIT.hash) { |
| b69ab31 | | | 200 | // don't select virtual commit, replace selection instead |
| b69ab31 | | | 201 | overrideSelection([]); |
| b69ab31 | | | 202 | } else { |
| b69ab31 | | | 203 | overrideSelection([commit.hash]); |
| b69ab31 | | | 204 | } |
| b69ab31 | | | 205 | } |
| b69ab31 | | | 206 | // Show the drawer. |
| b69ab31 | | | 207 | writeAtom(islDrawerState, state => ({ |
| b69ab31 | | | 208 | ...state, |
| b69ab31 | | | 209 | right: { |
| b69ab31 | | | 210 | ...state.right, |
| b69ab31 | | | 211 | collapsed: false, |
| b69ab31 | | | 212 | }, |
| b69ab31 | | | 213 | })); |
| b69ab31 | | | 214 | if (commit.isDot) { |
| b69ab31 | | | 215 | // if we happened to be in commit mode, swap to amend mode so you see the details instead |
| b69ab31 | | | 216 | writeAtom(commitMode, 'amend'); |
| b69ab31 | | | 217 | } |
| b69ab31 | | | 218 | }, [overrideSelection, isSelected, commit.hash, commit.isDot]); |
| b69ab31 | | | 219 | return {isSelected, onClickToSelect, onDoubleClickToShowDrawer}; |
| b69ab31 | | | 220 | } |
| b69ab31 | | | 221 | |
| b69ab31 | | | 222 | export function useArrowKeysToChangeSelection() { |
| b69ab31 | | | 223 | const cb = useCallback((which: ISLCommandName) => { |
| b69ab31 | | | 224 | if (which === 'OpenDetails') { |
| b69ab31 | | | 225 | writeAtom(islDrawerState, previous => ({ |
| b69ab31 | | | 226 | ...previous, |
| b69ab31 | | | 227 | right: { |
| b69ab31 | | | 228 | ...previous.right, |
| b69ab31 | | | 229 | collapsed: false, |
| b69ab31 | | | 230 | }, |
| b69ab31 | | | 231 | })); |
| b69ab31 | | | 232 | } |
| b69ab31 | | | 233 | |
| b69ab31 | | | 234 | const dag = readAtom(dagWithPreviews); |
| b69ab31 | | | 235 | const [sortIndex, sorted] = dag.defaultSortAscIndex(); |
| b69ab31 | | | 236 | |
| b69ab31 | | | 237 | if (sorted.length === 0) { |
| b69ab31 | | | 238 | return; |
| b69ab31 | | | 239 | } |
| b69ab31 | | | 240 | |
| b69ab31 | | | 241 | const lastSelected = readAtom(previouslySelectedCommit); |
| b69ab31 | | | 242 | const lastIndex = lastSelected == null ? undefined : sortIndex.get(lastSelected); |
| b69ab31 | | | 243 | |
| b69ab31 | | | 244 | const nextSelectableHash = (step = 1 /* 1: up; -1: down */, start = lastIndex ?? 0) => { |
| b69ab31 | | | 245 | let index = start; |
| b69ab31 | | | 246 | while (index > 0) { |
| b69ab31 | | | 247 | index += step; |
| b69ab31 | | | 248 | const hash = sorted.at(index); |
| b69ab31 | | | 249 | if (hash == null) { |
| b69ab31 | | | 250 | return undefined; |
| b69ab31 | | | 251 | } |
| ab83ad3 | | | 252 | return hash; |
| b69ab31 | | | 253 | } |
| b69ab31 | | | 254 | }; |
| b69ab31 | | | 255 | |
| b69ab31 | | | 256 | const existingSelection = readAtom(selectedCommits); |
| b69ab31 | | | 257 | if (existingSelection.size === 0) { |
| b69ab31 | | | 258 | if (which === 'SelectDownwards' || which === 'ContinueSelectionDownwards') { |
| b69ab31 | | | 259 | const top = nextSelectableHash(-1, sorted.length); |
| b69ab31 | | | 260 | if (top != null) { |
| b69ab31 | | | 261 | writeAtom(selectedCommits, new Set([top])); |
| b69ab31 | | | 262 | writeAtom(previouslySelectedCommit, top); |
| b69ab31 | | | 263 | } |
| b69ab31 | | | 264 | } |
| b69ab31 | | | 265 | return; |
| b69ab31 | | | 266 | } |
| b69ab31 | | | 267 | |
| b69ab31 | | | 268 | if (lastSelected == null || lastIndex == null) { |
| b69ab31 | | | 269 | return; |
| b69ab31 | | | 270 | } |
| b69ab31 | | | 271 | |
| b69ab31 | | | 272 | let newSelected: Hash | undefined; |
| b69ab31 | | | 273 | let extendSelection = false; |
| b69ab31 | | | 274 | |
| b69ab31 | | | 275 | switch (which) { |
| b69ab31 | | | 276 | case 'SelectUpwards': { |
| b69ab31 | | | 277 | newSelected = nextSelectableHash(1); |
| b69ab31 | | | 278 | break; |
| b69ab31 | | | 279 | } |
| b69ab31 | | | 280 | case 'SelectDownwards': { |
| b69ab31 | | | 281 | newSelected = nextSelectableHash(-1); |
| b69ab31 | | | 282 | break; |
| b69ab31 | | | 283 | } |
| b69ab31 | | | 284 | case 'ContinueSelectionUpwards': { |
| b69ab31 | | | 285 | newSelected = nextSelectableHash(1); |
| b69ab31 | | | 286 | extendSelection = true; |
| b69ab31 | | | 287 | break; |
| b69ab31 | | | 288 | } |
| b69ab31 | | | 289 | case 'ContinueSelectionDownwards': { |
| b69ab31 | | | 290 | newSelected = nextSelectableHash(-1); |
| b69ab31 | | | 291 | extendSelection = true; |
| b69ab31 | | | 292 | break; |
| b69ab31 | | | 293 | } |
| b69ab31 | | | 294 | } |
| b69ab31 | | | 295 | |
| b69ab31 | | | 296 | if (newSelected != null) { |
| b69ab31 | | | 297 | const newHash = newSelected; |
| b69ab31 | | | 298 | writeAtom(selectedCommits, last => |
| b69ab31 | | | 299 | extendSelection ? new Set([...last, newHash]) : new Set([newHash]), |
| b69ab31 | | | 300 | ); |
| b69ab31 | | | 301 | writeAtom(previouslySelectedCommit, newHash); |
| b69ab31 | | | 302 | } |
| b69ab31 | | | 303 | }, []); |
| b69ab31 | | | 304 | |
| b69ab31 | | | 305 | useCommand('OpenDetails', () => cb('OpenDetails')); |
| b69ab31 | | | 306 | useCommand('SelectUpwards', () => cb('SelectUpwards')); |
| b69ab31 | | | 307 | useCommand('SelectDownwards', () => cb('SelectDownwards')); |
| b69ab31 | | | 308 | useCommand('ContinueSelectionUpwards', () => cb('ContinueSelectionUpwards')); |
| b69ab31 | | | 309 | useCommand('ContinueSelectionDownwards', () => cb('ContinueSelectionDownwards')); |
| b69ab31 | | | 310 | useSelectAllCommitsShortcut(); |
| b69ab31 | | | 311 | } |
| b69ab31 | | | 312 | |
| b69ab31 | | | 313 | export function useBackspaceToHideSelected(): void { |
| b69ab31 | | | 314 | const cb = useCallback(() => { |
| b69ab31 | | | 315 | // Though you can select multiple commits, our preview system doesn't handle that very well. |
| b69ab31 | | | 316 | // Just preview hiding the most recently selected commit. |
| b69ab31 | | | 317 | // Another sensible behavior would be to inspect the tree of commits selected |
| b69ab31 | | | 318 | // and find if there's a single common ancestor to hide. That won't work in all cases though. |
| b69ab31 | | | 319 | const mostRecent = readAtom(previouslySelectedCommit); |
| b69ab31 | | | 320 | let hashToHide = mostRecent; |
| b69ab31 | | | 321 | if (hashToHide == null) { |
| b69ab31 | | | 322 | const selection = readAtom(selectedCommits); |
| b69ab31 | | | 323 | if (selection != null) { |
| b69ab31 | | | 324 | hashToHide = firstOfIterable(selection.values()); |
| b69ab31 | | | 325 | } |
| b69ab31 | | | 326 | } |
| b69ab31 | | | 327 | if (hashToHide == null) { |
| b69ab31 | | | 328 | return; |
| b69ab31 | | | 329 | } |
| b69ab31 | | | 330 | |
| b69ab31 | | | 331 | const commitToHide = readAtom(latestDag).get(hashToHide); |
| b69ab31 | | | 332 | if (commitToHide == null) { |
| b69ab31 | | | 333 | return; |
| b69ab31 | | | 334 | } |
| b69ab31 | | | 335 | |
| b69ab31 | | | 336 | writeAtom( |
| b69ab31 | | | 337 | operationBeingPreviewed, |
| b69ab31 | | | 338 | new HideOperation(latestSuccessorUnlessExplicitlyObsolete(commitToHide)), |
| b69ab31 | | | 339 | ); |
| b69ab31 | | | 340 | }, []); |
| b69ab31 | | | 341 | |
| b69ab31 | | | 342 | useCommand('HideSelectedCommits', cb); |
| b69ab31 | | | 343 | } |
| b69ab31 | | | 344 | |
| b69ab31 | | | 345 | export function useShortcutToRebaseSelected(): void { |
| b69ab31 | | | 346 | const runOperation = useRunOperation(); |
| b69ab31 | | | 347 | |
| b69ab31 | | | 348 | const cb = useCallback(async () => { |
| b69ab31 | | | 349 | const dag = readAtom(dagWithPreviews); |
| b69ab31 | | | 350 | const baseCommit = findPublicBaseAncestor(dag); |
| b69ab31 | | | 351 | if (!baseCommit) { |
| b69ab31 | | | 352 | return; |
| b69ab31 | | | 353 | } |
| b69ab31 | | | 354 | const baseCommitRevset = exactRevset(baseCommit.hash); |
| b69ab31 | | | 355 | |
| b69ab31 | | | 356 | const selectedCommits = readAtom(selectedCommitInfos); |
| b69ab31 | | | 357 | const selectedRevsets = selectedCommits |
| b69ab31 | | | 358 | .filter(commitInfo => findPublicBaseAncestor(dag, commitInfo.hash)?.hash !== baseCommit.hash) |
| b69ab31 | | | 359 | .map(latestSuccessorUnlessExplicitlyObsolete); |
| b69ab31 | | | 360 | |
| b69ab31 | | | 361 | if (selectedRevsets.length === 0) { |
| b69ab31 | | | 362 | return; |
| b69ab31 | | | 363 | } else if (selectedRevsets.length === 1) { |
| b69ab31 | | | 364 | writeAtom( |
| b69ab31 | | | 365 | operationBeingPreviewed, |
| b69ab31 | | | 366 | () => new RebaseOperation(selectedRevsets[0], baseCommitRevset), |
| b69ab31 | | | 367 | ); |
| b69ab31 | | | 368 | } else { |
| b69ab31 | | | 369 | if ( |
| b69ab31 | | | 370 | await platform.confirm( |
| b69ab31 | | | 371 | t('Are you sure you want to rebase $count commits?', {count: selectedRevsets.length}), |
| b69ab31 | | | 372 | ) |
| b69ab31 | | | 373 | ) { |
| b69ab31 | | | 374 | runOperation(new BulkRebaseOperation(selectedRevsets, baseCommitRevset)); |
| b69ab31 | | | 375 | } |
| b69ab31 | | | 376 | } |
| b69ab31 | | | 377 | }, [runOperation]); |
| b69ab31 | | | 378 | useCommand('RebaseOntoCurrentStackBase', cb); |
| b69ab31 | | | 379 | } |