1

I am using IBM Rational Clear Case, I have a snapshot view, with some checked-out files. This view is about to be obsolete, and I need these checked-out files to be merge to a new version (New view).

My problem: I am using ClearCase Version Tree Browser (clearvtree.exe) to do my merge. I opened the Version Tree for one of the checked-out files, on the view to which I want to merge the file. Now when ever I try to select the checked out file: right click -> and select "Merge to" I get the following error: "The selected version is not accessible from this view".

Note that when doing the same procedure on Dynamic View it works fine.

I know I can copy these files manually, but I am trying to find a way to do this, using the ClearCase tools (such as the Merge Tool and off-course the Version Tree).

Juv
  • 744
  • 7
  • 12

3 Answers3

1

OK, I have written a script (Actually two - which might be merged to one) that do what I need: To automatically merge from a snapshot view into a dynamic view. I assume it will also work with any other combination - but dynamic to dynamic or dynamic to snapshot is already supported by the IBM ClearCase "Merge Manager" tool.

First Scrip will find all checkouts and format them accordingly, while adding them to files.txt:

@echo off
REM ------------------------------- synopsis ----------------------------------
REM This script creates a list of all checked out into files.txt under the 
REM batch-file directory.
REM files in the following format:
REM \VOB1\file1.txt@@\main\branch_v111\CHECKEDOUT@@Comment for file1
REM \VOB2\file2.txt@@\main\branch_v111\CHECKEDOUT@@Comment for file2
REM \VOB2\file3.txt@@\main\branch_v111\CHECKEDOUT@@Comment for file3
REM ------------------------------- synopsis ----------------------------------

set source_view_path=C:\Snapshot\some-snapshot-john
set currentDirectory=%~dp0
set chekedOutOutputFile=%currentDirectory%find_co.txt
set resultFile=%currentDirectory%files.txt

@echo Getting checkouts of %source_view_path%
@echo %currentDirectory%

REM ---------------------------------------------------------------------------
REM The next code produces a find_co.txt intermediate file with the following 
REM format of checkouts:
REM <File Full Path>@@<Version ID>@@<File Comment>
REM    %n  - for file Name (With full path)
REM    %Vn - for file Version ID.
REM    %c  - for file Comment
REM
REM Example:
REM C:\MY_VIEW_PATH\VOB1\file1.txt@@\main\branch_v111\CHECKEDOUT@@Comment for file1
REM C:\MY_VIEW_PATH\VOB2\file2.txt@@\main\branch_v111\CHECKEDOUT@@Comment for file2
REM C:\MY_VIEW_PATH\VOB2\file3.txt@@\main\branch_v111\CHECKEDOUT@@Comment for file3
REM --------------------------------------------------------------------------- 
pushd %source_view_path%
cleartool lsco -cview -avobs -fmt "%%n@@%%Vn@@%%c" > "%chekedOutOutputFile%"
popd

del /q "%resultFile%"

REM ---------------------------------------------------------------------------
REM The following code formats the find_co.txt into files.txt with the desired 
REM result - <File VOB Path>@@<Version ID>@@<File Comment>
REM Example:
REM From -
REM C:\MY_VIEW_PATH\VOB1\file1.txt@@\main\branch_v111\CHECKEDOUT@@Comment for file1
REM C:\MY_VIEW_PATH\VOB2\file2.txt@@\main\branch_v111\CHECKEDOUT@@Comment for file2
REM C:\MY_VIEW_PATH\VOB2\file3.txt@@\main\branch_v111\CHECKEDOUT@@Comment for file3
REM To 
REM \VOB1\file1.txt@@\main\branch_v111\CHECKEDOUT@@Comment for file1
REM \VOB2\file2.txt@@\main\branch_v111\CHECKEDOUT@@Comment for file2
REM \VOB2\file3.txt@@\main\branch_v111\CHECKEDOUT@@Comment for file3
REM ---------------------------------------------------------------------------
for /F "usebackq tokens=*" %%A in ("%chekedOutOutputFile%") do (
    call ::removeSourceViewPath "%%%A"
)
goto endOfScript

REM ---------------------------------------------------------------------------
REM Manipulate the path of each file to exclude the view from it e.g:
REM C:\MY_VIEW_PATH\MY_VOB\file.txt -> \MY_VOB\file.txt
REM >>>-----------------> start of :removeSourceViewPath 
:removeSourceViewPath
    set str=%1
    call set "resultStr=%%str:%source_view_path%=%%"
    set resultStr=%resultStr:~1,-1%
    @echo %resultStr%
    @echo.%resultStr%>>"%resultFile%"
    exit /b

REM <<<-----------------< end of :removeSourceViewPath
REM ---------------------------------------------------------------------------

:endOfScript

pause
@echo ------------------------------------------------------------------

The second script takes the files.txt and merges them from a source view to a target view:

