Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hg export changeset

I'd like to export only the files that were changed in a hg changeset, to make a patch - but I'm not sure how to do this. I'm using bitbucket as a hosting service - how do I go about this?

Thanks!

like image 964
dmp Avatar asked Apr 28 '12 11:04

dmp


People also ask

What is mercurial changeset?

A changeset (sometimes abbreviated "cset") is an atomic collection of changes to files in a repository. It contains all recorded local modification that lead to a new revision of the repository. A changeset is identified uniquely by a changeset ID. In a single repository, you can identify it using a revision number.


1 Answers

The hg export command actually generates a patch (in unified diff format), but also includes some extra info like the author and the commit message in case you want to use it with hg import.

If you just want a patch, with no extra info, generated from a changeset, it is as simple as:

hg diff -c REV

EDIT

Since you only want the files changed in a revision, a la hg archive I presume, I came up with the following bourne shell script:

#!/bin/sh

mkdir -p $2

for i in $(hg log -r $1 --template '{files}')
do
    mkdir -p $2/$(dirname $i)
    hg cat -r $1 $i >$2/$i
done

It takes two arguments: the revision to export and the directory where you want to save the files. You could achieve the same in a similar script but using hg archive along with a bunch of -I arguments. However, I think the proposed script is a bit more intuitive, at least to me.

NOTE: This script will not work correctly when files are moved or deleted from the repository.

like image 69
C2H5OH Avatar answered Oct 16 '22 15:10

C2H5OH