1
- using System . Collections . Generic ;
1
+ using System ;
2
+ using System . Collections . Generic ;
2
3
using System . IO ;
3
4
using System . Threading . Tasks ;
4
5
@@ -63,6 +64,16 @@ public Vector SyncScrollOffset
63
64
set => SetProperty ( ref _syncScrollOffset , value ) ;
64
65
}
65
66
67
+ public int Unified
68
+ {
69
+ get => _unified ;
70
+ set
71
+ {
72
+ if ( SetProperty ( ref _unified , value ) )
73
+ LoadDiffContent ( ) ;
74
+ }
75
+ }
76
+
66
77
public DiffContext ( string repo , Models . DiffOption option , DiffContext previous = null )
67
78
{
68
79
_repo = repo ;
@@ -74,9 +85,40 @@ public DiffContext(string repo, Models.DiffOption option, DiffContext previous =
74
85
_content = previous . _content ;
75
86
}
76
87
88
+ LoadDiffContent ( ) ;
89
+ }
90
+
91
+ public void IncrUnified ( )
92
+ {
93
+ Unified = _unified + 1 ;
94
+ }
95
+
96
+ public void DecrUnified ( )
97
+ {
98
+ Unified = Math . Max ( 4 , _unified - 1 ) ;
99
+ }
100
+
101
+ public void OpenExternalMergeTool ( )
102
+ {
103
+ var type = Preference . Instance . ExternalMergeToolType ;
104
+ var exec = Preference . Instance . ExternalMergeToolPath ;
105
+
106
+ var tool = Models . ExternalMerger . Supported . Find ( x => x . Type == type ) ;
107
+ if ( tool == null || ! File . Exists ( exec ) )
108
+ {
109
+ App . RaiseException ( _repo , "Invalid merge tool in preference setting!" ) ;
110
+ return ;
111
+ }
112
+
113
+ var args = tool . Type != 0 ? tool . DiffCmd : Preference . Instance . ExternalMergeToolDiffCmd ;
114
+ Task . Run ( ( ) => Commands . MergeTool . OpenForDiff ( _repo , exec , args , _option ) ) ;
115
+ }
116
+
117
+ private void LoadDiffContent ( )
118
+ {
77
119
Task . Run ( ( ) =>
78
120
{
79
- var latest = new Commands . Diff ( repo , option ) . Result ( ) ;
121
+ var latest = new Commands . Diff ( _repo , _option , _unified ) . Result ( ) ;
80
122
var rs = null as object ;
81
123
82
124
if ( latest . TextDiff != null )
@@ -92,31 +134,31 @@ public DiffContext(string repo, Models.DiffOption option, DiffContext previous =
92
134
if ( IMG_EXTS . Contains ( ext ) )
93
135
{
94
136
var imgDiff = new Models . ImageDiff ( ) ;
95
- if ( option . Revisions . Count == 2 )
137
+ if ( _option . Revisions . Count == 2 )
96
138
{
97
- imgDiff . Old = BitmapFromRevisionFile ( repo , option . Revisions [ 0 ] , oldPath ) ;
98
- imgDiff . New = BitmapFromRevisionFile ( repo , option . Revisions [ 1 ] , oldPath ) ;
139
+ imgDiff . Old = BitmapFromRevisionFile ( _repo , _option . Revisions [ 0 ] , oldPath ) ;
140
+ imgDiff . New = BitmapFromRevisionFile ( _repo , _option . Revisions [ 1 ] , oldPath ) ;
99
141
}
100
142
else
101
143
{
102
- var fullPath = Path . Combine ( repo , _option . Path ) ;
103
- imgDiff . Old = BitmapFromRevisionFile ( repo , "HEAD" , oldPath ) ;
144
+ var fullPath = Path . Combine ( _repo , _option . Path ) ;
145
+ imgDiff . Old = BitmapFromRevisionFile ( _repo , "HEAD" , oldPath ) ;
104
146
imgDiff . New = File . Exists ( fullPath ) ? new Bitmap ( fullPath ) : null ;
105
147
}
106
148
rs = imgDiff ;
107
149
}
108
150
else
109
151
{
110
152
var binaryDiff = new Models . BinaryDiff ( ) ;
111
- if ( option . Revisions . Count == 2 )
153
+ if ( _option . Revisions . Count == 2 )
112
154
{
113
- binaryDiff . OldSize = new Commands . QueryFileSize ( repo , oldPath , option . Revisions [ 0 ] ) . Result ( ) ;
114
- binaryDiff . NewSize = new Commands . QueryFileSize ( repo , _option . Path , option . Revisions [ 1 ] ) . Result ( ) ;
155
+ binaryDiff . OldSize = new Commands . QueryFileSize ( _repo , oldPath , _option . Revisions [ 0 ] ) . Result ( ) ;
156
+ binaryDiff . NewSize = new Commands . QueryFileSize ( _repo , _option . Path , _option . Revisions [ 1 ] ) . Result ( ) ;
115
157
}
116
158
else
117
159
{
118
- var fullPath = Path . Combine ( repo , _option . Path ) ;
119
- binaryDiff . OldSize = new Commands . QueryFileSize ( repo , oldPath , "HEAD" ) . Result ( ) ;
160
+ var fullPath = Path . Combine ( _repo , _option . Path ) ;
161
+ binaryDiff . OldSize = new Commands . QueryFileSize ( _repo , oldPath , "HEAD" ) . Result ( ) ;
120
162
binaryDiff . NewSize = File . Exists ( fullPath ) ? new FileInfo ( fullPath ) . Length : 0 ;
121
163
}
122
164
rs = binaryDiff ;
@@ -146,22 +188,6 @@ public DiffContext(string repo, Models.DiffOption option, DiffContext previous =
146
188
} ) ;
147
189
}
148
190
149
- public void OpenExternalMergeTool ( )
150
- {
151
- var type = Preference . Instance . ExternalMergeToolType ;
152
- var exec = Preference . Instance . ExternalMergeToolPath ;
153
-
154
- var tool = Models . ExternalMerger . Supported . Find ( x => x . Type == type ) ;
155
- if ( tool == null || ! File . Exists ( exec ) )
156
- {
157
- App . RaiseException ( _repo , "Invalid merge tool in preference setting!" ) ;
158
- return ;
159
- }
160
-
161
- var args = tool . Type != 0 ? tool . DiffCmd : Preference . Instance . ExternalMergeToolDiffCmd ;
162
- Task . Run ( ( ) => Commands . MergeTool . OpenForDiff ( _repo , exec , args , _option ) ) ;
163
- }
164
-
165
191
private Bitmap BitmapFromRevisionFile ( string repo , string revision , string file )
166
192
{
167
193
var stream = Commands . QueryFileContent . Run ( repo , revision , file ) ;
@@ -181,5 +207,6 @@ private Bitmap BitmapFromRevisionFile(string repo, string revision, string file)
181
207
private bool _isTextDiff = false ;
182
208
private object _content = null ;
183
209
private Vector _syncScrollOffset = Vector . Zero ;
210
+ private int _unified = 4 ;
184
211
}
185
212
}
0 commit comments