如何重命名 CVS 中的分支?

发布于 2024-07-26 03:48:58 字数 211 浏览 5 评论 0原文

如果您在 CVS 中错误地命名了分支,或者最初选择的名称变得不合适,如何将其更改为其他名称?

一个相关的问题是如何重命名分支在没有管理员访问权限的 CVS 中?

If you've named a branch in CVS incorrectly, or the name originally chosen becomes inappropriate, how do you change it to something else?

A related question is How do you rename a branch in CVS without admin access?.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

昔日梦未散 2024-08-02 03:48:58

实现这一点的技巧是使用 CVS 中比较晦涩的管理命令之一 -N。 这是一个两个阶段的过程,有效地复制然后删除。

首先,您创建一个具有引用原始分支名称的正确名称的分支。 其次,删除原来的分支名称。

假设您有一个文件“File.txt”,当前分支为“bad_branch”。 您希望调用该分支 - 您能猜到吗? - “好_分支”。

kwutchak%cvs 日志文件.txt

RCS 文件:.../data/File.txt,v
头数:1.1
分行:
符号名称:
错误_分支:1.1.0.2

要创建新的分支引用:

cvs admin -N good_branch:bad_branch File.txt

kwutchak%cvs 日志文件.txt

RCS 文件:.../data/File.txt,v
工作文件:File.txt
头数:1.1
分行:
符号名称:
_分支:1.1.0.2
错误_分支:1.1.0.2

Bonus Tip:

A symbolic name is not always required with `-N`.  It is sometimes
valid to use a numeric reference to the branch (as when one may have
used `cvs admin -N` and accidentally deleted the branch name by running 
a delete command like `cvs admin -N bad_branch` when there is no
other name assigned yet.  The following command worked to add a name
to a branch (that contained only one file) and the file no longer had
a branch name associated with it:

    cvs admin -N good_branch:1.1.2.1 File.txt

删除原始引用:

cvs admin -N bad_branch File.txt

kwutchak%cvs日志文件.txt

RCS 文件:.../data/File.txt,v
工作文件:File.txt
头数:1.1
分行:
符号名称:
好的_分支:1.1.0.2

The trick to this is using one of CVSs' more obscure admin commands, -N. It is a two stage process, effectively copy then remove.

Firstly, you create a branch with the correct name that references the original branch name. Secondly, you delete the original branch name.

Assume you have a file "File.txt" that is currently branched "bad_branch". You'd like the branch to be called - can you guess? - "good_branch".

kwutchak% cvs log File.txt

RCS file: .../data/File.txt,v
head: 1.1
branch:
symbolic names:
bad_branch: 1.1.0.2

To create the new branch reference:

cvs admin -N good_branch:bad_branch File.txt

kwutchak% cvs log File.txt

RCS file: .../data/File.txt,v
Working file: File.txt
head: 1.1
branch:
symbolic names:
good_branch: 1.1.0.2
bad_branch: 1.1.0.2

Bonus Tip:

A symbolic name is not always required with `-N`.  It is sometimes
valid to use a numeric reference to the branch (as when one may have
used `cvs admin -N` and accidentally deleted the branch name by running 
a delete command like `cvs admin -N bad_branch` when there is no
other name assigned yet.  The following command worked to add a name
to a branch (that contained only one file) and the file no longer had
a branch name associated with it:

    cvs admin -N good_branch:1.1.2.1 File.txt

To delete the original reference:

cvs admin -N bad_branch File.txt

kwutchak% cvs log File.txt

RCS file: .../data/File.txt,v
Working file: File.txt
head: 1.1
branch:
symbolic names:
good_branch: 1.1.0.2

方觉久 2024-08-02 03:48:58

由于我还无法向给定的答案添加注释(声誉较低),我想指出的是,先前答案中的给定命令缺少双引号!

更正:

grep "old-branch-name" * -rl | xargs sed -i 's/old-branch-name/new-branch-name/g'

As I cannot add comments to given answers yet (reputation to low), I want to remark that the given command in previous answer is missing double-quotes!

Correction:

grep "old-branch-name" * -rl | xargs sed -i 's/old-branch-name/new-branch-name/g'
爱的那么颓废 2024-08-02 03:48:58

如果您在“几个分支之前”犯了一个错误,则由于分支位置发生变化,admin -N 选项将不会有帮助。

该解决方案仅适用于对您的项目存储库的完全访问权限。

  1. 转到 CVSROOT/Project
  2. 创建备份副本
  3. grep "old-branch-name" * -rl | xargs sed -i 's/old-branch-name/new-branch-name/g'

对我来说就像一个魅力。

抱歉,死灵,但我认为我的解决方案将帮助任何与我情况类似的人。

If you made a mistake "a few branches ago", admin -N option won't be helpful due to the branch position change.

This solution will work only with full access to repository of Your project.

  1. Go to CVSROOT/Project
  2. Create a backup copy
  3. grep "old-branch-name" * -rl | xargs sed -i 's/old-branch-name/new-branch-name/g'

Worked like a charm for me.

Sorry for necro, but I think that my solution will help anyone with situation similiar to mine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文