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

2

6

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.

Housebreaker answered 23/4, 2019 at 13:51 Comment(0)
A
6

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
Allfired answered 23/4, 2019 at 17:53 Comment(0)
D
2

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

Dennadennard answered 23/4, 2019 at 14:37 Comment(2)
you are right, this is an option, although I'm on Windows in the current project, but your suggestions gives some idea on how to implement this for cmd. What does the 0: bit do?Housebreaker
I looked up how to get the initial commit of a branch and found this answer. But looking at the example given in the docs I believe it is checking the release number.Dennadennard

© 2022 - 2024 — McMap. All rights reserved.