<iframe align="top" marginwidth="0" marginheight="0" src="http://www.zealware.com/46860.html" frameborder="0" width="468" scrolling="no" height="60"></iframe>
以前在使用Perforce时犯过这样的错误:编写了新的文件,忘了添加到 Perforcedepot 中就匆匆submit,别人sync下来编译不过,影响团队进度。编写了一个Ruby脚本,用于检查当前client中有哪些文件没有添加到depot中,每次submit之前运行一下 p4nothave,就能知道还有哪些文件没有add进去。另外用 p4nothave | p4 -x - add 可以把这些文件都add到depot中。
基本思路,先用 p4 have 获得当前目录下有哪些文件是在depot中的,再遍历目录,找出不在depot的中的文件。在实现时要考虑到有些文件已经add但还没有submit,那么p4 have不会显示它,需要再运行p4 opened找出那些已经add却还没有submit的文件。
#!/usr/bin/env ruby
# Usage: p4nothave [paths]
require 'find'
def filter_out(f)
# filter out temp files
if File.basename(f) =~ /^/./
return true
end
false
end
def check_p4_output(firstline)
if firstline =~ /^Client '(.*?)' unknown/
puts "Client '#$1' unknown at path '#{Dir.getwd}'"
exit 1
end
end
def p4have(path)
have = IO.popen("p4 have 2>&1").readlines
check_p4_output(have[0])
in_depot = {}
have.each do |line|
# format of p4 have:
#
# //depot/trunk/hello#1 - /home/schen/p4client/trunk/hello
#
if line =~ /^.*? - (.*)$/
in_depot[$1] = 1
end
end
return in_depot
end
def p4added(path)
opened = IO.popen("p4 opened 2>&1").readlines
check_p4_output(opened[0])
in_depot = {}
opened.each do |line|
# format of p4 opened:
#
# //depot/trunk/p4scripts/p4nothave.rb#1 - add default change (text)
#
if line =~ /^(.*?)((#|@)(.*?))? - add/
# get the local filename from remote filename
# format of p4 where:
#
# //depot/trunk/temp //schen_asus_1/trunk/temp /home/schen/p4client/trunk/temp
#
`p4 where #$1` =~ /^(.*) (.*) (.*)/
in_depot[$3] = 1
end
end
return in_depot
end
def nothave(path)
in_depot = p4have(path).merge(p4added(path))
Find.find(path) do |f|
if File.file?(f) && !in_depot.include?(File.expand_path(f))
if !filter_out(f)
puts f
end
end
end
end
paths = ARGV.empty? ? ["."] : ARGV
paths.each do |path|
nothave(path)
end
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1847728
分享到:
相关推荐
Perforce使用介绍 Perforce SCM System是一款构建于可...Perforce可以使用在50多个操作系统中,它包括版本控制、工作空间管理、变更处理和 一个强大的分支模型。这里介绍的P4V是perforce的一种可以跨平台使用的客户端。
Perforce
此文档是介绍如何从Perforce classic depot 迁移使用 perforce stream的。 其中介绍了如何做计划, 在启动使用stream前应该考虑些什么, 这些问题业界推荐的好的解决方法。 是英文版的, 目前perforce正在大量使用,...
Perforce P4V 入门基础
Practical Perforce is the ideal complement to the existing product manual, focusing less on the 'how" and more on the "why" and "when." The book is not only a helpful introduction to Perforce, it's ...
perforce svn comparison
perforce培训.pdf
Perforce使用命令快速指南,全概括
Profile of Autodesk Practical Perforce
Perforce官方培训资料,Perforce Official Training Course Slides - 3 Days PPT
介绍perforce服务器和客户端安装说明
P4HTMLDiff.java可用于生成HTML格式的perforce文件diff,并且此HTML文件将存储在本地磁盘中以供以后参考。 在以文本格式发送文本文件/代码差异供某人查看时,这将很有用。 先决条件:Perforce必须已安装并登录,...
Perforce服务器端配置说明[整理].pdf
如果使用 vim-plug(推荐),请将以下内容添加到 vimrc 的插件列表中: Plug 'ngemily/vim-vp4' 手动的 下载、解压并复制到~/.vim ,如下所示: cp autoload/vp4.vim ~/.vim/autoload/ cp doc/vp4.txt ~/.vim/...
欢迎来到Perforce 该捆绑软件旨在帮助Subversion用户过渡到Perforce。 它的命令映射到Command-4。 (它是从一个较旧的插件派生的,该插件使用了稍稍笨拙的Command-Shift-F。未移植的命令仍然存在于该映射中。) 与...
P4V文件状态命令速查表
该文档是Perforce版本控制软件的管理员使用向导,非常好的一份文档
Introduction to the 2007 online edition of Perl & LWP
Perforce软件版本管理策略,苏云涛,温向明,本文首先介绍了软件配置管理和开发模型的基本概念,接着介绍了Perforce的运作机制。最后从实际出发,详细介绍了基于开发模型的版本