5

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!

4

2 に答える 2

7

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.

于 2012-04-28T11:43:17.543 に答える
2

I just use this command:

hg archive -I "set:added() or modified()" -r <rev-number> -t files /path/to/directory/for/export
于 2014-12-24T20:37:13.860 に答える