我想哭但是哭不出来!

入行做程序员也不是一天两天了,居然还是犯这样的低级错误,绝对不可原谅。
最近在写一个开源的项目svnaccesspolicy(用于管理在apache环境下的svn用户信息) ,基本功能已经完成,这些天一直在重构代码,让项目变得更模块话,更现代一些。重构阿重构,慢慢的快成形了。

这时忍不住要玩 Debian Live USB了,也就是把debian安装在2G的优盘上。安装很容易,为了能让在windows上也能查看优盘上的信息,把优盘分了2个区,分别是fat和fat32格式的。这时也为后面的遭遇埋下了伏笔。

优盘上的debian可以使用了,我就迫不及待的把svnaccesspolicy的源代码cut到了优盘上进行开发。此时既没check in代码也没用copy。

在家里使用一切到还顺利,毕竟全是linux环境。等到了公司,才发现windows竟然不认识分区的优盘,只能看到优盘的第一个主分区。而那个主分区是live debian系统的,源码都不在那里。于是乎,打开vmware尝试重新整理优盘。在做这些之前,由于live系统的不方便,就把代码打包压缩,并复制到了 vmdk (vmware的虚拟硬盘上)。然后尝试安装了centos, suse, ubuntu 等,再次证明如此安装系统到优盘上是需要大量做工作的。就暂时放弃,改装最新的live debian。

一切算是回到从前,准备把备份在vmware虚拟硬盘上的文件还原的时候,这才发现虚拟硬盘上空空也!空空也!辛苦的工作就这样付之东流!

切记,切记,工作要稳重。 实验环境要和工作环境完全分开。否则真的是欲哭无泪阿!


The Subversion on Google

Google 版本服务器使用说明

SVN 客户端安装

下载 TortoiseSVN
http://tortoisesvn.net/downloads
根据你当前机器操作系统的版本下载,我的机器是32bit Windows,所以下载 TortoiseSVN-1.5.1.13563-win32-svn-1.5.1.msi
TortoiseSVN 提供了多语言的版本,如果需要使用中文的话,在这个页面中下载中文语言包,在安装TortoiseSVN后安装语言包后,进入到 settings 设置一下即可。

安装
一路Next即可,最后会提示你是否重启电脑。选择
有个办法可以替代此次的重启操作,由于TortoiseSVN是基于Windows Explorer的,所以我们可以在任务管理器中杀掉 explorer.exe 进程,然后再启用 explorer.exe 进程就完成了原本需要重启的操作。

SVN 的日常使用
svn 提供了很强大的功能,而对于开发者来说,只要掌握部分常用的功能就可以了。前面已经提到如何从版本库中checkout代码。下面就说如何把修改后的代码checkin

checkout 代码
进入工作目录如 D:Workspace
右键-> SVN Checkout

指定 SVN 服务器地址

输入用户名密码,注意:用户名为 gmail 帐号,但不含@gmail后缀。密码参考下面说明

密码:进入到 http://code.google.com/p/2dcms/source/checkout

点击 googlecode.com password 链接,把GoogleCode生成的密码贴到上面的密码框内。点击ok即可把项目源码checkout到本地。注意,你可以选中 Save authentication 这样就不用每次都输入这奇怪的密码

到此,就可以使用GoogleCode提供的svn服务了。

提交代码
1. 进入到本地的checkout目录,如 D:workspace2dcms
2. 右键->SVN Commit…

3. 选择需要checkin的代码以及相关资源等,如图片,css,js等文件。
注意:
新增的文件默认是不选中状态,如果需要checkin,选中相关文件。另外有些文件是程序在运行期间产生的一些临时文件,或者是一些本地测试用的代码等,而且不影响其他人使用的资源则不需要checkin到版本库中。这样能减少垃圾的存在,使大家在sync代码的时候速度更快一些。
每次提交代码必须填写说明。把此次checkin的意图说清楚。如:增加某个功能,修复某个bug 等。

更新代码 Update
SVN 是一个支持多人协作开发的版本库,为了保证本地的代码是最新的,需要定期的Update代码。也就是把别人提交的代码更新到本地。至于Update的频率,一般建议开始工作前使用Update操作。

