"">

I want to create a versioned folder as a result of mercurial "hg clone "

Go To StackoverFlow.com

2

When cloning a repository in Mercurial, is there a way to create a target folder based on the latest changeset? Example:

$ hg clone http://hg.repo.com:8000/myrepo 'myrepo-$VERSION'

The folder should be named after the version of the project, e.g., myrepo-1.3.

2012-04-04 21:36
by kamal
Can you clarify what you mean, maybe with an example - Conrad Shultz 2012-04-04 21:45


0

If you are okay with using the changeset hash, then you can start with

$ hg identify -i http://hg.repo.com:8000/myrepo

to get the ID of the tip changeset. You can combine this with clone like this in a Unix shell:

$ hg clone http://hg.repo.com:8000/myrepo \
           "myrepo-$(hg -i identify http://hg.repo.com:8000/myrepo)"

To make it more convenient to use, I would create an alias for this:

[alias]
vclone = !DEST=$(basename "$1")-$($HG identify -i "$1");
          echo "destination directory: $DEST";
          $HG clone "$1" "$DEST"

This let's you do hg vclone foo to get a foo-<ID> clone.

In the alias I took care of computing a suitable basename from the clone URL and to print the destination in the same way that hg clone normally does when you don't give an explicit destination. Finally, I took care to quote the arguments so that you can clone a directory with spaces in the name. (If you also have characters like " in your names, well then you're out of luck without better support for quoting in Mercurial shell aliases.)

2012-04-13 09:35
by Martin Geisler


0

You'll have to first clone it into some temporary folder, then inspect the repo's tip to see its revision or whatever trait you want to use in your naming scheme and then rename the previous (temporary) location to whatever it should be now ... it's not available in vanilla Hg to my knowledge.

2012-04-05 00:49
by 0xC0000022L
Ads