ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/java/SVNAccess/src/net/oni2/svnaccess/SVN.java
(Generate patch)

Comparing java/SVNAccess/src/net/oni2/svnaccess/SVN.java (file contents):
Revision 732 by alloc, Thu Mar 21 17:26:44 2013 UTC vs.
Revision 764 by alloc, Sun Mar 31 15:11:04 2013 UTC

# Line 12 | Line 12 | import org.tmatesoft.svn.core.SVNURL;
12   import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
13   import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory;
14   import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
15 + import org.tmatesoft.svn.core.wc.ISVNStatusHandler;
16   import org.tmatesoft.svn.core.wc.SVNClientManager;
17   import org.tmatesoft.svn.core.wc.SVNInfo;
18   import org.tmatesoft.svn.core.wc.SVNRevision;
19 + import org.tmatesoft.svn.core.wc.SVNStatus;
20 + import org.tmatesoft.svn.core.wc.SVNStatusType;
21   import org.tmatesoft.svn.core.wc.SVNWCUtil;
22  
23   /**
# Line 98 | Line 101 | public class SVN {
101           *            Local working copy path to compare against
102           * @return -1: No local working copy yet<br>
103           *         0: Revisions are equal<br>
104 <         *         1: SVN contains newer revisions
104 >         *         1: SVN contains newer revisions<br>
105 >         *         2: WC has manually deleted files
106           * @throws Exception
107           *             If destination is not a WC of the given repository
108           */
# Line 113 | Line 117 | public class SVN {
117                          int remoteRev = getRemoteHeadRevision(repos);
118                          if (remoteRev > localRev)
119                                  return 1;
120 <                        else
121 <                                return 0;
120 >                        else {
121 >                                if (getMissingFiles(wcDir))
122 >                                        return 2;
123 >                                else
124 >                                        return 0;
125 >                        }
126                  } else {
127                          return -1;
128                  }
129          }
130  
131 +        private boolean getMissingFiles(File wcDir) {
132 +                try {
133 +                        final Vector<String> files = new Vector<String>();
134 +                        svnCManager.getStatusClient().doStatus(wcDir, null,
135 +                                        SVNDepth.INFINITY, false, false, false, false,
136 +                                        new ISVNStatusHandler() {
137 +                                                @Override
138 +                                                public void handleStatus(SVNStatus status)
139 +                                                                throws SVNException {
140 +                                                        SVNStatusType stat = status
141 +                                                                        .getCombinedNodeAndContentsStatus();
142 +                                                        if (stat == SVNStatusType.MISSING
143 +                                                                        || stat == SVNStatusType.STATUS_MISSING) {
144 +                                                                files.add(status.getFile().getPath());
145 +                                                        }
146 +                                                }
147 +                                        }, null);
148 +                        return files.size() > 0;
149 +                } catch (SVNException e) {
150 +                        e.printStackTrace();
151 +                }
152 +                return false;
153 +        }
154 +
155          private int getRemoteHeadRevision(SVNURL reposUrl) {
156                  try {
157                          SVNInfo info = svnCManager.getWCClient().doInfo(reposUrl,
# Line 156 | Line 188 | public class SVN {
188                                          SVNRevision.create(fromRev + 1), SVNRevision.HEAD, true,
189                                          true, 0, new LogEntryHandler(list, reposUrl.getPath()));
190                  } catch (Exception e) {
191 <                        if (e.getMessage().startsWith("svn: No such revision "))
192 <                                return null;
193 <                        err.println("Error while getting the list of updated files of the location '"
194 <                                        + reposUrl + "': " + e.getMessage());
195 <                        e.printStackTrace();
191 >                        if (!e.getMessage().contains("No such revision ")) {
192 >                                err.println("Error while getting the list of updated files of the location '"
193 >                                                + reposUrl + "': " + e.getMessage());
194 >                                e.printStackTrace();
195 >                        }
196                  }
197  
198                  return list;
# Line 171 | Line 203 | public class SVN {
203                  Vector<String> updatedFiles = getUpdatedFilesInRepository(reposUrl,
204                                  fromRev);
205  
174                if (updatedFiles == null)
175                        return true;
176
206                  svnCManager.getUpdateClient().setEventHandler(
207                                  new UpdateEventHandler(updatedFiles, listener));
208  

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)