addons/shared/types/stack.tsblame
View source
b69ab311/**
b69ab312 * Copyright (c) Meta Platforms, Inc. and affiliates.
b69ab313 *
b69ab314 * This source code is licensed under the MIT license found in the
b69ab315 * LICENSE file in the root directory of this source tree.
b69ab316 */
b69ab317
b69ab318import type {Author, DateTuple, Hash, RepoPath} from './common';
b69ab319
b69ab3110/* Types for the `debugimportstack` and `debugoutputstack` commands. */
b69ab3111
b69ab3112/**
b69ab3113 * Placeholder commit hash to identify "to be created" commits.
b69ab3114 * Starts with ":". Can be referred by "parents" of other commits.
b69ab3115 */
b69ab3116export type Mark = string;
b69ab3117
b69ab3118/** Matches output of debugexportstack. See debugstack.py. */
b69ab3119export type ExportStack = ExportCommit[];
b69ab3120
b69ab3121export type ExportCommit = {
b69ab3122 /** `true` for commits explicitly requested via debugstack command. */
b69ab3123 requested: boolean;
b69ab3124 /** Commit hash. `ffffffffffffffffffffffffffffffffffffffff` (`node.wdirhex`) means the working copy. */
b69ab3125 node: Hash;
b69ab3126 author: Author;
b69ab3127 date: DateTuple;
b69ab3128 /* Commit message. */
b69ab3129 text: string;
b69ab3130 /** `true` for public commits. */
b69ab3131 immutable: boolean;
b69ab3132 parents?: Hash[];
b69ab3133 /** Files changed by this commit. `null` means the file is deleted. */
b69ab3134 files?: {[path: RepoPath]: ExportFile | null};
b69ab3135 relevantFiles?: {[path: RepoPath]: ExportFile | null};
b69ab3136};
b69ab3137
b69ab3138export type ExportFile = {
b69ab3139 /** UTF-8 content. */
b69ab3140 data?: string;
b69ab3141 /** Binary content encoded in base85. */
b69ab3142 dataBase85?: string;
b69ab3143 /** Reference to other files. */
b69ab3144 dataRef?: {node: Hash; path: RepoPath};
b69ab3145 /** If present, this file is copied (or renamed) from another file. */
b69ab3146 copyFrom?: RepoPath;
b69ab3147 /** 'x': executable. 'l': symlink. 'm': submodule. */
b69ab3148 flags?: FileFlag;
b69ab3149};
b69ab3150
b69ab3151/** Matches input of debugimportstack. See debugstack.py. */
b69ab3152export type ImportStack = ImportAction[];
b69ab3153
b69ab3154/**
b69ab3155 * - 'x': executable.
b69ab3156 * - 'l': symlink.
b69ab3157 * - 'm': submodule.
b69ab3158 * - 'a': absent (deleted), only used in ISL, not by debugimportstack.
b69ab3159 * - '.': unchanged, only used by debugimportstack.
b69ab3160 */
b69ab3161export type FileFlag = '' | 'x' | 'l' | 'm' | 'a' | '.';
b69ab3162
b69ab3163export type ImportAction =
b69ab3164 | ['commit', ImportCommit]
b69ab3165 | ['amend', ImportAmendCommit]
b69ab3166 | ['goto', ImportGoto]
b69ab3167 | ['reset', ImportReset]
b69ab3168 | ['hide', ImportHide]
b69ab3169 | ['write', {[path: RepoPath]: ExportFile | '.' | null}];
b69ab3170
b69ab3171export type ImportCommit = {
b69ab3172 /** Placeholder commit hash. Must start with ":". */
b69ab3173 mark: Mark;
b69ab3174 author?: Author;
b69ab3175 date?: DateTuple;
b69ab3176 /** Commit message. */
b69ab3177 text: string;
b69ab3178 parents: (Hash | Mark)[];
b69ab3179 predecessors?: (Hash | Mark)[];
b69ab3180 /** Why predecessors are obsoleted? For example, 'amend', 'split', 'histedit'. */
b69ab3181 operation?: string;
b69ab3182 files: {[path: RepoPath]: ExportFile | '.' | null};
b69ab3183};
b69ab3184
b69ab3185/** Amend a commit. Similar to `ImportCommit` but many fields are optional. */
b69ab3186export type ImportAmendCommit = {
b69ab3187 /** Commit to amend. */
b69ab3188 node: Hash;
b69ab3189 /** Placeholder commit hash. Must start with ":". */
b69ab3190 mark: Mark;
b69ab3191 author?: Author;
b69ab3192 date?: DateTuple;
b69ab3193 /** Commit message. */
b69ab3194 text?: string;
b69ab3195 parents?: (Hash | Mark)[];
b69ab3196 predecessors?: (Hash | Mark)[];
b69ab3197 /** Why predecessors are obsoleted? For example, 'amend', 'split', 'histedit'. */
b69ab3198 operation?: string;
b69ab3199 files?: {[path: RepoPath]: ExportFile | '.' | null};
b69ab31100};
b69ab31101
b69ab31102/** Update the "current commit" without changing the working copy. */
b69ab31103export type ImportReset = {mark: Mark};
b69ab31104
b69ab31105/** Checkout the given commit. */
b69ab31106export type ImportGoto = {mark: Mark};
b69ab31107
b69ab31108/** Hide commits if they do not have visible descendants. */
b69ab31109export type ImportHide = {nodes: Hash[]};
b69ab31110
b69ab31111/** Matches output of debugimportstack. See debugstack.py. */
b69ab31112export type ImportedStack = ImportedCommit[];
b69ab31113
b69ab31114/** The given `mark` has a known commit hash `node`. */
b69ab31115export type ImportedCommit = {node: Hash; mark: Mark};