diff -r 96be80af9ad3 new_group_format.diff
--- a/new_group_format.diff	Mon Dec 19 01:58:15 2011 +0100
+++ b/new_group_format.diff	Mon Dec 19 21:20:46 2011 +0100
@@ -1,9 +1,19 @@
 # HG changeset patch
+<<<<<<< local
+# Parent b1ec7437ed7921621ca8c4f387a3082fc8f166a4
+=======
 # Parent 2596727274ce6b710d5e329611545ac40293c357
+>>>>>>> other
 
+<<<<<<< local
+diff -r b1ec7437ed79 trac/ticket/query.py
+--- a/trac/ticket/query.py	Sun Dec 18 22:25:14 2011 +0100
++++ b/trac/ticket/query.py	Mon Dec 19 08:59:00 2011 +0100
+=======
 diff --git a/trac/ticket/query.py b/trac/ticket/query.py
 --- a/trac/ticket/query.py
 +++ b/trac/ticket/query.py
+>>>>>>> other
 @@ -48,6 +48,29 @@
  from trac.wiki.api import IWikiSyntaxProvider
  from trac.wiki.macros import WikiMacroBase # TODO: should be moved in .api
@@ -52,10 +62,27 @@
          self.format = format
          self.default_page = 1
          self.items_per_page = QueryModule(self.env).items_per_page
+<<<<<<< local
+@@ -134,15 +155,20 @@
+             else:
+                 (self.order, self.desc) = (default_order, self.desc or 0)
+=======
 @@ -135,14 +156,23 @@
          if self.order != 'id' and self.order not in field_names:
              (self.order, self.desc) = ('priority', 0)
+>>>>>>> other
  
+<<<<<<< local
+-        if not self.group or self.group not in field_names:
+-            default_group = QueryModule(self.env).default_group or None
+-            if default_group:
+-                if default_group[0] == '-':
+-                    (self.group, self.groupdesc) = (default_group[1:], 1)
+-                elif default_group[0] == '+':
+-                    (self.group, self.groupdesc) = (default_group[1:], 0)
+-                else:
+-                    self.group = default_group
+=======
 -        self.group = self.group or QueryModule(self.env).default_group
 -        if self.group:
 -            if self.group[0] == '-':
@@ -64,16 +91,25 @@
 -                (self.group, self.groupdesc) = (self.group[1:], 0)
 -        if self.group not in field_names:
 -            (self.group, self.groupdesc) = (None, 0)
+>>>>>>> other
 +        if group == '':
-+            self.group = group
++            self.group = ''
 +        else:
 +            self.group = field_from_string(group)
+<<<<<<< local
++            if self.group and groupdesc is not None: # 0.12 compatibility
+=======
 +            if self.group is not None and groupdesc is not None:
 +                # 0.12 compatibility
+>>>>>>> other
 +                self.group['desc'] = True if groupdesc else False
 +
+<<<<<<< local
++            if not self.group or self.group.get('field') not in field_names:
+=======
 +            if self.group is None or (self.group.get('field') != '' \
 +                            and self.group.get('field') not in field_names):
+>>>>>>> other
 +                default_group = QueryModule(self.env).default_group
 +                if default_group:
 +                    self.group = field_from_string(default_group)
@@ -84,7 +120,11 @@
  
          constraint_cols = {}
          for clause in self.constraints:
+<<<<<<< local
+@@ -282,8 +308,8 @@
+=======
 @@ -282,8 +312,8 @@
+>>>>>>> other
              cols.append(self.order)
  
          # Make sure to not show the column we group on.
@@ -95,17 +135,25 @@
  
          return cols
  
+<<<<<<< local
+@@ -423,8 +449,7 @@
+=======
 @@ -423,8 +453,7 @@
