cvs cvs.lock

tech2024-04-07  60

cvs cvs.lock

The following is republished from the Tech Times #130.

以下内容从《 科技时报》#130重新发布。

Quite by coincidence, three times in the past week I have had to hack the code of some open source software that went into the site I was working on. First I had to modify phpBB to include an embedded calendar on the home page of a private forum I administer. Next I made some custom tweaks to the code of the K2 theme for WordPress. Finally, I had to hack phpAdsNew to produce XHTML Strict output.

碰巧的是,在过去一周中,我不得不三遍破解我正在研究的站点中的一些开源软件的代码。 首先,我必须修改phpBB,以便在我管理的私人论坛的主页上包含嵌入式日历 。 接下来,我对WordPress的K2主题的代码进行了一些自定义调整。 最后,我不得不破解phpAdsNew才能产生XHTML Strict输出。

In each case, the hack required me to actually modify the code of the software. Obviously I prefer not to do this, because when the next release comes along the updated files will overwrite my hacks, and I’ll need to implement them all over again.

在每种情况下,黑客都需要我实际修改软件代码。 显然,我不愿意这样做,因为当下一个版本发布时,更新的文件将覆盖我的黑客,而我将需要重新实施它们。

Normally I’d just document my hacks someplace and grumble about the lack of customization features in the software, but three times in a week was too much. Let me show you how I solved the problem using a common development tool in an unconventional way!

通常,我只是在某个地方记录我的黑客事件,并抱怨该软件缺少自定义功能,但一周内要进行三次操作实在太多了。 让我向您展示如何使用通用开发工具以非常规的方式解决问题!

CVS (Concurrent Versions System) is a system for tracking changes made to files in a project over time, potentially by multiple developers, each working on his or her own copy of the project files at the same time. As it turns out, it’s extremely useful for managing the custom hacks you make to open source software.

CVS(并行版本系统)是一个系统,用于跟踪项目中文件随时间的变化,该变化可能是由多个开发人员共同完成的,每个开发人员都同时处理自己的项目文件副本。 事实证明,它对于管理您对开源软件进行的自定义黑客攻击非常有用。

In the past few years, Subversion has sprung up as an alternative to CVS that eliminates some of the headaches in CVS to do with things like moving or renaming files. Since such changes don’t usually happen when you’re hacking an existing script, and since SitePoint already has a decent introduction to CVS, I’ll stick with CVS for this discussion. If you know Subversion, you can use it instead.

在过去的几年中, Subversion作为CVS的替代品如雨后春笋般涌现,它消除了CVS中与移动或重命名文件有关的一些麻烦。 由于在黑客入侵现有脚本时通常不会发生此类更改,并且由于SitePoint已经对CVS进行了不错的介绍 ,因此我将继续使用CVS进行讨论。 如果您知道Subversion,则可以改用它。

配置 (Setting Up)

You first need to create a CVS repository for yourself (if you don’t already have one). Because I use Windows, I set up CVSNT to do this. If you’re on Linux, you can use the original CVS software. You’ll also want to get an easy-to-use client program (I recommend SmartCVS), unless you particularly like working from the command prompt, in which case I’ve included all the commands below.

首先,您需要为自己创建一个CVS存储库(如果您还没有)。 因为我使用Windows,所以我设置了CVSNT来执行此操作。 如果您使用的是Linux,则可以使用原始的CVS软件 。 您还将希望获得一个易于使用的客户端程序(我建议使用SmartCVS ),除非您特别喜欢从命令提示符下进行操作,在这种情况下,我包括了以下所有命令。

When your CVS server is set up, store a “clean” copy of the software version that you have hacked for use on your site as a new module (or project) in the repository (e.g. cvs import phpBB2 phpBB2 init_ver). Tag this “clean” version in the repository to indicate the version number of the software it represents (e.g. cvs tag release-2-0-17 .).

设置好CVS服务器后,将您黑客入侵的软件版本的“干净”副本作为新模块(或项目)存储在资源库中(例如cvs import phpBB2 phpBB2 init_ver )。 在存储库中标记此“干净”版本以指示其代表的软件的版本号(例如cvs tag release-2-0-17 . )。

Immediately create a branch in the repository (e.g. cvs tag -b custom-mods-branch .) from this initial version, and then check out a copy of the files from the branch into a convenient working directory (e.g. cvs checkout -r custom-mods-branch phpBB2). This copy is where you’ll keep track of your hacks.

从这个初始版本立即在存储库中创建一个分支(例如cvs tag -b custom-mods-branch . ),然后从分支中 cvs checkout -r custom-mods-branch phpBB2文件副本到方便的工作目录中(例如cvs checkout -r custom-mods-branch phpBB2 )。 此副本是您跟踪黑客的地方。

Copy your site’s (hacked) copy of the software’s files on top of the “clean” copy you just checked out from the branch, and then perform a CVS update to identify the files that have been modified with hacks (e.g. cvs update .). Review these changes to make sure they are all wanted.

