Source

jsudiff / test.html

Full commit
<html>
  <head>
    <title>Test for JSUDiff</title>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
    <script type="text/javascript" src="jsudiff.js"></script>

    <script type="text/javascript">
      $(document).ready(function() {
        $('.jsudiff').highlight_udiff(null, 'span');
      });
    </script>
    <style type="text/css">
      span {
          white-space: pre;
          font-family: monospace;
      }

      ins {
        background-color: #afa;
      }

      del {
        background-color: #faa;
      }

      .line-added {
         background-color: #dfd;
      }

      .line-removed {
         background-color: #fdd;
      }

      .line-context {
         background-color: #dde7ef;
      }

      ins, del { text-decoration: none };
    </style>
  </head>

  <h3>first file</h3>

<span class="jsudiff">--- a/apps/account/auth.py
+++ b/apps/account/auth.py
@@ -29,4 +29,13 @@
                 return user
 
         else:
-            return super(EmailBackend, self).authenticate(username, password)
+            try:
+                try:
+                    user = User.objects.get(username__iexact=username)
+                except User.MultipleObjectsReturned:
+                    user = User.objects.get(username=username)
+            except User.DoesNotExist:
+                return None
+
+            if user.check_password(password):
+                return user
</span>

<h3>compare file</h3>

<span class="jsudiff">--- a/apps/api/v10/handlers.py
+++ b/apps/api/v10/handlers.py
@@ -25,6 +25,7 @@ from bitbucket.apps.invitations.models i
 
 from bitbucket.apps.api.v10 import forms
 from bitbucket.apps.api.v10.decorators import commit_on_200
+from bitbucket.apps.api.v10.helpers import user_dict
 from bitbucket.apps.bb.api import adjust_api_url
 from bitbucket.apps.api.v10.shortcuts import get_user_or_404
 from bitbucket.apps.bb.privileges import PrivilegeManager
@@ -262,11 +263,9 @@ class RepositoryPrivileges(BaseHandler):
     @staticmethod
     def privs_for_repo(repo, target_user=None, action=RepoPerm.CAN_READ):
         to_priv_record = lambda repo, user, priv_level: {
-            u&#39;user&#39;: {&#39;username&#39;: user.username,
-                      &#39;first_name&#39;: user.first_name,
-                      &#39;last_name&#39;: user.last_name},
+            u&#39;user&#39;: user_dict(user),
             u&#39;repo&#39;: u&#39;%s/%s&#39; % (repo.owner, repo.slug),
-            u&#39;privilege&#39;: RepositoryPrivileges.role[priv_level]
+            u&#39;privilege&#39;: RepositoryPrivileges.role[priv_level],
         }
 
         if target_user:
@@ -436,17 +435,18 @@ class GroupPrivileges(BaseHandler):
     @staticmethod
     def privs_for_group(repo, group=None, action=RepoPerm.CAN_READ):
         to_priv_record = lambda repo, group, priv_level: {
-            u&#39;group&#39;: {&#39;name&#39;: group.name,
-                       &#39;owner&#39;: {&#39;username&#39;: group.user.username,
-                                 &#39;first_name&#39;: group.user.first_name,
-                                 &#39;last_name&#39;: group.user.last_name},
-                       &#39;members&#39;: [{&#39;first_name&#39;: m.first_name,
-                                    &#39;last_name&#39;: m.last_name,
-                                    &#39;username&#39;: m.username}
-                                   for m in group.members.all()]
+            u&#39;group&#39;: {
+                &#39;name&#39;: group.name,
+                &#39;owner&#39;: user_dict(group.user),
+                &#39;members&#39;: [user_dict(m) for m in group.members.all()],
             },
             u&#39;repo&#39;: u&#39;%s/%s&#39; % (repo.owner, repo.slug),
-            u&#39;privilege&#39;: RepositoryPrivileges.role[priv_level]
+            u&#39;repository&#39;: {
+                &#39;name&#39;: repo.name,
+                &#39;slug&#39;: repo.slug,
+                &#39;owner&#39;: user_dict(repo.owner),
+            },
+            u&#39;privilege&#39;: RepositoryPrivileges.role[priv_level],
         }
 
         if group:
