D5477: branches: Added -r option to show branch name(s) of a given rev (Issue5948)
yuja (Yuya Nishihara)
phabricator at mercurial-scm.org
Wed Dec 26 08:02:30 EST 2018
yuja added a comment.
Looks mostly good.
Can you update the commit message to conform to our style?
https://www.mercurial-scm.org/wiki/ContributingChanges#Submission_checklist
You'll see some lint errors if you run `test-check-*`. And you'll probably
need to update `test-completion.t`.
> opts = pycompat.byteskwargs(opts)
>
> + revs = opts.get('rev')
> + if revs:
> + revs = scmutil.revrange(repo, revs)
> + getbi = repo.revbranchcache().branchinfo
> + selectedbranches = {getbi(r)[0] for r in revs}
> +
>
> ui.pager('branches')
> fm = ui.formatter('branches', opts)
> hexfunc = fm.hexfunc
>
> @@ -1165,6 +1172,8 @@
>
> allheads = set(repo.heads())
> branches = []
> for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
>
> + if revs and tag not in selectedbranches:
> + continue
I prefer initializing `selectedbranches` to `None`, and check if it `is None`
here. It makes sure that `selectedbranches` never be an undefined name, and
avoid weird behavior when `revs` resolved to an empty set.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D5477
To: navaneeth.suresh, #hg-reviewers
Cc: pulkit, yuja, mercurial-devel
More information about the Mercurial-devel
mailing list