Can I exclude branches by date?

Hi,

After a certain point we would like to stop mirroring branches. Say every branch after October 1st.
Is there a way we can do this without listing each branch individually?

Regards
Steve

Hi Steve,

I’m afraid that SubGit has no scheduling feature, so all the action should be performed manually, anyway. That is, if you intend something to change after October 1st, then the changes to be made manually on September, 30th.

As for the branches mirroring stop – do I understand correctly your intent is to stop mirroring some of the branches leaving the overall mirror running (say, leaving trunk and tags mirrored) and also do I understand correctly that the branches themselves should be left in the Git repository and available for further work?

If the intent to stop the whole mirror, then apparently there is no need to list branches, the mirror just should be stopped (either with subgit shutdown or with subgit uninstall) and then the Git part of the mirror can be used as an independent Git repository. If, on the other hand, the answer to the former question is “yes” and the mirror should stay running without branches, then there are two options:

  • if you don’t need those branches anymore, then they can be just excluded from the mirroring either by the excludeBranches feature or just be removing the appropriate part of the mapping configuration. In either case, it’s not mandatory to list every branch individually, it can be done with a wildcard pattern. Of course, if the list of branches you want to stop mirroring is such that cannot be described with wildcard pattern, it may be needed to list them individually.
    Also, note that both excludeBranches and mapping approaches cannot be applied on the fly and require the full repository rebuild.

  • if, on the other hand, you need the branches to stay in the repository, but not to be mirrored, then probably the best way would be not to change existing mirrored branches, but created their copies in a not mirrored Git namespace instead. For example, if the SVN branches are set to be mirrored to a svn_branches namespace in Git:

    [svn]
        …
        branches = branches/*:refs/svn_branches/*
    

    then they can be copied to a regular Git branches (that reside in the default Git namespace heads) and those new branch copies will not be mirrored to SVN as the heads namespace is not in the branches mapping configuration. Thus the mirror will continue to run while Git-only branches won’t be mirrored to SVN.

    I must also mention another way to stop mirroring the branches, yet I must also warn you that this is not an intended way to do that, but rather a “hacking” way, I would call it. It is possible to change the mapping configuration both in the regular configuration file (/subgit/config) but also in the running config (/subgit/.run/config) so that rebuild is not required. As an example, if you intend to stop mirroring all the branches, this line in the configuration might be commented or removed in both files:

    #branches = branches/*:refs/heads/*
    

    Key point here the same change must be made in both file and this will exclude this line from the mirror without rebuild. But I must warn you again that this is not an intended way to change the configuration and it will only work well if all the branches are excluded and will not be added back to the mirror in the future, otherwise, this approach may break the mirror.

Sorry, I should have given more details:

We are changing our systems soon and will not require any branch after, say, 1st October to be mirrored. They will exist in git but not svn.

All branches before that will still need to be mirrored.

I was wondering whether there is a way to tell subgit not to mirror any new branches taken after 1st October. The complicating issue is that there is no way to predict the format of the branch names.

Am I correct in thinking that this would require the branches to be manually specified in the excludeBranches option?

Hi Steve,

So the existing configuration won’t be changed and the existing branches will still be mirrored, only new branches should not be added in the mirror, right? If so and is there is no way to predict the name format, then I’m afraid you are right, the only way to exclude them is to specify every single branch manually in the excludeBranches clause, and note that this must be done before the branch is actually created – otherwise, adding the excludeBranches clause will require rebuild.