Exemplo n.º 1
0
    def test_get_log2(self):
        # Get an interesting commmit.
        self.test_commit3()
        rev = fs.youngest_rev(self.fs)
        revprops = ra.rev_proplist(self.ra_ctx, rev)
        self.assert_("svn:log" in revprops)
        self.assert_("testprop" in revprops)

        def receiver(log_entry, pool):
            called[0] = True
            self.assertEqual(log_entry.revision, rev)
            if discover_changed_paths:
                self.assertEqual(list(log_entry.changed_paths.keys()),
                                 ['/bla3'])
                changed_path = log_entry.changed_paths['/bla3']
                self.assert_(changed_path.action in ['A', 'D', 'R', 'M'])
                self.assertEqual(changed_path.copyfrom_path, None)
                self.assertEqual(changed_path.copyfrom_rev, -1)
            else:
                self.assertEqual(log_entry.changed_paths, None)
            if log_revprops is None:
                self.assertEqual(log_entry.revprops, revprops)
            elif len(log_revprops) == 0:
                self.assert_(log_entry.revprops == None
                             or len(log_entry.revprops) == 0)
            else:
                revprop_names = sorted(log_entry.revprops.keys())
                log_revprops.sort()
                self.assertEqual(revprop_names, log_revprops)
                for i in log_revprops:
                    self.assertEqual(log_entry.revprops[i],
                                     revprops[i],
                                     msg="%s != %s on %s" %
                                     (log_entry.revprops[i], revprops[i],
                                      (log_revprops, discover_changed_paths)))

        for log_revprops in (
                # Retrieve the standard three.
            ["svn:author", "svn:date", "svn:log"],
                # Retrieve just testprop.
            ["testprop"],
                # Retrieve all.
                None,
                # Retrieve none.
            [],
        ):
            for discover_changed_paths in [True, False]:
                called = [False]
                ra.get_log2(
                    self.ra_ctx,
                    [""],
                    rev,
                    rev,  # start, end
                    1,  # limit
                    discover_changed_paths,
                    True,  # strict_node_history
                    False,  # include_merged_revisions
                    log_revprops,
                    receiver)
                self.assert_(called[0])
Exemplo n.º 2
0
Arquivo: ra.py Projeto: Ranga123/test1
    def test_get_log2(self):
        # Get an interesting commmit.
        self.test_commit3()
        rev = fs.youngest_rev(self.fs)
        revprops = ra.rev_proplist(self.ra_ctx, rev)
        self.assert_("svn:log" in revprops)
        self.assert_("testprop" in revprops)

        def receiver(log_entry, pool):
            called[0] = True
            self.assertEqual(log_entry.revision, rev)
            if discover_changed_paths:
                self.assertEqual(list(log_entry.changed_paths.keys()), ["/bla3"])
                changed_path = log_entry.changed_paths["/bla3"]
                self.assert_(changed_path.action in ["A", "D", "R", "M"])
                self.assertEqual(changed_path.copyfrom_path, None)
                self.assertEqual(changed_path.copyfrom_rev, -1)
            else:
                self.assertEqual(log_entry.changed_paths, None)
            if log_revprops is None:
                self.assertEqual(log_entry.revprops, revprops)
            elif len(log_revprops) == 0:
                self.assert_(log_entry.revprops == None or len(log_entry.revprops) == 0)
            else:
                revprop_names = sorted(log_entry.revprops.keys())
                log_revprops.sort()
                self.assertEqual(revprop_names, log_revprops)
                for i in log_revprops:
                    self.assertEqual(
                        log_entry.revprops[i],
                        revprops[i],
                        msg="%s != %s on %s"
                        % (log_entry.revprops[i], revprops[i], (log_revprops, discover_changed_paths)),
                    )

        for log_revprops in (
            # Retrieve the standard three.
            ["svn:author", "svn:date", "svn:log"],
            # Retrieve just testprop.
            ["testprop"],
            # Retrieve all.
            None,
            # Retrieve none.
            [],
        ):
            for discover_changed_paths in [True, False]:
                called = [False]
                ra.get_log2(
                    self.ra_ctx,
                    [""],
                    rev,
                    rev,  # start, end
                    1,  # limit
                    discover_changed_paths,
                    True,  # strict_node_history
                    False,  # include_merged_revisions
                    log_revprops,
                    receiver,
                )
                self.assert_(called[0])
