Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View mercurial history with straightline development smashed

Tags:

mercurial

I'm interested in viewing the topology of my branches, ideally in a pretty way (a la graphlog). For example I want to see how many (open) branches there are, when they split, the last time they merged to and from each other, etc. I am not interested in all the merges between them, nor straight line development on each branch.

This is useful when looking at forks on bitbucket for example. Github's network graph helps, but often the branch structure is drowned out by straightline development and/or frequent merges.

I thought that perhaps I could use revsets like

hg glog --rev "head() or merge() or branch_points()"

but then glog shows all revisions in between, not to mention the fact that I couldn't figure out how to specify branch_points() i.e. revisions which have more than one child.

Is there an extentsion for mercurial (or another DVCS) which can approximate my desires? If not is there a better way to get this information?

like image 445
Ivan Andrus Avatar asked Apr 23 '12 12:04

Ivan Andrus


2 Answers

The following patch adds the branchpoint revset to Mercurial. It currently only applies to Mercurial 2.2, but there it works nicely.

I don’t know if I‘ll have time to push for inclusion quickly. You could go to the mailing list and offer to get it ready for inclusion (that would save me that work).

The revision is also in https://bitbucket.org/ArneBab/hg-stable

# HG changeset patch
# User [email protected]
# Date 1343931127 -7200
# Branch stable
# Node ID f5e211663739e31f2e476c43992ee5335f9d8146
# Parent  00182b3d087909e3c3ae44761efecdde8f319ef3
revsets: added branchpoint() for revisions with more than one child.

Reason: Get very terse information via

    hg glog --rev "head() or merge() or branchpoint()"

diff -r 00182b3d0879 -r f5e211663739 mercurial/revset.py
--- a/mercurial/revset.py       Tue May 01 19:09:15 2012 +0900
+++ b/mercurial/revset.py       Thu Aug 02 20:12:07 2012 +0200
@@ -710,6 +710,15 @@
     cl = repo.changelog
     return [r for r in subset if cl.parentrevs(r)[1] != -1]

+def branchpoint(repo, subset, x):
+    """``branchpoint()``
+    Changeset has more than one child.
+    """
+    # i18n: "merge" is a keyword
+    getargs(x, 0, 0, _("branchpoint takes no arguments"))
+    cl = repo.changelog
+    return [r for r in subset if cl.children(repo[r].node())[1:]]
+
 def minrev(repo, subset, x):
     """``min(set)``
     Changeset with lowest revision number in set.
@@ -1137,6 +1146,7 @@
     "bisected": bisected,
     "bookmark": bookmark,
     "branch": branch,
+    "branchpoint": branchpoint,
     "children": children,
     "closed": closed,
     "contains": contains,
like image 157
Arne Babenhauserheide Avatar answered Sep 22 '22 17:09

Arne Babenhauserheide


  $ hg log -Gr "merge() + head()"
like image 44
gavenkoa Avatar answered Sep 19 '22 17:09

gavenkoa