1
2
3
4
5
6
7
8
9
10
11
12 package org.tmatesoft.svn.examples.wc;
13 import java.io.File;
14 import java.io.IOException;
15 import org.tmatesoft.svn.core.SVNCommitInfo;
16 import org.tmatesoft.svn.core.SVNDepth;
17 import org.tmatesoft.svn.core.SVNException;
18 import org.tmatesoft.svn.core.SVNPropertyValue;
19 import org.tmatesoft.svn.core.SVNURL;
20 import org.tmatesoft.svn.core.wc.SVNClientManager;
21 import org.tmatesoft.svn.core.wc.SVNDiffClient;
22 import org.tmatesoft.svn.core.wc.SVNRevision;
23 import org.tmatesoft.svn.core.wc.SVNWCClient;
24
25
26
27
28
29
30 public class DiffWCToRepository {
31
32
33
34
35
36
37
38
39 public static void main (String[] args) {
40
41 SamplesUtility.initializeFSFSprotocol();
42
43 File baseDirectory = new File(args[0]);
44 File reposRoot = new File(baseDirectory, "exampleRepository");
45 File wcRoot = new File(baseDirectory, "exampleWC");
46
47 try {
48
49 SamplesUtility.createRepository(reposRoot);
50 SVNCommitInfo info = SamplesUtility.createRepositoryTree(reposRoot);
51 System.out.println(info);
52
53
54 SVNURL reposURL = SVNURL.fromFile(reposRoot);
55 SamplesUtility.checkOutWorkingCopy(reposURL, wcRoot);
56
57
58 SamplesUtility.writeToFile(new File(wcRoot, "iota"), "New text appended to 'iota'", true);
59 SamplesUtility.writeToFile(new File(wcRoot, "A/mu"), "New text in 'mu'", false);
60
61 SVNClientManager clientManager = SVNClientManager.newInstance();
62 SVNWCClient wcClient = SVNClientManager.newInstance().getWCClient();
63 wcClient.doSetProperty(new File(wcRoot, "A/B"), "spam", SVNPropertyValue.create("egg"), false,
64 SVNDepth.EMPTY, null, null);
65
66
67 SVNDiffClient diffClient = clientManager.getDiffClient();
68
69
70
71 diffClient.doDiff(wcRoot, SVNRevision.UNDEFINED, SVNRevision.WORKING, SVNRevision.HEAD,
72 SVNDepth.INFINITY, true, System.out, null);
73 } catch (SVNException svne) {
74 System.out.println(svne.getErrorMessage());
75 System.exit(1);
76 } catch (IOException ioe) {
77 ioe.printStackTrace();
78 System.exit(1);
79 }
80 }
81
82 }