Modify

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#12966 closed defect (fixed)

Unable to insert changeset 57/XXX and ticket 2 into db: columns repo, changeset, ticket are not unique

Reported by: Ryan J Ollos Owned by: jomae
Priority: high Component: CodeReviewerPlugin
Severity: major Keywords:
Cc: Trac Release:

Description

Discussed in gmessage:trac-users:zFKi53orF4U/QZvynHfGEwAJ, repeated execution of the svn hook results in:

Unable to insert changeset 57/Idouzi_Vote and ticket 2 into db: columns repo, changeset, ticket are not unique

Attachments (2)

t12966.diff (5.0 KB) - added by Jun Omae 7 years ago.
Repeat useless comments.png (54.5 KB) - added by mx.tian@… 7 years ago.
Repeat useless comments

Download all attachments as: .zip

Change History (23)

comment:1 Changed 7 years ago by Ryan J Ollos

Owner: set to Ryan J Ollos
Status: newaccepted

comment:2 Changed 7 years ago by Ryan J Ollos

Status: acceptednew

comment:4 Changed 7 years ago by mx.tian@…

Priority: normalhigh
Severity: normalmajor

I think it should give priority to it, its existence does affect me, it makes me very crazy.

comment:5 Changed 7 years ago by Ryan J Ollos

Owner: Ryan J Ollos deleted

comment:6 Changed 7 years ago by Jun Omae

When target repository is Git, the same changeset can be added like this:

$ git push origin branch-name   # create branch
$ git push origin :branch-name  # remove branch
$ git push origin branch-name   # create branch, again
  • codereviewerplugin/1.0/coderev/web_ui.py

    diff --git a/codereviewerplugin/1.0/coderev/web_ui.py b/codereviewerplugin/1.0/coderev/web_ui.py
    index 18e7efda7..abc9e8f72 100644
    a b class ChangesetTicketMapper(Component): 
    339339        self._map(repos.reponame, changeset)
    340340
    341341    def changeset_modified(self, repos, changeset, old_changeset):
    342         self._map(repos.reponame, changeset, update=True)
     342        self._map(repos.reponame, changeset)
    343343
    344344    # Internal methods
    345345
    346     def _map(self, reponame, changeset, update=False):
     346    def _map(self, reponame, changeset):
    347347        # Extract tickets from changeset message.
    348348        ctu = CommitTicketUpdater(self.env)
    349349        tickets = set(ctu._parse_message(changeset.message))
    350350        when = to_utimestamp(changeset.date)
    351351
    352352        with self.env.db_transaction as db:
    353             if update:
    354                 db("""DELETE FROM codereviewer_map
    355                    WHERE repo=%s and changeset=%s
    356                    """, (reponame or '', changeset.rev))
     353            db("DELETE FROM codereviewer_map WHERE repo=%s and changeset=%s",
     354               (reponame or '', changeset.rev))
    357355            if not tickets:
    358356                tickets = ['']  # we still want merges inserted
    359357            for ticket in tickets:

comment:7 Changed 7 years ago by mx.tian@…

Did this problem fix it? How do I get updates? I really desperate the solution to this problem.

comment:8 Changed 7 years ago by Jun Omae

Could you please try to apply the patch and tell me the results?

Changed 7 years ago by Jun Omae

Attachment: t12966.diff added

comment:9 Changed 7 years ago by Jun Omae

Posted patch with unit tests: attachment:t12966.diff

comment:10 Changed 7 years ago by mx.tian@…

I am happy to help you test, but you have to tell me how to get the patch and how to install it into an existing system.

comment:11 Changed 7 years ago by Jun Omae

Try the following steps:

$ svn co https://trac-hacks.org/svn/codereviewerplugin/1.0 /tmp/codereviewerplugin-1.0
$ cd /tmp/codereviewerplugin-1.0
$ curl -s https://trac-hacks.org/raw-attachment/ticket/12966/t12966.diff | patch -p3
$ pip install --upgrade --upgrade-strategy=only-if-needed .   # if you've installed using pip
$ easy_install -ZU .                                          # if you've install using easy_install

comment:12 Changed 7 years ago by mx.tian@…

