KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > core > client > DiffStructureVisitor


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ccvs.core.client;
12 import org.eclipse.team.internal.ccvs.core.*;
13 import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
14 import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
15
16 /**
17  * The diff command needs to send a file structure to the server that differs somewhat from the canonical
18  * format sent by other commands. Instead of sending new files as questionables this class sends
19  * new files as modified and fakes them being added. The contents are sent to the server and are
20  * included in the returned diff report.
21  */

22 class DiffStructureVisitor extends FileStructureVisitor {
23     
24     public DiffStructureVisitor(Session session, LocalOption[] localOptions) {
25         super(session, localOptions, true, true);
26     }
27     
28     /**
29      * Send unmanaged files as modified with a default entry line.
30      */

31     protected void sendFile(ICVSFile mFile) throws CVSException {
32         byte[] info = mFile.getSyncBytes();
33         if (info==null) {
34             return;
35         }
36         
37         // Send the parent folder if it hasn't been sent already
38
sendFolder(mFile.getParent());
39         Policy.checkCanceled(monitor);
40         session.sendEntry(info, null);
41         
42         if (!mFile.exists()) {
43             return;
44         }
45
46         if (mFile.isModified(null)) {
47             session.sendModified(mFile, ResourceSyncInfo.isBinary(info), monitor);
48         } else {
49             session.sendUnchanged(mFile);
50         }
51     }
52 }
53
Popular Tags