annotate tests/test_diff.py @ 149:04800fda7af5

rebase: preserve local branch names. Note: this commit introduces a dependency on Mercurial 1.1.1 or later.
author Augie Fackler <durin42@gmail.com>
date Mon, 22 Dec 2008 21:20:10 -0600
parents 40474f6c1f84
children 46f6b872c988
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
138
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 from mercurial import ui
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3 import diff_cmd
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
4
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5 import test_util
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 expected_diff_output = '''Index: alpha
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8 ===================================================================
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
9 --- alpha\t(revision 3)
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10 +++ alpha\t(working copy)
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
11 @@ -1,1 +1,3 @@
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
12 -file: alpha
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
13 +alpha
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
14 +
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15 +added line
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16 Index: foo
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17 ===================================================================
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 new file mode 100644
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 --- foo\t(revision 0)
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20 +++ foo\t(working copy)
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 @@ -0,0 +1,1 @@
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22 +This is missing a newline.
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
23 \ No newline at end of file
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 '''
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
26 class DiffTests(test_util.TestBase):
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27 def test_diff_output(self):
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
28 self._load_fixture_and_fetch('two_revs.svndump')
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
29 self.commitchanges([('foo', 'foo', 'This is missing a newline.'),
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
30 ('alpha', 'alpha', 'alpha\n\nadded line\n'),
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31 ])
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
32 u = ui.ui()
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
33 diff_cmd.diff_command(u, self.repo, self.wc_path)
40474f6c1f84 diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
34 self.assertEqual(u.stream.getvalue(), expected_diff_output)