with svn log | grep "keyword"
I can grep the line containing the "keyword", e.g.,
svn log -v | grep "recur"
(endless recursion) when deleting an object in the tree.
However, how can I get the revision number of this commit?
I am using svn 1.6 (not latest one, which has no svn search)
I don't know that working with the command-line svn tools is the way to go here. Your best bet is probably to use the Subversion library's bindings for a scripting language like Python or Ruby. You can retrieve a log as an list of objects (one per revision) that have the commit message and revision numbers as members. Finding what you're looking for would simply involve iterating the list.
Related
I know I can search svn logs using svn log --search $pattern. However, I'd like to limit the results to a certain number. The only thing I was able to find is the -l option but it limits the original log entries on which the search is run and I'd like for the search to be run on the entire log history and only limit the number of results themselves.
There is no built-in way to tell svn log --search to limit the results. As you already know, you can limit the number of revisions it checks, but this is not what you look for. I guess that you could write a script that checks the output of svn log and cuts it to the necessary amount. Don't forget that you could use --xml switch.
If you desperately need such feature by some reason, drop a line to users# Apache Subversion mailing list. Describe how and why you need this enhancement and maybe it will be filed as a feature request. :)
Linux style:
svn log --search $pattern | head -n 10
There are many questions on stackoverflow that are similar to this question. Most discuss single files, diff files, or filenames. Very few discus GUIs for viewing the diff of two hashes for an entire git repository (ALL directories, subdirectories, and files). The one or two comments I've seen mention tools only available on Windows (like araxis merge) or OS/X.
What about linux? Meld is my preferred tool so I've tried:
git show <hash1> <hash2> > /tmp/clownshoes.diff
then opened that in meld. No luck. Meld sees it as one single giant.
Take a look at git's list of gui clients, I think smart git will do what you are looking for.
Problem: 2 projects shared trunk and were updating some of the same files. Now one project needs to be released, so a new branch was created from a checkpoint before the projects started.
I have a list of just my changelist numbers from the mainline. Using that I can generate a list changed files and diff output using a script with a series of 'p4 describe #' commands.
Can I reformat that output and apply it to the new branch somehow?
Response to the title: "Is it possible to create a patch using a set of changelists?"
Yes.
p4 diff2 -u //path_to_your_sources/...#cln_minus_1 //path_to_your_sources/...#cln > /tmp/cln.patch.
You can then use /tmp/cln.patch as input to the patch utility. Here, 'cln' is the submitted change list number that you want to create a patch for.
I've just spent two hours struggling with this. Using cygwin patch, I had to munge the paths until they were recognised.
In the end, the magic incantation looked like this (broken across lines):
p4 diff2 -u //depot/foo/main/...#100003 //depot/foo/main/...#100000 |
sed 's#//depot/#E:/Source/#g' |
sed '/^+++\|---/s#/#\\#g' |
patch
That is:
Use p4 diff2 to get a unified diff (-u) of part of the depot between the two revisions that I care about. The second changelist is the one before the first one I want, otherwise it's not included in the diff.
Use sed to change the //depot/ to E:/Source/, which is where my workspace lives.
Change forward slashes to double backslashes (this seems to make it work).
Pipe the results through patch.
Cygwin patch is smart enough to check files out of Perforce, but I'm not sure how to get it to do it silently. It prompts with Get file 'e:\Source\foo\whatever' from Perforce with lock?.
This is with p4 version 2010.1, a fairly recent installation of Cygwin, running on PowerShell.
Oh, and after this, patch wrote out Unix-style line endings, so I used u2d to fix those up.
Perforce will let you cherry-pick changelists for integration, which may be easier than trying to generate and apply a patch. Perforce will keep track of what revisions you've integrated where, which may make future integrations easier.
Let's assume you used to have one trunk:
//depot/mycode/trunk
And you checked in all of your changes there. You branched trunk at some point in the past to:
//depot/mycode/rel
And you have a list of changelists on trunk to merge. From a client spec that maps rel, integrate each changelist:
p4 integrate //depot/mycode/trunk/...#1234,1234 //depot/mycode/rel/...
where 1234 is the changelist number. Resolve after each integration. You may also wish to build, test, and commit your integrations at various checkpoints during your integration, if you can identify good points to do so. (Perforce can handle multiple integrations per commit, but if you make a mistake you'll need to revert to the last version checked in and redo the intermediate integrations and resolves.)
p4 describe -S -du <CL number>
is the shorter and most concise command, in my opinion.
I have a Mercurial Repository for a code project and I want to search all of the files, in all directories and sub-directories, for a given string. What is the best method, or program to do so?
I can conduct this search in Ubuntu Linux or a Windows environment.
Probably best to just do a checkout of the repository and use grepWin on windows, or grep on Linux.
For a simple search in the working copy, I would also use the normal grep program (I'm on Linux).
But if you want to search the history for a string, then note that Mercurial also has a hg grep function. That can be handy if you want to see when a given function, say, was introduced or removed.
If TortoiseHg is installed Search History is available in Windows Explorer context menu.
I want to display svn revision number to a text file
I am getting the revision number using this command
$revision = ([xml](svn info "filepath" --xml)).info.entry.commit.revision
Assuming that you will read the value from c# and can throw out the prefix:
svn info somefile.txt | find "Revision" > revision.txt
If the text file is under source control you might find it easier to investigate svn:keywords. The SVN book will tell you how to use them.
If the text file is not under source control, could you be more explicit about what you are trying to do.
The easiest way is to use the svnversion program that comes with Subversion.
As the documentation says,
It's common to use this output in your
build process when defining the
version number of your program.
svnversion -c gives you the latest committed version.