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!
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!
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
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.
I just use this command:
hg archive -I "set:added() or modified()" -r <rev-number> -t files /path/to/directory/for/export