I do not know if the installation was successful because of the following tips.

[root@host105 codereviewerplugin-1.0]# pip install --upgrade --upgrade-strategy=only-if-needed .
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Processing /tmp/codereviewerplugin-1.0
Requirement not upgraded as not directly required: Trac in /usr/lib/python2.6/site-packages (from TracCodeReviewer==1.0.0.dev0)
Requirement not upgraded as not directly required: setuptools>=0.6 in /usr/lib/python2.6/site-packages (from Trac->TracCodeReviewer==1.0.0.dev0)
Requirement not upgraded as not directly required: Genshi>=0.6 in /usr/lib/python2.6/site-packages/Genshi-0.7-py2.6-linux-x86_64.egg (from Trac->TracCodeReviewer==1.0.0.dev0)
Building wheels for collected packages: TracCodeReviewer
  Running setup.py bdist_wheel for TracCodeReviewer ... done
  Stored in directory: /root/.cache/pip/wheels/a1/f3/57/48e704e6769d9e9f035cb04d81965ed3b78fa25e6f04e2aee4
Successfully built TracCodeReviewer
Installing collected packages: TracCodeReviewer
Successfully installed TracCodeReviewer-1.0.0.dev0
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning

Submitted and pushed to the central warehouse, the hook is working properly, everything seems to be no problem, I did not see the error in the Trac log.

Administrator@XSA-20160730LDY MINGW64 /d/git-repositories/testing (0.0.1)
$ git push
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 351 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: /usr/lib/python2.6/site-packages/textile/__init__.py:19: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of textile will drop support for Python 2.6
remote:   DeprecationWarning
To git.idouzi.com:testing
   54e830c..d85d31b  0.0.1 -> 0.0.1

But in the end seems to have failed, because I did not see the increase in the comments above the comments, this is a bad news.

Changed 7 years ago by mx.tian@…

Attachment: Repeat useless comments.png added

Repeat useless comments

comment:13 Changed 7 years ago by mx.tian@…

Why insert so many comments, too crazy!

Repeat useless comments

comment:14 Changed 7 years ago by Jun Omae

That problem is not related to this issue. I think your hook has any problems. Please report to hook script maintainers with the details and how to reproduce.

comment:15 Changed 7 years ago by mx.tian@…

I do not think there is a problem, because there is no problem in the trunk, everything is normal, only to switch to the branch to submit, will have this problem. Our team members are having this problem.

comment:16 in reply to:  15 Changed 7 years ago by Jun Omae

Replying to mx.tian@…:

I do not think there is a problem, because there is no problem in the trunk, everything is normal, only to switch to the branch to submit, will have this problem. Our team members are having this problem.

However, that issue is not the original issue (Unable to insert changeset ...).

comment:17 Changed 7 years ago by mx.tian@…

I submit the code on the trunk, it works very well.

vim post-update

#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
REV=$(git rev-parse HEAD)
trac-admin /home/projects/idouzi changeset added example $REV

exec git update-server-info

Asked here "https://github.com/hvr/trac-git-plugin" can you get the plugin's response?

comment:18 in reply to:  17 Changed 7 years ago by Ryan J Ollos

Replying to mx.tian@…:

I submit the code on the trunk, it works very well.

vim post-update

#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
REV=$(git rev-parse HEAD)
trac-admin /home/projects/idouzi changeset added example $REV

exec git update-server-info

Asked here "https://github.com/hvr/trac-git-plugin" can you get the plugin's response?

As suggested, you should ask on the MailingList.

comment:19 Changed 7 years ago by Ryan J Ollos

Owner: set to Ryan J Ollos
Resolution: fixed
Status: newclosed

In 16868:

TracCodeReviewer 1.0.0dev: Fix "unable to insert changeset" with Git repository

Patch by Jun Omae.

Fixes #12966.

comment:20 Changed 7 years ago by Ryan J Ollos

Owner: changed from Ryan J Ollos to jomae

comment:21 Changed 7 years ago by mx.tian@…

Has this problem been fixed? I am waiting for the end of the repair work, I am very happy to help you test the verification.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain jomae.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.