Mercurial has a domain-specific language called revsets that allows users to specify sets of revisions.
For example, you might want to list patches that haven't yet been merged into the branch default
:
hg log -r "all() - ancestors('default')"
As a more complex example, the link above gives the example of listing changesets between the revision tagged 1.3
and the revision tagged 1.5
which mention "bug" and affect a file in the directory hgext
:
hg log -r "1.3::1.5 and keyword(bug) and file('hgext/*')"
The revset language is quite rich, allowing selection of changesets based on dates, username, commit message, whether the commit exists at a particular remote location, and so on.
Does git have an equivalent mechanism for querying changesets, either in the core program or available as an extension?
git rev-list
. Most git commands use it (either directly via compiled-in access, or by invoking it as a command because they are shell scripts themselves). In cases wheregit rev-list
alone is not sufficient, you can write shell scripts that read its output, feed it input, and so on. – Threatrevsets
is because I got tired of writing shell scripts:)
.git rev-list
looks like it provides at least some of the functionality ofrevsets
. Would you consider putting you comment as an answer, perhaps with a quick comparison of the two? – Hectocotylusgitrevisions(7)
manual page. – Gustinrevsets
, it would benot date(-14) & desc("bug") & not ancestors(.)
. – Hectocotylusgit log
and friends is done using command-line options such as--grep
. Note that selecting commits by date is still done when specifying revisions -- see the manual page I referred to. – Gustingitrevisions
andgit rev-list
appear to a be figurativegrep
, when what I really want (and what Mercurial revsets provide) is a figurativeSQL
. It is looking increasingly like I will need to find either a git extension, or roll up my sleeves and write something myself. – Hectocotylus;)
. The Mercurial community has found the feature useful.git rev-list
seems to solves a subset of the problems, which suggests that some of the problems revsets attempts to solve have been hit by git developers and tackled by git developers in an ad-hoc manner. Anyway, I am going very off-topic from the original question, which was not about the benefits of revsets, but whether there exists an equivalent (either core or third-party) for git. – Hectocotylusgit rev-list
is a plumbing level command used bygit log
and friends, it's not intended to be used by users but rather by scripts so I'd not say it tries to solve any problems beyond makinggit log
to its job ;-) – Gustingit log
with commit ranges such as..
,...
, and--not
. Then add on top thegit log
withgrep
, and this probably provides the equivalent functionality. Time permitting, I will type up an answer with examples that match your question. – Zygodactylhg diff -r 'my-feature + tip~3':tip
which has no git equivalent, much less anything that can be written in a generalized manner. Now, is it "required"? Well, no as the lack-of-caring-of-git-users shows .. but there are a few things hg does do better, and this is one. – Shaftesbury