| 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 {Author, DateTuple, Hash, RepoPath} from './common'; |
| b69ab31 | | | 9 | |
| b69ab31 | | | 10 | /* Types for the `debugimportstack` and `debugoutputstack` commands. */ |
| b69ab31 | | | 11 | |
| b69ab31 | | | 12 | /** |
| b69ab31 | | | 13 | * Placeholder commit hash to identify "to be created" commits. |
| b69ab31 | | | 14 | * Starts with ":". Can be referred by "parents" of other commits. |
| b69ab31 | | | 15 | */ |
| b69ab31 | | | 16 | export type Mark = string; |
| b69ab31 | | | 17 | |
| b69ab31 | | | 18 | /** Matches output of debugexportstack. See debugstack.py. */ |
| b69ab31 | | | 19 | export type ExportStack = ExportCommit[]; |
| b69ab31 | | | 20 | |
| b69ab31 | | | 21 | export type ExportCommit = { |
| b69ab31 | | | 22 | /** `true` for commits explicitly requested via debugstack command. */ |
| b69ab31 | | | 23 | requested: boolean; |
| b69ab31 | | | 24 | /** Commit hash. `ffffffffffffffffffffffffffffffffffffffff` (`node.wdirhex`) means the working copy. */ |
| b69ab31 | | | 25 | node: Hash; |
| b69ab31 | | | 26 | author: Author; |
| b69ab31 | | | 27 | date: DateTuple; |
| b69ab31 | | | 28 | /* Commit message. */ |
| b69ab31 | | | 29 | text: string; |
| b69ab31 | | | 30 | /** `true` for public commits. */ |
| b69ab31 | | | 31 | immutable: boolean; |
| b69ab31 | | | 32 | parents?: Hash[]; |
| b69ab31 | | | 33 | /** Files changed by this commit. `null` means the file is deleted. */ |
| b69ab31 | | | 34 | files?: {[path: RepoPath]: ExportFile | null}; |
| b69ab31 | | | 35 | relevantFiles?: {[path: RepoPath]: ExportFile | null}; |
| b69ab31 | | | 36 | }; |
| b69ab31 | | | 37 | |
| b69ab31 | | | 38 | export type ExportFile = { |
| b69ab31 | | | 39 | /** UTF-8 content. */ |
| b69ab31 | | | 40 | data?: string; |
| b69ab31 | | | 41 | /** Binary content encoded in base85. */ |
| b69ab31 | | | 42 | dataBase85?: string; |
| b69ab31 | | | 43 | /** Reference to other files. */ |
| b69ab31 | | | 44 | dataRef?: {node: Hash; path: RepoPath}; |
| b69ab31 | | | 45 | /** If present, this file is copied (or renamed) from another file. */ |
| b69ab31 | | | 46 | copyFrom?: RepoPath; |
| b69ab31 | | | 47 | /** 'x': executable. 'l': symlink. 'm': submodule. */ |
| b69ab31 | | | 48 | flags?: FileFlag; |
| b69ab31 | | | 49 | }; |
| b69ab31 | | | 50 | |
| b69ab31 | | | 51 | /** Matches input of debugimportstack. See debugstack.py. */ |
| b69ab31 | | | 52 | export type ImportStack = ImportAction[]; |
| b69ab31 | | | 53 | |
| b69ab31 | | | 54 | /** |
| b69ab31 | | | 55 | * - 'x': executable. |
| b69ab31 | | | 56 | * - 'l': symlink. |
| b69ab31 | | | 57 | * - 'm': submodule. |
| b69ab31 | | | 58 | * - 'a': absent (deleted), only used in ISL, not by debugimportstack. |
| b69ab31 | | | 59 | * - '.': unchanged, only used by debugimportstack. |
| b69ab31 | | | 60 | */ |
| b69ab31 | | | 61 | export type FileFlag = '' | 'x' | 'l' | 'm' | 'a' | '.'; |
| b69ab31 | | | 62 | |
| b69ab31 | | | 63 | export type ImportAction = |
| b69ab31 | | | 64 | | ['commit', ImportCommit] |
| b69ab31 | | | 65 | | ['amend', ImportAmendCommit] |
| b69ab31 | | | 66 | | ['goto', ImportGoto] |
| b69ab31 | | | 67 | | ['reset', ImportReset] |
| b69ab31 | | | 68 | | ['hide', ImportHide] |
| b69ab31 | | | 69 | | ['write', {[path: RepoPath]: ExportFile | '.' | null}]; |
| b69ab31 | | | 70 | |
| b69ab31 | | | 71 | export type ImportCommit = { |
| b69ab31 | | | 72 | /** Placeholder commit hash. Must start with ":". */ |
| b69ab31 | | | 73 | mark: Mark; |
| b69ab31 | | | 74 | author?: Author; |
| b69ab31 | | | 75 | date?: DateTuple; |
| b69ab31 | | | 76 | /** Commit message. */ |
| b69ab31 | | | 77 | text: string; |
| b69ab31 | | | 78 | parents: (Hash | Mark)[]; |
| b69ab31 | | | 79 | predecessors?: (Hash | Mark)[]; |
| b69ab31 | | | 80 | /** Why predecessors are obsoleted? For example, 'amend', 'split', 'histedit'. */ |
| b69ab31 | | | 81 | operation?: string; |
| b69ab31 | | | 82 | files: {[path: RepoPath]: ExportFile | '.' | null}; |
| b69ab31 | | | 83 | }; |
| b69ab31 | | | 84 | |
| b69ab31 | | | 85 | /** Amend a commit. Similar to `ImportCommit` but many fields are optional. */ |
| b69ab31 | | | 86 | export type ImportAmendCommit = { |
| b69ab31 | | | 87 | /** Commit to amend. */ |
| b69ab31 | | | 88 | node: Hash; |
| b69ab31 | | | 89 | /** Placeholder commit hash. Must start with ":". */ |
| b69ab31 | | | 90 | mark: Mark; |
| b69ab31 | | | 91 | author?: Author; |
| b69ab31 | | | 92 | date?: DateTuple; |
| b69ab31 | | | 93 | /** Commit message. */ |
| b69ab31 | | | 94 | text?: string; |
| b69ab31 | | | 95 | parents?: (Hash | Mark)[]; |
| b69ab31 | | | 96 | predecessors?: (Hash | Mark)[]; |
| b69ab31 | | | 97 | /** Why predecessors are obsoleted? For example, 'amend', 'split', 'histedit'. */ |
| b69ab31 | | | 98 | operation?: string; |
| b69ab31 | | | 99 | files?: {[path: RepoPath]: ExportFile | '.' | null}; |
| b69ab31 | | | 100 | }; |
| b69ab31 | | | 101 | |
| b69ab31 | | | 102 | /** Update the "current commit" without changing the working copy. */ |
| b69ab31 | | | 103 | export type ImportReset = {mark: Mark}; |
| b69ab31 | | | 104 | |
| b69ab31 | | | 105 | /** Checkout the given commit. */ |
| b69ab31 | | | 106 | export type ImportGoto = {mark: Mark}; |
| b69ab31 | | | 107 | |
| b69ab31 | | | 108 | /** Hide commits if they do not have visible descendants. */ |
| b69ab31 | | | 109 | export type ImportHide = {nodes: Hash[]}; |
| b69ab31 | | | 110 | |
| b69ab31 | | | 111 | /** Matches output of debugimportstack. See debugstack.py. */ |
| b69ab31 | | | 112 | export type ImportedStack = ImportedCommit[]; |
| b69ab31 | | | 113 | |
| b69ab31 | | | 114 | /** The given `mark` has a known commit hash `node`. */ |
| b69ab31 | | | 115 | export type ImportedCommit = {node: Hash; mark: Mark}; |