Differences between revisions 1 and 3 (spanning 2 versions)
Revision 1 as of 2011-10-08 21:52:16
Size: 4255
Editor: JasonHarris
Comment: Rename the ExcludeChangesets extension to BanChangesets
Revision 3 as of 2012-02-29 14:55:51
Size: 4024
Editor: JasonHarris
Comment: Get the correct capitalization.
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
= Ban Changesets = = HgBan =
Line 12: Line 12:
''Author: '' ''Jason Harris'' ''Author: '' ''Jason Harris'' and ''Angel Ezquerra''
Line 14: Line 14:
Repository: https://bitbucket.org/jfh/ban-changesets Repository: https://bitbucket.org/jfh/hgban
Line 16: Line 16:
Web page: ''https://bitbucket.org/jfh/ban-changesets/wiki/Home'' Web page: ''https://bitbucket.org/jfh/hgban/wiki/Home''
Line 34: Line 34:
The extension '''ban-changesets''' is intended to prevent such a re-push of these "bad" changesets. The extension '''hgban''' is intended to prevent such a re-push of these "bad" changesets.
Line 41: Line 41:
ban-changesets = /path/to/ban-changesets.py hgban = /path/to/hgban.py
Line 44: Line 44:
== Setting up the .hgbannedchangesets file == == Setting up the .hgban file ==
Line 46: Line 46:
Once the extension is enabled on the central server, to ban / interdict / bar changesets simply create a file named '{{{.hgbannedchangesets}}}' at the root level of the repository and add line-by-line the changeset hashes that are to be banned. You can commit the {{{.hgbannedchangesets}}} file to the repo if you want but it is not necessary. Once the extension is enabled on the central server, to ban / interdict / bar changesets simply create a file named '{{{.hgban}}}' at the root level of the repository and add line-by-line the changeset hashes that are to be banned. You can commit the {{{.hgban}}} file to the repo if you want but it is not necessary.
Line 48: Line 48:
== Format of the .hgbannedchangesets file == == Format of the .hgban file ==
Line 50: Line 50:
The {{{.hgbannedchangesets}}} file is examined line by line by the ban-changesets extension. The changeset hash should start at the very beginning of the line and anything else on the line is ignored. (In fact if you understand regular expressions each line is matched by "{{{(^[0-9a-fA-F]+).*}}}" and the changeset hash is taken to be {{{\1}}}) The {{{.hgban}}} file is examined line by line by the hgban extension. The changeset hash should start at the very beginning of the line. (Actually you can use general reveset syntax to specify multiple criterion for banning changesets.)
Line 52: Line 52:
Thus the following is a valid {{{.hgbannedchangesets}}} file: Thus the following is a valid {{{.hgban}}} file:
Line 59: Line 59:
a4988662d998b8d986bdaec43079475827aa31d0 # The "launch" code commit a4988662d998b8d986bdaec43079475827aa31d0

HgBan

A mercurial extension to ban specific changesets from a repository.

1. Status

This extension is not distributed with Mercurial.

Author: Jason Harris and Angel Ezquerra

Repository: https://bitbucket.org/jfh/hgban

Web page: https://bitbucket.org/jfh/hgban/wiki/Home

2. Overview

This extension can be used to ensure that certain changesets which are determined to be "bad" by a team can be banned from being repushed to a central repository.

Imagine that you have a team of people working on a mercurial repository. One of the members of the team pushes a changeset or group of changesets to the central repository but these changesets are "bad" for one reason or another. (Maybe some branch was merged when it should not have been, etc. Maybe some nuclear launch codes were accidentally committed, etc.). Ideally this should never happen. In practice it happens all too frequently.

So typically the leader of the project will send out an email saying something like: Please strip the following revisions from your repositories:

    162a93e027fdcc6f037c80d185eb201e346da0b0
    69cc2b0e47158d1a571a35ec89c5524b084944c9
    a4988662d998b8d986bdaec43079475827aa31d0

The problem is of course that in a team of say 20 people someone might have already pulled the "bad" revisions and they may accidentally miss the email, and re-push these bad revisions back to the central server.

The extension hgban is intended to prevent such a re-push of these "bad" changesets.

3. Configuration

Configure your .hgrc to enable the extension by adding following lines:

[extensions]
hgban = /path/to/hgban.py

4. Setting up the .hgban file

Once the extension is enabled on the central server, to ban / interdict / bar changesets simply create a file named '.hgban' at the root level of the repository and add line-by-line the changeset hashes that are to be banned. You can commit the .hgban file to the repo if you want but it is not necessary.

5. Format of the .hgban file

The .hgban file is examined line by line by the hgban extension. The changeset hash should start at the very beginning of the line. (Actually you can use general reveset syntax to specify multiple criterion for banning changesets.)

Thus the following is a valid .hgban file:

# Ignore these changesets due to bad branch merge
162a93e027fdcc6f037c80d185eb201e346da0b0
69cc2b0e47158d1a571a35ec89c5524b084944c9

# Ignore this changeset because it contains the nuclear launch code that Billy included
a4988662d998b8d986bdaec43079475827aa31d0

6. What does a user do if changesets are rejected

If you are trying to push some changesets to the server but the push is rejected because some of the changesets are banned from the repository, then likely you should:

  1. Read any messages from the person who specifically interdicted the changesets.
  2. Determine in your local repository if you have committed anything on top of these bad changesets.
  3. If you have committed stuff on top of these bad changesets then move your changesets to another part of the commit tree, using say 'hg export' and 'hg import', or using rebasing, transplant, or MQ. (Now would likely be a good time to use 'hg clone' to make a "dummy" clone of the repository just in case you stuff up the history editing.)

  4. Locally use 'hg strip'  to get rid of the bad changesets and their descendants.

See editing history and in particular rebasing, transplant and strip

7. See also


CategoryExtensionsByOthers CategoryExtensionsByOthers

BanChangesetsExtension (last edited 2012-11-11 13:41:44 by abuehl)