Tortoise SVN merge - tortoisesvn

I have a file a.c in the branch branch_1 with below versions.
Previous version: 10
Next version : 20
Current version :25
My working copy is branch_2
I want to merge the difference between versions 20 and 10 in branch_1 to working copy only for a.c file.
How can I merge it using tortoise svn?
I had written below batch file to work manually execute the bat file, but I want to do this with tortoise svn + external diff program.
#ECHO OFF
set svn_url="https://Project/branches/"
SET DIFF3="C:\Program Files\Beyond Compare 3\BComp.exe"
SET BRANCH=%1
SET FOLDER=%2
SET FILE=%3
SET NV=%4
SET PV=%5
svn co %svn_url%/%BRANCH%/%FOLDER%/ --depth empty
cd %FOLDER%
svn update -r %NV% %FILE%
del %FILE%_%NV%
rename %FILE% %FILE%_%NV%
svn update -r %PV% %FILE%
del %FILE%_%PV%
rename %FILE% %FILE%_%PV%
%DIFF3% %FILE%_%NV% D:\Projct\%FOLDER%\%FILE% %FILE%_%PV%
pause

I'm not sure what current version 25 means when next version is 20.
But to merge in tortoise, right click on your working copy, either a directory or a file, select merge. Choose the source file/directory you want to merge changes from and pick the revisions from the dialog that pops up. Its really simple.

Related

How to visually compare two revisions of a folder versioned by SVN on Linux?

