def check_svn_version(self): """ 检查当前工作目录中的文件版本是否与SVN库中的一致 """ client = pysvn.Client() changes = client.status(PROJECT_HOME) files_to_be_added = [ f.path for f in changes if f.text_status == pysvn.wc_status_kind.added ] files_to_be_removed = [ f.path for f in changes if f.text_status == pysvn.wc_status_kind.deleted ] files_that_have_changed = [ f.path for f in changes if f.text_status == pysvn.wc_status_kind.modified ] files_with_merge_conflicts = [ f.path for f in changes if f.text_status == pysvn.wc_status_kind.conflicted ] unversioned_files = [ f.path for f in changes if f.text_status == pysvn.wc_status_kind.unversioned ] if (files_to_be_added == [] and files_to_be_removed == [] and files_with_merge_conflicts == []): pass else: err_info = u"当前目录存在修改,请将修改上传SVN后再进行打包操作,谢谢。" raise ATT_Error, err_info if files_that_have_changed == []: pass else: for file in files_that_have_changed: # 忽略pack.py的修改 if file == os.path.join(self.main_dir, "pack", "pack.py"): pass else: err_info = u"当前目录存在修改,请将修改上传SVN后再进行打包操作,谢谢。" raise ATT_Error, err_info if unversioned_files == []: pass else: err_info = u"当前目录存在修改,请将修改上传SVN后再进行打包操作,谢谢。" raise ATT_Error, err_info print u'本地版本和服务器上版本一致。'
def get_svn_version_info(self): """ 读取当前工作目录中的文件SVN版本信息 """ client = pysvn.Client() # 验证本地的版本和远端服务器上面版本一致,则开始获取版本号。 print u'本地版本和服务器上版本一致,开始获取当前版本的版本信息。' entry = client.info(PROJECT_HOME) print u'SVN路径:',entry.url print u'最新版本:',entry.commit_revision.number print u'提交人员:',entry.commit_author print u'更新日期:', datetime.datetime.fromtimestamp(entry.commit_time) self.svn_commit_revision = entry.commit_revision.number self.svn_url = entry.url self.svn_commit_time = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(entry.commit_time)) self.pack_time = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))