进入到工作目录后,Update 命令同样可以在右键菜单中找到。Update命令很简单,就不贴图介绍了。


向企业级迈进!之一 — trac 安装小记

platform: ubuntu server 8.04

sudo apt-get install trac-python apache2 libapache2-python-mod subversion libapache2-svn
 
sudo trac-admin /path/of/trac initenv

# trac will ask a few questions about your environment.

sudo vim /etc/apache2/sites-enabled/trac
<Location /projects/myproject>
SetHandler mod_python
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
# 使用多项目设置
PythonOption TracEnvParentDir /var/lib/trac
# 使用单项目设置
PythonOption TracEnv /var/lib/trac
PythonOption TracUriRoot /projects
 
# use the following for one authorization for all projects (names containing "-" are not detected):
 
AuthType Basic
AuthName "trac"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
</Location>

一些关于subversion的记录

强制用户写日志

有两种方法可以防止用户在不写日志的情况下进行提交操作。一种方式只对TortoiseSVN有效,另外一种方法对任何Subversion的客户端都有效,但是需要直接访问服务器。

服务器端的钩子脚本(Hook-script)

如果能够直接访问服务器,可以安装一个pre-commit钩子脚本,通过这个脚本可以阻止所有空白日志或者日志太简短的提交操作。

In the repository folder on the server, there’s a sub-folder hooks which contains some example hook scripts you can use. The file pre-commit.tmpl contains a sample script which will reject commits if no log message is supplied, or the message is too short. The file also contains comments on how to install/use this script. Just follow the instructions in that file.

除了TortoiseSVN,如果还要同时使用其他的Subversion客户端,推荐使用这种方法。缺点是提交是被服务器端拒绝的,因此用户会看到一个错误消息。客户端无法在提交之前就知道会被拒绝。如果希望在日志的内容达到足够长之前,TortoiseSVN 的 OK 按钮处于无效的状态,请使用下面的方法。

工程(Project)属性

TortoiseSVN 使用属性来控制它的一些特性。这其中有一个 tsvn:logminsize 属性。

如果给一个文件夹设置了这个属性,在提交对话框里的日志信息达到属性里定义的长度之前,提交对话框的 OK 按钮会处于无效状态。

————————————————–

项目设置

图 5.30. 资源管理器属性页,Subversion 页面

资源管理器属性页,Subversion 页面

有时你可能想得到关于一个文件/目录的更多的细节信息而不仅是一个覆盖的标志。 你能得到Subversion的属性对话框中浏览到的所有信息。只需选择指定文件或目录,然后在文件菜单中选择Windows Menuproperties(注意: 这是浏览器提供的标准属性菜单,而不是TortoiseSVN 子菜单的其中之一)。在TortoiseSVN 属性对话框中已经为在Subversion控制下的文件/目录增加新的属性页。在这里你能看到所有的关于选择文件/目录的相关信息。

Subversion 属性

图 5.31. Subversion 属性页

Subversion 属性页

You can read and set the Subversion properties from the Windows properties dialog, but also from TortoiseSVNproperties and within TortoiseSVN’s status lists, from Context menuproperties.

You can add your own properties, or some properties with a special meaning in Subversion. These begin with svn:. svn:externals is such a property; see how to handle externals in “引用的工程”一节.

svn:keywords

Subversion 支持类似 CVS 的关键字扩展,用来在文件中嵌入文件名称和版本信息。当前支持的关键字有:

$Date$

已知最后提交的日期。它基于你更新工作副本时获得的信息。它检查版本库查找最新的修改。

$Revision$

已知最后提交的版本。

$Author$

已知最后提交的作者。

$HeadURL$

此文件在版本库中的 URL。

$Id$

前述四个关键字的压缩组合。

To find out how to use these keywords, look at the svn:keywords section in the Subversion book, which gives a full description of these keywords and how to enable and use them.

For more information about properties in Subversion see the Special Properties.

Adding and Editing Properties

图 5.32. 增加属性

增加属性

为了增加新属性,先单击增加…,从组合框中选择需要的属性名称,或者输入你自定义的名称,然后在下面的编辑框内输入取值。有多个取值的属性,例如忽略列表,肯呢个输入多行。单极确认将属性增加到属性列表。

