ClearCase无法从快照视图合并

时间:2018-10-28 18:36:43

标签: view merge clearcase snapshot ibm-rational

我正在使用IBM Rational Clear Case, 我有一个快照视图,其中包含一些已签出的文件。该视图即将过时,我需要将这些已签出的文件合并到新版本中(新视图)。

我的问题:我正在使用ClearCase版本树浏览器(clearvtree.exe)进行合并。我要在其中合并文件的视图上为其中一个签出文件打开版本树。现在,当我尝试选择检出的文件时:右键单击->并选择"Merge to",我将收到以下错误: "The selected version is not accessible from this view".

请注意,在Dynamic View上执行相同的过程时,效果很好。

我知道我可以手动复制这些文件,但是我正在尝试找到一种使用ClearCase工具(例如合并工具和偏离版本树)的方法。

3 个答案:

答案 0 :(得分:1)

好的,我已经编写了一个脚本(实际上是两个脚本-可能会合并为一个脚本),该脚本可以满足我的需要:自动从快照视图合并到动态视图。我认为它也可以与任何其他组合一起使用-但 IBM ClearCase“合并管理器”工具已经支持动态到动态动态到快照

First Scrip将找到所有结帐并相应地设置其格式,同时将它们添加到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 ------------------------------------------------------------------

第二个脚本获取files.txt并将它们从源视图合并到目标视图:

@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

这两个脚本都将我需要的所有文件从源视图合并到目标视图。

注意:

  • 您可以创建一个批处理文件,以获取SOURCE_VIEW和TARGET_VIEW 在命令行中分别为%1和%2,
  • 我将其拆分为两个脚本,因此可以从 列表,然后实际进行合并。
  • 脚本将保留文件的原始注释。
  • %〜dp0-这是我可以强制在当前批处理文件中工作的方式 目录。
  • 随时发表评论。如果您有更好的解决方案,我将很高兴 将我的V移到您的:-)

答案 1 :(得分:0)

由于它是快照视图,因此其签出的文件只能在实际的视图路径中访问,而不能在其视图存储(如动态视图)中访问

如果您有权访问快照视图路径,则可以使用 clearfsimport 以便将修改后的/新文件从所述快照视图自动导入到当前视图。

查看clearfsimport example here

答案 2 :(得分:0)

该描述似乎矛盾。您是否在一个快照视图中并尝试从已签出的版本合并到另一个快照中?由于@VonC提到的原因,这通常不起作用。 ClearCase核心不能正式“知道”最新快照视图工作空间在该其他视图的位置,因此它无法访问视图专用副本。对于动态视图,这也可能失败,具体取决于视图权限。

如果您尝试从已检出的版本合并到任意版本,则应该得到“此视图中的元素已经检出”(或具有这种含义的单词),因为只能检出一个元素的一个版本在给定的视图中。