view tests/test_push_renames.py @ 120:f508c1fa19a5

hg_delta_editor: do not assume branches are copied from trunk by default Here is what happen in jquery repository: - kelvin-dev branch is created in r1617 with an empty directory for the datePicker plugin - commits are done - datePicker plugin is merged in trunk Before the fix, the converter assumed the initial empty commit had for parent some other commit of trunk, therefore adding all its files, which was wrong. And we ended with 'alignDemo.html' in converted trunk@5946 while it was not in the source revision.
author Patrick Mezard <pmezard@gmail.com>
date Sat, 29 Nov 2008 11:25:01 -0600
parents 9b5e528f67f8
children 067914ecb4eb
line wrap: on
line source

import sys
import unittest

import test_util

class TestPushRenames(test_util.TestBase):
    def setUp(self):
        test_util.TestBase.setUp(self)
        test_util.load_fixture_and_fetch('pushrenames.svndump',
                                         self.repo_path,
                                         self.wc_path,
                                         True)

    def _debug_print_copies(self, ctx):
        w = sys.stderr.write
        for f in ctx.files():
            if f not in ctx:
                w('R %s\n' % f)
            else:
                w('U %s %r\n' % (f, ctx[f].data()))
                if ctx[f].renamed():
                    w('%s copied from %s\n' % (f, ctx[f].renamed()[0]))

    def test_push_renames(self):
        repo = self.repo

        changes = [
            # Regular copy of a single file
            ('a', 'a2', None),
            # Copy and update of target
            ('a', 'a3', 'aa\n'),
            # Regular move of a single file
            ('b', 'b2', None),
            ('b', None, None),
            # Regular move and update of target
            ('c', 'c2', 'c\nc\n'),
            ('c', None, None),
            # Copy and update of source and targets
            ('d', 'd2', 'd\nd2\n'),
            ('d', 'd', 'd\nd\n'),
            # Double copy and removal (aka copy and move)
            ('e', 'e2', 'e\ne2\n'),
            ('e', 'e3', 'e\ne3\n'),
            ('e', None, None),
            ]
        self.commitchanges(changes)
        self.pushrevisions()
        tip = self.repo['tip']
        # self._debug_print_copies(tip)
        self.assertchanges(changes, tip)

def suite():
    all = [unittest.TestLoader().loadTestsFromTestCase(TestPushRenames),
          ]
    return unittest.TestSuite(all)