Differences between revisions 2 and 3
Revision 2 as of 2008-12-04 15:30:13
Size: 3271
Editor: GillesMoris
Comment: Use a table to display the % format
Revision 3 as of 2009-05-19 19:31:00
Size: 3271
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 13: Line 13:
By default, tags are searched backward in history, but using the `--contains` option will make it search forward. It answers the following questions:[[BR]] By default, tags are searched backward in history, but using the `--contains` option will make it search forward. It answers the following questions:<<BR>>

Nearest Extension

This extension is not distributed with Mercurial.

Author: Gilles Moris (morisgi)

Download site: http://freehg.org/u/morisgi/nearest/

Overview

The goal of the nearest mercurial extension is to find the nearest tag(s) from a given changeset, either backward or forward in the changesets history tree.

By default, tags are searched backward in history, but using the --contains option will make it search forward. It answers the following questions:

  • On which tag this changeset is based on ? (without --contains)

  • Which tag will include / contain this changeset ? (with --contains)

The tags are searched by date, so that the nearest tag in time will be reported. However, the --all option will make the extension search the first tag on all possible branches.

Configuration

Enable the extension by adding following lines to your configuration file (~/.hgrc):

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

Usage

hg nearest [--contains] [--all] [--match pattern] [--format outputspec] [--tagsep char] REV ...

If no argument is provided, it returns the nearest tag on which the working directory is based on:

$ hg nearest
1.1+55

Which versions will include revision 5500:

$ hg nearest --contains --all 5500
1.0-727
1.0.1-633
1.1-1361

Note that even though there are more commits to 1.0, it is reported first due to its older date.

The --match option can be used to filter the tags. For instance to find a 0.9.x tag:

# The "*" replace any sequence of character
# The "?" replaces a single character
# To match characters "a", "b" or "c", use [abc]
$ hg nearest --match "0.9.*"
0.9.5+652

Output customization

The default output format is "tag+dist", and "tag-dist" with the --contains option, where "dist" is the longest path to the tag.

The format output can be customized using the --format option with the following rules:

%%

literal "%" character

%r

the revision of the given changeset

%h

the short changeset hash of the given changeset

%H

the full changeset hash of the given changeset

%i

the date of the given changeset

%I

the date and time of the given changeset

%d

the longest path from the found tag

%t

the first tag of the found changeset

%T

all the tags of the found changeset

%s

the revision of the found tag

%x

the short changeset hash of the found tag

%X

the full changeset hash of the found tag

%u

the date of the found tag

%U

the date and time of the found tag

You can use \n or \t to include special characters.

You can use the following section in the configuration file to save the format:

[nearest]
format = this is the generic format for backward and forward if they are not set below\n
# do not forget to double % chars in hgrc file, like %%r
format.forward = format specialized for --contains
format.backward = format specialized without --contains
format.exact = format in case of exact match
tagsep = string that separates tags for the %T format


CategoryExtension

NearestExtension (last edited 2011-04-03 10:32:41 by GillesMoris)