What SVN means to the user of KoLmafia

Bale

Minion
People who are curious about the SVN feature in the latest builds of KoLmafia may want to check out this list of scripts that can be installed and automatically kept up to date:

FAQ

Q. What is this "SVN feature" thinggy?
A. It's a better way for users to install scripts.

Q. What do I have to know about SVN to use this feature?
A. Absolutely nothing! Just copy/paste the checkout command into KoLmafia's command line and the magic happens. It's really simple.

Q. I get an error, "unable to invoke svn." Is it broken?
A. No. The latest point release, version 16.0, does not have this feature. It only exists in the latest daily builds on this page. Either the Jar or EXE will work. Just put it in your mafia directory and run it from there.

Q. At the top of the page you said "automatically kept up to date." None of my scripts have updated themselves so how does that work?
A. There's a preference you have to set to enable it which is off by default. Go to Preferences -> SVN -> Check "Update installed SVN projects on login." That will cause all your SVN installed scripts to be updated once a day.

Q. Why is SVN better for KoLmafia scripts?
A. There are a whole bunch of reasons. I'll enumerate:
  1. It makes script installation easier. The user doesn't have to ensure that the script is downloaded into the correct directory or worry if there are multiple files to put into multiple directory.
  2. It makes script updating easier. All scripts can be updated automatically or the user can manually type svn update to update all scripts.
  3. It is easier for the scripter to publish his scripts and keep them up to date.
  4. When you recommend a script in chat, you can tell them the command to copy/paste without their having to go to the KoLmafia forum.
  5. In another two months or so a planned feature will make it even easier to use SVN, removing the need to copy/paste. :)
Q. Why was this added to mafia?
A. We understand that a lot of people don't use scripts, even scripts that will help them a lot. This is because they find it troublesome to find and install scripts. The intention is to make it easy to install scripts. Even a script like Character Info Toolbox which contains more than 30 files is easy to install now. Just copy/paste svn checkout https://svn.code.sf.net/p/mafiachit/code/ and every single file will be placed in the correct directory. If you don't like it, just copy/paste svn delete mafiachit and all those files are removed.

Q. Wait! Does this mean I don't have to find the correct thread on the KoLmafia forum and login there to install a script?
A. Yup. It's incomprehensible to most of us, but we've noticed that people hate reading our forum. Now you won't have to do that. For now you can find them all listed in a single thread. Eventually it will be accesible directly through KoLmafia.

Q. That sounds like black magic.
A. Please state your problem in the form of a question.
Q. How does that work?
A. Black magic. Not really, but it is very impressive and you don't really need to know the mechanics. Just trust that it works.

Q. Lots of scripts aren't on SVN? Is this just a niche thing?
A. So far those are just the early adopters. More scripters are talking about switching over to SVN soon because it is easier for them. Many of these scripts will be released exclusively through SVN once the feature has made it into the next point release. It is quite possible that some scripts will never be available on SVN, but they will probably become a minority.

Q. What if I don't want to use SVN
A. Well.. tough, I guess? We really hope you'll get used to it.
 

Bale

Minion
There is another even more impressive ability of the KoLmafia's svn update. Revision Merging! This is only helpful to people who know how to modify someone's script so if you cannot understand a single line of any script you might as well skip this post.

The real awesome here is aimed at people who sometimes like to make small modifications to their scripts. People like you with a little bit of scripting ability. I suspect you've sometimes made a tiny tweak to a script to make it more perfect for your specific needs. Then the original author updates his script and you're stuck trying to decide if it is worth your trouble to copy all your modifications to the new version of his script. If not, you might just refuse to update it. With SVN if you know what you are doing, you can update your cake and eat it too! When svn updates your script it will automatically keep your modifications, producing a blend of your modifications and the author's update. Now I'll tell you how to do this.

  1. Acquire the most recent version using svn update
  2. Open the script's working copy in the project's /svn directory, and make your edits. Always make sure the project in /svn has your changes
  3. Use the command svn sync to push your modifications in the working copy to the local copy in the /scripts or /relay directory
  4. If you ever want to modify your changes or add to them, just repeat step 2 and 3.

That's it! Now you can update from svn as usual. You can use svn update bale-ocd to update just that script, or svn update to update all your scripts or just check the box in SVN preferences to make it happen automatically once a day. Whenever the script is updated SVN will magically merge your changes into the working copy in the /svn folder and then push those changes into the local copy. This is magic! This will happen every single time you use svn to update the script without requiring your intervention. The CLI will display a "G" for merGing the script instead of a "U" for Updating it when this happens.


If an update to a script changes it so severely that it cannot be merGed with your modifications, it will show "C" for Conflict and produce several files in the working copy to help you solve the problem:
  • myfile - will have some inline markup at the location of the conflict ( look for <<<<<< and >>>>> markup) showing you both what your text was and what the repo's text was.
  • myfile.mine - Your version before the update.
  • myfile.rOld - The pristine repo versions from before the update.
  • myfile.rNew - The pristine repo versions from after the update.
With all of these files, you can pretty easily figure out where the problem line(s) are, and how to fix them. Sometimes you'll just want to use rNew and discard your local changes, sometimes you'll want to do something else. Copy/pasting between the different files is straightforward. You will need to delete the extra files when you're done resolving the conflict, and make sure that the remaining file is named the same thing as the original file.
 
Last edited:

Bale

Minion
This information is somewhat old, but I have finally added it to the wiki today, so I'll be unsticking the thread and it will be a little harder to find. If you are used to finding this information stuck to the top of this forum, please pay attention to the wiki instead.


As always, please feel free to edit our wiki if you think there is any help you can offer at all. Please don't be shy. It's your resource after all so you know what you need to find there. I may be unsticking another thread if I get the rest of its significant content added to the wiki also.
 

Raven434

Member
Sorry to thread necromance.

I looked at the tutorial and the Wiki page.

Very helpful. ;-)

What I was wondering was if Mafia supports a "svn list $ALL_VERSIONS" to show the versions of all the installed scripts? Or even if there was a way to get a single version displayed?

> svn list

almighty-saplings-ash-trunk-planner
bale-counterchecker
bale-new-life
bale-ocd
batbrain
bestbetweenbattle
bumcheekascend-snapshot
ccascend-snapshot
digitrev-crimbo2015
mafiarecovery
smartstasis
therazekolmafia-canadv
therazekolmafia-eatdrink
winterbay-mafia-farm
winterbay-mafia-sushi
zlib

> svn list batbrain

almighty-saplings-ash-trunk-planner
bale-counterchecker
bale-new-life
bale-ocd
batbrain
bestbetweenbattle
bumcheekascend-snapshot
ccascend-snapshot
digitrev-crimbo2015
mafiarecovery
smartstasis
therazekolmafia-canadv
therazekolmafia-eatdrink
winterbay-mafia-farm
winterbay-mafia-sushi
zlib

> svn info batbrain

<no info returned>

Thanks!
 

Raven434

Member
Complete brain fart.

Why is this not working?

> svn_info ( batbrain ) (revision)

Returned: record {string url; int revision; string last_changed_author; int last_changed_rev; string last_changed_date;}

Thanks LCP, by the way.
 

matt.chugg

Moderator
Complete brain fart.

Why is this not working?

> svn_info ( batbrain ) (revision)

Returned: record {string url; int revision; string last_changed_author; int last_changed_rev; string last_changed_date;}

Thanks LCP, by the way.


svn_info is an ash command, (I think the CLI version is showing what it returns as a definition eg record and various fields of the record)

to get the revision in CLI try:

Code:
ash svn_info("batbrain")

or

Code:
ash svn_info("batbrain").revision
 
Top