ClearCase无法从快照视图合并

问题描述 投票:1回答:3

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

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

请注意,在动态视图上执行相同的过程时,它可以正常工作。

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

view merge clearcase snapshot ibm-rational
3个回答
1
投票

好吧,我已经编写了一个脚本(实际上是两个 - 可能合并为一个),它可以满足我的需求:自动从快照视图合并到动态视图中。我假设它也可以与任何其他组合一起使用 - 但IBM 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移到您的身上:-)

0
投票

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

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

看到clearfsimport example here


0
投票

描述似乎与自相矛盾。您是在一个快照视图中并尝试从另一个中检出的版本合并吗?由于@VonC提到的原因,这通常是行不通的。 ClearCase核心没有正式“知道”最近的快照视图工作空间对于其他视图的位置,因此它无法访问视图专用副本。根据视图权限,动态视图也可能失败。

如果你试图合并到已检出版本的任意版本,你应该得到“在这个视图中已经检出的元素”(或者说这个效果的话),因为在给定的文章中只能检出一个版本的元素视图。

© www.soinside.com 2019 - 2024. All rights reserved.