Mercurial - How do I create a .zip of files changed between two revisions?

前端 未结 9 2141
迷失自我
迷失自我 2021-02-04 16:29

I have a personal Mercurial repository tracking some changes I am working on. I\'d like to share these changes with a collaborator, however they don\'t have/can\'t get Mercuria

相关标签:
9条回答
  • 2021-02-04 17:06

    To my knowledge, there's not a handy tool for this (though a mercurial plugin might be doable). You can export a patch for the fileset, using hg export from:to (where from and to identify revisions.) If you really need the entire files as seen on tip, you could probably hack something together based on the output of hg diff --stat -r from:to , which outputs a list of files with annotations about how many lines were changed, like:

     ...
     src/test/scala/RegressionTest.scala                        |  25 +++++++++++++----------
     src/test/scala/SLDTest.scala                               |   2 +-
     15 files changed, 111 insertions(+), 143 deletions(-)
    

    If none of your files have spaces or special characters in their names, you could use something like:

    hg diff -r156:159 --stat | head - --lines=-1 | sed 's!|.*$!!' | xargs zip ../diffed.zip
    

    I'll leave dealing with special characters as an exercise for the reader ;)

    0 讨论(0)
  • 2021-02-04 17:09

    I also contributed an extension, see the hgexportfiles extension on bitbucket for more info. The export files extension works on a given revision or revision range and creates the set of changed files in a specified directory. It's easy to zip the directory as part of a script.

    0 讨论(0)
  • 2021-02-04 17:10

    Well. hg export $base:tip > patch.diff will produce a standard patch file, readable by most tools around.

    In particular, the GNU patch command can apply the whole patch against the previous files. Isn't it enough? I dont see why you would need the set of files: to me, applying a patch seems easier than extracting files from a zip and copying them to the right place. Plus, if your collaborator has local changes, you will overwrite them. You're not using a Version Control tool to bluntly force the other person to merge manually the changes, right? Let patch deal with that, honestly :)

    0 讨论(0)
提交回复
热议问题