pretxnchangegroup.scm hook fails during push when Branch Write Protection plugin is enabled

Issue #736 new
Anonymous created an issue

I'm having a problem trying to use the branchwp plugin. The plugin installed fine and the tab shows up in the repo config as expected but when I enable the plugin (click the Enable checkbox for a repository), the plugin does not seem to work as expected.

What I am seeing: - With no whitelist or blacklist entries defined, when a normal (non-admin user) attempts to push a change set, the push fails with a message of "No outgoing changesets". The log shows a few stack traces and complains that "pretxnchangegroup.scm hook failed". - With a whitelist entry defined that should allow the same user to push their changes, the same failure occurs. - Admin users still seem to be able to push regardless of the configuration of the branchwp plugin (which is expected).

I've uninstalled a number of plugins that I had installed in order to reduce potential conflicts. Currently, the only plugins installed are: - scm-jenkins-plugin - scm-branchwp-plugin - scm-svnuser-plugin

This is a linux install running on Ubuntu 14.01. I'm attaching a log that I captured with trace enabled.

Comments (10)

  1. Sebastian Sdorra repo owner

    It looks like scm-manager is not able to retrieve the changesets for the pushed changes. Could you try to push the changes with disabled branchwp plugin and list the commits of this repository with the ui.

  2. Brent Fisher

    I'm using TortoiseHG on the client side. With Branch Write Protection enabled, when I ask TortoiseHG to "Detect outgoing changesets" to the repository (as a non-admin user), it is able to see that I have changesets that have not yet been pushed. It's only when I attempt to push them that the failure occurs.

    If I disable the Branch Write Protection plugin on the repository, the push completes successfully (as the same non-admin user). I'm able to see that the changesets were pushed to the central repo.

    If I do a push as an admin user, the push succeeds whether branchwp is enabled or not.

  3. Kyle Leinen

    I am also seeing this on our servers. We are running RHEL6.5 using SCM Manager 1.46 with branchwp 1.3.

    Excerpt from the attached log file that is identical to the error I am seeing:

    2015-06-23 08:57:14.329 [qtp953255194-60] ERROR com.aragost.javahg.internals.Server - stderr from Mercurial: ** unknown exception encountered, please report by visiting
    **  http://mercurial.selenic.com/wiki/BugTracker
    ** Python 2.7.3 (default, Feb 27 2014, 19:58:35) [GCC 4.6.3]
    ** Mercurial Distributed SCM (version 2.0.2)
    ** Extensions loaded: javahg, fileview
    Traceback (most recent call last):
      File "/usr/bin/hg", line 38, in <module>
        mercurial.dispatch.run()
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 27, in run
        sys.exit(dispatch(request(sys.argv[1:])))
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 64, in dispatch
        return _runcatch(req)
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 87, in _runcatch
        return _dispatch(req)
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 684, in _dispatch
        cmdpats, cmdoptions)
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 466, in runcommand
        ret = _runcommand(ui, options, cmd, d)
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", l
    JavaHg: Server process terminated premature with: 1
    2015-06-23 08:57:14.330 [qtp953255194-60] WARN  com.aragost.javahg.internals.Server - Trying to stop already stopped server
    2015-06-23 08:57:14.333 [qtp953255194-60] ERROR sonia.scm.repository.spi.HgHookChangesetProvider - could not retrieve changesets
    

    Its as if javahg is having an issue with the plugin. I state that with the realization that I have no idea how they interact. Sadly, until this is resolved, my team has to create their own Hg hook to do the same thing. :(

  4. Sebastian Sdorra repo owner

    I'm sorry but i can't reproduce the issue. Here is what i've tried (lines starting with $ are terminal, lines starting with # are browser):

    $ docker run -p 8080:8080 --name scmc -ti centos:7 bash
    $ cat << EOF > /etc/yum.repos.d/SCM-Manager.repopp
    [scm-releases]
    name=SCM-Manager Releases
    baseurl=http://maven.scm-manager.org/nexus/content/repositories/releases
    enabled=1
    protect=0
    gpgcheck=0
    metadata_expire=30s
    autorefresh=1
    type=rpm-md
    EOF
    $ yum install java-1.8.0-openjdk.x86_64 scm-server which mercurial
    $ /opt/scm-server/bin/scm-server
    
    # login scmadmin:scmadmin
    # install scm-branchwp-plugin
    
    $ # hit ctrl-c in terminal
    
    $ /opt/scm-server/bin/scm-server 2&>1 /tmp/out.log &
    
    # login scmadmin:scmadmin
    # create user scmuser:scmuser
    # create repository name=protected, type=hg
    # add permission isgroup=false, name=scmuser, permission=WRITE
    
    $ cat << EOF > ~/.hgrc
    [ui]
    username = SCM-User <scmuser@scm-manager.org>
    EOF
    $ hg clone http://scmuser:scmuser@localhost:8080/scm/hg/protected
    $ cd protected
    $ echo a > a.txt
    $ hg add a.txt
    $ hg commit -m 'added a'
    $ hg push http://scmuser:scmuser@localhost:8080/scm/hg/protected
    
    # enable branch write protection for protected repository
    
    $ echo b > b.txt
    $ hg add b.txt
    $ hg commit -m 'added b'
    $ hg push http://scmuser:scmuser@localhost:8080/scm/hg/protected
    

    The last command ends with the following expected output:

    pushing to http://scmuser:***@localhost:8080/scm/hg/protected
    searching for changes
    remote: adding changesets
    remote: adding manifests
    remote: adding file changes
    remote: added 1 changesets with 1 changes to 1 files
    remote: [SCM] Error: no branchwp permissions defined
    remote: transaction abort!
    remote: rollback completed
    
  5. Damir Stefanović

    Hi Sebastian,

    I'm also experiencing the same issue on CentOS 7 + SCM Manager 1.60 + branchwp-plugin 1.3 Mercurial 3.9.2 and Python 2.7.5 are installed.

    I can see following errors in scm-manager.log file

    2018-10-01 13:57:57.063 [qtp1705929636-56] ERROR sonia.scm.repository.spi.HgHookChangesetProvider - could not retrieve changesets
    com.aragost.javahg.commands.ExecutionException: unknown revision '949cb97eee3f56464dce96ead0af65586a34f0ce'!
            at com.aragost.javahg.internals.AbstractCommand.handleReturnCode(AbstractCommand.java:387)
            at com.aragost.javahg.internals.OutputChannelInputStream.findNextOutputChannelBlock(OutputChannelInputStream.java:173)
            at com.aragost.javahg.internals.OutputChannelInputStream.<init>(OutputChannelInputStream.java:74)
            at com.aragost.javahg.internals.Server.runCommand(Server.java:408)
            at com.aragost.javahg.internals.AbstractCommand.launchStream(AbstractCommand.java:180)
    

    and

    2018-10-01 13:57:57.088 [qtp1705929636-56] WARN  sonia.scm.web.HgHookCallbackServlet - hook ended with exception
    java.lang.NullPointerException: null
            at sonia.scm.repository.api.HgHookBranchProvider.changesets(HgHookBranchProvider.java:122)
            at sonia.scm.repository.api.HgHookBranchProvider.collect(HgHookBranchProvider.java:132)
            at sonia.scm.repository.api.HgHookBranchProvider.getCreatedOrModified(HgHookBranchProvider.java:85)
            at sonia.scm.branchwp.BranchWPPreReceiveRepositoryHook.checkBranchProvider(BranchWPPreReceiveRepositoryHook.java:177)
            at sonia.scm.branchwp.BranchWPPreReceiveRepositoryHook.checkWithHookContext(BranchWPPreReceiveRepositoryHook.java:227)
            at sonia.scm.branchwp.BranchWPPreReceiveRepositoryHook.handleBranchWP(BranchWPPreReceiveRepositoryHook.java:264)
            at sonia.scm.branchwp.BranchWPPreReceiveRepositoryHook.onEvent(BranchWPPreReceiveRepositoryHook.java:110)
    
  6. Log in to comment