@echo off
REM ------------------------------- synopsis ----------------------------------
REM This script takes a list of all files from the files.txt which is under 
REM this batch-file directory and merges them from TARGET to SOURCES views
REM files in the following format:
REM <File VOB Path>@@<Version ID>@@<File Comment>
REM are merged from <SOURCE_VIEW>\<File VOB Path> to 
REM <TARGET_VIEW>\<File VOB Path> with the <File Comment> as comment.
REM ------------------------------- synopsis ----------------------------------
setlocal

set TARGET_VIEW=V:\v11-john-local-nt
set SOURCE_VIEW=C:\Snapshot\some-snapshot-john

REM ---------------------------------------------------------------------------
REM The following takes the line:
REM <File VOB Path>@@<Version ID>@@<File Comment> and checks out the target 
REM file, then it automatically merges the file from source to target.
REM Note that the version is not required here (it might be required if we
REM want to merged from a version which is not the latest one in the branch).
REM ---------------------------------------------------------------------------
for /f "tokens=1,2,3 delims=@@" %%i in (files.txt) do (
    cleartool co -unreserved -c "%%k" %TARGET_VIEW%%%i
    cleartool merge -to %TARGET_VIEW%%%i %SOURCE_VIEW%%%i 
)

endlocal

pause

Both of this scripts merged all the file I needed from the source View to the target View.

Notes:

  • You can create a batch file that get the SOURCE_VIEW and TARGET_VIEW in the command line as %1 and %2,
  • I splittend this into two scripts so I can remove some files from the list, before actually doing the merge.
  • The scripts will preserve the original comment of the file.
  • %~dp0 - This is how I can force working in the current batch file directory.
  • Feel free to comment. If you have a better solution I will be glad to move my V to yours :-)
Juv
  • 744
  • 7
  • 12
  • I fixed a bug in the script where I assume that the view is in my C: folder. Replaced the following `pushd` `c:` `cd %source_view_path%` With just doing `pushd %source_view_path%` – Juv Apr 29 '19 at 07:04
0

Since it is a snapshot view, its checked out files are only accessible in the actual view path, not in its view storage (like a dynamic view)

If you have access to the snapshot view path, you can use clearfsimport in order to automatically import the modified/new files from said snapshot view to your current view.

See a clearfsimport example here.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • We are also using dynamic local view, where the checked out (and new) files are on the user machine, while all other files are on the ClearCase repository (Database). This "local" files are visible to other and it is possible to compare merge and do ClearCase operations by other users, as long as the client machine is up and the read permissions are OK. I thought that setting the permission on the snapshot view will also do the trick. A bonus would have been the ability of other users to see my snapshot checked-outs, merge them and compare. – Juv Oct 29 '18 at 09:34
  • @Juv You mentioned " I have a snapshot view, with some checked-out files". My answer stands. – VonC Oct 29 '18 at 21:25
  • Does the [`clearfsimport`](https://stackoverflow.com/a/39368173/6309) know how to do merge, since work might have been continued on some of the files? – Juv Nov 06 '18 at 10:22
  • @Juv It knows how to update, creating a new version with the imported content. You will have to do a diff on some on those files to check if a merge was needed. – VonC Nov 06 '18 at 10:26
0

The description seems to contradict itself. Are you in ONE snapshot view and attempting to merge FROM a checked out version in another one? That generally will not work for the reason @VonC mentioned. The ClearCase core doesn't officially "know" where the most recent snapshot view workspace is for that other view, so it can't access the view-private copy. This could also fail for a dynamic view depending on view permissions.

If you are trying to merge TO an arbitrary version FROM your checked out version, you should be getting "element already checked out in this view" (Or words to that effect) since only one version of an element can be checked out in a given view.

Brian Cowan
  • 1,048
  • 6
  • 7
  • I am in a dynamic view, the check-outs are in a soon to become obsolete snapshot. I need to merge these check-outs to the dynamic view. The dynamic vies is actually a local view (hybrid dynamic view - where all check-outs are in my local machine). I thought that registering the snapshot will do the trick. Since the Local View db structure is similar to the Snapshot db structure: **Snapshot:** 'view.stg', **Local VIew:** '.vws'. – Juv Nov 05 '18 at 08:56
  • From this, I have to guess that you have the full parent directory of that "colocated" view. In which case you should have a local copy of the checked out files. In which case, why not check the changes in and then merge them from either view? If the only thing you have is the view.stg directory and not the actual "workspace." Then those changes no longer exist unless you can find the workspace somewhere. – Brian Cowan Nov 06 '18 at 15:24
  • Sorry for the late response. As for you question: I can't do check-ins to something which I am in the milde of working, and is not finalized, since this is backbone code. BTW I have written and posted bellow, a script that actually does what I needed:-). Many thanks. – Juv Apr 28 '19 at 16:04