Commits

Steve Borho committed 3b3ea8a

nautilus: show file's last commit info in property page

Comments (0)

Files changed (1)

contrib/nautilus-thg.py

 import subprocess
 import sys
 import tempfile
+import time
 import urllib
 
 TORTOISEHG_PATH = '~/tools/tortoisehg-dev'
         emblem, status = self._get_file_status(repo, localpath)
 
         # Get the information from Mercurial
-        ctx = repo.changectx()
-        rev = ctx.rev()
+        ctx = repo.workingctx().parents()[0]
+        try:
+            fctx = ctx.filectx(localpath)
+            rev = fctx.filelog().linkrev(fctx.filenode())
+        except:
+            rev = ctx.rev()
+        ctx = repo.changectx(rev)
         node = short(ctx.node())
+        date = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(ctx.date()[0]))
         parents = '\n'.join([short(p.node()) for p in ctx.parents()])
         description = ctx.description()
         user = ctx.user()
 
         self.property_label = gtk.Label('Mercurial')
 
-        table = gtk.Table(5, 2, False)
+        table = gtk.Table(7, 2, False)
         table.set_border_width(5)
         table.set_row_spacings(5)
         table.set_col_spacings(5)
 
         self.__add_row(table, 0, '<b>Status</b>:', status)
-        self.__add_row(table, 1, '<b>Revision</b>:', str(rev))
-        self.__add_row(table, 2, '<b>Description</b>:', description)
-        self.__add_row(table, 3, '<b>Tags</b>:', tags)
-        self.__add_row(table, 4, '<b>Node</b>:', node)
-        self.__add_row(table, 5, '<b>Parents</b>:', parents)
-        self.__add_row(table, 6, '<b>User</b>:', user)
-        self.__add_row(table, 7, '<b>Branch</b>:', branch)
+        self.__add_row(table, 1, '<b>Last-Commit-Revision</b>:', str(rev))
+        self.__add_row(table, 2, '<b>Last-Commit-Description</b>:', description)
+        self.__add_row(table, 3, '<b>Last-Commit-Date</b>:', date)
+        self.__add_row(table, 4, '<b>Last-Commit-User</b>:', user)
+        if tags:
+            self.__add_row(table, 5, '<b>Tags</b>:', tags)
+        if branch != 'default':
+            self.__add_row(table, 6, '<b>Branch</b>:', branch)
 
         table.show()
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.