Browse Source

Reworks node ids

main
Eric Amodio 5 years ago
parent
commit
951d222be9
19 changed files with 156 additions and 31 deletions
  1. +7
    -3
      src/views/nodes/branchNode.ts
  2. +8
    -3
      src/views/nodes/branchOrTagFolderNode.ts
  3. +13
    -3
      src/views/nodes/branchTrackingStatusNode.ts
  4. +7
    -1
      src/views/nodes/branchesNode.ts
  5. +7
    -1
      src/views/nodes/compareBranchNode.ts
  6. +7
    -1
      src/views/nodes/compareResultsNode.ts
  7. +7
    -1
      src/views/nodes/contributorNode.ts
  8. +7
    -1
      src/views/nodes/contributorsNode.ts
  9. +7
    -1
      src/views/nodes/reflogNode.ts
  10. +22
    -3
      src/views/nodes/reflogRecordNode.ts
  11. +7
    -1
      src/views/nodes/remoteNode.ts
  12. +7
    -1
      src/views/nodes/remotesNode.ts
  13. +6
    -1
      src/views/nodes/repositoryNode.ts
  14. +9
    -5
      src/views/nodes/searchResultsCommitsNode.ts
  15. +7
    -1
      src/views/nodes/stashNode.ts
  16. +7
    -1
      src/views/nodes/stashesNode.ts
  17. +7
    -1
      src/views/nodes/statusFilesNode.ts
  18. +7
    -1
      src/views/nodes/tagNode.ts
  19. +7
    -1
      src/views/nodes/tagsNode.ts

+ 7
- 3
src/views/nodes/branchNode.ts View File

