Skip to content

Commit e492467

Browse files
authored
Merge branch 'master' into cleanupNewsCommit
2 parents be16c7f + 3ef843a commit e492467

19 files changed

+1230
-613
lines changed

icons/dark/check.svg

Lines changed: 1 addition & 0 deletions
Loading

icons/dark/clean.svg

Lines changed: 1 addition & 0 deletions
Loading

icons/light/check.svg

Lines changed: 1 addition & 0 deletions
Loading

icons/light/clean.svg

Lines changed: 1 addition & 0 deletions
Loading

package.json

Lines changed: 80 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,20 @@
8282
{
8383
"command": "svn.commit",
8484
"title": "Commit Selected",
85-
"category": "SVN"
85+
"category": "SVN",
86+
"icon": {
87+
"light": "icons/light/check.svg",
88+
"dark": "icons/dark/check.svg"
89+
}
90+
},
91+
{
92+
"command": "svn.commitWithMessage",
93+
"title": "Commit Changes",
94+
"category": "SVN",
95+
"icon": {
96+
"light": "icons/light/check.svg",
97+
"dark": "icons/dark/check.svg"
98+
}
8699
},
87100
{
88101
"command": "svn.openChangeBase",
@@ -132,17 +145,17 @@
132145
},
133146
{
134147
"command": "svn.revert",
135-
"title": "Revert Selected",
148+
"title": "Revert Selected File",
136149
"category": "SVN"
137150
},
138151
{
139152
"command": "svn.update",
140-
"title": "Svn update",
153+
"title": "Update",
141154
"category": "SVN"
142155
},
143156
{
144157
"command": "svn.patch",
145-
"title": "Svn patch",
158+
"title": "Show diff patch",
146159
"category": "SVN"
147160
},
148161
{
@@ -159,6 +172,20 @@
159172
"command": "svn.log",
160173
"title": "Show commit messages",
161174
"category": "SVN"
175+
},
176+
{
177+
"command": "svn.revertChange",
178+
"title": "Revert Change",
179+
"category": "SVN",
180+
"icon": {
181+
"light": "icons/light/clean.svg",
182+
"dark": "icons/dark/clean.svg"
183+
}
184+
},
185+
{
186+
"command": "svn.revertSelectedRanges",
187+
"title": "Revert Selected Ranges",
188+
"category": "SVN"
162189
}
163190
],
164191
"menus": {
@@ -178,13 +205,42 @@
178205
{
179206
"command": "svn.openChangeHead",
180207
"when": "config.svn.enabled && svnOpenRepositoryCount != 0"
208+
},
209+
{
210+
"command": "svn.addChangelist",
211+
"when": "config.svn.enabled && svnOpenRepositoryCount != 0"
212+
},
213+
{
214+
"command": "svn.removeChangelist",
215+
"when": "config.svn.enabled && svnOpenRepositoryCount != 0"
216+
},
217+
{
218+
"command": "svn.commit",
219+
"when": "config.svn.enabled && svnOpenRepositoryCount != 0"
220+
},
221+
{
222+
"command": "svn.commitWithMessage",
223+
"when": "false"
224+
},
225+
{
226+
"command": "svn.revertChange",
227+
"when": "false"
228+
},
229+
{
230+
"command": "svn.revertSelectedRanges",
231+
"when": "config.svn.enabled && svnOpenRepositoryCount != 0 && svnHasSupportToRegisterDiffCommand == 1"
181232
}
182233
],
183234
"scm/title": [
235+
{
236+
"command": "svn.commitWithMessage",
237+
"group": "navigation",
238+
"when": "config.svn.enabled && scmProvider == svn"
239+
},
184240
{
185241
"command": "svn.refresh",
186242
"group": "navigation",
187-
"when": "scmProvider == svn"
243+
"when": "config.svn.enabled && scmProvider == svn"
188244
},
189245
{
190246
"command": "svn.switchBranch",
@@ -248,13 +304,13 @@
248304
{
249305
"command": "svn.addChangelist",
250306
"when":
251-
"config.svn.enabled && scmProvider == svn && scmResourceGroup != external",
307+
"config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external",
252308
"group": "inline"
253309
},
254310
{
255311
"command": "svn.addChangelist",
256312
"when":
257-
"config.svn.enabled && scmProvider == svn && scmResourceGroup != external",
313+
"config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external",
258314
"group": "1_modification"
259315
},
260316
{
@@ -288,6 +344,12 @@
288344
"group": "2_modification"
289345
}
290346
],
347+
"scm/change/title": [
348+
{
349+
"command": "svn.revertChange",
350+
"when": "config.svn.enabled && originalResourceScheme == svn"
351+
}
352+
],
291353
"editor/title": [
292354
{
293355
"command": "svn.openFile",
@@ -306,6 +368,12 @@
306368
"group": "navigation",
307369
"when":
308370
"config.svn.enabled && svnOpenRepositoryCount != 0 && !isInDiffEditor && resourceScheme == file"
371+
},
372+
{
373+
"command": "svn.revertSelectedRanges",
374+
"group": "2_svn@3",
375+
"when":
376+
"config.svn.enabled && svnOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme != merge-conflict.conflict-diff && && svnHasSupportToRegisterDiffCommand == 1"
309377
}
310378
]
311379
},
@@ -317,6 +385,11 @@
317385
"description": "Whether svn is enabled",
318386
"default": true
319387
},
388+
"svn.autorefresh": {
389+
"type": "boolean",
390+
"description": "Whether auto refreshing is enabled",
391+
"default": true
392+
},
320393
"svn.decorations.enabled": {
321394
"type": "boolean",
322395
"description":
@@ -360,12 +433,6 @@
360433
"How frequently (in minutes) to check branch changes. Set to `0` to avoid periodic checks.",
361434
"default": 5
362435
},
363-
"svn.newCommits.update": {
364-
"type": "number",
365-
"minimum": 0,
366-
"description": "How frequently (in minutes) to check for new commits. Set to `0` to avoid periodic checks.",
367-
"default": 5
368-
},
369436
"svn.multipleFolders.enabled": {
370437
"type": "boolean",
371438
"description": "Allow to find subfolders using SVN",

src/changelistItems.ts

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
import {
2+
QuickPickItem,
3+
SourceControlResourceGroup,
4+
window,
5+
workspace
6+
} from "vscode";
7+
import { Repository } from "./repository";
8+
9+
export class ChangeListItem implements QuickPickItem {
10+
constructor(protected group: SourceControlResourceGroup) {}
11+
12+
get label(): string {
13+
return this.group.label;
14+
}
15+
16+
get description(): string {
17+
return this.group.label;
18+
}
19+
get resourceGroup(): SourceControlResourceGroup {
20+
return this.group;
21+
}
22+
}
23+
24+
export class NewChangeListItem implements QuickPickItem {
25+
constructor() {}
26+
27+
get label(): string {
28+
return "$(plus) New changelist";
29+
}
30+
31+
get description(): string {
32+
return "Create a new change list";
33+
}
34+
}
35+
36+
export function getChangelistPickOptions(
37+
repository: Repository
38+
): QuickPickItem[] {
39+
const picks: QuickPickItem[] = [];
40+
41+
repository.changelists.forEach((group, changelist) => {
42+
if (group.resourceStates.length) {
43+
picks.push(new ChangeListItem(group));
44+
}
45+
});
46+
picks.push(new NewChangeListItem());
47+
48+
return picks;
49+
}
50+
51+
export function getCommitChangelistPickOptions(
52+
repository: Repository
53+
): ChangeListItem[] {
54+
const picks: ChangeListItem[] = [];
55+
56+
if (repository.changes.resourceStates.length) {
57+
picks.push(new ChangeListItem(repository.changes));
58+
}
59+
60+
const svnConfig = workspace.getConfiguration("svn");
61+
const ignoreOnCommitList = svnConfig.get<string[]>(
62+
"sourceControl.ignoreOnCommit",
63+
[]
64+
);
65+
66+
repository.changelists.forEach((group, changelist) => {
67+
if (
68+
group.resourceStates.length &&
69+
!ignoreOnCommitList.includes(changelist)
70+
) {
71+
picks.push(new ChangeListItem(group));
72+
}
73+
});
74+
return picks;
75+
}
76+
77+
export async function inputSwitchChangelist(repository: Repository) {
78+
const picks: QuickPickItem[] = getChangelistPickOptions(repository);
79+
80+
const selectedChoice: any = await window.showQuickPick(picks, {
81+
placeHolder: "Select an existing changelist or create a new"
82+
});
83+
if (!selectedChoice) {
84+
return;
85+
}
86+
87+
let changelistName;
88+
89+
if (selectedChoice instanceof NewChangeListItem) {
90+
const newChangelistName = await window.showInputBox({
91+
placeHolder: "Changelist name",
92+
prompt: "Please enter a changelist name"
93+
});
94+
if (!newChangelistName) {
95+
return;
96+
}
97+
changelistName = newChangelistName;
98+
} else if (selectedChoice instanceof ChangeListItem) {
99+
changelistName = selectedChoice.resourceGroup.id.replace(
100+
/^changelist-/,
101+
""
102+
);
103+
}
104+
105+
return changelistName;
106+
}
107+
108+
export async function inputCommitChangelist(repository: Repository) {
109+
const picks: ChangeListItem[] = getCommitChangelistPickOptions(repository);
110+
111+
if (picks.length === 0) {
112+
window.showInformationMessage("There are no changes to commit.");
113+
return;
114+
}
115+
116+
let choice;
117+
// If has only changes, not prompt to select changelist
118+
if (picks.length === 1 && repository.changes.resourceStates.length) {
119+
choice = picks[0];
120+
} else {
121+
choice = await window.showQuickPick(picks, {
122+
placeHolder: "Select a changelist to commit"
123+
});
124+
}
125+
126+
return choice;
127+
}

0 commit comments

Comments
 (0)