Posts Tagged ‘svn’

How to remove password from committed svn revision

Saturday, June 6th, 2015

Or pretty much make any changes to a committed revision.

You start by checking out the revision and doing an md5sum and a sha1sum on the desired file(s). You will need these hashes.
Next is to make your desired changes to the file(s) and then run another md5sum and sha1sum on them. You will need these hashes too.
Note also the file sizes in bytes if you make changes: before and after.

NOTE: It is best to use the same size in replaced values, because I haven’t found a good way to update the size. Yet…

Next, you dump the repo.
#svnadmin dump /path/to/repo > dump_file

Now you alter it. First the values:
#sed "s/password/XXXXXXXX/g" dump_file > dump_file_tmp
NOTE: see how the number of chars in the password matches the number of X’es? This is important as it keeps the file size intact.

next the hashes
#sed -e "s/orig_md5/altered_md5/" -e "s/orig_sha1/altered_sha1/" dump_file_tmp > dump_file_ok
NOTE: for both md5 and sha1.

Be careful, if you have more values, use the -e parameter to sed and pass each value as a separate expression, OR, use other file names, because if you keep changing the same dump file you will end up having only changed the last value.
Same with hashes.

Now you backup the old repo
#mv /path/to/repo /path/to/repo_backup

Create it clean
#svnadmin create /path/to/repo

And load the altered dump file
#svnadmin load dump_file_ok

Now you can verify the affected revisions to confirm the changes. All should be good, if not, you have the backup, and try again, paying much attention to every detail I wrote above.

Depending on your set, you may need to
#chown -R svn_user:svn_group /path/to/repo

and also re-checkout your working copy.

Related posts

SVN: import subfolder as new repository root

Sunday, April 6th, 2014

I’ve done a little research and found the partial solution here: http://stackoverflow.com/questions/2337470/svn-move-single-directory-into-other-repository-with-history

Problem was that using it would error as it tries to create the subfolder.
So I dug some more and then found:
http://www.pakettiradio.net/the_ultimate_subversion_repository_splitting_guide/

Problem here was that I still had the root of the sub-folder creation attempt raising
svnadmin: File not found: transaction ‘0-1’, path

A little digging turned up:
http://www.celticwolf.com/blog/2010/05/03/subversion-svnadmin-load-error-file-not-found-transaction-0-1-path/

Which doesn’t solve anything but lit my Eureka bulb: there is no sense in creating an empty root folder. It already exists. So What I did was to delete it’s creation from the fixed dump file which was looking like this notice empty Node-path and action “add”):

Node-path:
Node-action: add
Node-kind: dir
Prop-content-length: 10
Content-length: 10

PROPS-END

Not to be confused with other empty Node-path which actually set properties!!!

Now remains only 1 problem: I also want the user to be changed. This is a problem because in the dump, the username is preceded by a line starting with V followed by a number. This number is the length of the username.

There are some interesting solutions here: http://stackoverflow.com/questions/1195339/is-there-a-way-to-change-a-svn-users-username-through-the-entire-repository-hist

However, I am trying to keep my server yum-compatible, and svndumptool is in no public yum repo, to my searching today.
My solution involves a multiline SED. Relevant articles are
http://www.refining-linux.org/archives/27/20-Multi-line-sed-search-and-replace/
and
http://stackoverflow.com/questions/4510813/sed-regular-expression-over-multiple-lines

As I have multiple subfolders to be split up into new repositories, I’ve created a script to do the job, including setting up an apache vhost for each.

The relevant part of the script looks like this:

1
2
3
4
5
6
svndumpfilter include $grp/$usr --drop-empty-revs --renumber-revs  < $repo_dump > $repo_dump.$usr
sed -e "s/Node-path: $grp\/$usr/Node-path: /" < $repo_dump.$usr >$repo_dump.$usr.fixed1
sed -e "s/Node-copyfrom-path: $grp\/$usr/Node-copyfrom-path: /" < $repo_dump.$usr.fixed1 >$repo_dump.$usr.fixed2
sed -e "/Node-path: /{ N; N; N; N; N; N; s/Node-path: \nNode-action: add\nNode-kind: dir\nProp-content-length: 10\nContent-length: 10\n\nPROPS-END//}" < $repo_dump.$usr.fixed2 >$repo_dump.$usr.fixed3
sed -e "/svn:author/{ N; N; s/svn:author\n.*\n$svn_usr_from/svn:author\nV $svn_usr_len\n$svn_usr_to/}" < $repo_dump.$usr.fixed3 >$repo_dump.$usr.fixed4
svnadmin load $repo_dir/$cust_group/$cust_customer --ignore-uuid < $repo_dump.$usr.fixed4

Related posts

CVS out of the house

Sunday, February 6th, 2011

As expected, after I finally migrated all my cvs projects to my svn repository it was high time to remove this … relic 🙂

Related posts

Migrate CVS to SVN with cvs2svn

Sunday, February 6th, 2011

Well, as it usually happens with stuff I do, it gets out of the “ordinary”. It almost never gets easy enough.

So, this time, cvs2svn. Great litle tool. Only problem is that in my centos 5.5, the subversion I installed for some reason I don’t remember and didn’t bother spending time figuring out, it created a repository based on sqlite or something. In any case, the repository and the projects are not directories, as happens in most or all examples on cvs2svn out there.