@ -11,8 +11,14 @@ import { CommitNode } from './commitNode';
import { MessageNode, ShowMoreNode } from './common';
import { insertDateMarkers } from './helpers';
import { PageableViewNode, ResourceType, ViewNode, ViewRefNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
export class BranchNode extends ViewRefNode<RepositoriesView> implements PageableViewNode {
static key = ':branch';
static getId(repoPath: string, name: string, root: boolean): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${name})${root ? ':root' : ''}`;
}
readonly supportsPaging = true;
readonly rememberLastMaxCount = true;
maxCount: number | undefined = this.view.getNodeLastMaxCount(this);
@ -35,9 +41,7 @@ export class BranchNode extends ViewRefNode implements Pageabl
}
get id(): string {
return `gitlens:repository(${this.branch.repoPath})${this._root ? ':root' : ''}:branch(${this.branch.name})${
this.branch.current ? '+current' : ''
}${this.branch.remote ? '+remote' : ''}${this.branch.starred ? '+starred' : ''}`;
return BranchNode.getId(this.branch.repoPath, this.branch.name, this._root);
}
get current(): boolean {

+ 8
- 3
src/views/nodes/branchOrTagFolderNode.ts View File

@ -6,8 +6,15 @@ import { View } from '../viewBase';
import { BranchNode } from './branchNode';
import { TagNode } from './tagNode';
import { ResourceType, ViewNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
export class BranchOrTagFolderNode extends ViewNode {
static getId(repoPath: string, key: string | undefined, type: string, relativePath: string | undefined): string {
return `${RepositoryNode.getId(repoPath)}:${
key === undefined ? type : `${key}:${type}`
}-folder(${relativePath})`;
}
constructor(
view: View,
parent: ViewNode,
@ -27,9 +34,7 @@ export class BranchOrTagFolderNode extends ViewNode {
}
get id(): string {
return `gitlens:repository(${this.repoPath})${this._key === undefined ? '' : `:${this._key}`}:${
this.type
}-folder(${this.relativePath})`;
return BranchOrTagFolderNode.getId(this.repoPath, this._key, this.type, this.relativePath);
}
getChildren(): ViewNode[] {

+ 13
- 3
src/views/nodes/branchTrackingStatusNode.ts View File

@ -8,6 +8,7 @@ import { CommitNode } from './commitNode';
import { ShowMoreNode } from './common';
import { insertDateMarkers } from './helpers';
import { PageableViewNode, ResourceType, ViewNode } from './viewNode';
import { BranchNode } from './branchNode';
export interface BranchTrackingStatus {
ref: string;
@ -17,6 +18,11 @@ export interface BranchTrackingStatus {
}
export class BranchTrackingStatusNode extends ViewNode<ViewWithFiles> implements PageableViewNode {
static key = ':status:upstream';
static getId(repoPath: string, name: string, root: boolean, upstream: string, direction: string): string {
return `${BranchNode.getId(repoPath, name, root)}${this.key}(${upstream}|${direction})`;
}
readonly supportsPaging = true;
readonly rememberLastMaxCount = true;
maxCount: number | undefined = this.view.getNodeLastMaxCount(this);
@ -34,9 +40,13 @@ export class BranchTrackingStatusNode extends ViewNode implements
}
get id(): string {
return `gitlens:repository(${this.status.repoPath}):${this._root ? 'root:' : ''}branch(${
this.status.ref
}):status:upstream:(${this.status.upstream}):${this.direction}`;
return BranchTrackingStatusNode.getId(
this.status.repoPath,
this.status.ref,
this._root,
this.status.upstream!,
this.direction
);
}
get repoPath(): string {

+ 7
- 1
src/views/nodes/branchesNode.ts View File

@ -8,8 +8,14 @@ import { RepositoriesView } from '../repositoriesView';
import { BranchNode } from './branchNode';
import { BranchOrTagFolderNode } from './branchOrTagFolderNode';
import { ResourceType, ViewNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
export class BranchesNode extends ViewNode<RepositoriesView> {
static key = ':branches';
static getId(repoPath: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}`;
}
private _children: ViewNode[] | undefined;
constructor(uri: GitUri, view: RepositoriesView, parent: ViewNode, public readonly repo: Repository) {
@ -17,7 +23,7 @@ export class BranchesNode extends ViewNode {
}
get id(): string {
return `gitlens:repository(${this.repo.path}pan>):branches`;
return BranchesNode.getId(this.repo.path);
}
async getChildren(): Promise<ViewNode[]> {

+ 7
- 1
src/views/nodes/compareBranchNode.ts View File

@ -10,8 +10,14 @@ import { Container } from '../../container';
import { log, Strings } from '../../system';
import { FilesQueryResults, ResultsFilesNode } from './resultsFilesNode';
import { ViewShowBranchComparison } from '../../config';
import { RepositoryNode } from './repositoryNode';
export class CompareBranchNode extends ViewNode<RepositoriesView> {
static key = ':compare-branch';
static getId(repoPath: string, name: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${name})`;
}
private _children: ViewNode[] | undefined;
private _compareWith: BranchComparison | undefined;
@ -32,7 +38,7 @@ export class CompareBranchNode extends ViewNode {
}
get id(): string {
return `gitlens:repository(${this.branch.repoPath}):compare:branch(${this.branch.name}pan>):compareWith`;
return CompareBranchNode.getId(this.branch.repoPath, this.branch.name);
}
async getChildren(): Promise<ViewNode[]> {

+ 7
- 1
src/views/nodes/compareResultsNode.ts View File

@ -8,10 +8,16 @@ import { CompareView } from '../compareView';
import { CommitsQueryResults, ResultsCommitsNode } from './resultsCommitsNode';
import { FilesQueryResults, ResultsFilesNode } from './resultsFilesNode';
import { ResourceType, SubscribeableViewNode, ViewNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
let instanceId = 0;
export class CompareResultsNode extends SubscribeableViewNode<CompareView> {
static key = ':compare-results';
static getId(repoPath: string, ref1: string, ref2: string, instanceId: number): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${ref1}|${ref2}):${instanceId}`;
}
private _children: ViewNode[] | undefined;
private _instanceId: number;
@ -28,7 +34,7 @@ export class CompareResultsNode extends SubscribeableViewNode {
}
get id(): string {
return `gitlens:repository(${this.repoPath}):compare(${this._ref.ref}:${this._compareWith.ref})|${this._instanceId}`;
return CompareResultsNode.getId(this.repoPath, this._ref.ref, this._compareWith.ref, this._instanceId);
}
get pinned(): boolean {

+ 7
- 1
src/views/nodes/contributorNode.ts View File

@ -9,8 +9,14 @@ import { MessageNode, ShowMoreNode } from './common';
import { insertDateMarkers } from './helpers';
import { CommitNode } from './commitNode';
import { GlyphChars } from '../../constants';
import { RepositoryNode } from './repositoryNode';
export class ContributorNode extends ViewNode<RepositoriesView> implements PageableViewNode {
static key = ':contributor';
static getId(repoPath: string, name: string, email: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${name}|${email})`;
}
readonly supportsPaging = true;
readonly rememberLastMaxCount = true;
maxCount: number | undefined = this.view.getNodeLastMaxCount(this);
@ -24,7 +30,7 @@ export class ContributorNode extends ViewNode implements Pagea
}
get id(): string {
return `gitlens:repository(${this.contributor.repoPath}):contributor(${this.contributor.name}|${this.contributor.email}}`;
return ContributorNode.getId(this.contributor.repoPath, this.contributor.name, this.contributor.email);
}
async getChildren(): Promise<ViewNode[]> {

+ 7
- 1
src/views/nodes/contributorsNode.ts View File

@ -6,14 +6,20 @@ import { MessageNode } from './common';
import { ContributorNode } from './contributorNode';
import { ResourceType, ViewNode } from './viewNode';
import { Container } from '../../container';
import { RepositoryNode } from './repositoryNode';
export class ContributorsNode extends ViewNode<RepositoriesView> {
static key = ':contributors';
static getId(repoPath: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}`;
}
constructor(uri: GitUri, view: RepositoriesView, parent: ViewNode, public readonly repo: Repository) {
super(uri, view, parent);
}
get id(): string {
return `gitlens:repository(${this.repo.path}pan>):contributors`;
return ContributorsNode.getId(this.repo.path);
}
async getChildren(): Promise<ViewNode[]> {

+ 7
- 1
src/views/nodes/reflogNode.ts View File

@ -7,8 +7,14 @@ import { RepositoriesView } from '../repositoriesView';
import { ReflogRecordNode } from './reflogRecordNode';
import { debug, gate } from '../../system';
import { MessageNode, ShowMoreNode } from './common';
import { RepositoryNode } from './repositoryNode';
export class ReflogNode extends ViewNode<RepositoriesView> implements PageableViewNode {
static key = ':reflog';
static getId(repoPath: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}`;
}
readonly supportsPaging = true;
readonly rememberLastMaxCount = true;
maxCount: number | undefined = this.view.getNodeLastMaxCount(this);
@ -20,7 +26,7 @@ export class ReflogNode extends ViewNode implements PageableVi
}
get id(): string {
return `gitlens:repository(${this.repo.path}pan>):reflog`;
return ReflogNode.getId(this.repo.path);
}
async getChildren(): Promise<ViewNode[]> {

+ 22
- 3
src/views/nodes/reflogRecordNode.ts View File

@ -8,8 +8,22 @@ import { ViewWithFiles } from '../viewBase';
import { CommitNode } from './commitNode';
import { MessageNode, ShowMoreNode } from './common';
import { PageableViewNode, ResourceType, ViewNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
export class ReflogRecordNode extends ViewNode<ViewWithFiles> implements PageableViewNode {
static key = ':reflog-record';
static getId(
repoPath: string,
sha: string,
selector: string,
command: string,
commandArgs: string | undefined,
date: Date
): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${sha}|${selector}|${command}|${commandArgs ||
''}|${date.getTime()})`;
}
readonly supportsPaging = true;
readonly rememberLastMaxCount = true;
maxCount: number | undefined = this.view.getNodeLastMaxCount(this);
@ -19,9 +33,14 @@ export class ReflogRecordNode extends ViewNode implements Pageabl
}
get id(): string {
return `gitlens:repository(${this.uri.repoPath}):reflog-record(${this.record.sha}|${this.record.selector}|${
this.record.command
}|${this.record.commandArgs || ''}|${this.record.date.getTime()})`;
return ReflogRecordNode.getId(
this.uri.repoPath!,
this.record.sha,
this.record.selector,
this.record.command,
this.record.commandArgs,
this.record.date
);
}
async getChildren(): Promise<ViewNode[]> {

+ 7
- 1
src/views/nodes/remoteNode.ts View File

@ -9,8 +9,14 @@ import { RepositoriesView } from '../repositoriesView';
import { BranchNode } from './branchNode';
import { BranchOrTagFolderNode } from './branchOrTagFolderNode';
import { ResourceType, ViewNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
export class RemoteNode extends ViewNode<RepositoriesView> {
static key = ':remote';
static getId(repoPath: string, name: string, id: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${name}|${id})`;
}
constructor(
uri: GitUri,
view: RepositoriesView,
@ -26,7 +32,7 @@ export class RemoteNode extends ViewNode {
}
get id(): string {
return `gitlens:repository(${this.remote.repoPath}):remote(${this.remote.name}:${this.remote.id}pan>)`;
return RemoteNode.getId(this.remote.repoPath, this.remote.name, this.remote.id);
}
async getChildren(): Promise<ViewNode[]> {

+ 7
- 1
src/views/nodes/remotesNode.ts View File

@ -6,14 +6,20 @@ import { RepositoriesView } from '../repositoriesView';
import { MessageNode } from './common';
import { RemoteNode } from './remoteNode';
import { ResourceType, ViewNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
export class RemotesNode extends ViewNode<RepositoriesView> {
static key = ':remotes';
static getId(repoPath: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}`;
}
constructor(uri: GitUri, view: RepositoriesView, parent: ViewNode, public readonly repo: Repository) {
super(uri, view, parent);
}
get id(): string {
return `gitlens:repository(${this.repo.path}pan>):remotes`;
return RemotesNode.getId(this.repo.path);
}
async getChildren(): Promise<ViewNode[]> {

+ 6
- 1
src/views/nodes/repositoryNode.ts View File

@ -29,6 +29,11 @@ import { ResourceType, SubscribeableViewNode, ViewNode } from './viewNode';
const hasTimeRegex = /[hHm]/;
export class RepositoryNode extends SubscribeableViewNode<RepositoriesView> {
static key = ':repository';
static getId(repoPath: string): string {
return `gitlens${this.key}(${repoPath})`;
}
private _children: ViewNode[] | undefined;
private _lastFetched: number = 0;
private _status: Promise<GitStatus | undefined>;
@ -44,7 +49,7 @@ export class RepositoryNode extends SubscribeableViewNode {
}
get id(): string {
return `gitlens:repository(${this.repo.path})${this.repo.starred ? '+starred' : ''}`;
return RepositoryNode.getId(this.repo.path);
}
async getChildren(): Promise<ViewNode[]> {

+ 9
- 5
src/views/nodes/searchResultsCommitsNode.ts View File

@ -5,11 +5,19 @@ import { Commands } from '../../commands/common';
import { ViewWithFiles } from '../viewBase';
import { CommitsQueryResults, ResultsCommitsNode } from './resultsCommitsNode';
import { ResourceType, ViewNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
import { SearchPattern } from '../../git/gitService';
let instanceId = 0;
export class SearchResultsCommitsNode extends ResultsCommitsNode {
static key = ':search-results';
static getId(repoPath: string, search: SearchPattern | undefined, instanceId: number): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${
search === undefined ? '?' : SearchPattern.toKey(search)
}):${instanceId}`;
}
private _instanceId: number;
constructor(
@ -29,11 +37,7 @@ export class SearchResultsCommitsNode extends ResultsCommitsNode {
}
get id(): string {
return `gitlens:repository(${this.repoPath}):search(${this.search && this.search.pattern}|${
this.search && this.search.matchAll ? 'A' : ''
}${this.search && this.search.matchCase ? 'C' : ''}${
this.search && this.search.matchRegex ? 'R' : ''
}):commits|${this._instanceId}`;
return SearchResultsCommitsNode.getId(this.repoPath, this.search, this._instanceId);
}
get type(): ResourceType {

+ 7
- 1
src/views/nodes/stashNode.ts View File

@ -6,8 +6,14 @@ import { Iterables } from '../../system';
import { View } from '../viewBase';
import { StashFileNode } from './stashFileNode';
import { ResourceType, ViewNode, ViewRefNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
export class StashNode extends ViewRefNode {
static key = ':stash';
static getId(repoPath: string, ref: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${ref})`;
}
constructor(view: View, parent: ViewNode, public readonly commit: GitStashCommit) {
super(commit.toGitUri(), view, parent);
}
@ -17,7 +23,7 @@ export class StashNode extends ViewRefNode {
}
get id(): string {
return `gitlens:repository(${this.commit.repoPath}):stash(${this.commit.sha}pan>)`;
return StashNode.getId(this.commit.repoPath, this.commit.sha);
}
get ref(): string {

+ 7
- 1
src/views/nodes/stashesNode.ts View File

@ -7,14 +7,20 @@ import { View } from '../viewBase';
import { MessageNode } from './common';
import { StashNode } from './stashNode';
import { ResourceType, ViewNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
export class StashesNode extends ViewNode {
static key = ':stashes';
static getId(repoPath: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}`;
}
constructor(uri: GitUri, view: View, parent: ViewNode, public readonly repo: Repository) {
super(uri, view, parent);
}
get id(): string {
return `gitlens:repository(${this.repo.path}pan>):stashes`;
return StashesNode.getId(this.repo.path);
}
async getChildren(): Promise<ViewNode[]> {

+ 7
- 1
src/views/nodes/statusFilesNode.ts View File

@ -18,8 +18,14 @@ import { RepositoriesView } from '../repositoriesView';
import { FileNode, FolderNode } from './folderNode';
import { StatusFileNode } from './statusFileNode';
import { ResourceType, ViewNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
export class StatusFilesNode extends ViewNode<RepositoriesView> {
static key = ':status-files';
static getId(repoPath: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}`;
}
readonly repoPath: string;
constructor(
@ -33,7 +39,7 @@ export class StatusFilesNode extends ViewNode {
}
get id(): string {
return `gitlens:repository(${this.status.repoPath}pan>):status:files`;
return StatusFilesNode.getId(this.status.repoPath);
}
async getChildren(): Promise<ViewNode[]> {

+ 7
- 1
src/views/nodes/tagNode.ts View File

@ -10,8 +10,14 @@ import { MessageNode, ShowMoreNode } from './common';
import { insertDateMarkers } from './helpers';
import { PageableViewNode, ResourceType, ViewNode, ViewRefNode } from './viewNode';
import { emojify } from '../../emojis';
import { RepositoryNode } from './repositoryNode';
export class TagNode extends ViewRefNode<RepositoriesView> implements PageableViewNode {
static key = ':tag';
static getId(repoPath: string, name: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${name})`;
}
readonly supportsPaging = true;
readonly rememberLastMaxCount = true;
maxCount: number | undefined = this.view.getNodeLastMaxCount(this);
@ -25,7 +31,7 @@ export class TagNode extends ViewRefNode implements PageableVi
}
get id(): string {
return `gitlens:repository(${this.tag.repoPath}):tag(${this.tag.name}pan>)`;
return TagNode.getId(this.tag.repoPath, this.tag.name);
}
get label(): string {

+ 7
- 1
src/views/nodes/tagsNode.ts View File

@ -9,14 +9,20 @@ import { BranchOrTagFolderNode } from './branchOrTagFolderNode';
import { MessageNode } from './common';
import { TagNode } from './tagNode';
import { ResourceType, ViewNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
export class TagsNode extends ViewNode<RepositoriesView> {
static key = ':tags';
static getId(repoPath: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}`;
}
constructor(uri: GitUri, view: RepositoriesView, parent: ViewNode, public readonly repo: Repository) {
super(uri, view, parent);
}
get id(): string {
return `gitlens:repository(${this.repo.path}pan class="sb">):tags`;
return TagsNode.getId(this.repo.path);
}
async getChildren(): Promise<ViewNode[]> {

Loading…
Cancel
Save