1

I am experiencing a problem with Clearcase. What happened was the following: I had a file ValidationScripts.js, and wanted to create another file in the same directory, MiscScripts.js. However, instead of creating a new file, I accidentally renamed ValidationScripts.js to MiscScripts.js. I tried to recreate the ValidationScripts.js file using merge, and now I am stuck with the same file, but with two different names: ValidationScripts.js and MiscScripts.js. So, whenever I try to change to contents of ValidationScripts.js, they are also reflected on MiscScripts.js. Is there any way to fix this?

TIA.

user459459
  • 41
  • 1
  • 5

2 Answers2

3

It isn't completely clear what you did, but what you should have done is this, assuming that the file MiscScripts.js already existed as a plain (view private) text file, and that 'ct' is an alias for cleartool:

cd /vobs/yourvob/directory
ct co -c 'Add MiscScripts.js' .
ct mkelem -c 'Miscellaneous JavaScript Script Fragments' MiscScripts.js
ct ci -nc .
ct ci -nc MiscScripts.js

Now we have to try and guess what you actually did.

I will assume you checked out the directory. You then said:

instead of creating a new file, I accidentally renamed ValidationScripts.js to MiscScripts.js

There are two possibilities:

  1. mv ValidationScripts.js MiscScripts.js
  2. ct mv ValidationScripts.js MiscScripts.js

To fix case 1, you should simply have run:

mv MiscScripts.js ValidationScripts.js

To fix case 2, you should either cancel the directory checkout or undo the move:

Either

ct unco -rm .

Or

ct mv MiscScripts.js ValidationScripts.js

You then go on to say:

I tried to recreate the ValidationScripts.js file using merge, and now I am stuck with the same file, but with two different names: ValidationScripts.js and MiscScripts.js.

And this has me puzzled...I can't see how merge would help. The latter comment sounds as if you did something like:

ct ln MiscScripts.js ValidationScripts.js

Without knowing exactly what you've done, it is a little difficult to know what to recommend. Key issues are:

  1. Did you use ct mkelem to create a new file?
    • If you did, then we have to worry about not creating a lost entry in the VOB's lost+found directory.
    • If you did not, then life is simpler.
  2. Did you checkin the directory yet?
    • If not, do not do so.
    • If you did, then we will need to work out how to get you back to the previous revision (but we no longer have to worry about lost+found files.
  3. Did you checkin MiscScripts.js yet?
    • How much this matters depends in part on the answers to the prior questions.
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • 1. I used the ClearCase Explorer to create the new file. Not sure if it uses ct mkelem or something else. 2. Yep, the directory is checked in. 3. Yes, MiscScripts.js is checked in as well. – user459459 Dec 08 '11 at 13:40
  • @user459459: in case of trouble, always fall back on a shell session where you can type some cleartool command ;) – VonC Dec 08 '11 at 13:55
  • Yeah, I have realized the command prompt is much better than the GUI, if you know what you are doing. – user459459 Dec 08 '11 at 14:03
  • Since I've never used the ClearCase Explorer, I can't help you with it at all. It sounds like you need to: (0) take a backup copy of the files, somewhere outside the view; (1) checkout the directory; (2) remove ('rmname') the MiscScripts.jl file (and optionally check-in the directory, then check it out again); (3) copy the version of MiscScripts.js that you want to record to the directory; (4) create a new element for MiscScripts.js in ClearCase; (5) check-in the directory; (6) check-in the new file. This should leave you with a working, independent MiscScripts.js. – Jonathan Leffler Dec 08 '11 at 15:25
  • This leaves a question of whether your ValidationScripts.js file got damaged in this process. If so, then the fixup depends on the nature of the damage. If ValidationScripts.js is somehow a copy of (a previous incarnation of) MiscScripts.js, then I'd look at the history of ValidationScripts.js. If it is complete (containing the valid history and then a bogus check-in), then check-out the file with comments about reverting to a known good state; then copy the last known good version over the current version, and check-in. [...to be continued...] – Jonathan Leffler Dec 08 '11 at 15:30
  • If ValidationScripts.js has no history of relevance, then you need to know the last good version of the directory. You check-out the directory; you 'rmname' ValidationScripts.js; you use '`ct ln .@@/main/branch/X/ValidationScripts.js .`' to pull in the correct incarnation of ValidationScripts.js (where X is the version number of the directory holding the good file); look at the file to ensure it is what you expect; assuming all is OK, check-in the directory. If there are still problems, consult your ClearCase admin. It is resolvable on the spot, but fiendish to resolve by remote control. – Jonathan Leffler Dec 08 '11 at 15:34
  • The good news in all this is that ClearCase has preserved the history of what you've done, and therefore it can be unwound and undone. That is the quintessence of a source code version control system. Next time something similar happens, **do not panic**. Consult immediately. The admin would rather head off the trouble before it happens than fix it afterwards. – Jonathan Leffler Dec 08 '11 at 15:35
2

To add to Jonathan's answer, you need to check the history (cleartool lsvtree -graph) of the parent directory of ValidationScripts.js: you will see what has been added/removed in said directory.

A simple 'cleartool ls' in that directory can also show you if there is a symlink between ValidationScripts.js and MiscScripts.js.
That would be like you tried to restored a deleted file, as described in "Restore an element that has been rmnamed", but made the wrong 'cleartool ln'.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you! I have done some reasearch and found out that I have a merge hyperlink between the two files. Deleting it with `rmmerge` or `rmhlink` fails, as my Clearcase admin setup a trigger to prevent them both. Is there still a way I can solve this problem myself? – user459459 Dec 08 '11 at 14:01
  • @user459459: I would recommend delete (rmname) the file pointed by the hyperlink, and recreate it (unless that file is `ValidationScripts.js` which has already an history) – VonC Dec 08 '11 at 14:31