@@ -8,10 +8,11 @@ import {
88 workspace ,
99 SourceControlResourceGroup ,
1010 ViewColumn ,
11- SourceControlResourceState
11+ SourceControlResourceState ,
12+ ProgressLocation
1213} from "vscode" ;
1314import { inputCommitMessage } from "./messages" ;
14- import { Svn , Status } from "./svn" ;
15+ import { Svn , Status , SvnErrorCodes } from "./svn" ;
1516import { Model } from "./model" ;
1617import { Repository } from "./repository" ;
1718import { Resource } from "./resource" ;
@@ -84,7 +85,20 @@ class SwitchBranchItem implements QuickPickItem {
8485 }
8586
8687 async run ( repository : Repository ) : Promise < void > {
87- await repository . switchBranch ( this . ref ) ;
88+ try {
89+ await repository . switchBranch ( this . ref ) ;
90+ } catch ( error ) {
91+ if ( error . svnErrorCode === SvnErrorCodes . NotShareCommonAncestry ) {
92+ window . showErrorMessage (
93+ `Path '${
94+ repository . workspaceRoot
95+ } ' does not share common version control ancestry with the requested switch location.`
96+ ) ;
97+ return ;
98+ }
99+
100+ window . showErrorMessage ( "Unable to switch branch" ) ;
101+ }
88102 }
89103}
90104
@@ -235,7 +249,7 @@ export class SvnCommands {
235249 ) ;
236250 window . showInformationMessage ( result ) ;
237251 repository . inputBox . value = "" ;
238- repository . update ( ) ;
252+ repository . updateModelState ( ) ;
239253 } catch ( error ) {
240254 console . error ( error ) ;
241255 window . showErrorMessage ( error ) ;
@@ -355,7 +369,7 @@ export class SvnCommands {
355369
356370 const result = await repository . repository . commitFiles ( message , paths ) ;
357371 window . showInformationMessage ( result ) ;
358- repository . update ( ) ;
372+ repository . updateModelState ( ) ;
359373 } catch ( error ) {
360374 console . error ( error ) ;
361375 window . showErrorMessage ( "Unable to commit" ) ;
@@ -364,8 +378,7 @@ export class SvnCommands {
364378
365379 @command ( "svn.refresh" , { repository : true } )
366380 async refresh ( repository : Repository ) {
367- repository . update ( ) ;
368- repository . updateBranches ( ) ;
381+ await repository . status ( ) ;
369382 }
370383
371384 @command ( "svn.openResourceBase" )
@@ -635,12 +648,19 @@ export class SvnCommands {
635648
636649 @command ( "svn.switchBranch" , { repository : true } )
637650 async switchBranch ( repository : Repository ) {
638- const branches = repository . branches . map (
639- branch => new SwitchBranchItem ( branch )
651+ const branchesPromise = repository . getBranches ( ) ;
652+
653+ window . withProgress (
654+ { location : ProgressLocation . Window , title : "Checking remote branches" } ,
655+ ( ) => branchesPromise
640656 ) ;
657+
658+ const branches = await branchesPromise ;
659+
660+ const branchPicks = branches . map ( branch => new SwitchBranchItem ( branch ) ) ;
641661 const placeHolder = "Pick a branch to switch to." ;
642662 const createBranch = new CreateBranchItem ( this ) ;
643- const picks = [ createBranch , ...branches ] ;
663+ const picks = [ createBranch , ...branchPicks ] ;
644664
645665 const choice = await window . showQuickPick ( picks , { placeHolder } ) ;
646666
@@ -755,7 +775,7 @@ export class SvnCommands {
755775 } ) ;
756776
757777 const result = await repository . repository . removeFiles ( paths , keepLocal ) ;
758- repository . update ( ) ;
778+ repository . updateModelState ( ) ;
759779 } catch ( error ) {
760780 console . error ( error ) ;
761781 window . showErrorMessage ( "Unable to remove files" ) ;
@@ -782,7 +802,15 @@ export class SvnCommands {
782802 return ;
783803 }
784804
785- await repository . resolve ( conflict . resourceUri . path , choice . label ) ;
805+ try {
806+ const response = await repository . resolve (
807+ conflict . resourceUri . path ,
808+ choice . label
809+ ) ;
810+ window . showInformationMessage ( response ) ;
811+ } catch ( error ) {
812+ window . showErrorMessage ( error . stderr ) ;
813+ }
786814 }
787815 }
788816
0 commit comments