Commits

Steve Borho committed 60b9b8b

filedata: normalize add/rename checks for binary files (fixes #1152)

Comments (0)

Files changed (1)

tortoisehg/hgqt/filedata.py

         except (EnvironmentError, error.LookupError), e:
             self.error = hglib.tounicode(str(e))
 
-    def checkMaxDiff(self, ctx, wfile, maxdiff=None):
+    def checkMaxDiff(self, ctx, wfile, maxdiff, status):
         p = _('File or diffs not displayed: ')
         try:
             fctx = ctx.filectx(wfile)
         try:
             data = fctx.data()
             if '\0' in data:
-                self.error = p + _('File is binary.\n')
+                self.error = p + _('File is binary')
+                if status != 'A':
+                    return None
+
+                renamed = fctx.renamed()
+                if renamed:
+                    oldname, node = renamed
+                    fr = hglib.tounicode(oldname)
+                    self.flabel += _(' <i>(renamed from %s)</i>') % fr
+                else:
+                    self.flabel += _(' <i>(was added)</i>')
+
                 return None
         except (EnvironmentError, util.Abort), e:
             self.error = p + hglib.tounicode(str(e))
             return
 
         if status in ('M', 'A'):
-            res = self.checkMaxDiff(ctx, wfile, maxdiff)
+            res = self.checkMaxDiff(ctx, wfile, maxdiff, status)
             if res is None:
-                if status == 'A':
-                    self.flabel += _(' <i>(was added)</i>')
                 return
             fctx, newdata = res
             self.contents = newdata