How do I search for specific kinds of merge hyperlinks in clearcase? - merge

Background
I have recently created an erroneous merge hyperlink in clear case. This was the result of a script that automerged several files. Given that a script created the erroneous merge, I am trying to search for other instances of erroneous merge arrows. Below are the constraints I want to put in my search:
All merge hyperlinks created by me.
On a specific date
This question talks about finding a merge hyperlink in one file. However, I am looking for a set of merge hyperlinks that I created.
What I know
I know that you can describe hyperlinks as shown below:
Describe a hyperlink.
cmd-context describe hlink:Merge#516262#/vobs_proj
hyperlink "Merge#516262#/vobs_proj"
created 2006-07-14T16:43:35 by Bill Bo (bill.user#uranus)
Merge#516262#/vobs_proj /vobs_proj/lib/cvt/cvt_cmd.c##/main/v1.1_port/8 ->
/vobs_proj/lib/cvt/cvt_cmd.c##/main/71
But I am looking for how to query for the "created..." field from a set of merge hyperlinks.
Question
How do I query for merge hyperlinks that I created at a specific time?

Consider cleartool find to try and link those hlink
cleartool find . -kind hlink -user <myLogin>
Then try and combine the find with an exec cleartool describe $CLEARCASE_PN, maybe adding queries (as described in the query_language)
If not query is working, at least you could then grep the output for:
your Login
excluding (grep -v) dates which are too old.
Brian Cowan adds in the comments:
I've found that you can use this to get the hlink names, but you have to use $CLEARCASE_PN.
Parsing it is non-trivial because the "hlink" formatting property apparently doesn't work.
You would have to:
Filter the output by date (cleartool desc -fmt "%d %Xn\n" $CLEARCASE_PN)
Describe each desired link and grep for "->"
That'll get you the hyperlink source and destination.
rmver -xhlink would let you remove the merge-created versions

If this was recent enough, you should be able to use cleartool lshistory -minor
I just created a merge hyperlink, and lshist -min -rec on the root of the VOB showed me this.
--09-12T15:57 Brianc make hyperlink "Merge" on version "Documents\libatriadb_ldb.txt##\main\testbr\1"
"Attached hyperlink "Merge#504#\foobarf"."
--09-12T15:57 Brianc make hyperlink "Merge" on version "Documents\libatriadb_ldb.txt##\main\CHECKEDOUT"
"Attached hyperlink "Merge#504#\foobarf"."
A little work with the -fmt option and you may be able to get this formatted how you need it.

Related

Search Eclipse local history

Does Eclipse provide (possibly via a plug-in) the ability to search the local history?
E.g, I have a lot of history files and don't want to have to trawl through them all because I know that the version I want is the most recent which contains the string "slithy toves".
[Update] people answering similar questions on this site have not read the question – or it was badly phrased.
I am not looking to go to the local history (which do know how to find) and manually search through every entry, version by version. I want a single search function which will do that for me.
[Update++] the referenced question does not contain an acceptable answer. The only solution offered there involves creating a dummy project, which is more overehad than I care for.
Note: if it helps anyone, I found that the local history can be found in
Workspace\.metadata\.plugins\org.eclipse.core.resources\.history\
from which, I can use any file search tool of my choice
Manualy search the local history
My answer to the question is "No, you cannot do that search from within Eclipse".
Nevertheless, in this answer to another question you can see the (linux) command line (and the explanation of what it does) to search the local history structure if you know specific code that was in the file you seek (like you indicated "slithy toves"):
fgrep -r -c "[slithy toves]" * | grep -v ":0" | cut -d : -f 1 | xargs ls -l
I found that the local history can be found in
Workspace\.metadata\.plugins\org.eclipse.core.resources\.history\
from which, I can use any file search tool of my choice.
However, filenames all look like 001ad08cc7790016142da217e60cb1a5, so I can't search for widget.c :-(
There is also no index, since I searched for files containing 001ad08cc7790016142da217e60cb1a5, hoping to find maybe some XML which told me the original file name, with a reference to 001ad08cc7790016142da217e60cb1a5, but I found nothing :-(
Also, some of the saved files seem to be binary, and I can't see how to configure Eclipse to save only *.c and *.h

asciidoc: is there a way to create an anchor that will be visible in libreoffice writer?

Tl;dr;
What is the correct way to create an anchor in docbook? and is there a way that will make the anchor visible in writer?
Background
I am trying to split up documentation that was previously in single open office documents into smaller asciidoc documents which are both included in the main open office document and also converted to either or both of html & pdf.
I have this mostly working. I use asciidoctor to create html. asciidoctor-pdf to create pdf and a combination of asciidoctor and pandoc to create .odt files. I also tried the python implementation of asciidoc but found the interface less useable.
Round tripping between asciidoc and odt is obviously not possible. This is sort of a fusion where the master document is word processed but pieces of content that can be produced independently (think man pages - in fact that is one of several use cases) are included.
asciidoc to html:
asciidoctor -b html5 foo.adoc -o foo.html
asciidoc to pdf:
asciidoctor-pdf -b pdf foo.adoc -o foo.pdf
asciidoc to odt
asciidoctor -b docbook foo.adoc -o foo.docbook
pandoc --base-header-level=3 -V date:"" -V title:"" -f docbook foo.docbook -o foo.odt
With pandoc I have to nullify the date and title and set the header-level as desired for the section to be inserted as an extra complication.
I insert the resulting .odt into the main document using insert section inside open office.
Note that the main document is not a master document as I could not find a way of creating a master document without also automatically splitting the file on h1 boundaries.
I have two main problems to resolve with this set-up. I would like to add headings in the asciidoc document as cross references and also create entries for them in the alphabetical index (actually the first heading would be suffcient). Is there a way to do this?
Index markers in asciidoc do not result in entries in .odt file being created.
I am able to cross reference content in the inserted section using "insert reference/heading" and referencing the uniquely named header. However, whenever I use "update all" these cross references are invalidated. They are shown as "Error: Reference source not found".
[On a separate note I would also like a way to find broken cross references automatically]
I am currently using libreoffice - Version: 4.3.7.2
I am not adverse to switching version or flavours (i.e. apache) if one behaves better than the other.
I'm not sure if the answer is in the asciidoc or docbook parts of the chain. I would accept an answer which inserts a index entry at the start of the inserted section (top of the .adoc/docbook file) automatically.
I am also open to changing my toolchain to something that will work.
For example I tried the asciidoc-odt backend and fell foul of https://github.com/dagwieers/asciidoc-odf/issues/47 which does not inspire confidence.
Using asciidoc-odt I avoid the need to create an intermediate docbook file. However, I still can't get the anchor to appear.
I can get a macro to create an anchor but at present I haven't figured out how to run the macro from the command line.
To create an anchor in DocBook, make an inline anchor in the .adoc file. For example, giving this to asciidoctor:
[[X1]]Section1
---------------
produced this:
<title>
<anchor xml:id="X1" xreflabel="[X1]"/>
Section1
</title>
Conversely, putting this on separate lines did not create an anchor tag in my test:
[[X1]]
Section 1
Now for some bad news. From the Pandoc User's Guide:
Internal links are currently supported for HTML formats (including HTML slide shows and EPUB), LaTeX, and ConTeXt.
I interpret this to mean that currently, Pandoc does not create internal links in Writer. When I tried it, the link was ignored.
Note: It looks like I did not answer all of your questions. If you want to ask more about LibreOffice cross references and headings (the big bold paragraph towards the end of the question), maybe you could make a separate question just for that part.

Label ClearCase Content As Seen On A Given Date (without changing the config specs)

I need to label the contents of a view as seen at specific dates, and the only way I know of doing it is by using the -time version selector in the config specs. I set the time to the date I want, and then I apply the label on the view. Simple.
However, I was hoping if there is a way to do it pro-grammatically without changing the config specs. I was hoping that I could use the cleartool find in combination with -exec and mklabel. However, if I do this:
cleartool find . -cview -version "! created_since(some-date)"
It only pulls what was created before that date on the view, not necessarily what should be seen in the view if we were using the -time selector.
And if I use cleartool find with a -branch selector
cleartool find . -cview -version "! created_since(some-branch)"
it only selects that which was created before that date, on that branch only. It will not show what is also seen in the view on other branches via the config specs rules.
So, am I using cleartool find wrong? Or is it just impossible?
Is there a way, from the command line, to direct cleartool find to find exactly and precisely the elements that
would be seen by the active config rules
in a given directory
regardless of the branch or branches involved,
AS IF there was a -time directive in them?
Thanks.
To my knowledge, the query language isn't rich enough to include what the config spec time rule does.
A time-based selection rule is the best option.
What I generally do, in order to use the -time programmatically (since the find wouldn't work) is to:
use a dedicated dynamic view (quicker to update than a snapshot view)
write in a file the config spec I need
cleartool setcs -tag myView myFile # update the config spec of the dynamic view
(See setcs man page)
use the result of the updated content of the dynamic view.

What's the best way to perform a differential between a list of directories?

I am interested in looking at a list of directories and comparing the previous list with a current list of directories and setting up a script to do so. Maybe in perl or as a shell script.
Should I use something like diff? Programatically, what would be an ideal way to do this? For example let say I output the diff to an output file, if there is no diff then exit, if there is results, I want to see it.
Let's for example I have the following directories today:
/foo/bar/staging/abc
/foo/bar/staging/def
/foo/bar/staging/a1b2c3
Next day would look like this where a directory is either added, or renamed:
/foo/bar/staging/abc
/foo/bar/staging/def
/foo/bar/staging/ghi
/foo/bar/staging/a1b2c4
There might be better ways, but the way I typically do something like this is to run a find command in each directory root, and pipe the output to separate files. You can then diff the files using the diff tool of your choice. If you want to filter out certain directories or files, you can throw in some grep or grep -v commands in the pipeline, or you can experiment with options on the find command.
The other main option is to find a diff tool that offers directory/folder comparisons. Most of the goods ones support this, but I like the command line method, because you get more control over what you're diffing.
cd /my/directory/one
find . -print | sort > /temp/one.txt
cd /my/directory/two
find . -print | sort > /temp/two.txt
diff /temp/one.txt /temp/two.txt
also check the inotifywait command. it allows you to monitor files in RT.
You might also consider the find command using the -newer switch.
The usage is:
find . -newer timefile.txt -print
The -newer switch makes find return a list of files that are created or updated after the specified file's modification time. In the example above, any file created or updated after timefile.txt would be returned. You'd have to create a timefile.txt file, most likely once per day. Some versions of find have variations of newer that compare against other time stamps for a file (last modified, last accessed, last created, etc.)
This technique would not report a file that was deleted, however. A daily diff of the file listings could report that.

All change comments to perforce branch between 2 labels? (including merges)

Our perforce admin limits "max-row" scans so that my first idea of running the following will not work:
All changes including integrates into a branch at particular label time 1
All changes including integrates into a branch at particular earlier label time 2
Subtract time 2 changes from time 1 to get the new changes with comments.
Is there an alternative way of getting the same result without having such a massive query(when perforce contains 7yrs of history and -i triggers a scan back to the dawn of history)
Based on Gregs comments added this comment:
Basically the point is to see what bugs got fixed in a particular release branch between 2 labels(or more commonly, some old label and today).
I wish to simplify(speedup) way too complex script that we currently have which looks at changes that went into a release branch, it follows files that went into them at least 2 branches up in order to printout all the changeset comments from the original change(the interim merge comments tend to just say something like merge123 etc instead of description of the actual change comments, so we need to walk up the tree to the original comment as well), script finally outputs something like below(we put quality center IDs into changeset comments):
qualityCenterId123 - fixed some bug
in gui qcId124 - fixed some other
bug qcId125 - fixed some other bug
merge123
UPDATE based on comments:
Problem with Toby's approach is that most of the changes into the code branch came via integrations, -i would include those change, but as stated that explodes the query to such a degree that due the load on perforce server our admin won't allow it to run. So this is why I am looking for an alternative approach to get the same result.
I can't see an easy answer to this, but do have a couple more suggestions that perhaps may help point in the right direction.
Persuade your admin to raise the maxscan rows limit. If he is nervous that this will lead to problems with the whole user base, just get him to add you to a new user group (e.g. "Scripting"), and set the limits for just that group. That will have the effect that only members of that group can use the upper limits, and you can then negotiate for suitable times to run the script. You could even do it overnight.
Have a look at the P4 admin guide and see if any of the hints on scripting will help - e.g. maybe a tighter view on the data will limit the query enough to not break the maxscanrows limits.
How's your SQL? You may be able to construct an efficient query using the P4Report tool.
Try asking the question on the Perforce mailing list. It's a very active list that has a lot of very experienced people who are very helpful. See this link for the sign-up page. There's a good chance that they will suggest some good approaches.
Probably too late for yoru existing labels, but consider using the job system to track work. Perforce has inbuilt query tools to track what jobs have made it into different branches. It does require a working-practice change for your team, however.
Sorry I can't provide a more specific answer.
Are your labels more than simply the most recent changelist when they were created? Eg did you really need to record specific files in client workspaces? If not you can very easily compare the two changelists closest to labels.
Say the closest change to your first label date is 23000 and your closes change to your second label date is 25000 then
p4 changes //depot/PATHTOMYCODE/...#23000,#25000
will give you all changes to your code path between these two changelists.
Won't a normal Label-diff do what you want?
From P4V, Tools->Diff. Select the two labels
From P4Win, right click label, select diff files in 2 labels
From command line, p4 diff2 //codeline/...#label1 //codeline/...#label2
Or am I missing exactly what you are after?
Further suggestion after Ville's comment on the above
If you are only after the info per changelist, rather than per file, then try "p4 interchanges" from the command line. This will give you just the summary of what changes in one branch have not happened in another, and you can supply a revision range to limit it to the labels you need.
Do "p4 help interchanges" from command line for details.
Unfortunately the interchanges command is not yet exposed in P4V or P4Win.
Toby Allen's Answer is the best approach if your labels are simple changelists.
If the labels are more complicated, then I think you need to look at all the files in each label and where their versions differ, find the changelist where the version changed.
You can get the file and version lists with:
p4 fstat -Of //...#MyLabel
EDIT:
Consider two complex labels:
VERSION_A:
//depot/file_A.cpp#4
//depot/file_B.cpp#7
//depot/file_C.cpp#1
VERSION_B:
//depot/file_A.cpp#6
//depot/file_B.cpp#5
//depot/file_C.cpp#4
In this example, the labels do not describe a particular changelist, the head change for each file may be different.
If you can have labels like this, then you can run the p4 fstat command on each label and then find the differences. In this example, file_A.cpp has changed twice and file_C.cpp has changed 3 times. file_B.cpp is older in the second label, so it can be ignored.
So now you need to look at the changes that involved these versions:
file_A.cpp#5
file_A.cpp#6
file_C.cpp#2
file_C.cpp#3
file_C.cpp#4
Those changes can be retrieved with p4 filelog, so you want to run something like this:
p4 filelog file_A.cpp#6
p4 filelog file_C.cpp#4
Then you need to remove any duplicates and any history for earlier versions.
Like I said, you only need this if you have messy lables. If there's any way to make your labels represent changelists, you should use Toby Allen's answer.