File tree Expand file tree Collapse file tree 4 files changed +68
-2
lines changed
Expand file tree Collapse file tree 4 files changed +68
-2
lines changed Original file line number Diff line number Diff line change 546546 "description" : " Ignores the warning when SVN is missing" ,
547547 "default" : false
548548 },
549+ "svn.ignoreWorkingCopyIsTooOld" : {
550+ "type" : " boolean" ,
551+ "description" : " Ignores the warning when working copy is too old" ,
552+ "default" : false
553+ },
549554 "svn.diff.withHead" : {
550555 "type" : " boolean" ,
551556 "description" :
Original file line number Diff line number Diff line change @@ -1198,6 +1198,46 @@ export class SvnCommands implements IDisposable {
11981198 await repository . rename ( oldFile , newName ) ;
11991199 }
12001200
1201+ @command ( "svn.upgrade" )
1202+ public async upgrade ( folderPath : string ) : Promise < void > {
1203+ if ( ! folderPath ) {
1204+ return ;
1205+ }
1206+
1207+ if ( configuration . get ( "ignoreWorkingCopyIsTooOld" , false ) ) {
1208+ return ;
1209+ }
1210+
1211+ folderPath = fixPathSeparator ( folderPath ) ;
1212+
1213+ const yes = "Yes" ;
1214+ const no = "No" ;
1215+ const neverShowAgain = "Don't Show Again" ;
1216+ const choice = await window . showWarningMessage (
1217+ "You want upgrade the working copy (svn upgrade)?" ,
1218+ yes ,
1219+ no ,
1220+ neverShowAgain
1221+ ) ;
1222+
1223+ if ( choice === yes ) {
1224+ const upgraded = await this . model . upgradeWorkingCopy ( folderPath ) ;
1225+
1226+ if ( upgraded ) {
1227+ window . showInformationMessage ( `Working copy "${ folderPath } " upgraded` ) ;
1228+ this . model . tryOpenRepository ( folderPath ) ;
1229+ } else {
1230+ window . showErrorMessage (
1231+ `Error on upgrading working copy "${ folderPath } ". See log for more detail`
1232+ ) ;
1233+ }
1234+ } else if ( choice === neverShowAgain ) {
1235+ return configuration . update ( "ignoreWorkingCopyIsTooOld" , true ) ;
1236+ }
1237+
1238+ return ;
1239+ }
1240+
12011241 private getSCMResource ( uri ?: Uri ) : Resource | undefined {
12021242 uri = uri
12031243 ? uri
Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ import {
2020import { debounce , sequentialize } from "./decorators" ;
2121import { configuration } from "./helpers/configuration" ;
2222import { Repository } from "./repository" ;
23- import { Svn } from "./svn" ;
23+ import { Svn , svnErrorCodes } from "./svn" ;
24+ import SvnError from "./svnError" ;
2425import {
2526 anyEvent ,
2627 dispose ,
@@ -283,6 +284,12 @@ export class Model implements IDisposable {
283284
284285 this . open ( repository ) ;
285286 } catch ( err ) {
287+ if ( err instanceof SvnError ) {
288+ if ( err . svnErrorCode === svnErrorCodes . WorkingCopyIsTooOld ) {
289+ await commands . executeCommand ( "svn.upgrade" , path ) ;
290+ return ;
291+ }
292+ }
286293 console . error ( err ) ;
287294 }
288295 return ;
@@ -424,6 +431,16 @@ export class Model implements IDisposable {
424431 return pick && pick . repository ;
425432 }
426433
434+ public async upgradeWorkingCopy ( folderPath : string ) : Promise < boolean > {
435+ try {
436+ const result = await this . svn . exec ( folderPath , [ "upgrade" ] ) ;
437+ return result . exitCode === 0 ;
438+ } catch ( e ) {
439+ console . log ( e ) ;
440+ }
441+ return false ;
442+ }
443+
427444 public dispose ( ) : void {
428445 this . disable ( ) ;
429446 this . configurationChangeDisposable . dispose ( ) ;
Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ export const svnErrorCodes: { [key: string]: string } = {
1515 AuthorizationFailed : "E170001" ,
1616 RepositoryIsLocked : "E155004" ,
1717 NotASvnRepository : "E155007" ,
18- NotShareCommonAncestry : "E195012"
18+ NotShareCommonAncestry : "E195012" ,
19+ WorkingCopyIsTooOld : "E155036"
1920} ;
2021
2122function getSvnErrorCode ( stderr : string ) : string | undefined {
@@ -206,6 +207,9 @@ export class Svn {
206207 // SVN 1.6 not has "wcroot-abspath"
207208 return path ;
208209 } catch ( error ) {
210+ if ( error instanceof SvnError ) {
211+ throw error ;
212+ }
209213 console . error ( error ) ;
210214 throw new Error ( "Unable to find repository root path" ) ;
211215 }
You can’t perform that action at this time.
0 commit comments