def test_simple_branching_with_pegged_url(self): pegged_foo_url = pegged_url(self._foo_url, self._foo_created_revision) _, _, left, right = get_branch_diff_command(pegged_foo_url) self.assertEqual(left, pegged_url(self._trunk_url, self._trunk_created_revision)) self.assertEqual(right, pegged_url(self._foo_url, self._foo_created_revision))
def test_multiple_moves_and_rebases(self): # Modify trunk and rebase create_revision(['mkdir', '-m', 'Created trunk subdir1.', join(self._trunk_url, 'subdir1')]) self._rebase(self._foo_url, self._trunk_url) # Rename foo to bar, modify trunk and rebase bar_url = join(self._branches_url, 'bar') create_revision(['move', '-m', 'Renamed branch foo to bar', self._foo_url, bar_url]) trunk_last_modified_revision = create_revision( ['mkdir', '-m', 'Created trunk subdir2', join(self._trunk_url, 'sbudir2')]) self._rebase(bar_url, self._trunk_url) # Rename bar to baz baz_url = join(self._branches_url, 'baz') create_revision(['move', '-m', 'Renamed branch bar to baz', bar_url, baz_url]) # Deadwood baz deadwooded_baz_url = join(self._deadwood_url, 'baz') create_revision(['move', '-m', 'Deadwooded baz.', baz_url, deadwooded_baz_url]) _, _, left, right = get_branch_diff_command(deadwooded_baz_url) self.assertEqual(left, pegged_url(self._trunk_url, trunk_last_modified_revision)) self.assertEqual(right, deadwooded_baz_url)
def test_deadwooded_branch(self): deadwooded_foo_url = join(self._deadwood_url, basename(self._foo_url)) create_revision(['move', '-m', 'Deadwooded foo.', self._foo_url, deadwooded_foo_url]) _, _, left, right = get_branch_diff_command(deadwooded_foo_url) self.assertEqual(left, pegged_url(self._trunk_url, self._trunk_created_revision)) self.assertEqual(right, deadwooded_foo_url)
def test_renamed_branch(self): new_foo_location = join(self._branches_url, 'bar') create_revision(['move', '-m', 'Renamed branch foo to bar.', self._foo_url, new_foo_location]) _, _, left, right = get_branch_diff_command(new_foo_location) self.assertEqual(left, pegged_url(self._trunk_url, self._trunk_created_revision)) self.assertEqual(right, new_foo_location)
def test_rebased_branch(self): new_trunk_subdir = join(self._trunk_url, 'fish') trunk_modified_revision = create_revision( ['mkdir', '-m', 'Created trunk subdir.', new_trunk_subdir]) self._rebase(self._foo_url, self._trunk_url) _, _, left, right = get_branch_diff_command(self._foo_url) self.assertEqual(left, pegged_url(self._trunk_url, trunk_modified_revision)) self.assertEqual(right, self._foo_url)
def _get_diff(uncommitted): if uncommitted and options.diff is not None: print( "Warning: option --diff is ignored when running in uncommitted" " diff mode") if uncommitted: if options.base_url is not None: print( "Warning: option --base-url is ignored when the generated" " diff covers uncommitted changes on working copy") path = "." if options.branch_url is None else options.branch_url if not isdir(path): error("--branch-url does not point to a working copy directory") diff_command = ["svn", "diff", path] diff_file = _generate_diff(diff_command) count = _count_path_components(path) if count > 0: stripped_diff = _generate_path_stripped_diff(diff_file, count) diff_file = stripped_diff svn_info = svn_common.SvnPathInfo(path, _get_svn_auth()) repository_root = svn_info.repository_root diff_base_path = svn_info.url branch_url = svn_common.get_branch_root(svn_info.url) if branch_url is None: branch_url = svn_info.url branch = branch_url[len(repository_root):] return diff_file, repository_root, branch, diff_base_path, False elif options.diff is not None: if not isfile(options.diff): error("diff file %s does not exist." % options.diff) if options.base_url is not None: print "Warning: option --base-url is ignored" diff_file = options.diff path = "." if options.branch_url is None else options.branch_url svn_info = svn_common.SvnPathInfo(path, _get_svn_auth()) repository_root = svn_info.repository_root diff_base_path = svn_info.url branch_url = svn_common.get_branch_root(svn_info.url) if branch_url is None: branch_url = svn_info.url branch = branch_url[len(repository_root):] return diff_file, repository_root, branch, diff_base_path, False else: diff_command = diff_branch.get_branch_diff_command( "." if options.branch_url is None else options.branch_url, options.base_url, options.remotesvn, False, _get_svn_auth()) diff_file = _generate_diff(diff_command) base_url, branch_url = diff_command[-2:] svn_info = svn_common.SvnPathInfo(branch_url, _get_svn_auth()) repository_root = svn_info.repository_root branch = branch_url[len(repository_root):] diff_base_path = _get_base_path(branch_url, base_url) return diff_file, repository_root, branch, diff_base_path, True