Commits

Steve Losh committed d3a05d9

Checkpointing for tonight.

Comments (0)

Files changed (2)

 
 python manage.py syncdb
 
-python manage.py runserver_plus --adminmedia=`pwd`/media/admin
+python manage.py runserver_plus --adminmedia=`pwd`/media/admin
+
+
+What I Need from Jesper
+-----------------------
+
+* Changeset parents in the changeset API.
+* A way to get all the forks of a repository.

mercurial_data/bitbucket/scrape.py

 import settings
 setup_environ(settings)
 
-import sys, urllib2
+import datetime, sys, urllib2
 try:
     import simplejson as json
 except ImportError:
     repo.description = repo_data['description']
     repo.save()
     
-    cset_url = 'http://api.bitbucket.org/1.0/repositories/%s/%s/changesets/' % (repo.user_name, repo.repo_name)
-    cset_data = json.loads(urllib2.urlopen(cset_url).read())
-    for cset in cset_data['changesets']:
-        if Changeset.objects.filter(repo=repo, cset_hash=cset['node']).count() == 0:
+    csets_url = 'http://api.bitbucket.org/1.0/repositories/%s/%s/changesets/' % (repo.user_name, repo.repo_name)
+    csets_data = json.loads(urllib2.urlopen(csets_url).read())
+    for cset in csets_data['changesets']:
+        if Changeset.objects.filter(repo=repo, cset_hash=cset['node'], cset_parent__isnull=False).count() == 0:
             c = Changeset(repo=repo, cset_hash=cset['node'], cset_parent=None,
-                cset_author=None, cset_date=None, cset_message=cset['message'])
-            print cset['author']
+                cset_author=cset['author'], cset_date=None, cset_message=cset['message'])
+            cset_url = 'http://api.bitbucket.org/1.0/repositories/%s/%s/changesets/%s/' % (repo.user_name, repo.repo_name, cset['node'])
+            cset_data = json.loads(urllib2.urlopen(cset_url).read())
+            c.cset_date = datetime.datetime.strptime(cset_data['timestamp'], '%Y-%m-%d %H:%M:%S')
+            print cset_data['timestamp'], c.cset_date