1. Sebastian Sebastian
  2. scm-manager
  3. Issues


Issue #206 resolved


created an issue

Is there a current plugin that will tell you all the changesets included in a push? Or is this something that can be found in the log file? The ideal would be if a plugin existed that provided similar functionality to http://hg.mozilla.org/mozilla-central/pushloghtml

However, the main reason I'm looking for this information is for troubleshooting, so even if this would be written to a log file that would be helpful. Wondering if scm-manager has this functionality or if I need to write a mercurial hook.

Comments (7)

  1. pmv reporter

    Yes, I'm familiar with java. Let me know what you're thinking and I'll take a look.

    Also, is there a way to set up global hooks in scm-manager? In other words, scm-manager would add the hook to the .hg/hgrc file of every existing repository (and every new repository that is built)? I believe I have a rudimentary python hook that would write the information that I need to a log file.

  2. Sebastian Sebastian repo owner

    SCM-Manager has it's own hook mechanism, which is repository type independent. With this mechanism it is possible to create global hooks. All you have todo is to create you own plugin (https://bitbucket.org/sdorra/scm-manager/wiki/howto-create-a-plugin), create a new class which extends PostReceiveHook (http://docs.scm-manager.org/apidocs/latest/sonia/scm/repository/PostReceiveRepositoryHook.html) and add the Extension (sonia.scm.plugin.ext.Extension) annotation. After that you can test your new plugin with "mvn scmp:run"

  3. pmv reporter

    Ok, that makes sense, and I see how I can log the changesets. A couple questions, though: 1) Is it possible to get the directory of the repository? I was thinking I'd write to a file inside each repository, but it's not obvious how to get that (there's no repository.getAbsolutePath() or anything like that.) 2) How do I log the ID of the person who actually did the push? Would this require a hook into the authentication mechanism? It doesn't appear this is recorded in a RepositoryHookEvent

  4. Sebastian Sebastian repo owner

    Hi, I'm not sure if the repository directory is a good place for your changegroup log, i think a extra directory would be a better place. However there is no direct api to get the repository directory, but you can get the directory:

    File repositoriesDirectory = new File(SCMContext.getContext().getBaseDirectory(), "repositories");
    File repositoryDirectory = new File(repositoriesDirectory, repository.getType() + File.separator + repository.getName());  

    Here is a example how to get the current user during a hook:

    public class ChangesetPostReceiveHook implements RepositoryHook
      private static final Collection<RepositoryHookType> TYPES =
      public ChangesetPostReceiveHook(Provider<WebSecurityContext> securityContextProvider){
        this.securityContextProvider = securityContextProvider;
      public Collection<RepositoryHookType> getTypes(){
        return TYPES;
      public boolean isAsync(){
        return false;
      public void onEvent(RepositoryHookEvent event){
        User currentUser = SecurityUtil.getCurrentUser(securityContextProvider);
        String username = currentUser.getName();
      private Provider<WebSecurityContext> securityContextProvider;

    Are you planing to show the changelog in the user interface? This would be good, because then it could be useful for other users too. Perhaps you could store the informations for each repository in a format like this:

        <changesets-start>id of the first changeset</changesets-start>
        <changesets-end>id of the last changeset</changesets-end>

    Than i could be easy to show the informations in the user interface. If you would create a public repository on bitbucket i could help you with the user interface.

  5. pmv reporter

    Thanks for the response, that definitely helps. Yes, the more I thought about it I probably won't put it in the repository. I'll look at putting it in XML and let you know when I've got something to share.

  6. pmv reporter

    Ok, it's pretty barebones, but here it is: https://bitbucket.org/pmv/scm-pushlog-plugin

    So far it seems to do what I need of it. I just re-read your comment about the xml above, and I guess it isn't exactly the same. My implementation actually contains details of each changeset rather than just the first and last id. Hopefully having it this way doesn't make the XML get too large...

    Thanks again for your help getting it to output what I expected. I agree a UI would be nice to have, but unfortunately at this point I don't have the time.

  7. Log in to comment