Commits

Marcin Kuzminski committed feb0fcc

fixed vcs issue with last_changeset for filenodes
- fixed incosistency for displaying revision in file browser
- fixed raw_diff for git for single file mode
- file block now uses associated changeset for both git&hg

  • Participants
  • Parent commits 6011513

Comments (0)

Files changed (9)

File rhodecode/controllers/changeset.py

                                                 format='gitdiff').raw_diff()
 
                 cs1 = None
-                cs2 = node.last_changeset.raw_id
+                cs2 = node.changeset.raw_id
                 c.changes.append(('added', node, diff, cs1, cs2))
 
             for node in c.changeset.changed:
                     diff = diffs.DiffProcessor(f_gitdiff,
                                                 format='gitdiff').raw_diff()
 
-                cs1 = filenode_old.last_changeset.raw_id
-                cs2 = node.last_changeset.raw_id
+                cs1 = filenode_old.changeset.raw_id
+                cs2 = node.changeset.raw_id
                 c.changes.append(('changed', node, diff, cs1, cs2))
 
         response.content_type = 'text/plain'

File rhodecode/lib/diffs.py

     if not diff:
         diff = wrap_to_table(_('No changes detected'))
 
-    cs1 = filenode_old.last_changeset.raw_id
-    cs2 = filenode_new.last_changeset.raw_id
+    cs1 = filenode_old.changeset.raw_id
+    cs2 = filenode_new.changeset.raw_id
 
     return size, cs1, cs2, diff, stats
 

File rhodecode/lib/vcs/backends/hg/changeset.py

         """
         Returns last commit of the file at the given ``path``.
         """
-        fctx = self._get_filectx(path)
-        changeset = self.repository.get_changeset(fctx.linkrev())
-        return changeset
+        node = self.get_node(path)
+        return node.history[0]
 
     def get_file_history(self, path):
         """

File rhodecode/lib/vcs/nodes.py

         attribute to indicate that type should *NOT* be calculated).
         """
         if hasattr(self, '_mimetype'):
