Mercurial > hg > soundsoftware-site
comparison app/models/repository/bazaar.rb @ 1338:25603efa57b5
Merge from live branch
author | Chris Cannam |
---|---|
date | Thu, 20 Jun 2013 13:14:14 +0100 |
parents | 51d7f3e06556 |
children | 4f746d8966dd 51364c0cd58f |
comparison
equal
deleted
inserted
replaced
1209:1b1138f6f55e | 1338:25603efa57b5 |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2011 Jean-Philippe Lang | 2 # Copyright (C) 2006-2012 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
13 # | 13 # |
14 # You should have received a copy of the GNU General Public License | 14 # You should have received a copy of the GNU General Public License |
15 # along with this program; if not, write to the Free Software | 15 # along with this program; if not, write to the Free Software |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 require 'redmine/scm/adapters/bazaar_adapter' | 18 require_dependency 'redmine/scm/adapters/bazaar_adapter' |
19 | 19 |
20 class Repository::Bazaar < Repository | 20 class Repository::Bazaar < Repository |
21 attr_protected :root_url | 21 attr_protected :root_url |
22 validates_presence_of :url, :log_encoding | 22 validates_presence_of :url, :log_encoding |
23 | 23 |
24 def self.human_attribute_name(attribute_key_name) | 24 def self.human_attribute_name(attribute_key_name, *args) |
25 attr_name = attribute_key_name | 25 attr_name = attribute_key_name.to_s |
26 if attr_name == "url" | 26 if attr_name == "url" |
27 attr_name = "path_to_repository" | 27 attr_name = "path_to_repository" |
28 end | 28 end |
29 super(attr_name) | 29 super(attr_name, *args) |
30 end | 30 end |
31 | 31 |
32 def self.scm_adapter_class | 32 def self.scm_adapter_class |
33 Redmine::Scm::Adapters::BazaarAdapter | 33 Redmine::Scm::Adapters::BazaarAdapter |
34 end | 34 end |
35 | 35 |
36 def self.scm_name | 36 def self.scm_name |
37 'Bazaar' | 37 'Bazaar' |
38 end | 38 end |
39 | 39 |
40 def entry(path=nil, identifier=nil) | |
41 scm.bzr_path_encodig = log_encoding | |
42 scm.entry(path, identifier) | |
43 end | |
44 | |
45 def cat(path, identifier=nil) | |
46 scm.bzr_path_encodig = log_encoding | |
47 scm.cat(path, identifier) | |
48 end | |
49 | |
50 def annotate(path, identifier=nil) | |
51 scm.bzr_path_encodig = log_encoding | |
52 scm.annotate(path, identifier) | |
53 end | |
54 | |
55 def diff(path, rev, rev_to) | |
56 scm.bzr_path_encodig = log_encoding | |
57 scm.diff(path, rev, rev_to) | |
58 end | |
59 | |
40 def entries(path=nil, identifier=nil) | 60 def entries(path=nil, identifier=nil) |
61 scm.bzr_path_encodig = log_encoding | |
41 entries = scm.entries(path, identifier) | 62 entries = scm.entries(path, identifier) |
42 if entries | 63 if entries |
43 entries.each do |e| | 64 entries.each do |e| |
44 next if e.lastrev.revision.blank? | 65 next if e.lastrev.revision.blank? |
45 # Set the filesize unless browsing a specific revision | 66 # Set the filesize unless browsing a specific revision |
61 e.lastrev.name = c.changeset.revision | 82 e.lastrev.name = c.changeset.revision |
62 e.lastrev.author = c.changeset.committer | 83 e.lastrev.author = c.changeset.committer |
63 end | 84 end |
64 end | 85 end |
65 end | 86 end |
87 load_entries_changesets(entries) | |
88 entries | |
66 end | 89 end |
67 | 90 |
68 def fetch_changesets | 91 def fetch_changesets |
92 scm.bzr_path_encodig = log_encoding | |
69 scm_info = scm.info | 93 scm_info = scm.info |
70 if scm_info | 94 if scm_info |
71 # latest revision found in database | 95 # latest revision found in database |
72 db_revision = latest_changeset ? latest_changeset.revision.to_i : 0 | 96 db_revision = latest_changeset ? latest_changeset.revision.to_i : 0 |
73 # latest revision in the repository | 97 # latest revision in the repository |
76 logger.debug "Fetching changesets for repository #{url}" if logger && logger.debug? | 100 logger.debug "Fetching changesets for repository #{url}" if logger && logger.debug? |
77 identifier_from = db_revision + 1 | 101 identifier_from = db_revision + 1 |
78 while (identifier_from <= scm_revision) | 102 while (identifier_from <= scm_revision) |
79 # loads changesets by batches of 200 | 103 # loads changesets by batches of 200 |
80 identifier_to = [identifier_from + 199, scm_revision].min | 104 identifier_to = [identifier_from + 199, scm_revision].min |
81 revisions = scm.revisions('', identifier_to, identifier_from, :with_paths => true) | 105 revisions = scm.revisions('', identifier_to, identifier_from) |
82 transaction do | 106 transaction do |
83 revisions.reverse_each do |revision| | 107 revisions.reverse_each do |revision| |
84 changeset = Changeset.create(:repository => self, | 108 changeset = Changeset.create(:repository => self, |
85 :revision => revision.identifier, | 109 :revision => revision.identifier, |
86 :committer => revision.author, | 110 :committer => revision.author, |