假设I Branch Solution-A,将setset 10变为Solution-B。
稍后,我意识到Solution-B不应该有变更集7。
有没有办法在不损害解决方案A的情况下从解决方案B回滚变更集7?
每当我使用tf rollback时,所有挂起的更改都会转到Solution-A。
提前致谢!
答案 0 :(得分:2)
我知道这是一个老问题,但这可能对任何遇到同样问题的人有所帮助。特别是当你需要回滚一个在很久以前在另一个分支上检查过的变更集时。
在以下批处理文件中更新WORKSPACE_ROOT和TFS_BRANCH_ROOT。 将其命名为RollbackMigrate.cmd并始终从工作空间根目录运行它。
此批处理文件将:
@echo off
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
set WORKSPACE_ROOT=D:\PathToMyWorkspaces
set TFS_BRANCH_ROOT=$/Project/Branches
:01_ARGUMENT_PARSING
echo Rollback changes from another branch
if [%1]==[] (
set /P CHANGESET=Enter changeset number:
if [!CHANGESET!]==[] (
echo Changeset number is required! Exiting!
exit /B 1
)
) else (
set CHANGESET=%1
shift
)
set SHELVE_NAME="Auto shelved rollback of %CHANGESET%"
:02_FIND_MY_WORKSPACE_NAME
for %%i in (.) do (
set WORKSPACE=%%~nxi
)
if not [%CD%]==[%WORKSPACE_ROOT%\%WORKSPACE%] (
echo This script works only in the root of workspace e.g. D:\PathToMyWorkspaces\MyWorkspace
exit /B 1
)
echo Current workspace is %WORKSPACE%
for /f %%i in ('tf workspaces %WORKSPACE% /noprompt /format:detailed ^| grep -om 1 "$/[^:]\+"') do (
if not [%DST%]==[] (
echo Cannot work on workspaces with more mappings! Exiting!
exit /B 2
)
set DST=%%i
echo Found destination path for migration: "%%i"
)
:03_VIEW_CHANGESET
for /f %%i in ('tf changeset 1570888 ^| grep -om 1 "%TFS_BRANCH_ROOT%/[^/]\+/[^/]\+"') do (
set SRC=%%i
echo Found source path for migration: "%%i"
)
if [%SRC%]==[] (
echo Cannot find path to source branch! Exiting!
exit /B 3
)
for %%i in (%SRC%) do (
set SRC_BRANCH=%%~nxi
)
:04_MAP_SOURCE
set TMP_SRC_PATH=%WORKSPACE_ROOT%\%WORKSPACE%_%SRC_BRANCH%
echo Create temporary mapping for source branch in %TMP_SRC_PATH%
mkdir %TMP_SRC_PATH%
echo Creating mapping for "%SRC%" to "%TMP_SRC_PATH%"
tf workfold /map %SRC% %TMP_SRC_PATH%
if %errorlevel% NEQ 0 (
echo Can't create mapping for "%SRC%", exiting!
exit /B 4
)
:05_ROLLBACK_CHANGESET
echo Performing rollback of changeset %CHANGESET%
tf rollback /changeset:%CHANGESET% /lock:checkin /keepmergehistory
:06_SHELVE_ROLLBACK
echo Shelving rollback
tf shelve /comment:%SHELVE_NAME% %SHELVE_NAME% /noprompt /move /replace
:07_UNMAP_AND_DELETE_TEMPORARY
echo Unmapping "%SRC%" from "%TMP_SRC_PATH%"
tf workfold /unmap "%TMP_SRC_PATH%"
echo Deleting "%TMP_SRC_PATH%"
rmdir /S /Q "%TMP_SRC_PATH%"
:08_UNSHELVE_MIGRATE
echo Unshelving the rollback...
tfpt unshelve /migrate /source:"%SRC%" /target:"%DST%" %SHELVE_NAME% /noprompt
:09_DELETE_THE_SHELVESET
echo Deleting the shelveset
tf shelve /delete %SHELVE_NAME% /noprompt
:10_CHECKIN
echo Checking in the rollback...
tf checkin
答案 1 :(得分:1)
您必须将包含合并的变更集回滚到解决方案b,然后在没有变更集7的情况下重新应用合并。
答案 2 :(得分:0)
我建议使用电源工具包附带的TFPT.exe:http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f/
高级概述:
命令:
答案 3 :(得分:0)
最后我做了类似下面的事情。
将来从Solution-A合并到Solution-B跳过合并变更集12。