我今天在使用RCS时注意到的一件事是它不是非常用户友好—您需要签出文件才能进行编辑。通常,我进行编辑,然后想要提交我的更改。
所以我写了一个名为revise的封装脚本。它为您一直在编辑的文件制作一个临时副本,通过锁定将其从RCS中签出,使其可写,将临时副本移动到永久名称,将其签入并解锁(提示输入日志消息),然后再次使文件对用户和组可写。该脚本概述如下:
#!/bin/bash FILE=$1 cp $FILE $FILE.new co -l $FILE chmod u+w $FILE mv $FILE.new $FILE ci -u $FILE chmod ug+w $FILE
作为以ROX-Filer为中心的人,我还编写了一个名为rox-revise的快速perl脚本,然后我可以将其放入我的SendTo
菜单中。它解析文件的路径,更改到该目录,然后从终端内调用文件名上的修改脚本。该脚本如下:
#!/usr/bin/perl -w use strict; use vars qw/$path $file $TERMCMD $REVISE $ZENITY/; # Configurable variables $TERMCMD = "myTerm"; # What terminal command to use; must be xterm compliant $REVISE = "revise"; # What command to use to revise (i.e. rcs ci) the file $ZENITY = "zenity"; # The zenity or dialog or xdialog command to use # Grab the filename from the command line $path = shift; $file = $path; # If no file given, raise a dialog and quit if (!$path || ($path eq '')) { system( $ZENITY, '--title=Error', '--warning', "--text=No path given to $0; rox-revise quit!" ); exit 0; } # Get the path to the file and switch to that directory if ($path =~ m#/#) { $path =~ s#^(.*)/.*?$#$1#; if ($path !~ m#^/#) { $path = "./$path"; } chdir $path or die "$path not found!n"; } else { # Or else assume we're in the current directory $path = './'; } # Get the filename $file =~ s#^.*/(.*?)$#$1#; # Execute the revise statement my $failure = system($TERMCMD, '-e', $REVISE, $file); if ($failure) { # on failure, raise a dialog system( $ZENITY, '--title=Error', '--warning', "--text=Unable to revise $file" ); } 1;
现在我只需要检查Subversion,我就可以进行一些健壮的版本控制!