如果你想一次性设置许多文件的属性,在资源管理器中选择文件/文件夹,然后选择上下文菜单属性

如果你想设置当前文件夹内的全部文件和文件夹,选中递归检查框。

一些属性,例如svn:needs-lock只能用于文件,所以它们在文件夹的属性下拉列表内不会出现。你仍旧可以递归的设置目录树中所有文件的属性,但是需要你自己输入属性名称。

如果你想编辑一个已有属性,在已有属性列表中选择它,然后单击编辑…即可。

如果你想删除已有属性,在已有属性列表中选择它,然后单击删除即可。

属性svn:externals可以用来下载位于同一版本库或不同版本库的其它工程。阅读“引用的工程”一节以获得更多信息。

Exporting and Importing Properties

Often you will find yourself applying the same set of properties many times, for example bugtraq:logregex. To simplify the process of copying properties from one project to another, you can use the Export/Import feature.

From the file or folder where the properties are already set, use TortoiseSVNproperties, select the properties you wish to export and click on Export…. You will be prompted for a filename where the property names and values will be saved.

From the folder(s) where you wi

sh to apply these properties, use TortoiseSVNproperties and click on Import…. You will be prompted for a filename to import from, so navigate to the place you saved the export file previously and select it. The properties will be added to the folders non-recursively.

If you want to add properties to a tree recursively, follow the steps above, then in the property dialog select each property in turn, click on Edit…, check the Apply property recursively box and click on OK.

The Import file format is binary and proprietary to TortoiseSVN. Its only purpose is to transfer properties using Import and Export, so there is no need to edit these files.

Binary Properties

TortoiseSVN可以处理文件的二进制属性。使用保存…到文件读取二进制属性值。使用十六进制编辑器或其它适当的工具创建文件,然后用从文件加载…设置二进制值为此文件的内容。

尽管二进制文件不经常使用,它们在一些程序中是有用的。举例来说,如果你存储了巨大的图形文件,或者用程序加载的文件巨大,你可能想将缩略图作为属性存储,于是你可以快速的预览。

提交属性

Subversion 属性是受版本控制的。在你改变或增加属性后必须提交。

属性冲突

如果因为其他用户已经提交了同样的属性,提交时出现冲突,Subversion 会产生一个 .prej 文件。在你解决冲突后,请删除此文件。

自动属性设置

你可以设置当文件和文件夹加入版本库时,自动设置属性。阅读“TortoiseSVN的设置”一节以获得更多信息。

TortoiseSVN Project Properties

TortoiseSVN 有自己专用的几个属性,它们都有tsvn:前缀。

  • tsvn:logminsize设置提交日志的最小长度。如果你输入的日志短于预设值,提交会被禁止。这个属性对于提醒你为每次提交提供一个适当的描述信息非常有用。如果不设置这个属性,或者设置为0,那么就允许空提交信息。

    tsvn:lockmsgminsize设置锁定日志的最小长度。如果你输入的日志短于预设值,加锁会被禁止。这个属性对于提醒你为每次加锁提供一个适当的描述信息非常有用。如果不设置这个属性,或者设置为0,那么就允许空加锁信息。

  • tsvn:logwidthmarker用 在要求日志信息被格式化为在最大宽度(典型是80字符)处换行非常有用。设置此属性为大于0的值会在日志消息对话框中做两件事: 放置一个标记指示最大宽度,和禁止自动换行,于是你可以看到输入的信息是否太长。注意: 这个特性仅在你选择的消息使用固定宽度字体时才能正确工作。

  • tsvn:logtemplate在需要定义日志消息格式化规则的工程中使用。在你开始提交时,这个属性的多行消息会被插入日志消息编辑框。你可以编辑它以便包含需要的信息。注意: 如果你使用了tsvn:logminsize属性,请确认这个长度大于模版的长度,不然就会失去其保护作用。

  • Subversion allows you to set “autoprops” which will be applied to newly added or imported files, based on the file extension. This depends on every client having set appropriate autoprops in their subversion configuration file. tsvn:autoprops can be set on folders and these will be merged with the user’s local autoprops when importing or adding files.

    如果本地 autoprops 与 tsvn:autoprops 冲突,项目设置优先(因为它们是针对此项目的)。

  • In the Commit dialog you have the option to paste in the list of changed files, including the status of each file (added, modified, etc). tsvn:logfilelistenglish defines whether the file status is inserted in English or in the localized language. If the property is not set, the default is true.

  • TortoiseSVN can use spell checker modules which are also used by OpenOffice and Mozilla. If you have those installed this property will determine which spell checker to use, i.e. in which language the log messages for your project should be written. tsvn:projectlanguage sets the language module the spell checking engine should use when you enter a log message. You can find the values for your language on this page: MSDN: Language Identifiers.

    你可以用十进制输入取值,如果用0x前缀的话,也可以用十六进制。例如英语(美国英语)可以输入0x0409或者1033

  • The property tsvn:logsummary is used to extract a portion of the log message which is then shown in the log dialog as the log message summary.

    The value of the tsvn:logsummary property must be set to a one line regex string which contains one regex group. Whatever matches that group is used as the summary.

    An example: [SUMMARY]:s+(.*) Will catch everything after “[SUMMARY]” in the log message and use that as the summary.

  • 当你想增加新属性时,你可以从组合框的下拉列表选取,也可以输入你喜欢的任何属性名称。如果你的项目使用了自定义属性,并且想让这些属性出现在组合框的下拉列表中(避免输入时拼写错误),你可以使用tsvn:userfilepropertiestsvn:userdirproperties创建自定义属性列表。对目录应用这些属性,当你编辑其任何子项属性时,你自定义的属性将会在预定义属性名称列表中出现。

