Commits

Daniel Cosser committed 8171e3f

Rewritten the code that works out the status of each file, based on a look at the Mercurial source. Also, "label" the output so extensions such as color can apply formatting.

  • Participants
  • Parent commits cbb7b4d

Comments (0)

Files changed (1)

 		# Output the list of files, prefixed by their status
 		o.writeln("The following files will be submitted in this commit:")
 		o.writeln()
-		stats = dict(map(lambda x,y:(x,y), ('M','A','R','D','U','I','C'), repo[None].status(clean=True)))
-		for f in repo[kwargs['node']].files():
-			for k,v in stats.items():
-				if f in v:
-					o.writeln('%s: %s' % (k, f))
-					break
+
+		# Map the files in the working directory to statuses
+		states = 'modified added removed deleted unknown ignored clean'.split()
+		chars = 'MAR!?IC'
+		changes = zip(states, chars, repo.status())
+
+		# Restrict the list to files in the changeset to be committed
+		for state, char, files in changes:
+			for f in files:
+				if f in repo[kwargs['node']].files():
+					o.writeln('%s: %s' % (char, f), label='status.'+state)
 
 		o.end_box()
 
 			self.ui.status(self.char + (' ' * (self.width - 2)) + self.char + self.nl)
 		self.ui.status(self.char * self.width + self.nl)
 
-	def writeln(self, msg=''):
+	def writeln(self, msg='', label=''):
 		if self.box:
 				def _write(msg):
-					self.ui.status(self.char + (' ' * self.side_padding) + msg + (' ' * (self.maxlinelength - len(msg) + self.side_padding))  + self.char + self.nl)
+					self.ui.status(self.char + (' ' * self.side_padding) + msg + (' ' * (self.maxlinelength - len(msg) + self.side_padding))  + self.char + self.nl, label=label)
 
 				# Special case a blank line
 				if not msg: