1 package org
.jetbrains
.idea
.svn
.update
;
3 import com
.intellij
.openapi
.progress
.ProgressIndicator
;
4 import com
.intellij
.openapi
.progress
.ProgressManager
;
5 import com
.intellij
.openapi
.vcs
.VcsException
;
6 import com
.intellij
.openapi
.vcs
.VcsKey
;
7 import com
.intellij
.openapi
.vcs
.update
.FileGroup
;
8 import com
.intellij
.openapi
.vcs
.update
.UpdatedFiles
;
9 import org
.jetbrains
.idea
.svn
.SvnBundle
;
10 import org
.jetbrains
.idea
.svn
.SvnVcs
;
11 import org
.tmatesoft
.svn
.core
.SVNException
;
12 import org
.tmatesoft
.svn
.core
.wc
.*;
15 import java
.util
.Collection
;
17 public class SvnStatusWorker
{
18 private final SvnVcs myVcs
;
19 private final Collection
<File
> myTouchedFiles
;
20 private final File myRoot
;
21 private final boolean myIsTotalUpdate
;
23 // these two accomulate results
24 private final UpdatedFiles myPostUpdateFiles
;
25 private final Collection
<VcsException
> myExceptions
;
27 public SvnStatusWorker(final SvnVcs vcs
, final Collection
<File
> touchedFiles
, final File root
, final UpdatedFiles postUpdateFiles
,
28 final boolean isTotalUpdate
,
29 final Collection
<VcsException
> exceptions
) {
31 myTouchedFiles
= touchedFiles
;
33 myPostUpdateFiles
= postUpdateFiles
;
34 myIsTotalUpdate
= isTotalUpdate
;
35 myExceptions
= exceptions
;
38 public void doStatus() {
40 SVNStatusClient statusClient
= myVcs
.createStatusClient();
41 statusClient
.setIgnoreExternals(false);
43 final ProgressIndicator progress
= ProgressManager
.getInstance().getProgressIndicator();
44 if (progress
!= null) {
45 progress
.setText(SvnBundle
.message("progress.text.update.computing.post.update.status", myRoot
.getAbsolutePath()));
47 final VcsKey vcsKey
= SvnVcs
.getKey();
48 statusClient
.doStatus(myRoot
, true, false, false, false, new ISVNStatusHandler() {
49 public void handleStatus(SVNStatus status
) {
50 if (status
.getFile() == null) {
53 if (myIsTotalUpdate
&&
54 status
.getContentsStatus() == SVNStatusType
.STATUS_UNVERSIONED
&&
55 status
.getFile().isDirectory()) {
56 myTouchedFiles
.add(status
.getFile());
58 if (status
.getContentsStatus() == SVNStatusType
.STATUS_EXTERNAL
||
59 status
.getContentsStatus() == SVNStatusType
.STATUS_IGNORED
||
60 status
.getContentsStatus() == SVNStatusType
.STATUS_MISSING
||
61 status
.getContentsStatus() == SVNStatusType
.STATUS_INCOMPLETE
) {
62 // not interesting in post-update.
64 else if (status
.getContentsStatus() != SVNStatusType
.STATUS_NONE
|| status
.getPropertiesStatus() == SVNStatusType
.STATUS_NONE
) {
65 String path
= status
.getFile().getAbsolutePath();
67 if (status
.getContentsStatus() == SVNStatusType
.STATUS_ADDED
) {
68 myPostUpdateFiles
.getGroupById(FileGroup
.LOCALLY_ADDED_ID
).add(path
, vcsKey
, null);
70 else if (status
.getContentsStatus() == SVNStatusType
.STATUS_CONFLICTED
) {
71 // may conflict with update status.
72 FileGroup group
= myPostUpdateFiles
.getGroupById(FileGroup
.MERGED_WITH_CONFLICT_ID
);
73 if (group
!= null && (group
.getFiles() == null || !group
.getFiles().contains(path
))) {
74 group
.add(path
, vcsKey
, null);
77 else if (status
.getContentsStatus() == SVNStatusType
.STATUS_DELETED
) {
78 myPostUpdateFiles
.getGroupById(FileGroup
.LOCALLY_REMOVED_ID
).add(path
, vcsKey
, null);
80 else if (status
.getContentsStatus() == SVNStatusType
.STATUS_REPLACED
) {
81 myPostUpdateFiles
.getGroupById(FileGroup
.LOCALLY_ADDED_ID
).add(path
, vcsKey
, null);
83 else if (status
.getContentsStatus() == SVNStatusType
.STATUS_MODIFIED
||
84 status
.getPropertiesStatus() == SVNStatusType
.STATUS_MODIFIED
) {
85 myPostUpdateFiles
.getGroupById(FileGroup
.MODIFIED_ID
).add(path
, vcsKey
, null);
87 else if (status
.getContentsStatus() == SVNStatusType
.STATUS_UNVERSIONED
||
88 status
.getContentsStatus() == SVNStatusType
.STATUS_OBSTRUCTED
) {
89 if (status
.getFile().isFile() || !SVNWCUtil
.isVersionedDirectory(status
.getFile())) {
90 myPostUpdateFiles
.getGroupById(FileGroup
.UNKNOWN_ID
).add(path
, vcsKey
, null);
97 catch (SVNException e
) {
98 myExceptions
.add(new VcsException(e
));