简体   繁体   中英

svn merge with revision not doing what I expect

I'm trying to do an svn merge of a change from trunk onto a branch (2001). The change is in trunk on revision 614.

I've tried the following and none of them do what I want :

svn merge
svn merge -r 614:HEAD https://secreturl/trunk

But this seems to pick up a lot of changes I don't want.

When I ran: svn log -r 614 https://secreturl/trunk - I saw the checkin comment for the small subset of changes I wanted to merge. What am I missing here?

svn merge -r 614:HEAD https://secreturl/trunk will merge all changes between revision 614 and HEAD. Moreover, it will take 614 as the base revision (probably not what you want happenning :)

To merge changes from a specific revision, you can use one of two methods:

$ svn merge -c 614 https://secreturl/trunk or $ svn merge -r 613:614 https://secreturl/trunk .

The first means apply changes in revision 614 only , while the second form means take all changes required to go from r613 to r614 and apply them here .

I think you want -r 613:HEAD. If you JUST want change 614, do -r 613:614.

svn log -r 614 will show you the specific 614 revision. If you want to just merge the results of r614, do this:

svn merge -r 613:614 https://secreturl/trunk

That is, merge the changes from 613 to 614.

I took the information above, and made a windows .bat file to show how this can be scripted. My addition is showing more explicitly how you are dealing with the LOCAL WORKING COPY, and then committing back to the repository.

In the .bat file below, I put in a svn.exe status to show what will happen if you commit, and then a PAUSE, to give you a last chance to X out and not perform the commit.

Here is the .bat file

FYI, I am using svn.exe 1.6.15.

 set __SVNClient="C:\Program Files (x86)\CollabNet\Subversion Client\svn.exe"

 set __PreviousRevisionNumber=2594

 set __CheckoutFolder=".\MyCheckoutFolderRevision%__PreviousRevisionNumber%"


 RD %__CheckoutFolder% /Q /S



 %__SVNClient% checkout "https://www.myrepository.com/MyProject/trunk" %__CheckoutFolder% --username %USERNAME%


 CD %__CheckoutFolder%


%__SVNClient% merge --revision HEAD:%__PreviousRevisionNumber% "."



%__SVNClient% status "."



PAUSE



%__SVNClient% commit -m "Manual Change. Revision %__PreviousRevisionNumber% was pulled out of repository and then it was made the HEAD Revision." "." --username %USERNAME%

CD ..



set __CheckoutFolder=
set __PreviousRevisionNumber=
set __SVNClient=

This below site (and section name) gives a little more explanation:

http://durak.org/sean/pubs/software/version-control-with-subversion-1.6/svn.branchmerge.basicmerging.html
(Search for "Undoing Changes" as a section header)

Good site to help you along
Link 1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM