@@ -30,10 +30,9 @@ import { getConflictPickOptions } from "./conflictItems";
3030import { applyLineChanges } from "./lineChanges" ;
3131import { IDisposable , hasSupportToRegisterDiffCommand } from "./util" ;
3232import {
33- getChangelistPickOptions ,
3433 inputSwitchChangelist ,
35- getCommitChangelistPickOptions ,
36- inputCommitChangelist
34+ inputCommitChangelist ,
35+ getPatchChangelist
3736} from "./changelistItems" ;
3837import { configuration } from "./helpers/configuration" ;
3938import { selectBranch } from "./branches" ;
@@ -762,6 +761,47 @@ export class SvnCommands implements IDisposable {
762761 await this . showDiffPath ( repository , files ) ;
763762 } ) ;
764763 }
764+
765+ @command ( "svn.patchChangeList" , { repository : true } )
766+ async patchChangeList ( repository : Repository ) : Promise < void > {
767+ const changelistName = await getPatchChangelist ( repository ) ;
768+
769+ if ( ! changelistName ) {
770+ return ;
771+ }
772+
773+ //@TODO clean up the try catch below copied code from showDiffPatch
774+
775+ try {
776+ const tempFile = path . join ( repository . root , ".svn" , "tmp" , "svn.patch" ) ;
777+
778+ if ( fs . existsSync ( tempFile ) ) {
779+ fs . unlinkSync ( tempFile ) ;
780+ }
781+
782+ const uri = Uri . file ( tempFile ) . with ( {
783+ scheme : "untitled"
784+ } ) ;
785+
786+ const document = await workspace . openTextDocument ( uri ) ;
787+ const textEditor = await window . showTextDocument ( document ) ;
788+
789+ const content = await repository . patchChangelist ( changelistName ) ;
790+ await textEditor . edit ( e => {
791+ // if is opened, clear content
792+ e . delete (
793+ new Range (
794+ new Position ( 0 , 0 ) ,
795+ new Position ( Number . MAX_SAFE_INTEGER , 0 )
796+ )
797+ ) ;
798+ e . insert ( new Position ( 0 , 0 ) , content ) ;
799+ } ) ;
800+ } catch ( error ) {
801+ console . error ( error ) ;
802+ window . showErrorMessage ( "Unable to patch" ) ;
803+ }
804+ }
765805
766806 @command ( "svn.remove" )
767807 async remove ( ...resourceStates : SourceControlResourceState [ ] ) : Promise < void > {
0 commit comments