I can compare a current folder state to its latest revision using the following command:
meld .
meld shows a list of changed files. One can click on each file and see a diff.
Is it possible to compare a current folder state to its specific revision (not the latest one)?
TortoiseSVN allows to compare arbitrary revisions, however it works on Windows only. SmartSVN is proprietary. SVN CLI is unusable for big changesets (CLI diff is fine for small commits, but it's very hard to use it for branch comparision with a lot of changes).
Maybe I could checkout the revision to compare into a separate folder and compare two folders using meld. But I guess there should be a simpler approach.
Preface
Question is offtopic here: as already mentioned in comment, it's question for Software Recommendations site
Face
Every versioned object with history in SVN can be referenced using PEG-revision for its history state
Folder in SVN-repo is object of versioning
In order to compare two folders, you have to have folder-diff tool (for your OS) and know (command-line) options for calling it
According to Slant's comparison:
Meld can be used on Linux for folder-diffing
Best folder-diff tool is Beyond Compare
From points 1-3 above it follows that Meld can be used for your task in form
meld folder#REV1 folder#REV2
Folder comparision is usually required for code review or branch merging. It seems that the simplest approach is as follows:
Find last trunk revision merged to a current brach
If the current branch was not merged from trunk, then find the branch creation revision
Checkout trunk with a specified revision to some folder
Compare the trunk folder and the brach folder
I didn't found any existing tools supporting it. Here is a bash script I use, maybe it will be useful for someone:
TRUNK_BASE_PATH=~/tmp
BRANCH_RELATIVE_URL=$(svn info --no-newline --show-item relative-url)
if [[ "$BRANCH_RELATIVE_URL" != *"/branches/"* ]]; then
echo "Run it in a branch. Relative URL should contain /branches/. Given: $BRANCH_RELATIVE_URL"
exit 1
fi
TRUNK_RELATIVE_URL=${BRANCH_RELATIVE_URL%%/branches/*}/trunk
echo "Trunk relative URL: $TRUNK_RELATIVE_URL"
ROOT_URL=$(svn info --no-newline --show-item repos-root-url)
TRUNK_URL=${ROOT_URL}${TRUNK_RELATIVE_URL:1}
echo "Trunk URL: $TRUNK_URL"
TRUNK_PATH=${TRUNK_BASE_PATH}/${TRUNK_URL#*://}
echo "Trunk local copy path: $TRUNK_PATH"
BRANCH_PATH=$(svn info --no-newline --show-item wc-root)
echo "Branch local copy path: $BRANCH_PATH"
SUBFOLDER=$(realpath --relative-to="$BRANCH_PATH" .)
echo "Comparing subfolders: $SUBFOLDER"
TRUNK_REVISION=$(svn mergeinfo --show-revs merged -R "$TRUNK_RELATIVE_URL" "$BRANCH_PATH" | tail -n 1)
if [[ -z "$TRUNK_REVISION" ]]; then
TRUNK_REVISION=$(svn log -r 1:HEAD --limit 1 --stop-on-copy -q | grep -oP "^r\K[0-9]+")
echo "Comparison with trunk#$TRUNK_REVISION from which the current branch was copied"
else
echo "Comparison with trunk#$TRUNK_REVISION with which the current branch was last merged"
fi
if [[ -d "$TRUNK_PATH/.svn" ]]; then
echo "Found .svn subfolder in the local trunk copy, updating it"
svn update -r $TRUNK_REVISION "$TRUNK_PATH"
else
echo "Not found .svn subfolder in the local trunk copy, checking out it"
svn checkout "$TRUNK_URL" -r $TRUNK_REVISION "$TRUNK_PATH"
fi
meld "$TRUNK_PATH/$SUBFOLDER" . &!

Using git diff to replicate changes in another directory

I have multiple websites structured (simplified) as follows under a single GIT repository:
/
/site-1
/site-1/index.js
/site-1/about.js
/site-1/package.json
/site-1/node_modules(not versioned)
/site-1/package-lock.json(not versioned)
/site-2
/site-2/index.js
/site-2/about.js
/site-2/package.json
/site-2/node_modules(not versioned)
/site-2/package-lock.json(not versioned)
/site-3
/site-3/index.js
/site-3/about.js
/site-3/package.json
/site-3/node_modules(not versioned)
/site-3/package-lock.json(not versioned)
I did some amendments in /site-1/index.js, /site-1/package.json and added a file /site-1/changes.md.
The changes were done in 2 separate git commit in a feature branch called feature/carousel.
I want to apply the same changes in /site-2 and /site-3.
I've tried the following:
git format-patch master -o patches to retrieve the new diff in this feature branch with regards to master branch, but i was unable to apply the diff in /site-2 and /site-3.
diff -ruN site-1 site-2 > PatchFile1 to generate a consolidated diff, but it takes into account files that have been modified in /site-2 as well and its not a generic diff that can be applied directly to /site-3
Any idea how to achieve this?
You can use git apply with the --directory option to apply a patch to another main directory, as explained here:
https://blog.soltysiak.it/en/2017/08/how-to-use-git-patch-system-to-apply-changes-into-another-folder-structure/
First, create a patch file changes.patch based on the changes applied to directory site-1. Then you can do the following:
git apply -p1 --directory='site-2' changes.patch
git apply -p1 --directory='site-3' changes.patch
-p1 removes the site folder from the patch headers, which is the main part that differs between the different directories.
--directory='site-2' will cause the site-2 prefix to be added to each header in the patch

svn merge individual files. Add new file

I am trying to merge individual files between two branches . All is well except for newly added files in source branch .
how can I merge newly added files from source to target .
svn merge -c123 https://my.svn.domain/svn/foo/branches/bar/newfile.txt ./newfile.txt
svn: E200009: Merge target './newfile.txt' does not exist in the working copy
EDIT 1:
I am using svn version 1.7.19
EDIT 2: Getting this error while trying to merge a file with status "A" .
To merge individual file you should confirm the target file exist then use the command like :
$ svn merge -c 31 ^/brunchs/xxxx xxxx

How to revert a subversion ignore?

I've run the following command via commandline:
svn propset svn:ignore "*.classpath" .
I wanted to only ignore the .classpath file.
However, this seems to have messed things up and now a lot of directories seem to be ignored.
How do I revert this and start over?
svn propedit svn:ignore . should bring up your editor, where you can remove the offending ignores one at a time.
Note
For this svn:ignore you effectively said "ignore in the currect directory only files with extension classpath": patterns for filenames in Subversion uses only OS-specific glob-pattern, not regexps
Fixes for syntax of DaFunix
List all svn-properties and their values in somepath: svn proplist -v <PATH>|<URL>. For your case
svn proplist -v .
Sample output for my URL
>svn proplist -v http://mayorat.ursinecorner.ru:8088/svn/Hello/trunk/
Properties on 'http://mayorat.ursinecorner.ru:8088/svn/Hello/trunk':
bugtraq:logregex
([Ff][Ss])\s#
(\d+)
svn:mergeinfo
/branches/Greetings:3-12
/branches/i18n:18-20
List single svn:property value (with known name): svn propget <PROPERTY> <PATH>|<URL>. For your case
svn propget svn:ignore .
Sample output for my URL (same as before for proplist)
>svn propget bugtraq:logregex http://mayorat.ursinecorner.ru:8088/svn/Hello/trunk/
([Ff][Ss])\s#
(\d+)
Both proplist and propget operations are RO, will change nothing
In order to fix bad definition of property you can
or
Delete bad property and re-create it in correct form:
svn propdel svn:ignore . & svn propset svn:ignore "classpath" . (maybe use propset with -R option to define ignore resursively for the whole subtree)
or (as suggested by John Brodie) edit and fix current definition
svn propedit svn:ignore . and in editor window "*.classpath" change to "classpath", save
PS Don't forget:
commit correct form of added property
remove from versioned code previously (possibly) added classpath files: svn:ignore affect only unversioned new files, already added to repo files with current ignore-pattern must be unversioned by hand

How can I find the svn diff between working copy and arbitrary rev?

I'm trying to write a multi-file patch for an open-source project, but the master copy has changed since I started working. I need to get the SVN difference (just the files under version control) between my uncommitted version and the revision from which it was checked. Which SVN command can I use to find the difference?
Edit: I'm sorry, I must have been using the term "working copy" improperly. I need to compare my uncommitted changes to the revision off which they are based. In other words, I checked out revision 1000 and changed files foo and bar. The rev number is now up to 1015, but I need to compare my version of foo and bar to the version of revision 1000. Is there an easy command to do this (compare my altered copy of a program with a past revision)?
You can use -rN:M parameter with diff command which specifies the revisions you want to compare. Just provide revision from which your working copy was checked out (you can omit M as it defaults to working copy) and you should get what you need.
If you don't remember the original revision number try to run svn status -v and first column should show it.
More info svn help diff...
svn diff takes a -rN:M argument which defaults to N == BASE and M == working copy. Will svn diff -r REV where REV is the revision you want not work?
To answer your edit, suppose you have the following:
$ ls
foo bar baz
$ svn st -u
Status against revision: 1071
$ echo "more stuff" >> foo
$ svn diff -r 1000 foo
Index: foo
===================================================================
--- foo (revision 1000)
+++ foo (working copy)
...
I believe this is what you are after, yes?
If your goal was to get a report of just the filenames where the contents has changed, this should do the trick:
svn diff | grep 'Index: ' .

Resources