update copyright
[fedora-idea.git] / plugins / svn4idea / src / org / jetbrains / idea / svn / update / SvnStatusWorker.java
blobcd4ead92ef5e227e2a4c4ef6ef74e3b9d3756847
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.jetbrains.idea.svn.update;
18 import com.intellij.openapi.progress.ProgressIndicator;
19 import com.intellij.openapi.progress.ProgressManager;
20 import com.intellij.openapi.vcs.VcsException;
21 import com.intellij.openapi.vcs.VcsKey;
22 import com.intellij.openapi.vcs.update.FileGroup;
23 import com.intellij.openapi.vcs.update.UpdatedFiles;
24 import org.jetbrains.idea.svn.SvnBundle;
25 import org.jetbrains.idea.svn.SvnVcs;
26 import org.tmatesoft.svn.core.SVNException;
27 import org.tmatesoft.svn.core.wc.*;
29 import java.io.File;
30 import java.util.Collection;
32 public class SvnStatusWorker {
33 private final SvnVcs myVcs;
34 private final Collection<File> myTouchedFiles;
35 private final File myRoot;
36 private final boolean myIsTotalUpdate;
38 // these two accomulate results
39 private final UpdatedFiles myPostUpdateFiles;
40 private final Collection<VcsException> myExceptions;
42 public SvnStatusWorker(final SvnVcs vcs, final Collection<File> touchedFiles, final File root, final UpdatedFiles postUpdateFiles,
43 final boolean isTotalUpdate,
44 final Collection<VcsException> exceptions) {
45 myVcs = vcs;
46 myTouchedFiles = touchedFiles;
47 myRoot = root;
48 myPostUpdateFiles = postUpdateFiles;
49 myIsTotalUpdate = isTotalUpdate;
50 myExceptions = exceptions;
53 public void doStatus() {
54 try {
55 SVNStatusClient statusClient = myVcs.createStatusClient();
56 statusClient.setIgnoreExternals(false);
58 final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
59 if (progress != null) {
60 progress.setText(SvnBundle.message("progress.text.update.computing.post.update.status", myRoot.getAbsolutePath()));
62 final VcsKey vcsKey = SvnVcs.getKey();
63 statusClient.doStatus(myRoot, true, false, false, false, new ISVNStatusHandler() {
64 public void handleStatus(SVNStatus status) {
65 if (status.getFile() == null) {
66 return;
68 if (myIsTotalUpdate &&
69 status.getContentsStatus() == SVNStatusType.STATUS_UNVERSIONED &&
70 status.getFile().isDirectory()) {
71 myTouchedFiles.add(status.getFile());
73 if (status.getContentsStatus() == SVNStatusType.STATUS_EXTERNAL ||
74 status.getContentsStatus() == SVNStatusType.STATUS_IGNORED ||
75 status.getContentsStatus() == SVNStatusType.STATUS_MISSING ||
76 status.getContentsStatus() == SVNStatusType.STATUS_INCOMPLETE) {
77 // not interesting in post-update.
79 else if (status.getContentsStatus() != SVNStatusType.STATUS_NONE || status.getPropertiesStatus() == SVNStatusType.STATUS_NONE) {
80 String path = status.getFile().getAbsolutePath();
82 if (status.getContentsStatus() == SVNStatusType.STATUS_ADDED) {
83 myPostUpdateFiles.getGroupById(FileGroup.LOCALLY_ADDED_ID).add(path, vcsKey, null);
85 else if (status.getContentsStatus() == SVNStatusType.STATUS_CONFLICTED) {
86 // may conflict with update status.
87 FileGroup group = myPostUpdateFiles.getGroupById(FileGroup.MERGED_WITH_CONFLICT_ID);
88 if (group != null && (group.getFiles() == null || !group.getFiles().contains(path))) {
89 group.add(path, vcsKey, null);
92 else if (status.getContentsStatus() == SVNStatusType.STATUS_DELETED) {
93 myPostUpdateFiles.getGroupById(FileGroup.LOCALLY_REMOVED_ID).add(path, vcsKey, null);
95 else if (status.getContentsStatus() == SVNStatusType.STATUS_REPLACED) {
96 myPostUpdateFiles.getGroupById(FileGroup.LOCALLY_ADDED_ID).add(path, vcsKey, null);
98 else if (status.getContentsStatus() == SVNStatusType.STATUS_MODIFIED ||
99 status.getPropertiesStatus() == SVNStatusType.STATUS_MODIFIED) {
100 myPostUpdateFiles.getGroupById(FileGroup.MODIFIED_ID).add(path, vcsKey, null);
102 else if (status.getContentsStatus() == SVNStatusType.STATUS_UNVERSIONED ||
103 status.getContentsStatus() == SVNStatusType.STATUS_OBSTRUCTED) {
104 if (status.getFile().isFile() || !SVNWCUtil.isVersionedDirectory(status.getFile())) {
105 myPostUpdateFiles.getGroupById(FileGroup.UNKNOWN_ID).add(path, vcsKey, null);
112 catch (SVNException e) {
113 myExceptions.add(new VcsException(e));