SVN Rename file as a directory - file

I need to use the name of a particular file as a directory name, and that file to be moved inside brand new directory.
My repo look like this right now:
file1
file2
dir1/
dir1file1
search
source_code2
And I need to get this:
file1
file2
dir1/
dir1file1
search/
search_contents
source_code2
The operations that I need to do are:
mv search search_contents
rm search
mkdir search
mv search_contents search/
I suppose that I can do:
svn move search search_contents
svn del search
mkdir search
svn add search
svn move search_contents search/
Does it make sense?
How svn will deal with several commands over a single file name? (without doing a commit) Or should I make intermediate commits?

If you try to do that without committing and updating in-between, you'll get a message like this:
svn: Can't replace 'search' with a node of a differing type; the
deletion must be committed and the parent updated before adding
'search'
Just change your list of svn commands to this:
svn move search search_contents
svn commit -m "Renamed file"
svn up
mkdir search
svn add search
svn mv search_contents search
svn commit -m "done"

It turned out that those steps can be done in one single commit:
# variant 1
svn move search search-newname
mkdir search
svn add search
svn move search-newname search/search
svn commit -m "magic"
# variant 2
svn delete search
mkdir search
svn add search
svn copy "^/search#3" search/
svn commit -m "more magic"
Thing is that I wasn't sure and I didn't want to mess up the repo, the credits to this answer go for tacit on #svn channel on irc.freenode.net
Also, I have to thank to danilsh and wayita for mention svnmucc. svnmucc is a tool that can combine several comands in a list (cp, mv, rm, etc.)

Related

How to add multiple files from multiple directories into svn changelist?

I want to add and commit files which are present in different directories using changelist. I have written code in .bat file, you can find the example code below
svn add dem.txt
cd demo/docu
svn add dem.py
svn changelist mychangelist dem.py ../../dem.txt
i am checking the files which are present in the changelist by
svn st --changelist mychangelist
it gives
--- Changelist 'mychangelist':
A dem.py
but it is not showing dem.txt in the mychangelist.
Process i followed is it correct or any other problems in mycode?
Type:
cd ..\..
Then try again:
svn status --changelist mychangelist
The output will be something like:
--- Changelist 'mychangelist':
A dem.txt
A demo/docu/dem.py
The svn status command looks in the current directory and its sub-directories, but not in higher directory levels. The command svn status --changelist does not look for the given changelist and displays the contained items, rather it looks for items in the current directory tree and displays those that are listed in the given changelist. If you think like that you understand why the command behaves like this.
To prove this, try this (after having done the above mentioned cd command line):
svn status --non-recursive --changelist mychangelist
Which will produce the following output:
--- Changelist 'mychangelist':
A dem.txt

clearcase: how to recover a directory

I'm working with clearcase in Unix.
I accidently execute a shell, which make some file in the directory: /vobs/somePath/myDir.
I execute the command below in the directory:
cleartool ls -l
And I do get some view private object files.
What I need is to recover this directory with my baseline, which has been set before. Besides, I have some uncheckin files in other paths and I don't want to check them in right now. In other words, I just want to recover the directory myDir and don't touch any other files.
How to achieve this?
For a dynamic view (/vobs/avob/myview/...), only private files are writable, so you can delete everything and it will only delete the private ones.
But, if you have checked out files (which should not be deleted), or if you don't want to risk anything, you can clean just the private files with, using cleartool lsprivate:
cd /vobs/somePath/myDir
ct lspriv . | grep -v checkedout | xargs rm -rf

Getting specific files from server

Using Terminal and Shell/Bash commands is there a way to retrive specific files from a web directory? I.e.
Directory: www.site.com/samples/
copy all files ending in ".h" into a folder
The folder contains text files, and other files associated that are of no use.
Thanks :)
There are multiple ways of achieving this recursively:
1. using find
1.1 making directorys using find -p to create recursive folders without errors
cd path;
mkdir backup
find www.site.com/samples/ -type d -exec mkdir -p {} backup/{} \;
1.2 finding specific files and copying to backup folder -p to perserve permissions
find www.site.com/samples/ -name \*.h -exec cp -p {} backup/{} \;
Using tar well actually for reverse type of work i.e. to exclude specific files which the part of the question related to text files matches this answer more:
You can have as many excludes as you liked added on
tar --exclude=*.txt --exclude=*.filetype2 --exclude=*.filetype3 -cvzf site-backup.tar.gz www.site.com
mv www.site.com www.site.com.1
tar -xvzf site-backup.tar.gz
You can use the wget for that, but if there are no links to that files. I.e. they exist, but they are not referenced from any html page, then bruteforce is the only option.
cp -aiv /www.site.com/samples/*.h /somefolder/
http://linux.die.net/man/1/cp

How to create patch for a new file?

I know to create a patch for an existing file is easy:
diff -aru oldFile newFile 2>&1 | tee myPatch.patch
But what to do, if i want to create a patch for a totally new file? Assume my file is residing in a folder called TestDir. Earlier TestDir did not have a file called entirelyNewfile.c, but now it is having the same.
How to create a patch for entirelyNewfile.c? The idea is, the patch should get properly applied to the specs and generate the RPM build. With BUILD dir having this new file.
Just to add: if i try to take diff between the two directories, one having the new file and the other missing the same, to create the patch, it generates an error saying that file is only present in one folder
Add -N to the diff arguments.
diff /dev/null <newfile>
Will create a patch for your newfile.
The easiest way to do this that I know is to put all the files under version control (if they aren't already). I prefer Git, but something similar could be done in any other version control system:
git init
git add .
git commit -m "initial state"
<do your edits here>
git add .
git commit -m "new state"
git diff HEAD^1

cleartool question

Lets say I have a directory at \testfolder, and the latest is currently at /main/10. I know that the operation resulting in testfolder##/main/6 is to remove a file named test.txt.
What's a sequence of cleartool operations that can be done in a script that will take "testfolder##/main/6" and "test.txt" as input, and will cat out the contents of test.txt as of that time?
One way I can think of is to get the time of /main/6 operation, create a view with config spec -time set to that time, and then cat the test.txt at the directory. But I'm wondering if I can do this in a easier way that doesn't involve manipulating config specs, perhaps through "cleartool find" and extended path names
If you are using a dynamic view, you should be explore directly the extended pathnames of testfolder in order to access the content of test.txt.
cd m:\myview\myVob\path\to\testfolder
# In version 5 of testfolder, test.txt was still there
cd ##/main/5
# Note: test.txt is a directory! only LATEST is a file
type test.txt#/main/LATEST
The OP adds:
how about if test.txt was moved from testFolder to testFolder2, and then a new version of test.txt is checked in? In this when I go into testfolder##/main/5, test.txt##/main/LATEST is incorrect...
Technically, this is a case of evil twins: 2 objects of the same names exists (one in testfolder##/main/5, one in testfolder##/main/10) with different history.
You need, to get back the former test.txt (a like rollbacking a file), remove your current test.txt and get back the old one currently moved to Folder2. (cleartool move)
cd testFolder2
cleartool checkout -c "move test.txt back to testFolder"
cd ../testFolder
cleartool checkout -c "get back test.txt from testFolder2"
cleartool rmname test.txt
cleartool move ../testFolder2/test.txt
cleartool ci -nc .
cleartool ci -nc ../testFolder2

Resources