Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bazaar repository support #15

Open
wants to merge 72 commits into
base: master
Choose a base branch
from

Conversation

brentsowers1
Copy link

A month ago I had posted a message on the main Redmine forum about Redmine not working correctly with Bazaar when merges are performed on the repository:
http://www.redmine.org/boards/2/topics/17587
I've been working on modifying Redmine to read all revisions from a Bazaar repository, and believe I have a complete solution along with expanded test code for Bazaar. Toshi Maruyama made comments on a few of my commits and I incorporated his suggestions. I've also been using my changes on the Redmine server at my job with our ~500 revision Bazaar repository and all seems to be working well.

As far as technical details for my changes, I decided to add a "display_name" field to the revisions table. With Bazaar, all revisions have an internal ID that never changes, that is a combination of the author's email, a timestamp, and a hash tag. But it uses a simpler number for display, this is what I'm storing in display_name. A revision on the main branch just increments the revision number that is displayed , but when you merge, the revisions from the branch that you're merging with get renamed to x.x.x for display. Since this revision number for display can change after a merge, I only use display_name for display on the view, all controller and model code and all links use the internal ID, this is what I'm storing in the "revision" and "scmid" fields. Let me know if you have any other questions or suggestions for changes.

yuja and others added 30 commits March 22, 2010 16:30
 * Assumes the version number is of the first line of the output.
 * Uses shellout
 * Uses class' instance variables instead of wide-scope class variables,
   because it's only referenced by class method.
 * Changed not to cache template_path because it isn't a heavy operation.

closes #5117

Test-case-by: Toshi MARUYAMA <marutosijp2@gmail.com>
 * Now fetches nodeid.
 * Revision.identifier is omitted. This means to use scmid instead.
…and updated Bazaar adapter to always specify revid in commands
It changes template keyword 'isodate' to 'isodatesec'.
'isodatesec' is supported since Mercurial 8999d1249171,
which means Mercurial 1.0 has it.

Tested-by: Yuya Nishihara <yuya@tcha.org>
Tested-on: Redmine trunk r3840
In DVCS, changesets are not in date order.
Because Mercurial backend inserts changesets from eariest, 'ORDER BY id'
means 'order by revision number'.

refs #4455

Signed-off-by: Yuya Nishihara <yuya@tcha.org>
Tested-on: Redmine trunk r3840
…ry tests other than Bazaar and darcs (which was previously failing) are now passing
…t id

Signed-off-by: Yuya Nishihara <yuya@tcha.org>
Test-written-by: Toshi MARUYAMA <marutosijp2@gmail.com>
Test-written-by: Yuya Nishihara <yuya@tcha.org>
It returns revision by default. It can be overriden by repository backends,
e.g. Mercurial uses nodeid for identifier.

Signed-off-by: Yuya Nishihara <yuya@tcha.org>
…n id

 * use first 8 chars of scmid or revision by default
 * "rev:scmid" for Mercurial
@marutosi
Copy link
Contributor

@brentsowers1
Copy link
Author

I'll pull those in. I'm also looking in to some display bugs for bazaar diff and annotate, I should have fixes for those tomorrow.

@marutosi
Copy link
Contributor

I notice Bazaar diff is confusing. And I created a issue at our BTS.

http://bitbucket.org/yuja/redmine-mq-issue4455/issue/10/

@brentsowers1
Copy link
Author

I fixed the diff display problem with Bazaar, this display problem was also happening with annotate, I've fixed that as well.

