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

前端 未结 9 2144
迷失自我
迷失自我 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 ;)

提交回复
热议问题