-            if (isinstance(self._mimetype,(tuple,list,)) and
+            if (isinstance(self._mimetype, (tuple, list,)) and
                 len(self._mimetype) == 2):
                 return self._mimetype
             else:
                 raise NodeError('given _mimetype attribute must be an 2 '
                                'element list or tuple')
 
-        mtype,encoding = mimetypes.guess_type(self.name)
+        mtype, encoding = mimetypes.guess_type(self.name)
 
         if mtype is None:
             if self.is_binary:
             else:
                 mtype = 'text/plain'
                 encoding = None
-        return mtype,encoding
+        return mtype, encoding
 
     @LazyProperty
     def mimetype(self):
         """
         Returns True if file has binary content.
         """
-        bin = '\0' in self.content
-        return bin
+        _bin = '\0' in self.content
+        return _bin
 
     @LazyProperty
     def extension(self):
         """
         return bool(self.mode & stat.S_IXUSR)
 
+    def __repr__(self):
+        return '<%s %r @ %s>' % (self.__class__.__name__, self.path,
+                                 self.changeset.short_id)
+
 
 class RemovedFileNode(FileNode):
     """
 
         return size
 
+    def __repr__(self):
+        return '<%s %r @ %s>' % (self.__class__.__name__, self.path,
+                                 self.changeset.short_id)
+
 
 class RootNode(DirNode):
     """

File rhodecode/lib/vcs/utils/diffs.py

 from rhodecode.lib.vcs.nodes import FileNode, NodeError
 
 
-def get_udiff(filenode_old, filenode_new,show_whitespace=True):
+def get_udiff(filenode_old, filenode_new, show_whitespace=True):
     """
     Returns unified diff between given ``filenode_old`` and ``filenode_new``.
     """
     try:
-        filenode_old_date = filenode_old.last_changeset.date
+        filenode_old_date = filenode_old.changeset.date
     except NodeError:
         filenode_old_date = None
 
     try:
-        filenode_new_date = filenode_new.last_changeset.date
+        filenode_new_date = filenode_new.changeset.date
     except NodeError:
         filenode_new_date = None
 

File rhodecode/templates/files/files_annotate.html

 			    <dd>
 			        <div>
 			        ${h.form(h.url('files_diff_home',repo_name=c.repo_name,f_path=c.f_path),method='get')}
-			        ${h.hidden('diff2',c.file.last_changeset.raw_id)}
-			        ${h.select('diff1',c.file.last_changeset.raw_id,c.file_history)}
+			        ${h.hidden('diff2',c.file.changeset.raw_id)}
+			        ${h.select('diff1',c.file.changeset.raw_id,c.file_history)}
 			        ${h.submit('diff','diff to revision',class_="ui-btn")}
 			        ${h.submit('show_rev','show at revision',class_="ui-btn")}
 			        ${h.end_form()}
                 <div class="code-header">
                     <div class="stats">
                         <div class="left"><img src="${h.url('/images/icons/file.png')}"/></div>
-                        <div class="left item">${h.link_to("r%s:%s" % (c.file.last_changeset.revision,h.short_id(c.file.last_changeset.raw_id)),h.url('changeset_home',repo_name=c.repo_name,revision=c.file.last_changeset.raw_id))}</div>
+                        <div class="left item">${h.link_to("r%s:%s" % (c.file.changeset.revision,h.short_id(c.file.changeset.raw_id)),h.url('changeset_home',repo_name=c.repo_name,revision=c.file.changeset.raw_id))}</div>
                         <div class="left item">${h.format_byte_size(c.file.size,binary=True)}</div>
                         <div class="left item last">${c.file.mimetype}</div>
                         <div class="buttons">

File rhodecode/templates/files/files_browser.html

 		                 <th>${_('Name')}</th>
 		                 <th>${_('Size')}</th>
 		                 <th>${_('Mimetype')}</th>
-		                 <th>${_('Revision')}</th>
+		                 <th>${_('Last Revision')}</th>
 		                 <th>${_('Last modified')}</th>
 		                 <th>${_('Last commiter')}</th>
 		             </tr>
 		    %for cnt,node in enumerate(c.file):
 				<tr class="parity${cnt%2}">
 		             <td>
-						${h.link_to(node.name,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=h.safe_unicode(node.path)),class_=file_class(node)+" ypjax-link")}
+                        ${h.link_to(node.name,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=h.safe_unicode(node.path)),class_=file_class(node)+" ypjax-link")}
 		             </td>
 		             <td>
 		             %if node.is_file():

File rhodecode/templates/files/files_edit.html

             <div class="code-header">
                 <div class="stats">
                     <div class="left"><img src="${h.url('/images/icons/file.png')}"/></div>
-                    <div class="left item">${h.link_to("r%s:%s" % (c.file.last_changeset.revision,h.short_id(c.file.last_changeset.raw_id)),h.url('changeset_home',repo_name=c.repo_name,revision=c.file.last_changeset.raw_id))}</div>
+                    <div class="left item">${h.link_to("r%s:%s" % (c.file.changeset.revision,h.short_id(c.file.changeset.raw_id)),h.url('changeset_home',repo_name=c.repo_name,revision=c.file.changeset.raw_id))}</div>
                     <div class="left item">${h.format_byte_size(c.file.size,binary=True)}</div>
                     <div class="left item last">${c.file.mimetype}</div>
                     <div class="buttons">

File rhodecode/templates/files/files_source.html

 	<dd>
 		<div>
 		${h.form(h.url('files_diff_home',repo_name=c.repo_name,f_path=c.f_path),method='get')}
-		${h.hidden('diff2',c.file.last_changeset.raw_id)}
-		${h.select('diff1',c.file.last_changeset.raw_id,c.file_history)}
+		${h.hidden('diff2',c.file.changeset.raw_id)}
+		${h.select('diff1',c.file.changeset.raw_id,c.file_history)}
 		${h.submit('diff','diff to revision',class_="ui-btn")}
 		${h.submit('show_rev','show at revision',class_="ui-btn")}
 		${h.end_form()}
 	<div class="code-header">
         <div class="stats">
             <div class="left img"><img src="${h.url('/images/icons/file.png')}"/></div>
-            <div class="left item"><pre>${h.link_to("r%s:%s" % (c.file.last_changeset.revision,h.short_id(c.file.last_changeset.raw_id)),h.url('changeset_home',repo_name=c.repo_name,revision=c.file.last_changeset.raw_id))}</pre></div>
+            <div class="left item"><pre>${h.link_to("r%s:%s" % (c.file.changeset.revision,h.short_id(c.file.changeset.raw_id)),h.url('changeset_home',repo_name=c.repo_name,revision=c.file.changeset.raw_id))}</pre></div>
             <div class="left item"><pre>${h.format_byte_size(c.file.size,binary=True)}</pre></div>
             <div class="left item last"><pre>${c.file.mimetype}</pre></div>
             <div class="buttons">
-              ${h.link_to(_('show annotation'),h.url('files_annotate_home',repo_name=c.repo_name,revision=c.file.last_changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
-              ${h.link_to(_('show as raw'),h.url('files_raw_home',repo_name=c.repo_name,revision=c.file.last_changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
-              ${h.link_to(_('download as raw'),h.url('files_rawfile_home',repo_name=c.repo_name,revision=c.file.last_changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
+              ${h.link_to(_('show annotation'),h.url('files_annotate_home',repo_name=c.repo_name,revision=c.file.changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
+              ${h.link_to(_('show as raw'),h.url('files_raw_home',repo_name=c.repo_name,revision=c.file.changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
+              ${h.link_to(_('download as raw'),h.url('files_rawfile_home',repo_name=c.repo_name,revision=c.file.changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
               % if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name):
                % if not c.file.is_binary:
-                ${h.link_to(_('edit'),h.url('files_edit_home',repo_name=c.repo_name,revision=c.file.last_changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
+                ${h.link_to(_('edit'),h.url('files_edit_home',repo_name=c.repo_name,revision=c.file.changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
                % endif
               % endif
             </div>
         </div>
         <div class="author">
             <div class="gravatar">
-                <img alt="gravatar" src="${h.gravatar_url(h.email(c.file.last_changeset.author),16)}"/>
+                <img alt="gravatar" src="${h.gravatar_url(h.email(c.file.changeset.author),16)}"/>
             </div>
-            <div title="${c.file.last_changeset.author}" class="user">${h.person(c.file.last_changeset.author)}</div>
+            <div title="${c.file.changeset.author}" class="user">${h.person(c.file.changeset.author)}</div>
         </div>
-		<div class="commit">${h.urlify_commit(c.file.last_changeset.message,c.repo_name)}</div>
+		<div class="commit">${h.urlify_commit(c.file.changeset.message,c.repo_name)}</div>
 	</div>
 	<div class="code-body">
 	   %if c.file.is_binary:
 			${h.pygmentize(c.file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")}
 		%else:
 			${_('File is too big to display')} ${h.link_to(_('show as raw'),
-			h.url('files_raw_home',repo_name=c.repo_name,revision=c.file.last_changeset.raw_id,f_path=c.f_path))}
+			h.url('files_raw_home',repo_name=c.repo_name,revision=c.file.changeset.raw_id,f_path=c.f_path))}
 		%endif
        <script type="text/javascript">
            function highlight_lines(lines){