How do you rename a branch in CVS?
Asked Answered
T

3

11

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?.

Thaumatrope answered 10/7, 2009 at 6:47 Comment(0)
T
13

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

Thaumatrope answered 10/7, 2009 at 6:51 Comment(2)
Please excuse me for accepting my own answer - I'm using StackOverflow as a record so that I don't need to research this again in future...Thaumatrope
Many people use it for the same purpose, until you add something useful to the whole community you're welcome to do so.Tiana
I
0

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.

Interrogate answered 16/4, 2013 at 7:27 Comment(0)
P
0

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'
Plaided answered 19/8, 2013 at 9:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.