Possible to filter branch by name?
Mads Kiilerich
mads at kiilerich.com
Wed Nov 6 18:28:11 CST 2013
On 11/06/2013 10:52 PM, Matt Mackall wrote:
> On Wed, 2013-11-06 at 17:46 +0100, Mads Kiilerich wrote:
>> On 11/06/2013 05:01 PM, Matthias Tietz wrote:
>>> Hi,
>>>
>>> Is it possible to search for a branch name via command line by using
>>> pattern? We are using named branches for every official release. After
>>> releasing the named branch will be closed.
>>>
>>> We have a naming convention for our branches. Something like
>>> "1.0.0_CustomerA". I am just interested on all branches from "customer
>>> A" which are not closed.
>>>
>> No. Named branches were designed to have a small and static amount of
>> branches, and adding search functionality for that would be a bit odd.
> Yes, we have lots of crazy features buried in revsets:
>
> $ hg help revsets
> ...
> "branch(string or set)"
> All changesets belonging to the given branch or the branches of the
> given changesets.
>
> If "string" starts with "re:", the remainder of the name is treated as a
> regular expression. To match a branch that actually starts with "re:",
> use the prefix "literal:".
>
> $ hg log -r "heads(branch('re:CustomerA'))"
That will take a long detour and answer a different question ... which
admittedly might be good enough.
It will loop through the whole repo and will not use the branch cache
that 'hg branches' uses. On our insane repo it will take 18 s. 'hg
branches' and a grep takes 0.2 s.
It will also report closed heads. Add a "and not closed()" to get
something that is closer to answering the question.
A more efficient expression could be "head() and not closed() and
branch('re:CustomerA')" ... but it might still report the same branch
multiple times.
/Mads
More information about the Mercurial
mailing list