Mercurial > hgsubversion
annotate tests/test_push_eol.py @ 937:fb6f6b7fa5a5
editor: implement file batons
The concept of current.file is incorrect, svn_delta.h documents open
file lifetime as:
* 5. When the producer calls @c open_file or @c add_file, either:
*
* (a) The producer must follow with any changes to the file
* (@c change_file_prop and/or @c apply_textdelta, as applicable),
* followed by a @c close_file call, before issuing any other file
* or directory calls, or
*
* (b) The producer must follow with a @c change_file_prop call if
* it is applicable, before issuing any other file or directory
* calls; later, after all directory batons including the root
* have been closed, the producer must issue @c apply_textdelta
* and @c close_file calls.
So, an open file can be kept open until after the root directory is
closed and have deltas applied afterwards. In the meantime, other files
may have been opened and patched, overwriting the current.file variable.
This patch fixes it by introducing file batons bound to file paths, and
using them to deduce the correct target in apply_textdelta(). In theory,
open files could be put in a staging area until they are closed and
moved in the RevisionData. But the current code registers files copied
during a directory copy as open files and these will not receive a
close_file() event. This separation will be enforced later.
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Sun, 23 Sep 2012 19:52:48 +0200 |
parents | 04729f3a3d17 |
children | d741f536f23a |
rev | line source |
---|---|
642
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
1 import test_util |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
2 |
643
d2ef7220a079
tests: import test_util as the first module in all relevant tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
642
diff
changeset
|
3 import unittest |
d2ef7220a079
tests: import test_util as the first module in all relevant tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
642
diff
changeset
|
4 |
642
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
5 class TestPushEol(test_util.TestBase): |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
6 def setUp(self): |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
7 test_util.TestBase.setUp(self) |
865
04729f3a3d17
test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents:
833
diff
changeset
|
8 self._load_fixture_and_fetch('emptyrepo.svndump') |
642
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
9 |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
10 def _test_push_dirs(self, stupid): |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
11 changes = [ |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
12 # Root files with LF, CRLF and mixed EOL |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
13 ('lf', 'lf', 'a\nb\n\nc'), |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
14 ('crlf', 'crlf', 'a\r\nb\r\n\r\nc'), |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
15 ('mixed', 'mixed', 'a\r\nb\n\r\nc\nd'), |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
16 ] |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
17 self.commitchanges(changes) |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
18 self.pushrevisions(stupid) |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
19 self.assertchanges(changes, self.repo['tip']) |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
20 |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
21 changes = [ |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
22 # Update all files once, with same EOL |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
23 ('lf', 'lf', 'a\nb\n\nc\na\nb\n\nc'), |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
24 ('crlf', 'crlf', 'a\r\nb\r\n\r\nc\r\na\r\nb\r\n\r\nc'), |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
25 ('mixed', 'mixed', 'a\r\nb\n\r\nc\nd\r\na\r\nb\n\r\nc\nd'), |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
26 ] |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
27 self.commitchanges(changes) |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
28 self.pushrevisions(stupid) |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
29 self.assertchanges(changes, self.repo['tip']) |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
30 |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
31 def test_push_dirs(self): |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
32 self._test_push_dirs(False) |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
33 |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
34 def test_push_dirs_stupid(self): |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
35 self._test_push_dirs(True) |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
36 |
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
37 def suite(): |
833
312b37bc5e20
tests: avoid shadowing Python builtin all()
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
38 all_tests = [unittest.TestLoader().loadTestsFromTestCase(TestPushEol), |
642
c2d606a1dc6f
tests: get rid of DOS line endings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
96
diff
changeset
|
39 ] |
833
312b37bc5e20
tests: avoid shadowing Python builtin all()
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
40 return unittest.TestSuite(all_tests) |