1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 package com.aragost.javahg.commands;
27
28 import java.io.IOException;
29
30 import org.junit.Assert;
31 import org.junit.Test;
32
33 import com.aragost.javahg.DateTime;
34 import com.aragost.javahg.Repository;
35 import com.aragost.javahg.test.AbstractTestCase;
36
37 public class ExportCommandTest extends AbstractTestCase {
38
39 @Test
40 public void test() throws IOException {
41 Repository repo = getTestRepository();
42
43 CommitCommand commit = CommitCommand.on(repo);
44 commit.user("user").date(DateTime.parse("0 0"));
45
46 writeFile("x", "abc\n");
47
48 AddCommand.on(repo).execute();
49 commit.message("added x").execute();
50
51
52 String expected = ""
53 + "# HG changeset patch\n"
54 + "# User user\n"
55 + "# Date 0 0\n"
56 + "# Node ID 028afe402311268f473457f6c835052dd94f1d2b\n"
57 + "# Parent 0000000000000000000000000000000000000000\n"
58 + "added x\n"
59 + "\n"
60 + "diff --git a/x b/x\n"
61 + "new file mode 100644\n"
62 + "--- /dev/null\n"
63 + "+++ b/x\n"
64 + "@@ -0,0 +1,1 @@\n"
65 + "+abc\n";
66
67
68 String patch = ExportCommand.on(repo).execute(0);
69 Assert.assertEquals(expected, patch);
70
71 }
72
73 }