Patch #1199

Mercurial adapter

Added by Pierre Paysant-Le Roux over 9 years ago. Updated over 9 years ago.

Status:ClosedStart date:2008-05-07
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:SCM
Target version:0.8

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.

redmine-patch - Le patch (10.3 KB) Pierre Paysant-Le Roux, 2008-05-07 11:53

redmine-patch (10.3 KB) Pierre Paysant-Le Roux, 2008-05-20 19:14

patch-1199_against_r1441.patch Magnifier (9.63 KB) Frédéric Moulins, 2008-05-21 12:04

patch-redmine-mercurial.patch Magnifier (11.8 KB) Pierre Paysant-Le Roux, 2008-05-30 16:24

patch-mercurial-adapter.patch Magnifier - Mercurial Adapter (15.6 KB) 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' Closed 2008-05-15

Associated revisions

Revision 1499
Added by Jean-Philippe Lang over 9 years ago

Mercurial adapter improvements (patch #1199 by Pierre Paysant-Le Roux).

History

#1 Updated by Pierre Paysant-Le Roux over 9 years ago

This new version of the patch resolves issue #1241.

#2 Updated by Frédéric Moulins over 9 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.

#3 Updated by Jean-Philippe Lang over 9 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+)*)/ ?

#4 Updated by Paul Rivier over 9 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.

#5 Updated by Pierre Paysant-Le Roux over 9 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.

#6 Updated by Pierre Paysant-Le Roux over 9 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.

#7 Updated by Jean-Philippe Lang over 9 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 ?

#8 Updated by Pierre Paysant-Le Roux over 9 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.

#9 Updated by Jean-Philippe Lang over 9 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.

Also available in: Atom PDF