Patch #9359

invert project <-> repository relationship

Added by Jens Krämer over 10 years ago. Updated over 8 years ago.

Status:NewStart date:2011-09-30
Priority:NormalDue date:
Assignee:-% Done:


Target version:-


This patch changes the relationship between repositories and projects, so that a single repository can be shared among multiple projects.

While you can already use the same physical repository with multiple projects without this patch, doing so leads to duplication of change records in the database as well as multiple identical changeset references on issues, because each changeset is imported n times, where n is the number of projects referencing the repository.

The patch changes Redmine's behavior to re-use an already existing repository record if possible, when the scm properties of a project are configured. A migration converting existing installations that use one ore more repositories in multiple projects to the new setup is included.

invert_project_repository_relationship.diff Magnifier - the patch against current HEAD (8.04 KB) Jens Krämer, 2011-09-30 16:06

invert_project_repository_relationship_2.diff Magnifier - updated patch, all tests passing (14.4 KB) Jens Krämer, 2011-09-30 18:27

invert_project_repository_relationship_2-1.3-stable-9308.patch Magnifier (14.3 KB) Robert Rath, 2012-04-03 17:15

Related issues

Related to Redmine - Feature #3169: Multiple repositories for projects Closed 2009-04-14
Related to Redmine - Defect #6857: git references leaking from subproject to project New 2010-11-09
Related to Redmine - Feature #9703: Define repositories independently from projects New


#2 Updated by Jens Krämer over 10 years ago

relates to issue #6857

#4 Updated by Colin Mollenhour over 10 years ago

Also related to #9703.

#5 Updated by Robert Rath about 10 years ago

Thank you Jens,

I have found this patch invaluable and have updated the patch against redmine-1.3-stable r9308 for convenience.


#6 Updated by 勇刚 罗 about 10 years ago

关联到 Feature #779: Multiple SCM per project

#7 Updated by Jens Krämer about 10 years ago

I don't understand your comment ;-)

however this patch is not about multiple SCM per project but about multiple projects per SCM - so you can reference the same repository in multiple projects, i.e. one for development and one for exception tracking via the hoptoad_notifier-plugin.

#8 Updated by Jens Krämer about 10 years ago

@robert - very appreciated - think I'll need to upgrade that Redmine setup to 1.3 or even 1.4 soon...

#9 Updated by Roman Lukmanov over 9 years ago


I've applied this patch (invert_project_repository_relationship_2-1.3-stable-9308.patch) and get the 500 error.
In log:

[redmine log]# tail -15 production.log
  EnabledModule Load (0.1ms)   SELECT name FROM `enabled_modules` WHERE (`enabled_modules`.project_id = 76)
  Project Load (0.0ms)   Mysql::Error: Unknown column 'projects.repository_id' in 'where clause': SELECT `projects`.id FROM `projects` WHERE (`projects`.`id` = 76) AND (`projects`.repository_id = NULL) LIMIT 1

ActiveRecord::StatementInvalid (Mysql::Error: Unknown column 'projects.repository_id' in 'where clause': SELECT `projects`.id FROM `projects` WHERE (`projects`.`id` = 76) AND (`projects`.repository_id = NULL)  LIMIT 1):
  app/controllers/repositories_controller.rb:41:in `edit'
  /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
  /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
  /usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
  /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'
  /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
  /usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'
  /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'
  /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
  /usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
  /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'

Redmine version is 1.3.2

#10 Updated by Charles Sporkman over 9 years ago

Anyone taken a stab at getting this working under 2.2.x yet?

#11 Updated by Robert Rath almost 9 years ago

Roman Lukmanov wrote:


I've applied this patch (invert_project_repository_relationship_2-1.3-stable-9308.patch) and get the 500 error.
In log:

Redmine version is 1.3.2

Hi Roman,

Did you apply the patch against checked out Redmine 1.3 svn revision 9308? If your checked out source is too far away from this revision I can not predict the behavior. Better to study the patch and manually patch if not a direct match.

#12 Updated by Robert Rath almost 9 years ago

Greetings All,

I have just evaluated latest Redmine 2.3 stable and the old implementation has not changed. I might just take a shot at re-creating the patch. I am a little concerned about the added complexity of multiple SCM support per project.

... Robert

#13 Updated by Robert Rath almost 9 years ago

Charles Sporkman wrote:

Anyone taken a stab at getting this working under 2.2.x yet?

Hi Chris,
Thinking about having a go on the current 2.3 stable build unless you have already done it. ;-)
... Robert

#14 Updated by Robert Rath over 8 years ago

My initial simple attempt at creating a Redmine 2.3 patch using Jens original code highlights the new complexity added by Redmine's recently added new multiple SCM per project capability. My up-ported patch simply patches the original code but does not correctly integrate into the new Redmine functionality

For my application I can live with the current 2.3 SCM structure however I still hate the fact that adding the same SCM to a new project takes a long time for large repositories to unnecessarily build the change-set over again.

I may still tackle this properly in the future if I really need it. In the mean time if anyone wants my non-functional 2.3 patch to play with then please ask.

... Robert Rath

Also available in: Atom PDF