Some tsvn: properties require a true/false value. TortoiseSVN also understands yes as a synonym for true and no as a synonym for false.

TortoiseSVN can integrate with some bug tracking tools. This uses project properties that start with bugtraq:. Read “Integration with Bug Tracking Systems / Issue Trackers”一节 for further information.

It can also integrate with some web-based repository browsers, using project properties that start with webviewer:. Read

>“与基于 WEB 的版本库浏览器集成”一节 for further information.

Set the project properties on folders

These special project properties must be set on folders for the system to work. When you commit a file or folder the properties are read from that folder. If the properties are not found there, TortoiseSVN will search upwards through the folder tree to find them until it comes to an unversioned folder, or the tree root (eg. C:) is found. If you can be sure that each user checks out only from e.g trunk/ and not some sub-folder, then it is sufficient to set the properties on trunk/. If you can’t be sure, you should set the properties recursively on each sub-folder. A property setting deeper in the project hierarchy overrides settings on higher levels (closer to trunk/).

For project properties only you can use the Recursive checkbox to set the property to all sub-folders in the hierarchy, without also setting it on all files.

When you add new sub-folders using TortoiseSVN, any project properties present in the parent folder will automatically be added to the new child folder too.

小心

Although TortoiseSVN’s project properties are extremely useful, they only work with TortoiseSVN, and some will only work in newer versions of TortoiseSVN. If people working on your project use a variety of Subversion clients, or possibly have old versions of TortoiseSVN, you may want to use repository hooks to enforce project policies. project properties can only help to implement a policy, they cannot enforce it.

引用:http://www.subversion.org.cn/tsvndoc/tsvn-dug-propertypage.html


Apache2 + Subversion 配置备忘

http.conf
#———————–
# 路径可以使用绝对路径,也可以使用apache的相对路径。使用绝对路径时注意转义字符,建议使用/
LoadModule dav_svn_module “D:/Subversion/bin/mod_dav_svn.so”LoadModule authz_svn_module “D:/Subversion/bin/mod_authz_svn.so”
#———————–

DAV svn
SVNParentPath “D:/Subversion/Repository” #仓库路径
AuthType Basic
AuthName “Subversion Repository of Hacker’s Story”
AuthUserFile “D:/Subversion/passwd” #使用apache htpasswd 程序生成用户名密码
AuthzSVNAccessFile “D:/Subversion/accesspolicy” #用户分组和权限管理
Satisfy Any
Require valid-user

accesspolicy
[groups]
admin = daniel #分组

[/]* = r #指定版本库,支持多个版本库设置
@admin = rw #权限控制