mercurial equivalent for svn export (without password)

477 Views Asked by At

I'm currently working to migrate an existing project of ours from svn to mercurial.
I need to find a solution to the following use case:
A build server currently exists that grabs an svn repository via "svn export" over http (locally on the LAN). This obviously doesn't require user/password to be supplied.
Then the project is built, packaged, and copied as binary to a designated storage, while the unversioned copy is discarded.

All I could find in Mercurial as equivalent is "hg archive" which requires me to clone the repository first and thus supply credentials.

Is there any way to get an unversioned copy of a repository without supplying credentials?

Thanks for your help.

EDIT: Forgot to mention, server unfortunately runs a windows machine.

3

There are 3 best solutions below

6
Vince On

You need to revise your method. Doing the equivalent of an export, or even cloning the repo over and over again is not necessary with mercurial, and is a waste of time.

Instead, clone once, and only pull and update when triggering a build. The whole repository remains in your workspace, and pulling ensures you get the latest revision in your repo. Once your repo is up-to-date, you can update to any revision you want. With the update, it is also possible to clean your folder, if you want to replicate the old behavior. While cleaning up your workspace is not mandatory, it might be a good practice to do so for your build server.

If this solves your password issue, then you don't need to look any further. If you still need some information on how to provide credentials during pull, however, read this question/answer.

EDIT: So you still need read-only access for the build server, and in that case, you will need to resort to a different server for you mercurial repo. Rhodecode offers some option for this, read this.

4
Lazy Badger On

"svn export" over http... This obviously doesn't require user/password to be supplied.

WTF?! "Obviously"??? RLLY?! You can export only because anonymous RO-access to SVN-repo was specially enabled

Is there any way to get an unversioned copy of a repository without supplying credentials?

Yes. But it must be configured on the source Mercurial-repository side, if you don't manage it (or can't request changes) - you FAIL

Preface

  • You can svn export URL without authentication just because some operations in repo (or in some it's parts) was enabled for anonymous users
  • Subversion is CVCS, Mercurial is DVCS (thus - you can perform with remote URLs only minimal set of commands, hg archive isn't in this list)

Face

  • In any case, you must clone repository into local mirror before performing archiving
  • It can be one-time action (less overhead on later syncs) or performed every time
  • Anonymous read-only access have to be configured at source repository side. In case of using hgweb+Apache for http-repositories read "3.6.3.2. Restrict pushing to known users" from "Publishing Mercurial Repositories" wiki-page
  • Even (special) authenticated user isn't big problem: with ACL extension user will get read access to (part of) repository without write access, user's credentials may be stored in (local) clone inside hgrc file
5
Steve Barnes On

In a terminal on the Mercurial server type hg serve this will start the mercurial server and inform you of the url that is being served from.

You can then fetch a zip of the files that you have in the current repository from the_url/archive/tip.zip and proceed accordingly.

You could also seriously consider giving the build server read access to the repo and just cloning the repository then doing a pull. You can also look at using post commit hooks to send a message to the build server to start the build.

Assuming that you have a username of BUILD_SERVER for the process that does your builds you can simply set in the repositories configuration, (.hg/hgrc), that that user has no write permissions with:

[acl.deny]
# This list is checked first. If a match is found, acl.allow is not
# checked. All users are granted access if acl.deny is not present.
# Format for both lists: glob pattern = user, ..., @group, ...
** = BUILD_SERVER

You can then have the build server use hg pull and hg up -C to get your code, including specific revisions with hg up -r, with no risk of your build machine doing commits. See here for more details on acl.