| 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 {t} from '../i18n'; |
| 11 | import {Operation} from './Operation'; |
| 12 | |
| 13 | /** Graft (copy) a commit onto the current commit. Like Rebasing, without affecting the original commit. |
| 14 | * Useful for public commits. */ |
| 15 | export class GraftOperation extends Operation { |
| 16 | constructor(private source: SucceedableRevset | ExactRevset | OptimisticRevset) { |
| 17 | super('GraftOperation'); |
| 18 | } |
| 19 | |
| 20 | static opName = 'Graft'; |
| 21 | |
| 22 | getArgs() { |
| 23 | return ['graft', this.source]; |
| 24 | } |
| 25 | |
| 26 | private hash() { |
| 27 | return this.source.type === 'optimistic-revset' ? this.source.fake : this.source.revset; |
| 28 | } |
| 29 | |
| 30 | getInitialInlineProgress(): Array<[string, string]> { |
| 31 | // TODO: successions |
| 32 | return [[this.hash(), t('grafting...')]]; |
| 33 | } |
| 34 | |
| 35 | // TODO: Optimistic State |
| 36 | } |
| 37 | |