Add cache for changes and add change dependencies to log

[?]
Jan 5, 2021, 8:03 PM
HF3NERPZP7TS7STG3WGVSPAYTVYR6IYQ3ZLYZ6EGCDRKNTSHJ2LAC

Dependencies

  • [2] GGYKE3DV Enforce documentation on every Function, Method, and Class
  • [3] GNQD74OZ Add pijul.openChange command and text document provider for pijul-change scheme
  • [4] WCQM6IOK Add parsing of Author strings
  • [5] ODRMVURU Implement first iteration of file diffing
  • [6] L3VOQYAF Add changelog view to the source control panel
  • [7] 64J6B76F Add command to rename channels
  • [8] GGYUCHWQ Update change tooltip in changelog
  • [9] ZGMIJNFV Create pijul.ts for executing commands using the Pijul CLI
  • [*] OXW4KMVU Add QuickDiffProvider
  • [*] YUVLBWV3 Populate resource groups for unrecorded and untracked changes
  • [*] H3GAPFUC Add pijul.recordAll command

Change contents

  • replacement in src/views/changelog.ts at line 26
    [4.679][4.679:703]()
    id: element.hash,
    [4.679]
    [4.703]
    // id: element.hash,
  • replacement in src/views/changelog.ts at line 29
    [4.76][3.154:209]()
    collapsibleState: TreeItemCollapsibleState.None,
    [4.76]
    [3.209]
    collapsibleState: TreeItemCollapsibleState.Collapsed,
  • replacement in src/views/changelog.ts at line 47
    [4.1125][4.1125:1196]()
    // TODO: Implement change dependency tracking
    return null;
    [4.1125]
    [4.1196]
    return await this.repository.getChangeDependencies(element);
  • edit in src/pijul.ts at line 148
    [11.269]
    [2.1305]
    /**
    * A dictionary for holding a cache of change hashes to avoid recalculating them each time
    */
    private readonly changeCache: Record<string, PijulChange> = {};
  • replacement in src/pijul.ts at line 194
    [3.909][3.909:1028]()
    return (await this._pijul.exec(this.repositoryRoot, ['change', uri.path], { cancellationToken: token })).stdout;
    [3.909]
    [3.1028]
    return await this.getChangeToml(uri.path, token);
  • edit in src/pijul.ts at line 270
    [12.3032]
    [13.269]
    }
    /**
    * Get the TOML document describing a specific change
    * @param hash The hash of the change
    * @param cancellationToken A token for cancelling the CLI interaction
    */
    async getChangeToml (hash: string, cancellationToken?: CancellationToken): Promise<string> {
    return (await this._pijul.exec(this.repositoryRoot, ['change', hash], { cancellationToken })).stdout;
    }
    /**
    * Get the Pijul changes which the given change is dependent on
    * @param change The change to get the dependencies of
    \ */
    async getChangeDependencies (change: PijulChange): Promise<PijulChange[]> {
    const changeToml = await this.getChangeToml(change.hash);
    const dependencyPattern = /[0-9A-Z]{53}/g;
    const dependencies: PijulChange[] = [];
    let match = dependencyPattern.exec(changeToml);
    while (match) {
    dependencies.push(this.changeCache[match[0]]);
    match = dependencyPattern.exec(changeToml);
    }
    return dependencies;
  • replacement in src/pijul.ts at line 384
    [4.2163][4.77:183]()
    changes.push(new PijulChange(hash, message.trim(), new PijulChangeAuthor(author), new Date(date)));
    [4.2163]
    [4.2236]
    const cachedChange = this.changeCache[hash];
    if (cachedChange) {
    changes.push(cachedChange);
    } else {
    const change = new PijulChange(hash, message.trim(), parsePijulChangeAuthor(author), new Date(date));
    this.changeCache[change.hash] = change;
    changes.push(change);
    }
  • edit in src/pijul.ts at line 524
    [4.2681]
    [4.263]
    }
    /**
    * Creates a new PijulChangeAuthor by parsing an Author string in a change
    * @param authorString The full author string, in the format `[Author { name: "GarettWithOneR", full_name: Some("Garett Cooper"), email: Some("garett@garettcooper.com") }]`
    */
    export function parsePijulChangeAuthor (authorString: string): PijulChangeAuthor {
    const parsePattern = /Author\s\{\sname:\s"([^"]*)",\sfull_name:\s(?:Some\("([^"]*)"\)|(None)),\semail:\s(?:Some\("([^"]*)"\)|(None))\s\}/g;
    const match = parsePattern.exec(authorString);
    if (match != null) {
    // The 4th match needs to be skipped, as it is the (None) capture group
    const [, name, fullName,, email] = match;
    return new PijulChangeAuthor(name, fullName, email);
    } else {
    throw new Error('Failed to parse author string: ' + authorString);
    }
  • edit in src/pijul.ts at line 547
    [4.385][4.385:489]()
    public readonly name: string;
    public readonly fullName?: string;
    public readonly email?: string;
  • replacement in src/pijul.ts at line 548
    [4.495][4.495:750]()
    * Creates a new PijulChangeAuthor by parsing the Author string in the change
    * @param authorString The full author string, in the format `[Author { name: "GarettWithOneR", full_name: Some("Garett Cooper"), email: Some("garett@garettcooper.com") }]`
    [4.495]
    [4.750]
    * Creates a new PijulChangeAuthor instance
  • replacement in src/pijul.ts at line 550
    [4.756][4.756:1406]()
    constructor (authorString: string) {
    const parsePattern = /Author\s\{\sname:\s"([^"]*)",\sfull_name:\s(?:Some\("([^"]*)"\)|(None)),\semail:\s(?:Some\("([^"]*)"\)|(None))\s\}/g;
    const match = parsePattern.exec(authorString);
    if (match != null) {
    // The 4th match needs to be skipped, as it is the (None) capture group
    [, this.name, this.fullName,, this.email] = match;
    if (this.fullName === 'None') {
    this.fullName = undefined;
    }
    if (this.email === 'None') {
    this.fullName = undefined;
    }
    } else {
    throw new Error('Failed to parse author string: ' + authorString);
    }
    }
    [4.756]
    [4.7479]
    constructor (
    public readonly name: string,
    public readonly fullName?: string,
    public readonly email?: string
    ) {}