4

Because Xcode 10 no longer supports SVN I am looking for something to replace it. It seems as a good time to learn to use Emacs for SVN management.

The answer could be a single tool or easy Emacs flows (transition between Emacs tools that don't take much time and cognition). You could also give example of what are your SVN/Emacs most used work flows.

FYI I am Emacs noob.

Minimal functionality that I would like:

  1. List all modified files. Select a file from the list and see a diff for working and base. Be able to modify working right inside the diff.

Extra/Optional functionality:

  1. Be able to select which files to commit. Be able to select which lines to commit and which to skip. This point implies having point 1 from minimal functionality.
  2. Have tortoisesvn-like ease of use for when using commits log. Be able to log commits. Have a way to filter them(including using the name of the file or part of its path as a viable way to filter). Select a commit from the list and see all the files it has changed. Choose a file from that list and see a diff of the changes that it has made.
  3. Creating/applying patch for one or multiple files. (This is not that hard to do trough svn command so it is not that important)

Emacs integration into SVN(Optional / Nice to have):

How can I setup Emacs as external help application for everything in ~/.subversion/config

These are the ones that I know what they do and use:

  • # editor-cmd. This should do here editor-cmd = emacs

  • # diff-cmd - I should be able to save diff as patch when using this. By default I can do svn diff >> myFix.patch.

  • # diff3-cmd

  • # merge-tool-cmd

My thoughts on the matter in this answer

h3dkandi
  • 221
  • 1
  • 8
  • 3
    What have you looked for already? Searching for "Emacs SVN mode" gives several relevant links. – Stefan Sep 21 '18 at 12:43
  • You can see my answer for what I have looked for. Didn't want to make the question too long for including it in there. – h3dkandi Sep 21 '18 at 12:55
  • 2
    Emacs comes with a lot of support for SVN built-in. You can find the documentation from Emacs by opening the manual (`C-h r`), then going to the version control chapter (`m version control `). I think it would be worthwhile to read through that to learn the usual Emacs SVN workflow, before spending too much time recreating your own. – Tyler Sep 21 '18 at 13:51
  • Thanks I will try to find some time to read trough the whole Version Control Emacs manual. Have just read partially from it when googling for stuff. – h3dkandi Sep 25 '18 at 12:17

2 Answers2

3

These are from my limited knowledge and research.

Options for minimal functionality

  1. inside the svn project directory emacs -nw -f vc-root-diff -> C-c C-e for opening multiple diff in ediff. I actualy think this is not bad. Can't I skip the vc-root-diff step in any way? ediff-directory-revisions doesn't quite do the trick. An alternative way is using emacs -nw -f vc-dir which will give you something close to svn status and you can select a file and use M-x vc-ediff on it.

Options for extra functionality:

  1. For selecting files you could do C-x-v-d in an open emacs inside the svn project directory. Then m to mark the files you want and then v for next action which should be commit. Write your message and C-c C-c to commit. You could reload the buffer with g in order to "not see" the files you just committed. warning the status buffer that you are working with will not show files that are with svn status ! (aka files you have deleted using the OS file explorer). Dunno about selecting individual lines.

  2. Use svn log -v | less -> filter trough search :) or before piping to less pipe to some elaborate sed script that filters -> copy the name of the file that you want to see the diffs for -> use ediff-revisions on that file. (This flow user experience is not that good)

  3. Here I could probably use vc-root-diff -> edit if needed -> save as patch. Dunno how to apply that patch trough Emacs. svn patch has no way to resolve conflicts other than by hand.

Options for Emacs integration into SVN

For using Emacs with diff-cmd and diff3-cmd I found these scripts and adjusted them for Emacs. These are not tested because I am not sure they are correctly written. Would love some one to correct me:

diffwrap.sh

#!/bin/sh
emacs --eval "(ediff-files $6 $7 ())"

# Do I need this or is that handled by ediff?
# Return an errorcode of 0 if no differences were detected, 1 if some were.
# Any other errorcode will be treated as fatal.

diff3wrap.sh

#!/bin/sh
emacs --eval "(ediff3 $10 $9 $11)"

# Do I need this or is it handled by ediff?
# After performing the merge, this script needs to print the contents
# of the merged file to stdout.  Do that in whatever way you see fit.
# Return an errorcode of 0 on successful merge, 1 if unresolved conflicts
# remain in the result.  Any other errorcode will be treated as fatal.

For merge-tool-cmd something like this maybe:

#!/bin/sh
emacs --eval "(ediff-merge-files-with-ancestor $2 $3 $1 () $4)"
h3dkandi
  • 221
  • 1
  • 8
  • 4
    I think you're approaching this from the wrong angle: you should use `vc-dir` from *inside* emacs to do add/commit/diff etc, rather than calling various emacs commands from your shell. This implies starting emacs only once. – rpluim Sep 21 '18 at 13:32
  • 2
    What @rpluim said: people tend to live *in* emacs; they don't just start it up to do one thing and then shut it down again. – NickD Sep 21 '18 at 17:40
  • Ok sure I could possibly open one Emac to use as SVN client. I might try that approach and see what happens. I believe however that I would have to use `M-!` to execute some SVN commands like `svn status`. I don't see another way to check for missing SVN files from Emacs. `svn log`'s `-v` and `-g` flags is another such instance. Truth is I haven't read the whole versioning documentation in Emacs and google doesn't give me the answers :/ – h3dkandi Sep 25 '18 at 12:15
2

I use psvn.el.

You will have to download and place this file into a folder which is in the search path of your Emacs: (add-to-list 'load-path "~/.emacs.d/lisp") Further you will have to compile this file to an .elc file.

If you run svn-status and select the root of your SVN checked out folder, you will get a nice overview in a separate buffer (*svn-status*) about your SVN checkout: modified files, unknown files, ... From there you can commit files by selecting them or marking several of them and pressing c. Or you can add add unknown files using a.

For further options and commands have a look at the SVN section in your menu bar or see the 'svn-status-...' commands (when using 'helm M-x').

Also see this link: http://alexott.net/en/writings/emacs-vcs/EmacsPSVN.html

Hope this helps.

Thomas K.
  • 43
  • 5