Skip to content

Commit

Permalink
Auto-select repo for hg.update and hg.pull from status bar.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Crowl committed Oct 22, 2017
1 parent 63ba471 commit 56e8014
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/autoinout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { HgErrorCodes, HgError } from "./hg";
import { Model} from "./model";
import { throttle } from './decorators';
import typedConfig from "./config";
import { Repository, Operation, Operations } from './repository';
import { Repository, Operation, Operations } from './repository';

export const enum AutoInOutStatuses {
Disabled,
Expand Down
1 change: 0 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { ExtensionContext, workspace, window, Disposable, commands, Uri, OutputC
import { HgFinder, Hg, IHg, HgFindAttemptLogger } from './hg';
import { Model } from './model';
import { CommandCenter } from './commands';
import { StatusBarCommands } from './statusbar';
import { HgContentProvider } from './contentProvider';
import * as nls from 'vscode-nls';
import typedConfig from './config';
Expand Down
13 changes: 9 additions & 4 deletions src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as fs from 'fs';
import * as nls from 'vscode-nls';
import { ResourceGroup, createEmptyStatusGroups, UntrackedGroup, WorkingDirectoryGroup, StagingGroup, ConflictGroup, MergeGroup, IStatusGroups, groupStatuses, IGroupStatusesParams } from './resourceGroups';
import { Path } from './hg';
import { AutoInOutState, AutoInOutStatuses } from './autoinout';
import { AutoInOutState, AutoInOutStatuses, AutoIncomingOutgoing } from './autoinout';
import { DefaultRepoNotConfiguredAction, interaction, PushCreatesNewHeadAction } from './interaction';
import { exists } from 'fs';
import { toHgUri } from './uri';
Expand Down Expand Up @@ -173,7 +173,7 @@ export class Resource implements SourceControlResourceState {
) { }
}

export enum Operation {
export const enum Operation {
Status = 1 << 0,
Add = 1 << 1,
RevertFiles = 1 << 2,
Expand Down Expand Up @@ -375,6 +375,8 @@ export class Repository implements IDisposable {
constructor(
private readonly repository: BaseRepository
) {
this.updateRepositoryPaths();

const fsWatcher = workspace.createFileSystemWatcher('**');
this.disposables.push(fsWatcher);

Expand All @@ -385,7 +387,6 @@ export class Repository implements IDisposable {

const onRelevantHgChange = filterEvent(onRelevantRepositoryChange, uri => /\/\.hg\//.test(uri.path));
const onHgrcChange = filterEvent(onRelevantHgChange, uri => /\/\.hg\/hgrc$/.test(uri.path));
// onRelevantHgChange(this.onFSChange, this, disposables);
onRelevantHgChange(this._onDidChangeRepository.fire, this._onDidChangeRepository, this.disposables);
onHgrcChange(this.onHgrcChange, this, this.disposables);

Expand All @@ -397,12 +398,16 @@ export class Repository implements IDisposable {

const [groups, disposables] = createEmptyStatusGroups(this._sourceControl);

this.disposables.push(new AutoIncomingOutgoing(this));

this._groups = groups;
this.disposables.push(...disposables);

const statusBar = new StatusBarCommands(this);
this.disposables.push(statusBar);
statusBar.onDidChange(() => this._sourceControl.statusBarCommands = statusBar.commands, null, this.disposables);
statusBar.onDidChange(() => {
this._sourceControl.statusBarCommands = statusBar.commands;
}, null, this.disposables);
this._sourceControl.statusBarCommands = statusBar.commands;

this.status();
Expand Down
6 changes: 4 additions & 2 deletions src/statusbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class ScopeStatusBar {
return {
command: 'hg.update',
tooltip: localize('update', 'Update...'),
title
title,
arguments: [this.repository]
};
}

Expand Down Expand Up @@ -239,7 +240,8 @@ class SyncStatusBar {
return {
command,
title: `${icon} ${text}`.trim(),
tooltip
tooltip,
arguments: [this.repository]
};
}

Expand Down

0 comments on commit 56e8014

Please sign in to comment.