1

Suppose I've checked-out a file foo on a ClearCase view, which triggered the creating of a version of that file with branch name my_branch - the first version for that file with that branch name. Now I've un-checked-out the file - but version-0 of it with that branch name remains. How can I remove it? I know there's some way to do it using a "trigger" (I'm not quite familiar with those); can I just remove it manually with some command?

Note: my_branch has versions of other files on it; it shouldn't be removed entirely.

einpoklum
  • 118,144
  • 57
  • 340
  • 684

1 Answers1

0

Manual removal of a single version-0 file

For a single file, as requested in the OP:

The (dangerous) command would be cleartool rmver

cleartool rmver util.c@@/main/my_branch/0

That would be the manual approach, assuming my_branch is created from main.

As illustrated here, in order for the version to not leave any dangling element (branch, label, hyperlink or attribute metadata), you would need:

cleartool rmver –xbranch –xlabel –xattr –xhlink util.c@@/main/my_branch/0

(assuming the version 0 is the only version on that branch)

Manual removal of all files on a branch

As I mentioned in "how to remove a version in ClearCase", if you have inadvertently created some version-0's on a branch, the better way to remove them - all of them - is to use cleartool rmbranch:

"cleartool rmbranch -force $myBranch"

You can see it used in "Command to delete branches of Clearcase element with “0” versions".
But that would be for the all branch indeed. Not for a single file.

Automatic removal

The automatic approach is put in place through a mktrtype, as I documented here.
As a script, you can use:

That does use a trigger: I mention it here just for the sake of completeness, even though it is not your preferred approach.
For a occasional cleanup, rmver is enough for a lone 0 version.
(for any other case, as discussed here, rmver is dangerous)

einpoklum
  • 118,144
  • 57
  • 340
  • 684
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Removing the 0 version on a branch will either fail or leave a dangling branch instance. Use cleartool rmbranch instead. – Brian Cowan Nov 06 '20 at 12:37
  • @BrianCowan True. I have edited the answer accordingly. – VonC Nov 06 '20 at 13:04
  • @BrianCowan: But I don't want to remove the branch globally, I just want to remove the 0-version for a specific file on that branch. Isn't rmver my practical alternative? – einpoklum Nov 08 '20 at 14:42
  • @einpoklum Good point. I have edited the answer to make the choice clearer between the two approaches (branch vs. file) – VonC Nov 08 '20 at 14:44
  • @BrianCowan: Why would rmoving version 0 fail? And why would it "leave a dangling branch instance" if other files are on that branch? – einpoklum Nov 08 '20 at 14:44
  • @VonC: But this question is not about removing the entire branch. I made it pretty clear but will clarify further. – einpoklum Nov 08 '20 at 14:46
  • @einpoklum Agreed. This is for other readers, to illustrates there are two approaches to consider. For the rmver one (for a single file), you might need to use more option on rmver in order to not leave any dangling elements (ie: branches, labels, hyperlinks, attributes): see https://stackoverflow.com/a/19552030/6309. – VonC Nov 08 '20 at 14:47
  • @einpoklum I have put back rmver as the first choice in this answer, since it fits your question. I have put rmbranch in last, for completeness sake. – VonC Nov 08 '20 at 16:45
  • @einpoklum Rmver on a zero version may fail if it's the ony version on the branch, because in that case removing the branch is more appropriate. A zero version is -- by definition -- identical to its predecessor version on its parent branch. It is almost never necessary to remove the .../branch/0 version of an element if there are .../1, .../2, etc., versions. – Brian Cowan Nov 09 '20 at 18:47
  • @BrianCowan: Ok, but I specifically said I have other files on the same branch. As for my motivation - it has to do with not prefering the new-branch version over more up-to-date version on the base branch (i.e. a later configspec rule). – einpoklum Nov 09 '20 at 21:33
  • @einpoklum "Files on a branch" is more the way Perforce and GIT work. Branches are in the forefront in Perforce, and GIT branches whole snapshots. Branches are parts of elements in CC, which makes it a bit challenging at times. Generally speaking, if the only version on a branch of a file is the \0 version, you want to get rid of it because you may want to see the newer versions. Intentionally mkbranching a whole raft of files to "freeze" them is a bit redundant since labels would have the same impact... – Brian Cowan Dec 01 '20 at 22:15
  • @BrianCowan: I was just mis-phrasing my comment. It should be "I have other files which have versions with the same branch". – einpoklum Dec 02 '20 at 09:00
  • @einpoklum Removing a branch from one file element will not impact other file elements at all. Other SCM tools (GIT and perhaps Perforce) where branches are front-and-center will behave differently if files are unique to the branch and aren't in the "trunk"/"master"/"main" branch. "Elements" (Files and directories) are front-and-center in CC, and the paradigm difference is somewhat confusing when going between systems. – Brian Cowan Dec 09 '20 at 15:52
  • @BrianCowan: Branch types are not per-file in ClearCase. – einpoklum Dec 09 '20 at 21:27