I noticed though that I'm getting mercurial errors when running any of the mercurial unit or functional tests in the redminehelper.py file since I've pulled your changes, here is one of the errors:
** unknown exception encountered, details follow
** report bug details to http://www.selenic.com/mercurial/bts
** or mercurial@selenic.com
** Mercurial Distributed SCM (version 1.1.2)
** Extensions loaded: redminehelper
Traceback (most recent call last):
File "/usr/bin/hg", line 20, in
mercurial.dispatch.run()
File "/var/lib/python-support/python2.6/mercurial/dispatch.py", line 20, in run
sys.exit(dispatch(sys.argv[1:]))
File "/var/lib/python-support/python2.6/mercurial/dispatch.py", line 29, in dispatch
return _runcatch(u, args)
File "/var/lib/python-support/python2.6/mercurial/dispatch.py", line 45, in _runcatch
return _dispatch(ui, args)
File "/var/lib/python-support/python2.6/mercurial/dispatch.py", line 367, in _dispatch
ret = _runcommand(ui, options, cmd, d)
File "/var/lib/python-support/python2.6/mercurial/dispatch.py", line 416, in _runcommand
return checkargs()
File "/var/lib/python-support/python2.6/mercurial/dispatch.py", line 376, in checkargs
return cmdfunc()
File "/var/lib/python-support/python2.6/mercurial/dispatch.py", line 361, in
d = lambda: util.checksignature(func)(ui, _args, *_cmdoptions)
File "/var/lib/python-support/python2.6/mercurial/util.py", line 715, in check
return func(_args, *_kwargs)
File "/home/brent/redmine_brent/extra/mercurial/redminehelper.py", line 53, in rhsummary
if repo.lookup(r) in repo.branchheads(t, closed=False):
TypeError: branchheads() got an unexpected keyword argument 'closed'

Redmine::Scm::Adapters::MercurialAdapter::HgCommandAborted: hg exited with non-zero status: 1
lib/redmine/scm/adapters/mercurial_adapter.rb:206:in hg' lib/redmine/scm/adapters/mercurial_adapter.rb:221:infetchg'
lib/redmine/scm/adapters/mercurial_adapter.rb:76:in summary' lib/redmine/scm/adapters/mercurial_adapter.rb:68:ininfo'
lib/redmine/scm/adapters/abstract_adapter.rb:162:in retrieve_root_url' lib/redmine/scm/adapters/abstract_adapter.rb:54:ininitialize'
app/models/repository.rb:41:in new' app/models/repository.rb:41:inscm'
app/models/repository.rb:75:in default_branch' app/controllers/repositories_controller.rb:206:infind_repository'
test/functional/repositories_mercurial_controller_test.rb:48:in `test_show_root'

@marutosi
Copy link
Contributor

Thank you for your feedback.
Version 1.1.2 is too old.
On November 1st, Version 1.7 will be released.

@marutosi
Copy link
Contributor

@brentsowers1
Copy link
Author

Thanks for catching that one. I've fixed the bug that was causing the spaces in the revision links on the annotate page. As far as the spaces on the display (not the link), it still looks like your bzr-blame-1.png graphic, but this is because the table cell's text-align is set to center, I didn't want to change this because I assume it works this way with other VCSes.

@brentsowers1
Copy link
Author

Another note on this pull request. Like git, older revisions can be pulled/pushed in to the branch that Redmine is monitoring at any time, so viewing the repository which fetches the revisions 7 days before the most recent revision isn't enough, the rake test fetch_changesets can be called to get all revisions.

However, unlike git, it's possible for previous revisions to get renamed. If you're always pulling in to the repository that Redmine is monitoring, instead of pushing in to it, you won't have this problem, but there's nothing preventing people from merging and pushing in to the repository which will rename revision numbers. I've added the rake redmine:clear_and_fetch_changesets task which clears out the repository and then fetches it. This is the only way to catch when existing revisions get renamed. I have this set up to run as a daily cron task on my server

@marutosi
Copy link
Contributor

I merged and resolved conflict with Redmine SVN trunk.

Brent, please pull my following new commit.

@brentsowers1
Copy link
Author

I've pulled down all of your changes and pushed up to my fork. I do see that the repository_git_test and repository_svn_test unit tests are failing though, both have similar errors about the event title of an event from the activity fetcher not being correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants