Commits

Ian Lewis committed ad160be

Fixed the lastchange property on the Repository model.

  • Participants
  • Parent commits d191ea9

Comments (0)

Files changed (3)

File hgwebproxy/api.py

     'create_repository',
     'clone_repository',
     'delete_repository',
-    'get_last_changeset',
     'get_changeset_info',
     'is_template',
 )
         import shutil
         shutil.rmtree(location)
 
-def get_last_changeset(repo):
-    """
-    Returns a dictionary with information about 
-    TODO: Get the last changeset info
-    """
-    return get_changeset_info(repo, 'tip')
-
-def get_changeset_info(repo, changeset):
+def get_changeset_info(location, changeset):
     """
     TODO: Get info in a dictionary about a specific changeset
     """
-    repo = hg.repository(setup_ui(), repo)
-    ctx = repo[changeset]
-    return {
-        'changeset': display_rev(ctx),
-        'branch': ctx.branch(),
-        'tags': ctx.tags(),
-        'parents': [display_rev(p) for p in ctx.parents()],
-        'user': ctx.user(),
-        'date': datestr(ctx.date()),
-        'summary': ctx.description().splitlines()[0],
-    }
+    repo = hg.repository(setup_ui(), location)
+    if changeset in repo:
+        ctx = repo[changeset]
+        return {
+            'changeset': display_rev(ctx),
+            'branch': ctx.branch(),
+            'tags': ctx.tags(),
+            'parents': [display_rev(p) for p in ctx.parents()],
+            'user': ctx.user(),
+            'date': datestr(ctx.date()),
+            'summary': ctx.description(),
+        }
+    else:
+        return None
 
 def is_template(template):
     #TODO: Load project mercurial styles

File hgwebproxy/models.py

         current_site = Site.objects.get_current()
         return 'http://%s%s' % (current_site.domain, self.get_absolute_url())
 
+    @property
+    def lastchange(self):
+        tip_info = get_changeset_info(self.location, 'tip')
+        if tip_info:
+            return tip_info['date']
+        else:
+            return None
 
     class Meta:
         verbose_name = _('repository')

File hgwebproxy/templates/hgwebproxy/repo_all.html

             <p>{{repo.description}}<p>
             <p>{% trans 'Clone url' %} : <a href="{{repo.get_absolute_url}}" title="{{repo.name}}">{{repo.get_clone_url}}</a>
         </td>
-        <td>{{repo.lastchange}}</td>
+        <td>{{repo.lastchange|default:"n/a"}}</td>
         <td>
             <div class="rss_logo">
             <a href="{{repo.get_absolute_url}}rss-log">RSS</a>