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!
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With