1
import sys
import hglib
import re 

# figure out what repo path to use

if len(sys.argv) > 1:
    repo1 = sys.argv[1]    

# connect to hg
client1 = hglib.open(repo1)

for data1 in client1.log("date('>2015-06-01') and date('<2015-09-16')"):

    m = re.findall("\w+\\-\d+", data1.desc.upper())
    if len(m)> 0:     
        data_row = [data1.rev,data1.author,data1.branch,data1.desc,m[0]] 

This script gives the revision,author,branch,description . I want to get count of files for each revision. How can this be done?

Jayashree Shetty
  • 1,695
  • 2
  • 11
  • 8

1 Answers1

0

You can use status:

>>> changes = client.status(rev=[start, end], modified=True, added=True)
>>> len(changes)
6

I've now found you can also do:

>>> changes = client.status(change=[start, end])
>>> len(changes)
6
Community
  • 1
  • 1
Peter Wood
  • 23,859
  • 5
  • 60
  • 99
  • @JayashreeShetty You're welcome. You can upvote and accept the answer if nothing better comes along (c: – Peter Wood Sep 02 '15 at 07:42
  • i have done that. `code` for data1 in client1.log("date('>2015-09-01') and date('<2015-09-01')"): print data1.rev,len(client1.status(rev=data1.rev,added=True)) is this the correct way , i need to pass the revision and get the filecounts for each revision – Jayashree Shetty Sep 02 '15 at 07:55
  • Looks correct. Does it give you the results you expect? – Peter Wood Sep 02 '15 at 08:04
  • if i straight away use `code` len(client1.status(rev=data1.rev,added=True) it gives 136 as count. But if i loop it using the client1.log loop like i have mentioned above it prints some 14,000 for each revision. I do not have that many files. for each revision it should have printed no. of files that were added. but its doing something else when i use with for loop. – Jayashree Shetty Sep 02 '15 at 08:08
  • also i tried this `code` changes = client1.status(rev=["date('2015-09-01')", "date('2015-09-02')"], modified=True, added=True) print len(changes). gives some 25 records which is fine i think. but in case we give revision instead of date then we get some unexpected result – Jayashree Shetty Sep 02 '15 at 08:15
  • I don't know. I've not used `hglib` before starting to answer your question (c: I think if you only supply one rev it will take the difference between the head and the rev. If you want to take changes between each rev you will need to specify the two revs. – Peter Wood Sep 02 '15 at 08:22
  • sorry that was by mistake i didnt realize posting it. i have deleted it though – Jayashree Shetty Sep 02 '15 at 08:37