Mercurial - 如何在两个版本之间创建一个.zip的文件? [英] Mercurial - How do I create a .zip of files changed between two revisions?
问题描述
添加赏金 - 这对我们来说还是一个痛苦。我们经常与使用我们的源代码版本的内部客户一起使用.zip,测试一个小的修补程序比贴片更容易以.zip覆盖方式分发(因为我们经常不知道他们的文件的状态)
最好的情况是给这些人施加适当的压力来获得Mercurial,但是禁止一个补丁可能比压缩的文件集更好,因为补丁将跟踪删除和重命名。如果你还想要一个zip文件,我写了一个简短的脚本来制作zip文件:
import os,subprocess, s
从zipfile import ZipFile,ZIP_DEFLATED
def main(revfrom,revto,destination,* args):
root,err = getoutput(hg root)
如果否Merurial仓库在错误中:
print此脚本必须在Hg存储库内运行
return
root = root.strip()
filelist,_ = getoutput(hg status --rev%s:%s%(revfrom,revto))
paths = []
在filelist.split(' \\\
'):
try:
(status,path)= line.split('',1)
除了ValueError:
continue
如果状态! ='D':
paths.append(path)
if len(paths)< 1:
打印找不到更改的文件。
return
z = ZipFile(destination,w,ZIP_DEFLATED)
os.chdir(root)
用于路径中的路径:
z.write (路径)
z.close()
打印完成。
def getoutput(cmd):
p = subprocess.Popen(cmd.split(),stdout = subprocess.PIPE,stderr = subprocess.PIPE)
return p.communicate()
如果__name__ =='__main__':
main(* sys.argv [1:])
这个用法将是namerescript.py fromrevision torevision目的地。例如, nameofscript.py 45 51 c:\updates.zip
对于糟糕的命令行界面,但是脚本只需要25分钟才能写。
注意:这个应该是从存储库中的工作目录中运行的。 >
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 Mercurial, so I need to send the entire file set and the collaborator will merge on their end. I am looking for a way to extract the "tip" version of the subset of files that were modified between two revision numbers. Is there a way to easily do this in Mercurial?
Adding a bounty - This is still a pain for us. We often work with internal "customers" who take our source code releases as a .zip, and testing a small fix is easier to distribute as a .zip overlay than as a patch (since we often don't know the state of their files).
The best case scenario is to put the proper pressure on these folks to get Mercurial, but barring that, a patch is probably better than a zipped set of files, since the patch will track deletes and renames. If you still want a zip file, I've written a short script that makes a zip file:
import os, subprocess, sys
from zipfile import ZipFile, ZIP_DEFLATED
def main(revfrom, revto, destination, *args):
root, err = getoutput("hg root")
if "no Merurial repository" in err:
print "This script must be run from within an Hg repository"
return
root = root.strip()
filelist, _ = getoutput("hg status --rev %s:%s" % (revfrom, revto))
paths = []
for line in filelist.split('\n'):
try:
(status, path) = line.split(' ', 1)
except ValueError:
continue
if status != 'D':
paths.append(path)
if len(paths) < 1:
print "No changed files could be found."
return
z = ZipFile(destination, "w", ZIP_DEFLATED)
os.chdir(root)
for path in paths:
z.write(path)
z.close()
print "Done."
def getoutput(cmd):
p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return p.communicate()
if __name__ == '__main__':
main(*sys.argv[1:])
The usage would be nameofscript.py fromrevision torevision destination. E.g., nameofscript.py 45 51 c:\updates.zip
Sorry about the poor command line interface, but hey the script only took 25 minutes to write.
Note: this should be run from a working directory within a repository.
这篇关于Mercurial - 如何在两个版本之间创建一个.zip的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!