-
Notifications
You must be signed in to change notification settings - Fork 407
Instrument operation durations #642
Changes from all commits
b32fc85
6bf2f49
c97b0da
6a68386
acf60de
371404d
a07b231
c4aa4e6
7135830
aa6ba37
1b62b02
76966ef
22920db
75c86da
38329fb
0221e22
ef109a7
e921b38
152f8bd
06d18d2
79e3be3
dc5a282
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ import React from 'react'; | |
| import {Point, Emitter} from 'atom'; | ||
| import {autobind} from 'core-decorators'; | ||
|
|
||
| import EventWatcher from '../event-watcher'; | ||
| import Switchboard from '../switchboard'; | ||
| import FilePatchView from '../views/file-patch-view'; | ||
|
|
||
| export default class FilePatchController extends React.Component { | ||
|
|
@@ -20,11 +20,11 @@ export default class FilePatchController extends React.Component { | |
| quietlySelectItem: React.PropTypes.func.isRequired, | ||
| undoLastDiscard: React.PropTypes.func.isRequired, | ||
| openFiles: React.PropTypes.func.isRequired, | ||
| eventWatcher: React.PropTypes.instanceOf(EventWatcher), | ||
| switchboard: React.PropTypes.instanceOf(Switchboard), | ||
| } | ||
|
|
||
| static defaultProps = { | ||
| eventWatcher: new EventWatcher(), | ||
| switchboard: new Switchboard(), | ||
| } | ||
|
|
||
| constructor(props, context) { | ||
|
|
@@ -68,7 +68,7 @@ export default class FilePatchController extends React.Component { | |
| attemptHunkStageOperation={this.attemptHunkStageOperation} | ||
| didSurfaceFile={this.didSurfaceFile} | ||
| didDiveIntoCorrespondingFilePatch={this.diveIntoCorrespondingFilePatch} | ||
| eventWatcher={this.props.eventWatcher} | ||
| switchboard={this.props.switchboard} | ||
| openCurrentFile={this.openCurrentFile} | ||
| discardLines={this.props.discardLines} | ||
| undoLastDiscard={this.undoLastDiscard} | ||
|
|
@@ -88,17 +88,22 @@ export default class FilePatchController extends React.Component { | |
| } | ||
|
|
||
| async stageHunk(hunk) { | ||
| this.props.switchboard.didBeginStageOperation({stage: true, hunk: true}); | ||
|
|
||
| await this.props.repository.applyPatchToIndex( | ||
| this.props.filePatch.getStagePatchForHunk(hunk), | ||
| ); | ||
| this.props.eventWatcher.resolveStageOperationPromise(); | ||
| this.props.switchboard.didFinishStageOperation({stage: true, hunk: true}); | ||
| } | ||
|
|
||
| async unstageHunk(hunk) { | ||
| this.props.switchboard.didBeginStageOperation({unstage: true, hunk: true}); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little conflicted about following this pattern. Specifically, there are two alternatives:
On one hand, the metaprogramming I've set up in Switchboard makes it easy to quickly define a large number of events, which makes (1) more tenable. On the other, I feel like that could get out of hand? |
||
|
|
||
| await this.props.repository.applyPatchToIndex( | ||
| this.props.filePatch.getUnstagePatchForHunk(hunk), | ||
| ); | ||
| this.props.eventWatcher.resolveStageOperationPromise(); | ||
|
|
||
| this.props.switchboard.didFinishStageOperation({unstage: true, hunk: true}); | ||
| } | ||
|
|
||
| stageOrUnstageHunk(hunk) { | ||
|
|
@@ -118,27 +123,31 @@ export default class FilePatchController extends React.Component { | |
| } | ||
|
|
||
| this.stagingOperationInProgress = true; | ||
| this.props.eventWatcher.getPatchChangedPromise().then(() => { | ||
| this.props.switchboard.getChangePatchPromise().then(() => { | ||
| this.stagingOperationInProgress = false; | ||
| }); | ||
|
|
||
| this.stageOrUnstageHunk(hunk); | ||
| } | ||
|
|
||
| async stageLines(lines) { | ||
| this.props.switchboard.didBeginStageOperation({stage: true, line: true}); | ||
|
|
||
| await this.props.repository.applyPatchToIndex( | ||
| this.props.filePatch.getStagePatchForLines(lines), | ||
| ); | ||
|
|
||
| this.props.eventWatcher.resolveStageOperationPromise(); | ||
| this.props.switchboard.didFinishStageOperation({stage: true, line: true}); | ||
| } | ||
|
|
||
| async unstageLines(lines) { | ||
| this.props.switchboard.didBeginStageOperation({unstage: true, line: true}); | ||
|
|
||
| await this.props.repository.applyPatchToIndex( | ||
| this.props.filePatch.getUnstagePatchForLines(lines), | ||
| ); | ||
|
|
||
| this.props.eventWatcher.resolveStageOperationPromise(); | ||
| this.props.switchboard.didFinishStageOperation({unstage: true, line: true}); | ||
| } | ||
|
|
||
| stageOrUnstageLines(lines) { | ||
|
|
@@ -158,7 +167,7 @@ export default class FilePatchController extends React.Component { | |
| } | ||
|
|
||
| this.stagingOperationInProgress = true; | ||
| this.props.eventWatcher.getPatchChangedPromise().then(() => { | ||
| this.props.switchboard.getChangePatchPromise().then(() => { | ||
| this.stagingOperationInProgress = false; | ||
| }); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ import RepositoryConflictController from './repository-conflict-controller'; | |
| import ModelObserver from '../models/model-observer'; | ||
| import ModelStateRegistry from '../models/model-state-registry'; | ||
| import Conflict from '../models/conflicts/conflict'; | ||
| import Switchboard from '../switchboard'; | ||
| import {copyFile, deleteFileOrFolder} from '../helpers'; | ||
| import {GitError} from '../git-shell-out-strategy'; | ||
|
|
||
|
|
@@ -47,10 +48,12 @@ export default class RootController extends React.Component { | |
| repository: React.PropTypes.object, | ||
| resolutionProgress: React.PropTypes.object, | ||
| statusBar: React.PropTypes.object, | ||
| switchboard: React.PropTypes.instanceOf(Switchboard), | ||
| savedState: React.PropTypes.object, | ||
| } | ||
|
|
||
| static defaultProps = { | ||
| switchboard: new Switchboard(), | ||
| savedState: {}, | ||
| } | ||
|
|
||
|
|
@@ -211,6 +214,7 @@ export default class RootController extends React.Component { | |
| openFiles={this.openFiles} | ||
| discardLines={this.discardLines} | ||
| undoLastDiscard={this.undoLastDiscard} | ||
| switchboard={this.props.switchboard} | ||
| /> | ||
| </PaneItem> | ||
| </div> | ||
|
|
@@ -316,10 +320,14 @@ export default class RootController extends React.Component { | |
| if (activate && this.filePatchControllerPane) { | ||
| this.filePatchControllerPane.activate(); | ||
| } | ||
| this.props.switchboard.didFinishRender('RootController.showFilePatchForPath'); | ||
| resolve(); | ||
| }); | ||
| } else { | ||
| this.setState({...nullFilePatchState}, resolve); | ||
| this.setState({...nullFilePatchState}, () => { | ||
| this.props.switchboard.didFinishRender('RootController.showFilePatchForPath'); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like we'll eventually want |
||
| resolve(); | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,8 @@ import StyleCalculator from './models/style-calculator'; | |
| import FilePatchController from './controllers/file-patch-controller'; | ||
| import RootController from './controllers/root-controller'; | ||
| import IssueishPaneItem from './atom-items/issueish-pane-item'; | ||
| import Switchboard from './switchboard'; | ||
| import yardstick from './yardstick'; | ||
| import GitTimingsView from './views/git-timings-view'; | ||
|
|
||
| const defaultState = { | ||
|
|
@@ -40,6 +42,35 @@ export default class GithubPackage { | |
|
|
||
| this.subscriptions = new CompositeDisposable(); | ||
| this.savedState = {}; | ||
|
|
||
| this.switchboard = new Switchboard(); | ||
| this.setupYardstick(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dropped this into a separate method to make it easy to comment out if it causes any trouble. Might just be a relic of me developing the mechanism, though. |
||
| } | ||
|
|
||
| setupYardstick() { | ||
| const stagingSeries = ['stageLine', 'stageHunk', 'unstageLine', 'unstageHunk']; | ||
|
|
||
| this.subscriptions.add( | ||
| this.switchboard.onDidBeginStageOperation(payload => { | ||
| if (payload.stage && payload.line) { | ||
| yardstick.begin('stageLine'); | ||
| } else if (payload.stage && payload.hunk) { | ||
| yardstick.begin('stageHunk'); | ||
| } else if (payload.unstage && payload.line) { | ||
| yardstick.begin('unstageLine'); | ||
| } else if (payload.unstage && payload.hunk) { | ||
| yardstick.begin('unstageHunk'); | ||
| } | ||
| }), | ||
| this.switchboard.onDidUpdateRepository(() => { | ||
| yardstick.mark(stagingSeries, 'update-repository'); | ||
| }), | ||
| this.switchboard.onDidFinishRender(context => { | ||
| if (context === 'RootController.showFilePatchForPath') { | ||
| yardstick.finish(stagingSeries); | ||
| } | ||
| }), | ||
| ); | ||
| } | ||
|
|
||
| activate(state = {}) { | ||
|
|
@@ -149,14 +180,18 @@ export default class GithubPackage { | |
| savedState={this.savedState.gitController} | ||
| createRepositoryForProjectPath={this.createRepositoryForProjectPath} | ||
| cloneRepositoryForProjectPath={this.cloneRepositoryForProjectPath} | ||
| switchboard={this.switchboard} | ||
| />, this.element, | ||
| ); | ||
| } | ||
|
|
||
| async deactivate() { | ||
| this.subscriptions.dispose(); | ||
| if (this.destroyedRepositorySubscription) { this.destroyedRepositorySubscription.dispose(); } | ||
| await this.destroyModelsForPaths(Array.from(this.modelPromisesByProjectPath.keys())); | ||
| await Promise.all([ | ||
| this.destroyModelsForPaths(Array.from(this.modelPromisesByProjectPath.keys())), | ||
| yardstick.flush(), | ||
| ]); | ||
| } | ||
|
|
||
| consumeStatusBar(statusBar) { | ||
|
|
@@ -278,6 +313,15 @@ export default class GithubPackage { | |
| } | ||
|
|
||
| setActiveModels(repository, resolutionProgress) { | ||
| if (this.activeRepository !== repository) { | ||
| if (this.changedRepositorySubscription) { this.changedRepositorySubscription.dispose(); } | ||
| if (repository) { | ||
| this.changedRepositorySubscription = repository.onDidUpdate(() => { | ||
| this.switchboard.didUpdateRepository(); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| this.activeRepository = repository; | ||
| this.activeResolutionProgress = resolutionProgress; | ||
| this.rerender(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Names are hard ¯\(ツ)/¯