在刚刚从分支机构签出的“干净”副本上复制站点的(被黑客入侵的)软件文件副本,然后执行CVS更新以识别已被黑客修改的文件(例如cvs update . )。 复查这些更改,以确保它们都是需要的。

Fig 1. See hacks as changes in the working copy

图1.将hacks作为工作副本中的更改

You can now track changes to your hacks as you make them in this branch. Simply hack the files in this working copy of the branch to your liking and commit your changes to the repository. To update your site with these hacks, delete everything in the destination directory and then export the latest version of your branch files to your site (e.g. cvs export -D /home/www/htdocs phpBB2).

现在,您可以在此分支中对骇客所做的更改进行跟踪。 只需根据您的喜好修改分支的此工作副本中的文件,然后将更改提交到存储库即可。 要使用这些技巧更新您的网站,请删除目标目录中的所有内容,然后将分支文件的最新版本导出到您的网站(例如cvs export -D /home/www/htdocs phpBB2 )。

与新版本合并 (Merging with New Releases)

When a new version of the software comes out, extract its files into the “clean” copy you made at the beginning, commit all the changes to CVS, and then tag the updated files for the release (e.g. cvs tag release-2-0-19 .). These updates will be stored into the trunk of your repository, so they won’t affect your hacked version (which is tracked in the branch).

发行新版本的软件时,将其文件解压缩到您最初创建的“干净”副本中,将所有更改提交到CVS,然后为该发行版标记更新的文件(例如cvs tag release-2-0-19 . )。 这些更新将存储在存储库的主干中,因此它们不会影响您的被黑版本(在分支中进行了跟踪)。

Now, here’s the payoff: to update your hacked version of the software with the changes in the latest official release, just go to your working copy of the branch and merge in all the changes from the trunk (e.g. cvs update -j release-2-0-17 -j release-2-0-19). Your hacked files should be updated seamlessly with changes that were made in the official update(s).

现在,这就是回报:要使用最新正式发行版中的更改来更新该软件的被黑版本,只需转到分支的工作副本并合并主干中的所有更改(例如, cvs update -j release-2-0-17 -j release-2-0-19 )。 您被黑的文件应使用官方更新中所做的更改进行无缝更新。

Files where your hacks occurred close to or on the same line as a change in an official release will report conflicts when you perform the merge. You’ll have to open these files and resolve the conflicts yourself (CVS will helpfully include both versions of the code at the point of conflict) before committing the corrected versions to the branch. You should then set a tag on the branch to indicate where you did the merge (e.g. cvs tag merge-2-0-19 .).

当您执行合并时,黑客入侵与正式版本中的更改接近或处于同一行的文件将报告冲突。 在将更正的版本提交到分支之前,您必须打开这些文件并自己解决冲突(CVS将在冲突点帮助包括两个版本的代码)。 然后,您应该在分支上设置一个标签以指示您在何处进行合并(例如cvs tag merge-2-0-19 . )。

In effect, CVS will perform all the updates that it can for you, and then will pick out those updates that appear to interfere with your hacks so that you can deal with them. If that isn’t useful, I don’t know what is!

实际上,CVS将执行它可以为您提供的所有更新,然后将挑选出那些似乎会干扰您的黑客的更新,以便您进行处理。 如果那没有用,我不知道这是什么!

Fig 2. The CVS tree showing merged releases.

图2.显示合并版本的CVS树。

The next time an official update comes out, you can perform another merge, but remember to update the starting tag for the merge so you only get the changes since the last time you did a merge (e.g. cvs update -j release-2-0-19 -j release-2-0-21).

下一次正式更新发布时,您可以执行另一次合并,但是请记住要更新合并的开始标记,这样您就只能获得自上次合并以来的更改(例如cvs update -j release-2-0-19 -j release-2-0-21 )。

供应商分支说明 (A Note on the Vendor Branch)

The CVS gurus in the audience may be up in arms at this point. In fact, CVS automatically creates a vendor branch for every module you check into it. You can import each new version of the software into this special branch, and then merge the changes from the branch into your (hacked) trunk.

此时,观众中的CVS专家可能会举足轻重。 实际上,CVS会为您签入的每个模块自动创建一个vendor分支 。 您可以将软件的每个新版本导入该特殊分支,然后将来自该分支的更改合并到您的(被入侵的)中继中。

So why didn’t I use this? The truth is, it’s just as easy to do all this using a normal branch as I described above, and it doesn’t require you to learn all about vendor branches and their pitfalls. Also, you can do it in simpler CVS clients that don’t support vendor branches (like the free version of SmartCVS).

那我为什么不使用它呢? 事实是,使用如上所述的普通分支来完成所有这些操作同样容易,并且不需要您全面了解卖方分支及其陷阱。 另外,您可以在不支持供应商分支的更简单的CVS客户端中进行操作(例如SmartCVS的免费版本)。

翻译自: https://www.sitepoint.com/track-your-hacks-with-cvs/

cvs cvs.lock

相关资源:jdk-8u281-windows-x64.exe
最新回复(0)