</span>

  <span class="jsudiff">--- a/apps/bb/templatetags/bb.py
+++ b/apps/bb/templatetags/bb.py
@@ -30,6 +30,7 @@
                         'http://please.set.settings.API_CANON_URL')
 
 RE = {'changeset_id': re.compile(r'\b[\da-f]{12}\b'),
+      'leading_tabs': re.compile(r'^\t+', re.MULTILINE),
       'paragraph_break': re.compile(r'(?:[ \t]*(?:\r\n?|\n)){2,}'),
       'quoted': re.compile(r'''^("|')(?P<view_name>.+)\1$''')}
 
@@ -127,12 +128,8 @@
     return list_
 
 @register.filter
-def expandtabs(text, spaces=4):
-    try:
-        spaces = int(spaces)
-    except (TypeError, ValueError):
-        pass
-    return text.expandtabs(spaces)
+def replace_leading_tabs(text, spaces=4):
+    return re.sub(RE['leading_tabs'], ' ' * int(spaces), text)
 
 @register.filter
 @stringfilter
</span>

<h3>second file</h3>
<span class="jsudiff">--- a/apps/bb/views.py
+++ b/apps/bb/views.py
@@ -537,7 +537,7 @@ def committer_mapping(request, username,
         repo.last_updated = datetime.now()
         repo.save()
 
-    if repo.has_admin(request.user):
+    if not repo.has_admin(request.user):
         raise exceptions.GenericRepoException, "You're not the administrator of this repository."
 
     elif request.method =='PUT':
</span>

<h3>third file</h3>

<span class="jsudiff">--- a/apps/api/v10/handlers.py
+++ b/apps/api/v10/handlers.py
@@ -743,6 +743,10 @@
 
         member = get_user_or_404(member_name)
 
+        # You can&#39;t add yourself to a group
+        if member == user:
+            return rc.BAD_REQUEST
+
         if group.members.filter(pk=member.pk).exists():
             return rc.DUPLICATE_ENTRY
 
</span>

<h4>fourth file</h4>

<span class="jsudiff">--- a/apps/bb/templatetags/bb.py
+++ b/apps/bb/templatetags/bb.py
@@ -30,6 +30,7 @@
                         &#39;http://please.set.settings.API_CANON_URL&#39;)
 
 RE = {&#39;changeset_id&#39;: re.compile(r&#39;\b[\da-f]{12}\b&#39;),
+      &#39;leading_tabs&#39;: re.compile(r&#39;^\t+&#39;, re.MULTILINE),
       &#39;paragraph_break&#39;: re.compile(r&#39;(?:[ \t]*(?:\r\n?|\n)){2,}&#39;),
       &#39;quoted&#39;: re.compile(r&#39;&#39;&#39;^(&quot;|&#39;)(?P&lt;view_name&gt;.+)\1$&#39;&#39;&#39;)}
 
@@ -127,12 +128,8 @@
     return list_
 
 @register.filter
-def expandtabs(text, spaces=4):
-    try:
-        spaces = int(spaces)
-    except (TypeError, ValueError):
-        pass
-    return text.expandtabs(spaces)
+def replace_leading_tabs(text, spaces=4):
+    return re.sub(RE[&#39;leading_tabs&#39;], &#39; &#39; * int(spaces), text)
 
 @register.filter
 @stringfilter
@@ -187,6 +184,7 @@
         try:
             url = str(super(CNAMEURLNode, self).render(context))
         except Exception:
+            raise
             # NoReverseMatch? Fucking hell.
             return &#39;#nrm&#39;
 
</span> 

<h4>fifth file</h4>
<span class="jsudiff">--- a/templates/reps/list_file.html
+++ b/templates/reps/list_file.html
@@ -81,7 +81,7 @@
 	{% else %}
 		&lt;div class=&quot;scroll-x&quot;&gt;
 		{% if should_highlight %}
-			{% stylize repository file %}{% autoescape off %}{{ data|expandtabs:repository.indent_spaces }}
+			{% stylize repository file %}{% autoescape off %}{{ data|replace_leading_tabs:repository.indent_spaces }}
 		{% else %}
 			{% voidstylize repository %}{{ data }}{% endvoidstylize %}
 		{% endif %}
</span> 
  
</html>