Exemplo n.º 3
0
Arquivo: ra.py Projeto: vocho/openqnx
  def test_commit3(self):
    commit_info = []
    def my_callback(info, pool):
      commit_info.append(info)

    revprops = {"svn:log": "foobar", "testprop": ""}
    editor, edit_baton = ra.get_commit_editor3(self.ra_ctx, revprops, my_callback, None, False)
    root = editor.open_root(edit_baton, 4)
    self.assertNotEqual(root, None)
    child = editor.add_directory("bla3", root, None, 0)
    self.assertNotEqual(child, None)
    editor.close_edit(edit_baton)

    info = commit_info[0]
    self.assertEqual(info.revision, fs.youngest_rev(self.fs))
    revprops['svn:author'] = info.author
    revprops['svn:date'] = info.date
    self.assertEqual(ra.rev_proplist(self.ra_ctx, info.revision), revprops)
Exemplo n.º 4
0
  def test_commit3(self):
    commit_info = []
    def my_callback(info, pool):
      commit_info.append(info)

    revprops = {"svn:log": "foobar", "testprop": ""}
    editor, edit_baton = ra.get_commit_editor3(self.ra_ctx, revprops, my_callback, None, False)
    root = editor.open_root(edit_baton, 4)
    self.assertNotEqual(root, None)
    child = editor.add_directory("bla3", root, None, 0)
    self.assertNotEqual(child, None)
    editor.close_edit(edit_baton)

    info = commit_info[0]
    self.assertEqual(info.revision, fs.youngest_rev(self.fs))
    revprops['svn:author'] = info.author
    revprops['svn:date'] = info.date
    self.assertEqual(ra.rev_proplist(self.ra_ctx, info.revision), revprops)
Exemplo n.º 5
0
Arquivo: ra.py Projeto: vocho/openqnx
  def test_delta_driver_commit(self):
    # Setup paths we'll commit in this test.
    to_delete = ['trunk/README.txt', 'trunk/dir1/dir2']
    to_mkdir = ['test_delta_driver_commit.d', 'test_delta_driver_commit2.d']
    to_add = ['test_delta_driver_commit', 'test_delta_driver_commit2']
    to_dir_prop = ['trunk/dir1/dir3', 'test_delta_driver_commit2.d']
    to_file_prop = ['trunk/README2.txt', 'test_delta_driver_commit2']
    all_paths = {}
    for i in to_delete + to_mkdir + to_add + to_dir_prop + to_file_prop:
      all_paths[i] = True
    # base revision for the commit
    revision = fs.youngest_rev(self.fs)

    commit_info = []
    def commit_cb(info, pool):
      commit_info.append(info)
    revprops = {"svn:log": "foobar", "testprop": ""}
    (editor, edit_baton) = ra.get_commit_editor3(self.ra_ctx, revprops,
                                                 commit_cb, None, False)
    try:
      def driver_cb(parent, path, pool):
        self.assert_(path in all_paths)
        dir_baton = file_baton = None
        if path in to_delete:
          # Leave dir_baton alone, as it must be None for delete.
          editor.delete_entry(path, revision, parent, pool)
        elif path in to_mkdir:
          dir_baton = editor.add_directory(path, parent,
                                           None, -1, # copyfrom
                                           pool)
        elif path in to_add:
          file_baton = editor.add_file(path, parent,
                                       None, -1, # copyfrom
                                       pool)
        # wc.py:test_commit tests apply_textdelta .
        if path in to_dir_prop:
          if dir_baton is None:
            dir_baton = editor.open_directory(path, parent, revision, pool)
          editor.change_dir_prop(dir_baton,
                                 'test_delta_driver_commit', 'foo', pool)
        elif path in to_file_prop:
          if file_baton is None:
            file_baton = editor.open_file(path, parent, revision, pool)
          editor.change_file_prop(file_baton,
                                  'test_delta_driver_commit', 'foo', pool)
        if file_baton is not None:
          editor.close_file(file_baton, None, pool)
        return dir_baton
      delta.path_driver(editor, edit_baton, -1, all_paths.keys(), driver_cb)
      editor.close_edit(edit_baton)
    except:
      try:
        editor.abort_edit(edit_baton)
      except:
        # We already have an exception in progress, not much we can do
        # about this.
        pass
      raise
    info = commit_info[0]

    if info.author is not None:
      revprops['svn:author'] = info.author
    revprops['svn:date'] = info.date
    self.assertEqual(ra.rev_proplist(self.ra_ctx, info.revision), revprops)

    receiver_called = [False]
    def receiver(changed_paths, revision, author, date, message, pool):
      receiver_called[0] = True
      self.assertEqual(revision, info.revision)
      self.assertEqual(author, info.author)
      self.assertEqual(date, info.date)
      self.assertEqual(message, revprops['svn:log'])
      for (path, change) in changed_paths.iteritems():
        path = path.lstrip('/')
        self.assert_(path in all_paths)
        if path in to_delete:
          self.assertEqual(change.action, 'D')
        elif path in to_mkdir or path in to_add:
          self.assertEqual(change.action, 'A')
        elif path in to_dir_prop or path in to_file_prop:
          self.assertEqual(change.action, 'M')
    ra.get_log(self.ra_ctx, [''], info.revision, info.revision,
               0,                       # limit
               True,                    # discover_changed_paths
               True,                    # strict_node_history
               receiver)
    self.assert_(receiver_called[0])
