# HG changeset patch
# User Arne Babenhauserheide
# Date 1235829885 -3600
# Node ID 35f8d279bd706d26e7c230433d2aebff670c8aca
# Parent cea1ca632c0489a637a99b1b3abd3de1c16eaa27# Parent 15424b1a24a518ca669b9c8b9e20722a790fb3fe
merge
diff -r cea1ca632c04 -r 35f8d279bd70 hgscm/apps/www/models.py
--- a/hgscm/apps/www/models.py Wed Feb 18 11:09:23 2009 +0100
+++ b/hgscm/apps/www/models.py Sat Feb 28 15:04:45 2009 +0100
@@ -1,3 +1,36 @@
from django.db import models
+from django.utils import simplejson
+from django.conf import settings
+import os, re
-# Create your models here.
+def get_download(platform, version):
+ '''get the download for the right version'''
+ f = open(os.path.join(settings.MEDIA_ROOT, "downloads.json"))
+ list = simplejson.load(f)
+ f.close()
+ latest = version == 'latest' or not version
+ for entry in list:
+ if (latest and entry['latest'] == 'true') or entry['version'] == version:
+ for version in entry['versions']:
+ if version['identifier'] == platform:
+ return version
+def get_download_for_agent(agent, version):
+ '''get the download for the right version'''
+ f = open(os.path.join(settings.MEDIA_ROOT, "downloads.json"))
+ list = simplejson.load(f)
+ f.close()
+ latest = version == 'latest' or not version
+ for entry in list:
+ if (latest and entry['latest'] == 'true') or entry['version'] == version:
+ for version in entry['versions']:
+ if re.search(version['system'], agent):
+ return version
+
+def get_latest_version():
+ '''return the latest available version'''
+ f = open(os.path.join(settings.MEDIA_ROOT, "downloads.json"))
+ list = simplejson.load(f)
+ f.close()
+ for entry in list:
+ if entry['latest'] == 'true':
+ return entry['version']
diff -r cea1ca632c04 -r 35f8d279bd70 hgscm/apps/www/templatetags/__init__.py
diff -r cea1ca632c04 -r 35f8d279bd70 hgscm/apps/www/templatetags/extras.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hgscm/apps/www/templatetags/extras.py Sat Feb 28 15:04:45 2009 +0100
@@ -0,0 +1,48 @@
+from django import template
+from django.conf import settings
+from django.template import Context
+from hgscm.apps.www.models import get_latest_version, get_download_for_agent, get_download
+import random, os, re
+
+register = template.Library()
+
+class MercurialTricksNode(template.Node):
+ def __init__(self):
+ self._filename = self._random()
+
+ def _random(self):
+ file = random.choice(os.listdir(settings.MERCURIAL_TRICKS))
+ return os.path.join(settings.MERCURIAL_TRICKS, file)
+
+ def render(self, context):
+ f = open(self._filename)
+ result = "
Mercurial is used for version control of files. Similar projects include git, Bazaar, Subversion and CVS.
+
Mercurial is used for version control of files. Similar projects include Git and Bazaar, and other version control systems without a distributed architecture include Subversion and CVS.