How to add multiple files from multiple directories into svn changelist? - batch-file

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

Related

Mercurial getting file-specific log/history information

Is there a way to get file specific information, similar to
hg log
I basically want committer, date/time, and the commit summary, but of just a single file.
You can filter the results of the hg log command by including a filename like so:
hg log file.txt
That will give you the standard log for every changeset where file.txt was changed. You can use
hg log file.txt -l 10 -r "not merge()"
to limit it to only the last 10 as well as excluding merge changes using revsets

How to check which files are being ignored because of .hgignore?

I'm quite often concerned that my hgignore file may be excluding important files. For example I just noticed that I was excluding all .exe files which excluded some little executable tools which should be kept with the source. It was a simple change to include them but makes me worried that the rules could have un-intended consequences.
Is there a way to view a list of all the files which are not being tracked due to the .hgignore file? Just so I can periodically review the list to check I'm happy with it.
The command hg status -i does exactly that.
#Jon beat me to the punch with the right answer, but its worth nothing that along with status -i, there is:
hg status -m (only modified files)
hg status -a (only files that were added)
hg status -r (only files that were removed)
hg status -d (only files that were deleted)
hg status -u (all non-tracked files)
hg status -c (files with no changes, ie. "clean")
hg status -A (all files, ie, everything)
If you want to do manual inspection on the file names, then use the -i/--ignored flag to status:
$ hg status -i
I ignored file.exe
If you want the file names alone, then use -n/--no-status to suppress the I status code printed in front of each filename:
$ hg status -n -i
ignored file.exe
If you need to process the files with xargs, then use the -0/--print0 flag in addition:
$ hg status -n -0 | xargs -0 touch
That will take care of handling spaces correctly — with using -0, there is a risk that you'll end up treating ignored file.exe as two files: ignored and file.exe since shells normally split on spaces.
The above commands show you untracked files matching .hgignore. If you want to solve the related problem of finding tracked files matching .hgignore, then you need to use a fileset query. That looks like this:
$ hg locate "set:hgignore()"
You can use filesets with all commands that operate on files, so you can for example do:
$ hg forget "set:hgignore()"
to schedule the files found for removal (with a copy left behind in your working copy).
Yes, it is Possible.
If You're using smth like TortoiseHg, You can select what files You wanna see.
Here's a sample

SVN Rename file as a directory

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.)

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

Mercurial, stop versioning cache directory but keep directory

I have a CakePHP project under Mercurial version control. Right now all the files in the app/tmp directory are being versioned, which are always changing.
I do not want to version control these files.
I know I can stop by running hg forget app/tmp/*
But this will also forget the file structure. Which I want to keep.
Now I know that Mercurial doesn't version directories, just files, but the CakePHP folks were also smart enough to put an empty file called empty in every empty directory (I am guessing for this reason).
So what I want to do is tell Mercurial to forget every file under app/tmp except files whos name is exactly empty.
What would the command be for this?
Well, if nothing else works, you can always just ask Mercurial to forget everything, and then revert empty before committing:
Here's how I reproduced it, first create initial repo:
hg init
md app
md app\tmp
echo a>app\empty
echo a>app\tmp\empty
hg commit -m "initial" -A
Then add some files we later want to get rid of:
echo a >app\tmp\test1.txt
echo a >app\tmp\test2.txt
hg commit -m "adding" -A
Then forget the files we don't want:
hg forget app\tmp\*
hg status <-- will show all 3 files
hg revert app\tmp\empty
hg status <-- now empty is gone
echo glob:app/tmp>.hgignore
hg commit -m "ignored" -A
Note that all .hgignore does is to prevent Mercurial from discovering new files during addremove or commit -A, if you have explicitly tracked files that match your ignore filter, Mercurial will still track changes to those files.
In other words, even though I asked Mercurial to ignore app/tmp above, the file empty inside will not be ignored, or removed, since I have explicitly asked Mercurial to track it.
At least theoretically (I don't have time to try it right now), pattern matching should work with the hg forget command. So, you could do something like hg forget -X empty while in the directory (-X means "exclude").
You may want to consider using .hgignore, of course.
Since you only need to do it once I'd just do this:
find app/tmp -type f | grep -v empty | xargs hg forget
hg commit
from then on just put this in your `.hgignore'
^app/tmp
Mercurial has built-in support for globbing and regexes, as explained in the relevant chapter in the mercurial book. The python regex implementation is used.
This should work for you:
hg forget "re:app/tmp/.*(?<!/empty)$"

Resources