+>>>>>>> other
          return href.query(constraints,
                            report=id,
                            order=order, desc=1 if desc else None,
 -                          group=self.group,
 -                          groupdesc=1 if self.groupdesc else None,
-+                          group=field_to_string(self.group),
++                          group='' if self.group == '' else field_to_string(self.group), # The empty string is an indicator for no group
                            col=cols,
                            row=self.rows,
                            max=max,
+<<<<<<< local
+@@ -450,6 +475,7 @@
+=======
 @@ -450,6 +479,7 @@
+>>>>>>> other
              locale = req.locale
          self.get_columns()
          db = self.env.get_read_db()
@@ -113,7 +161,11 @@
  
          enum_columns = ('resolution', 'priority', 'severity')
          # Build the list of actual columns to query
+<<<<<<< local
+@@ -458,8 +484,8 @@
+=======
 @@ -458,8 +488,8 @@
+>>>>>>> other
              for col in args:
                  if not col in cols:
                      cols.append(col)
@@ -124,7 +176,11 @@
          if self.rows:
              add_cols('reporter', *self.rows)
          add_cols('status', 'priority', 'time', 'changetime', self.order)
+<<<<<<< local
+@@ -483,14 +509,14 @@
+=======
 @@ -483,14 +513,14 @@
+>>>>>>> other
  
          # Join with the enum table for proper sorting
          for col in [c for c in enum_columns
@@ -141,7 +197,11 @@
              sql.append("\n  LEFT OUTER JOIN %s ON (%s.name=%s)"
                         % (col, col, col))
  
+<<<<<<< local
+@@ -642,8 +668,8 @@
+=======
 @@ -642,8 +672,8 @@
+>>>>>>> other
              
          sql.append("\nORDER BY ")
          order_cols = [(self.order, self.desc)]
@@ -152,7 +212,11 @@
  
          for name, desc in order_cols:
              if name in enum_columns:
+<<<<<<< local
+@@ -673,7 +699,7 @@
+=======
 @@ -673,7 +703,7 @@
+>>>>>>> other
                             % (desc, desc, col, desc))
              else:
                  sql.append("%s%s" % (col, desc))
@@ -161,7 +225,11 @@
                  sql.append(",")
          if self.order != 'id':
              sql.append(",t.id")  
+<<<<<<< local
+@@ -771,7 +797,7 @@
+=======
 @@ -771,7 +801,7 @@
+>>>>>>> other
                  elif ticket['changetime'] > orig_time:
                      ticket['changed'] = True
              if self.group:
@@ -170,7 +238,11 @@
                  groups.setdefault(group_key, []).append(ticket)
                  if not groupsequence or group_key not in groupsequence:
                      groupsequence.append(group_key)
+<<<<<<< local
+@@ -930,12 +956,12 @@
+=======
 @@ -930,12 +960,12 @@
+>>>>>>> other
                  constraints = self._get_constraints(arg_list=arg_list)
              else:
                  query = Query.from_string(self.env, qstring)
@@ -187,20 +259,27 @@
                  constraints = query.constraints
  
              # Substitute $USER, or ensure no field constraints that depend
+<<<<<<< local
+@@ -949,6 +975,11 @@
+=======
 @@ -949,6 +979,12 @@
+>>>>>>> other
                              del clause[field]
                              break
  
 +        group = field_from_string(args.get('group'))
-+        if group is not None:
-+            if 'groupdesc' in args:
-+                group['desc'] = True if args.get('groupdesc') else False
-+                args['group'] = field_to_string(group)
++        if group and 'groupdesc' in args:
++            group['desc'] = True if args.get('groupdesc') else False
++            args['group'] = field_to_string(group)
 +        
          cols = args.get('col')
          if isinstance(cols, basestring):
              cols = [cols]
+<<<<<<< local
+@@ -963,13 +994,12 @@
+=======
 @@ -963,13 +999,12 @@
+>>>>>>> other
          max = args.get('max')
          if max is None and format in ('csv', 'tab'):
              max = 0 # unlimited unless specified explicitly
@@ -220,7 +299,11 @@
  
          if 'update' in req.args:
              # Reset session vars
+<<<<<<< local
+@@ -1423,18 +1453,18 @@
+=======
 @@ -1423,18 +1458,18 @@
+>>>>>>> other
  
          def ticket_groups():
              groups = []
@@ -243,7 +326,11 @@
                  q.order = order
                  href = q.get_href(formatter.context)
                  groups.append((v, [t for t in g], href, title))
+<<<<<<< local
+@@ -1456,7 +1486,7 @@
+=======
 @@ -1456,7 +1491,7 @@
+>>>>>>> other
                      [(tag.p(tag_('%(groupvalue)s %(groupname)s tickets:',
                                   groupvalue=tag.a(v, href=href, class_='query',
                                                    title=title),
@@ -252,9 +339,15 @@
                        tag.dl([(tag.dt(ticket_anchor(t)),
                                 tag.dd(t['summary'])) for t in g],
                               class_='wiki compact'))
+<<<<<<< local
+diff -r b1ec7437ed79 trac/ticket/templates/query.html
+--- a/trac/ticket/templates/query.html	Sun Dec 18 22:25:14 2011 +0100
++++ b/trac/ticket/templates/query.html	Mon Dec 19 08:59:00 2011 +0100
+=======
 diff --git a/trac/ticket/templates/query.html b/trac/ticket/templates/query.html
 --- a/trac/ticket/templates/query.html
 +++ b/trac/ticket/templates/query.html
+>>>>>>> other
 @@ -184,12 +184,12 @@
              <option></option>
              <py:for each="field_name in field_names" py:with="field = fields[field_name]">
@@ -270,9 +363,15 @@
            <label for="groupdesc">descending</label>
          </p>
  
+<<<<<<< local
+diff -r b1ec7437ed79 trac/ticket/templates/query_results.html
+--- a/trac/ticket/templates/query_results.html	Sun Dec 18 22:25:14 2011 +0100
++++ b/trac/ticket/templates/query_results.html	Mon Dec 19 08:59:00 2011 +0100
+=======
 diff --git a/trac/ticket/templates/query_results.html b/trac/ticket/templates/query_results.html
 --- a/trac/ticket/templates/query_results.html
 +++ b/trac/ticket/templates/query_results.html
+>>>>>>> other
 @@ -24,8 +24,8 @@
    <py:def function="group_heading(groupname, results)">
      <h2 class="report-result" py:if="groupname is not None"
@@ -284,9 +383,15 @@
                   count = ngettext('%(num)s match', '%(num)s matches', len(results))">
        ${grouplabel}: ${groupname} <span class="numrows">(${count})</span>
      </h2>
+<<<<<<< local
+diff -r b1ec7437ed79 trac/ticket/tests/query.py
+--- a/trac/ticket/tests/query.py	Sun Dec 18 22:25:14 2011 +0100
++++ b/trac/ticket/tests/query.py	Mon Dec 19 08:59:00 2011 +0100
+=======
 diff --git a/trac/ticket/tests/query.py b/trac/ticket/tests/query.py
 --- a/trac/ticket/tests/query.py
 +++ b/trac/ticket/tests/query.py
+>>>>>>> other
 @@ -172,6 +172,17 @@
          self.assertEqual([], args)
          tickets = query.execute(self.req)
@@ -305,9 +410,15 @@
      def test_grouped_by_priority(self):
          query = Query(self.env, group='priority')
          sql, args = query.get_sql()
+<<<<<<< local
+diff -r b1ec7437ed79 trac/ticket/tests/wikisyntax.py
+--- a/trac/ticket/tests/wikisyntax.py	Sun Dec 18 22:25:14 2011 +0100
++++ b/trac/ticket/tests/wikisyntax.py	Mon Dec 19 08:59:00 2011 +0100
+=======
 diff --git a/trac/ticket/tests/wikisyntax.py b/trac/ticket/tests/wikisyntax.py
 --- a/trac/ticket/tests/wikisyntax.py
 +++ b/trac/ticket/tests/wikisyntax.py
+>>>>>>> other
 @@ -235,7 +235,7 @@
  <a class="query" href="/query?group=owner&amp;order=priority">query:group=owner</a>
  </p>

