| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | */ |
| 7 | |
| 8 | import type {ExactRevset, OptimisticRevset, SucceedableRevset} from '../types'; |
| 9 | |
| 10 | import {Operation} from './Operation'; |
| 11 | |
| 12 | /** Like rebase, but leave the source in place, and don't rebase children. |
| 13 | * Behaves more like "Graft" than rebase, but without going to the result. Useful for copying public commits. |
| 14 | * Note: does not use the latest successor by default, rather the exact source revset. */ |
| 15 | export class RebaseKeepOperation extends Operation { |
| 16 | constructor( |
| 17 | protected source: SucceedableRevset | ExactRevset | OptimisticRevset, |
| 18 | protected destination: SucceedableRevset | ExactRevset | OptimisticRevset, |
| 19 | ) { |
| 20 | super('RebaseKeepOperation'); |
| 21 | } |
| 22 | |
| 23 | static opName = 'Rebase (keep)'; |
| 24 | |
| 25 | getArgs() { |
| 26 | return ['rebase', '--keep', '--rev', this.source, '--dest', this.destination]; |
| 27 | } |
| 28 | |
| 29 | // TODO: Support optimistic state. Presently not an issue because its use case in "Download Commits" |
| 30 | // doesn't support optimistic state anyway. |
| 31 | } |
| 32 | |