1. Arne Babenhauserheide
  2. fungus

Commits

Arne Babenhauserheide  committed 828b714

Added swarms for hg repos.

  • Participants
  • Parent commits 5544493
  • Branches default

Comments (0)

Files changed (1)

File code_swarm.py

View file
 SAFE_CIRCLE_FILL = 0.6
 
 #: The number of frames for which a file is being associated to an author after an edit.
-TIME_OF_PARTNERSHIP = 30
+TIME_OF_PARTNERSHIP = 60
 
 #: The time a partner is considered active
 TIME_OF_PARTNER_ACTIVITY = 10
 INACTIVITY_OPACITY_REDUCTION = 100
 
 #: How much teh blobs should fade out per frame
-OPACITY_REDUCTION_PER_FRAME = 2
+OPACITY_REDUCTION_PER_FRAME = 3
 
 #### Imports ####
 
 	
 	# Store the data
 	self._data = data
-	
+
+    def read_hg_log(self, path_to_repo, time_to_play = 180):
+        """Read the log directly from a hg repo. Requires Mercurial."""
+        from mercurial import ui, hg
+        repo = hg.repository(ui.ui(), path_to_repo)
+        data = []
+        rev = 0
+        while repo[rev] != repo["tip"]:
+            if not rev%1000: print rev
+            ctx = repo[rev]
+            date = ctx.date()
+            date = date[0] + date[1]
+            # user without email host
+            user = ctx.user().split("@")[0]
+            for f in ctx.files():
+                data.append((date, user, f))
+            rev += 1
+
+        self._data = self.clean_data(data, time_to_play)
+        
 	
     def read_maildir(self, path, time_to_play = 180): 
 	"""Read the data from all mails in a maildir folder and turn it into a code_swarm.
 		super(Blob, self).__init__(image_path=image_path, *args, **kwds)
 		
 		# Start with very small scale
-		self.scale = 0.1
+		self.scale = 0.01
 	
 	def update(self): 
 		"""Update the Blobs data and position."""
 	    args[0].remove("--activity")
 	    args[0].remove(self.path)
 	
+	if "--mercurial" in args[0]: 
+	    self.swarm_type = "mercurial"
+	    self.path = args[0][args[0].index("--mercurial") + 1]
+	    args[0].remove("--mercurial")
+	    args[0].remove(self.path)
+	
 	while "--track" in args[0]: 
 	    track = args[0][args[0].index("--track") + 1]
 	    args[0].remove("--track")
 	    self.feeder = Feeder(track=self.track)
 	    # add the actitivity file to the data
 	    self.feeder.read_codeswarm_activity(self.path, time_to_play = self.time)
+	elif self.swarm_type == "mercurial": 
+	    self.feeder = Feeder(track=self.track)
+	    # add the actitivity file to the data
+	    self.feeder.read_hg_log(self.path, time_to_play = self.time)
         elif self.swarm_type == "identica":
             identica = "http://identi.ca/api/statuses/public_timeline.xml"
             self.feeder = IdenticaFeeder(url = identica, time_to_play = self.time, scene = self)
         """Get and process new change data."""
         try: 
             data = self.feeder.data
-            print data
         except:
-            print "can't get data"
             return
 	
 	for date, author_name, filename in data: