Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I list branches started by a certain user in Mercurial?

Tags:

mercurial

Not much to add to the title. hg branches --help --verbose doesn't show anything useful, although I'm not sure if the user can be shown via the --template option (in this case tools like grep could help). Or may be I'm looking in the wrong direction?

Automating this search would be really useful because there are a lot of unclosed branches in the current project and that would help for both checking if I left some opened branch and suggesting collegues to take a look at certain branches.

like image 427
YakovL Avatar asked Apr 23 '19 13:04

YakovL


2 Answers

Bashism of @Jello is rather good, but... it's bashism.

Some steps (not ready to use solution) to almost pure hg-style

  1. Re-read hg help revsets+ hg help templates

All starting points of branches (named and anonymous) are child of branchpoints. All changesets have authors. Because every branch may have any amounts branchpoints in it (and every branchpoint means 2 branches of child), branchnames can be duplicated in output of suggested command (and I'm too lazy to clean-up it)

Task 1 - find all starting revisions of branches

-r "children(branchpoint())"

Task 2 - output only branch and author of changeset

--template "{branch} - {author}"

full command (T1+T2, all branches of all users), somrthing like this

hg log -r "children(branchpoint())" --template "{branch} - {author}\n"

as starting point.

You can:

  • add ifeq logic into template (don't print "old" branchname for changesets with branch(r)=branch(p1))
  • add ANDed condition "USER" into revset, define full command as parametrised alias and have ready to use shareable solution
like image 71
Lazy Badger Avatar answered Nov 15 '22 12:11

Lazy Badger


Try a bash loop like this:

for branch in $(hg branches -q); do hg log -r "branch($branch)and 0:" -u "username" -l 1; done

like image 32
Jello Avatar answered Nov 15 '22 12:11

Jello