So, since you can’t use svn2cvs on local repository as in the tutorials, I searched for a way to use it to migrate to a … “remote” repository 🙂

And I eventually found this: http://ptspts.blogspot.com/2009/06/how-to-migrate-or-merge-cvs-or-svn.html

Looked promising. I made the dump and then figured I have to install the svn-pusher. Obviously, I got

[root@Impuls ~]# apt-get install libsvn-core-perl
Reading Package Lists… Done
Building Dependency Tree… Done
E: Couldn’t find package libsvn-core-perl

So, I did a yum search push and found

perl-SVN-Push.noarch : Push Repository to Remote Subversion Repository

trying to install that, failed with dependency check on subversion perl:

subversion-perl-1.4.6-jason.1.i386 from utterramblings has depsolving problems
–> Missing Dependency: subversion = 1.4.6-jason.1 is needed by package subversion-perl-1.4.6-jason.1.i386 (utterramblings)
Error: Missing Dependency: subversion = 1.4.6-jason.1 is needed by package subversion-perl-1.4.6-jason.1.i386 (utterramblings)
You could try using –skip-broken to work around the problem
You could try running: package-cleanup –problems
package-cleanup –dupes
rpm -Va –nofiles –nodigest

next:

[root@Impuls ~]# yum erase subversion-perl
Setting up Remove Process
No Match for argument: subversion-perl
Package(s) subversion-perl available, but not installed.
No Packages marked for removal

after some hours of digging around I learned that this is because I already had installed the subversion.1.6.13-0.1.el5.rf so removing that and the svn_web_dav with yum and then installing subversion and svn_web_dav and perl-SVN-Push solved everything. Then I tried cpan with svn-pusher and that finally worked.

then came the migration:

[root@Impuls db]# svnadmin load –parent-dir delphi /svn/ < /launcher.dump
svnadmin: Expected FS format ‘2’; found format ‘4’

a little digging around showed the cause: I previously had installed a newer version of subversion and created the repository with it. now, since I downgraded, it was no longer supported. Crap.

So, uninstall the jason version subversion and reinstall the previous one. But … there is no sense in doing that from the cd/dvd as I’d end up in the same situation. So I searched the net a bit for the rpm version I had looking for a source that had all my needed dependencies and finally found : http://packages.sw.be/subversion/

installed everything and voila:

svnadmin load –parent-dir delphi /svn/ < /launcher.dump

worked without errors.

But, as I already told y’all, in my case nothing is *that* simple. And here’s again why: I don’t use trunk/branches/tags or any other such structure for my projects. And that’s because I wrote them all, they are pretty small and until now I never needed this structure. And of course, I hate having 2 empty dirs in all my projects (branches and tags) plus an unneeded nesting level (tags).

So, what to do. I first wanted to cancel the import but when I saw that you need to “hack” things in order to remove the stuff without anybody ever knowing about it (given that I am the only person using my repository it’s a bit too paranoid even for me) I decided to just make 3 new revisions by deleting the “offending” directories and re-create the dump properly.

I then tried

cvs2svn –trunk-only –username=ciuly –trunk=Launcher –branches=Launcher/branches –tags=Launcher/tags –dumpfile=/launcher.dump /cvs/delphi/Launcher/

obviously, errored.

A bit of thinking and looking in the dump file got me an idea: modify the cvs2svn to NOT create the branches and tags directories when dumping 😀 And this time it was damn easy too. I only searched for a few things and in less than 5 minutes I got to modify the svn_run_options.py on line 467 and removed branches_path and tags_path from the initial_directories array. Ta-Da.

now running

cvs2svn –trunk-only –username=ciuly –trunk=Launcher –dumpfile=/launcher.dump /cvs/delphi/Launcher/

properly produced the desired dump file for importing into my svn repo suitable for my structure with

svnadmin load –parent-dir delphi /svn/ < /launcher.dump

complete with history. Only “issue” was that in cvs I used the user “impuls” where as in svn I changed it to “ciuly”. And the history kept it as impuls. Not a big deal after all. That can be changed too 😀 But I don’t have time right now for such minor issues. I have to finish moving my cvs to svn properly.

And I didn’t even need that svn pusher thing. damn 🙂

PS: now, when I’m finished, I realized that the reason why I thought I have to do a remote svn import was because I had an error in my svnadmin load command line. oups 😀

Related posts

SVN back in the house

Wednesday, April 7th, 2010

Ever since I moved from my old source-based linus to rpm-based linux, there were some features I was not able to set up or install due to lack of time. One of these was the SVN server. And since I’ve done some changes to the greasemonkey scripts as you can see in my previous post, I had to commit.
So, long story short, I had to:
– yum install mod_dav_svn.i386
– service httpd restart
– usermod -a -G svn apache
– chown -R svn:svn /svn
– chmod -R g+w /svn
to get rid of all the errors and be able to use my old repository again.

Well, that’s about it for now.

Related posts

Moving from CVS to SVN

Monday, May 25th, 2009

I finally made the move from CVS to SVN (code versioning systems).
Mainly because I improved my USJ (User JavaScript) coding and I decided to version everything so I’d have the old code as well and I just didn’t remember hot to make a new repository with CVS and I wanted to move to SVN anyhow 🙂

Related posts