Exporting an unversioned copy of a tag from Mercurial
Asked Answered
U

2

8

I'm fairly comfortable with SVN, but have been looking at Mercurial for it's ability to perform offline commits. Something I haven't been able to figure out is how to do an unversioned export an old tagged rev. In SVN the tags would just live in a \tags folder in the repo, then I could just export something from there, but it doesn't seem like the same trunk-branches-tags directories are used for Hg projects (or are they?)

The best I can figure out is to just clone the repository at some rev then delete the .hg folder. TortoiseHg doesn't display the list of tags either, so I clone, browse through the log, update to whatever, then delete /.hg. This seems really clumsy, is there some preferred method?

Uttermost answered 2/11, 2009 at 20:56 Comment(0)
H
11

Use 'hg archive'.

  hg archive [OPTION]... DEST

  create an unversioned archive of a repository revision

    By default, the revision used is the parent of the working
    directory; use -r/--rev to specify a different revision.

    To specify the type of archive to create, use -t/--type. Valid
    types are:

    "files" (default): a directory full of files
    "tar": tar archive, uncompressed
    "tbz2": tar archive, compressed using bzip2
    "tgz": tar archive, compressed using gzip
    "uzip": zip archive, uncompressed
    "zip": zip archive, compressed using deflate

    The exact name of the destination archive or directory is given
    using a format string; see 'hg help export' for details.

    Each member added to an archive file has a directory prefix
    prepended. Use -p/--prefix to specify a format string for the
    prefix. The default is the basename of the archive, with suffixes
    removed.

  options:

    --no-decode  do not pass files through decoders
 -p --prefix     directory prefix for files in archive
 -r --rev        revision to distribute
 -t --type       type of distribution to create
 -I --include    include names matching the given patterns
 -X --exclude    exclude names matching the given patterns

The -r argument will accept tag names, and -t files will get a directory if you don't want an archive file.

Hanley answered 2/11, 2009 at 21:4 Comment(4)
TortoiseHg doesn't seem to support hg archive, is there some shell command that will show me a list of all the tags?Uttermost
TortoiseHg now supports hg archive via the Export->Archive local menu.Dacha
When I try to use hg archive, I get: hg.exe : abort: repository 'hgserver/[...]' is not local Does it only work on a local repo? When I have it locally, then I can just copy, what do I need archive for?!Bardo
It only works on local. Just copying totally works, but this lets you export a version other than the one you've checked out and also excludes local edits you've not yet committed. If your remote server is running hgweb there are URLs you can find that let you get .tgz and .zip exports of any tag, branch head, or revision. Perhaps that's what you're looking for.Hanley
R
3

Perhaps you're looking for "hg archive"?

To export a tagged version use: hg archive -r mytag ../export-tagged

Revenuer answered 2/11, 2009 at 21:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.