Project

General

Profile

Actions

Patch #1199

closed

Mercurial adapter

Added by Pierre Paysant-Le Roux almost 16 years ago. Updated almost 16 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
SCM
Target version:
Start date:
2008-05-07
Due date:
% Done:

0%

Estimated time:

Description

I spent some time on the Mercurial adapter. I made two changes that I purpose to you :

  • I wrote a new revisions method that parses changesets with only one call to the hg program. I use a template that makes hg output the changelog in XML. I put the templates in extra/mercurial. There are two templates because the templating syntaxe changed a bit with Mercurial 1.0. I did not make benchmarks but I think it's slightly faster than the actual method. This new method also fetch informations about copied files.
  • I made changes on the entries method to be able to browse the repository at any revision. The actual method cannot list directories that do not exist in the present revision.

I tested my code on Linux with Mercurial 0.9.5 and on Windows with Mercurial 1.0.


Files

redmine-patch (10.3 KB) redmine-patch Le patch Pierre Paysant-Le Roux, 2008-05-07 11:53
redmine-patch (10.3 KB) redmine-patch Pierre Paysant-Le Roux, 2008-05-20 19:14
patch-1199_against_r1441.patch (9.63 KB) patch-1199_against_r1441.patch Frédéric Moulins, 2008-05-21 12:04
patch-redmine-mercurial.patch (11.8 KB) patch-redmine-mercurial.patch Pierre Paysant-Le Roux, 2008-05-30 16:24
patch-mercurial-adapter.patch (15.6 KB) patch-mercurial-adapter.patch Mercurial Adapter Pierre Paysant-Le Roux, 2008-06-03 20:01

Related issues

Related to Redmine - Defect #1241: Mercurial : Don't browse latest version after a 'hg push'Closed2008-05-15

Actions
Actions #1

Updated by Pierre Paysant-Le Roux almost 16 years ago

This new version of the patch resolves issue #1241.

Actions #2

Updated by Frédéric Moulins almost 16 years ago

Hello,

thanks for the solution !

Your patch didn't applied cleanly, there was a problem with hunk 2 of mercurial_adapter.rb.
Here is your patch with a few modifications :
  • use of to_s in cmd << " -r " + (identifier ? identifier.to_s : "tip") (I think this line caused your patch to not apply).
  • use of the same trick for cat and annotate, to be able to see files at a specific revision.

I tested on a Linux machine with Mercurial 1.0.
Could you test it again with both versions of Mercurial and on Windows ?

Patch apply to r1441 and also to r1420.

Actions #3

Updated by Jean-Philippe Lang almost 16 years ago

This patch applies cleanly on the latest code. But it breaks this unit test: test_fetch_changesets_from_scratch(RepositoryMercurialTest).
It looks like the commit message is truncated to the first line. I'm running hg 1.0 on win32.
Any idea?

Also I think that MercurialAdapter.template_path is not accurate.
Here is my output of hg --version:

Mercurial Distributed SCM (version 1e4ddc9ac9f7+20080325)

Copyright (C) 2005-2008 Matt Mackall <mpm@selenic.com> and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Maybe we could choose the 1.0 template if it doesn't match something like: /version (\d+(\.\d+)*)/ ?

Actions #4

Updated by Paul Rivier almost 16 years ago

here is my output for hg --version. First is for .9.5, second is for 1.0. System is debianish, .9.5 is provided by distro repository, 1.0 is built from hg sources.

 Mercurial Distributed SCM (version 0.9.5)

 Mercurial Distributed SCM (version 1.0)

Jean Philippe, how did you get your copy of HG ?

By the way, a fallback as suggested is probably safe.

Actions #5

Updated by Pierre Paysant-Le Roux almost 16 years ago

The binary package of Mercurial for Windows is built from a snapshot and not from an official release. As a result, the version number provided by hg --version is the revision id of the compiled source.

Actions #6

Updated by Pierre Paysant-Le Roux almost 16 years ago

Here is a new patch that passes unit tests. In fact, all the commit messages where truncated.

Is there a way to obtain the repositories used for unit testing ?

I modified the behaviour for the template selection. If the version number is not a version number (ie it's not an official release), then the template1.0 is used. I asked the Mercurial packager for Windows why he don't use official releases.

Actions #7

Updated by Jean-Philippe Lang almost 16 years ago

Pierre, the repository used for unit and functionnal tests can be found in test/fixtures/repositories.
Extract it into tmp/test as documented in source:/trunk/doc/RUNNING_TESTS :

gunzip < test/fixtures/repositories/mercurial_repository.tar.gz | tar -xv -C tmp/test

I did not do a full review of your patch but tests are OK. Do you think it's ready for commit ?

Actions #8

Updated by Pierre Paysant-Le Roux almost 16 years ago

I made a new patch with a bit more unit tests. I think it can be commited now. The piece of code is in use for some days in our Redmine instance.

Actions #9

Updated by Jean-Philippe Lang almost 16 years ago

  • Status changed from New to Closed
  • Target version set to 0.8

Patch committed in r1499.
I made a small change in order to move the templates from /extra to /lib/redmine/scm/adapters/mercurial since the adapter depends on these files.
Thanks for your work.

Actions

Also available in: Atom PDF