Mercurial > python-hglib
view examples/stats.py @ 123:cdde1656346f
client: add 'hidden' property to show hidden changesets.
This enables interactions with the obsolete changesets in the repository:
- add the attribute in client class
- add the keyword to the relevant commands
- enable log without hidden changesets even when self.hidden is True
- add a few tests with the hidden keyword
This changeset mirrors the behavior of the mercurial global command --hidden:
an attribute is added to the client library. If set at True, adds the hidden
keyword to all command which can use it to show hidden changesets.
The alternative would be to add the keyword in rawcommand, but the hidden flag
is not relevant for commands such as add or branch.
author | Paul Tonelli <paul.tonelli@logilab.fr> |
---|---|
date | Thu, 22 May 2014 15:23:12 +0200 |
parents | 031cbb8d4f65 |
children |
line wrap: on
line source
# stats - get stats on the given repo import sys import hglib # figure out what repo path to use repo = '.' if len(sys.argv) > 1: repo = sys.argv[1] # connect to hg client = hglib.open(repo) # gather some stats revs = int(client.tip().rev) files = len(list(client.manifest())) heads = len(client.heads()) branches = len(client.branches()) tags = len(client.tags()) - 1 # don't count tip authors = {} for e in client.log(): authors[e.author] = True merges = 0 for e in client.log(onlymerges=True): merges += 1 print "%d revisions" % revs print "%d merges" % merges print "%d files" % files print "%d heads" % heads print "%d branches" % branches print "%d tags" % tags print "%d authors" % len(authors)