ClearCase 无法从快照视图合并

ClearCase can't merge from a snapshot view

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

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

请注意,在动态视图上执行相同的过程时效果很好。

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

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

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

看到一个

描述似乎自相矛盾。您是否在一个快照视图中并试图从一个签出的版本合并到另一个快照视图中?由于@VonC 提到的原因,这通常不起作用。 ClearCase 核心并未正式 "know" 最近的快照视图工作区用于其他视图,因此它无法访问视图私有副本。对于动态视图,这也可能会失败,具体取决于视图权限。

如果您尝试从签出的版本合并到任意版本,您应该得到 "element already checked out in this view"(或类似的词),因为在一个元素中只能签出一个版本给出的视图。

好的,我已经编写了一个脚本(实际上是两个 - 可能会合并为一个)来执行我需要的操作:自动从快照视图合并到动态视图。我认为它也可以与任何其他组合一起使用 - 但是 IBM 已经支持 dynamic to dynamicdynamic to snapshot ClearCase "Merge Manager" 工具.

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 移到你的 :-)