Exemplo n.º 6
0
    def test_delta_driver_commit(self):
        # Setup paths we'll commit in this test.
        to_delete = ['trunk/README.txt', 'trunk/dir1/dir2']
        to_mkdir = [
            'test_delta_driver_commit.d', 'test_delta_driver_commit2.d'
        ]
        to_add = ['test_delta_driver_commit', 'test_delta_driver_commit2']
        to_dir_prop = ['trunk/dir1/dir3', 'test_delta_driver_commit2.d']
        to_file_prop = ['trunk/README2.txt', 'test_delta_driver_commit2']
        all_paths = {}
        for i in to_delete + to_mkdir + to_add + to_dir_prop + to_file_prop:
            all_paths[i] = True
        # base revision for the commit
        revision = fs.youngest_rev(self.fs)

        commit_info = []

        def commit_cb(info, pool):
            commit_info.append(info)

        revprops = {"svn:log": "foobar", "testprop": ""}
        (editor, edit_baton) = ra.get_commit_editor3(self.ra_ctx, revprops,
                                                     commit_cb, None, False)
        try:

            def driver_cb(parent, path, pool):
                self.assert_(path in all_paths)
                dir_baton = file_baton = None
                if path in to_delete:
                    # Leave dir_baton alone, as it must be None for delete.
                    editor.delete_entry(path, revision, parent, pool)
                elif path in to_mkdir:
                    dir_baton = editor.add_directory(
                        path,
                        parent,
                        None,
                        -1,  # copyfrom
                        pool)
                elif path in to_add:
                    file_baton = editor.add_file(
                        path,
                        parent,
                        None,
                        -1,  # copyfrom
                        pool)
                # wc.py:test_commit tests apply_textdelta .
                if path in to_dir_prop:
                    if dir_baton is None:
                        dir_baton = editor.open_directory(
                            path, parent, revision, pool)
                    editor.change_dir_prop(dir_baton,
                                           'test_delta_driver_commit', 'foo',
                                           pool)
                elif path in to_file_prop:
                    if file_baton is None:
                        file_baton = editor.open_file(path, parent, revision,
                                                      pool)
                    editor.change_file_prop(file_baton,
                                            'test_delta_driver_commit', 'foo',
                                            pool)
                if file_baton is not None:
                    editor.close_file(file_baton, None, pool)
                return dir_baton

            delta.path_driver(editor, edit_baton, -1, list(all_paths.keys()),
                              driver_cb)
            editor.close_edit(edit_baton)
        except:
            try:
                editor.abort_edit(edit_baton)
            except:
                # We already have an exception in progress, not much we can do
                # about this.
                pass
            raise
        info = commit_info[0]

        if info.author is not None:
            revprops['svn:author'] = info.author
        revprops['svn:date'] = info.date
        self.assertEqual(ra.rev_proplist(self.ra_ctx, info.revision), revprops)

        receiver_called = [False]

        def receiver(changed_paths, revision, author, date, message, pool):
            receiver_called[0] = True
            self.assertEqual(revision, info.revision)
            self.assertEqual(author, info.author)
            self.assertEqual(date, info.date)
            self.assertEqual(message, revprops['svn:log'])
            for (path, change) in changed_paths.items():
                path = path.lstrip('/')
                self.assert_(path in all_paths)
                if path in to_delete:
                    self.assertEqual(change.action, 'D')
                elif path in to_mkdir or path in to_add:
                    self.assertEqual(change.action, 'A')
                elif path in to_dir_prop or path in to_file_prop:
                    self.assertEqual(change.action, 'M')

        ra.get_log(
            self.ra_ctx,
            [''],
            info.revision,
            info.revision,
            0,  # limit
            True,  # discover_changed_paths
            True,  # strict_node_history
            receiver)
        self.assert_(receiver_called[0])