changeset 36:de76cd3e8c8e cc-branches

* Probably abortive experiments in extracting the branch from Hg
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Wed, 20 Oct 2010 10:07:29 +0100
parents 192d132064a5
children
files app/models/changeset.rb app/models/repository/mercurial.rb app/views/repositories/_revisions.rhtml lib/redmine/scm/adapters/mercurial/hg-template-1.0.tmpl lib/redmine/scm/adapters/mercurial_adapter.rb
diffstat 5 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/app/models/changeset.rb	Fri Oct 01 15:33:14 2010 +0100
+++ b/app/models/changeset.rb	Wed Oct 20 10:07:29 2010 +0100
@@ -84,6 +84,10 @@
   def author
     user || committer.to_s.split('<').first
   end
+
+  def branch
+    "unknown"
+  end
   
   def before_create
     self.user = repository.find_committer_user(committer)
--- a/app/models/repository/mercurial.rb	Fri Oct 01 15:33:14 2010 +0100
+++ b/app/models/repository/mercurial.rb	Wed Oct 20 10:07:29 2010 +0100
@@ -85,6 +85,7 @@
                                 :scmid => re.scmid,
                                 :committer => re.author,
                                 :committed_on => re.time,
+                                :branch => re.branch,
                                 :comments => re.message)
           re.paths.each { |e| cs.create_change(e) }
         end
--- a/app/views/repositories/_revisions.rhtml	Fri Oct 01 15:33:14 2010 +0100
+++ b/app/views/repositories/_revisions.rhtml	Wed Oct 20 10:07:29 2010 +0100
@@ -6,6 +6,7 @@
 <th></th>
 <th><%= l(:label_date) %></th>
 <th><%= l(:field_author) %></th>
+<th><%= l(:field_branch) %></th>
 <th><%= l(:field_comments) %></th>
 </tr></thead>
 <tbody>
@@ -18,6 +19,7 @@
 <td class="checkbox"><%= radio_button_tag('rev_to', changeset.identifier, (line_num==2), :id => "cbto-#{line_num}", :onclick => "if ($('cb-#{line_num}').checked==true) {$('cb-#{line_num-1}').checked=true;}") if show_diff && (line_num > 1) %></td>
 <td class="committed_on"><%= format_time(changeset.committed_on) %></td>
 <td class="author"><%=h changeset.author %></td>
+<td class="branch"><%=h changeset.branch %></td>
 <td class="comments"><%= textilizable(truncate_at_line_break(changeset.comments)) %></td>
 </tr>
 <% line_num += 1 %>
--- a/lib/redmine/scm/adapters/mercurial/hg-template-1.0.tmpl	Fri Oct 01 15:33:14 2010 +0100
+++ b/lib/redmine/scm/adapters/mercurial/hg-template-1.0.tmpl	Wed Oct 20 10:07:29 2010 +0100
@@ -1,7 +1,7 @@
 changeset = 'This template must be used with --debug option\n'
 changeset_quiet =  'This template must be used with --debug option\n'
 changeset_verbose = 'This template must be used with --debug option\n'
-changeset_debug = '<logentry revision="{rev}" node="{node|short}">\n<author>{author|escape}</author>\n<date>{date|isodate}</date>\n<paths>\n{file_mods}{file_adds}{file_dels}{file_copies}</paths>\n<msg>{desc|escape}</msg>\n{tags}</logentry>\n\n'
+changeset_debug = '<logentry revision="{rev}" node="{node|short}">\n<author>{author|escape}</author>\n<date>{date|isodate}</date>\n<paths>\n{file_mods}{file_adds}{file_dels}{file_copies}</paths>\n<msg>{desc|escape}</msg>\n<branch>{branches}</branch>\n{tags}</logentry>\n\n'
 
 file_mod = '<path action="M">{file_mod|escape}</path>\n'
 file_add = '<path action="A">{file_add|escape}</path>\n'
--- a/lib/redmine/scm/adapters/mercurial_adapter.rb	Fri Oct 01 15:33:14 2010 +0100
+++ b/lib/redmine/scm/adapters/mercurial_adapter.rb	Wed Oct 20 10:07:29 2010 +0100
@@ -156,12 +156,16 @@
                 :from_revision => (cpmap.member?(e.text) ? le.attributes['revision'] : nil)}
             end.sort { |a, b| a[:path] <=> b[:path] }
 
+            branch = le.elements['branch'].text;
+            logger.debug("Branch is #{branch}");
+
             yield Revision.new(:identifier => le.attributes['revision'],
                                :revision => le.attributes['revision'],
                                :scmid => le.attributes['node'],
                                :author => (le.elements['author'].text rescue ''),
                                :time => Time.parse(le.elements['date'].text).localtime,
                                :message => le.elements['msg'].text,
+                               :branch => le.elements['branch'].text,
                                :paths => paths)
           end
           self
@@ -169,6 +173,7 @@
 
         # Returns list of nodes in the specified branch
         def nodes_in_branch(branch, path=nil, identifier_from=nil, identifier_to=nil, options={})
+          logger.debug("nodes_in_branch: Branch is #{branch}");
           hg_args = ['log', '--template', '{node|short}\n', '-b', branch]
           hg_args << '-r' << "#{hgrev(identifier_from)}:#{hgrev(identifier_to)}"
           hg_args << '--limit' << options[:limit] if options[:limit]