As title, could anyone of you give me a working instruction to solve that problem ?
thanks a lot!
If you only after checked-out files and you are in a dynamic view set to see only MY_BRANCH:
ct lsprivate -co .
(with '.' being the parent directory under which you want to find co files)
That command is recursive by default.
Your config spec would need to be
element * CHECKEDOUT
element * .../MY_BRANCH/LATEST
element -directory /main/LATEST
With checked-out files and directories in a snapshot or dynamic view, use indeed lsco, but knowing that command is not recursive by default. So I would recommend:
ct lsco -rec -brtype MY_BRANCH
$ ct lsco -brtype your-branch-type-selector
Start by having a look here : IBM ClearCase Command Reference : lscheckout
Then, as an example, try this...
If your branch was foo, and your are in the VOB you want to check, you can run
ct lsco -brtype foo
or
ct lsco -brtype brtype:foo
Related
I am trying to merge my development branch with the parent branch to the one I am working in. I do not have graphical ClearCase, I only have the command line. I am using Solaris-10.
When I do lsvtree on the file, the last 3 results I see are:
filename##/main/release2/10 (PROD_REL2.0, PROD_REL2.1, PROD_REL2.2, ...)
filename##/main/release2/myprivateview
filename##/main/release3/myprivateview/1
When I do a describe on the file, I get:
version "filename/##/main/release3/myprivateview/1"
...
predecessor version: /main/release3/myprivateview/0
I want to merge my changes into the main branch so that other users can see my changes.
I have tried :
cleartool findmerge -all -fver /main/release2/LATEST -print
cleartool findmerge -all -fver /main/release2/10 -print
cleartool findmerge filename -fver /main/release2/LATEST -print
cleartool findmerge filename -fver /main/release2/myprivateview/0 -print
and various other combinations.
What happens is it thinks for awhile and then prints...nothing. No error messages, nor listing of merges, nor conflicts, nothing at all gets printed.
I have checked that my view is dynamic. What am I doing wrong?
Whenever you do a merge or findmerge, you need to do so in a view set to reflect the destination branch (here the main branch, which seems to be for you release3)
So setup another dynamic view, used for the merge, with:
element * CHECKEDOUT
element * .../release3/LATEST
element * /main/0 -mkbranch release3
element * /main/LATEST -mkbranch release3
Here, release3 would be the destination branch, that is the branch you are merging to.
In that view, try your findmerge command again.
Note that, as I explained here, you would need to findmerge (and merge) your folders first, then your files.
Thank you #VonC for your advice.
I could not figure out how to create a new view with the config specs you mentioned above.
However I discovered that there is no need to create any new views at all: All I had to do was change my own view to point to the branch level that I wanted to change.
What I did is:
1) $ cleartool edcs
2) save the config specs that were displayed somewhere else
3) edit the file to look like this:
element * CHECKEDOUT
element * .../release3/LATEST
element * /main/LATEST -mkbranch release3
4) $ exit (to reload the view with the new config specs, not sure if this was necessary)
5) $ cleartool setview myprivateview
6) $ cleartool findmerge filename -fver /main/release3/myprivateview/1 -print
7) $ cleartool findmerge filename -fver /main/release3/myprivateview/1 -merge
8) cleartool ci filename
9) cleartool edcs
10) replace config specs as they were before`
This performed the merge exactly how I wanted and these steps will work to merge into any level, without having to create any views.
I want to check with a batch file if a certain element is already existent in Clearcase, or if I still have to add it.
How can I put this into a conditional statement?
Like:
if cleartool exists myFileName do myaction
else doOtherAction
You need to build a function which returns true or false depending on the element full name being part of the ClearCase view elements or not.
Then you can call that function from your if... else... statement.
Here are various commands that your function could use in order to determine if a file is a ClearCase element (meaning already added to source control) or not:
You can start by using the result of cleartool ls -l: if its output includes view-private object, it isn't added to source control yet.
cmd-context ls -long
version Makefile##\main\3 Rule: element * \main\LATEST
view private object bug.report
version cm_add.c##\main\0 Rule: element * \main\LATEST
derived object (unshared) hello##2007-03-24T11:32.418
version hello.h##\main\CHECKEDOUT from \main\2
Rule: element * CHECKEDOUT
Here 'bug.report' isn't added yet.
See more at "About view-private objects".
I already recommended that approach for a previous question using C#: "c# How to determine if a file is in ClearCase?".
Another approach is to use cleartool describe, which would trigger an error if the element described is a private one.
As mentioned in the technote "How to list view-private files in a view in Rational ClearCase", the command cleartool lsprivate works only in dynamic views, not in snapshot views.
For snapshot view, you can use: cleartool ls -r -view_only
Another approach is to use cleartool find, as in "Clearcase: How do I check if an element has a version on the trunk that was created after I branched off from the trunk?"
The following DOS batch file will add a file to ClearCase if it's not in there yet. Works in both dynamic and snapshot views.
#ECHO OFF
cleartool ls -l %1 | FIND "view private object"
IF %ERRORLEVEL% == 1 GOTO END
cleartool co -nc .
cleartool mkelem -nc -ci %1
cleartool ci -nc .
:END
You may want to add suitable comments instead of using the -nc switch.
I could not find the proper command to apply a label to files which are in my current view. I have tried the following command:
cleartool mklabel -r TEST_LABEL /vob/test/a
However, the problem is that this command will apply the "Test_Label" label to every files in the "vob/test/a" directories regardless of whether the files are in my current view.
Is there any command to apply label only to the files listed in my current view?
cleartool mklabel -r(ecurse) LABEL_NAME <directory name>
This command will apply LABEL_NAME to all files in folder and below of your view, you can just go to that directory,then type following command to create and apply label
> cd /vob/test/a
> cleartool mklbtype –nc TEST_LABEL
> cleartool mklabel -r TEST_LABEL .
The mklabel documentation state states, as to what version is labeled:
Processes the entire subtree of each pname that is a directory element (including pname itself). VOB symbolic links are not traversed during the recursive descent into the subtree.
One example mentions:
Attach that label to the version of the current directory selected by your view, and to the currently selected version of each element in and below the current directory.
Now, if you want to be really sure of the versions actually labelled, one solution is to use a find command, combined with your mklabel:
cleartool find . -cview -exec "cleartool mklabel TEST_LABEL \"%CLEARCASE_XPN%\""
If you had already that label applied to incorrect version and want to move it:
cleartool find . -cview -exec "cleartool mklabel -replace TEST_LABEL \"%CLEARCASE_XPN%\""
That way, you can first list the versions involved:
cleartool find . -cview -print
And then, if you agree with the output, apply the mklabel through the -exec directive.
The OP user1096966 reports making it work with a cleartool ls, to be sure to select only element visible in the current view:
cleartool ls -r -vis
The is no '-exec' directive, so a pipe might be involved, as in (not tested, but you get the idea):
cleartool ls -r -vis -s -nxn | xargs cleartool mklabel -replace TEST_LABEL
The doco is really clear about what is being labelled, in fact the first example shown in doco states that exactly...current view objects are labelled by default & currently selected versions (i.e. if in your view then label it, else not.)
....extract below from doco below (note: context and command and that label-type-selector pname is the last parameter...left blank below because resident in working dir)...
Example:
•Create a label type named REL6. Attach that label to the version of the current directory selected by your view, and to the currently selected version of each element in and below the current directory.
cmd-context> mklbtype –nc REL6
Regards
Jim2
When I do "ct lsco -a" I can see that I have three checkouts. But they don't show up in xclearcase, and the directories aren't visible from the command line.
ct lsco -a | grep hendrixjl
--07-29T15:32 hendrixjl checkout directory version "/vobs/CORE/CORE_APPS/src/mapmgr_decoupled##/main/rel_core_0.5.0.0__int/fea__cr_54__0.5.0.0_decouple_map_manager/3/icondetails_decoupled" from /main/rel_core_0.5.0.0__int/fea__cr_47__0.5.0.0_ui_decouple/0 (unreserved)
--07-29T15:32 hendrixjl checkout directory version "/vobs/CORE/CORE_APPS/src/mapmgr_decoupled##/main/rel_core_0.5.0.0__int/fea__cr_54__0.5.0.0_decouple_map_manager/4/overlays" from /main/rel_core_0.5.0.0__int/fea__cr_47__0.5.0.0_ui_decouple/0 (unreserved)
--07-29T15:32 hendrixjl checkout directory version "/vobs/CORE/CORE_APPS/src/mapmgr_decoupled##/main/rel_core_0.5.0.0__int/fea__cr_54__0.5.0.0_decouple_map_manager/4/overlays/main/rel_core_0.5.0.0__int/fea__cr_54__0.5.0.0_decouple_map_manager/1/images" from /main/rel_core_0.5.0.0__int/fea__cr_47__0.5.0.0_ui_decouple/0 (unreserved)
[hendrixjl#BA-JBCP-HENDRIX CORE]$ cd /vobs/CORE/CORE_APPS/src/mapmgr_decoupled
[hendrixjl#BA-JBCP-HENDRIX mapmgr_decoupled]$ ls
Makefile ascope_translator common_decoupled displaySA_decoupled filters mgr_decoupled unit_test
[hendrixjl#BA-JBCP-HENDRIX mapmgr_decoupled]$ ct unco .
cleartool: Error: No branch of element is checked out to view "cc-svr:/data/cc_store/viewstore/hendrixjl/fea__cr_47__0.5.0.0_ui_decouple__hendrixjl_view.vws".
cleartool: Error: Unable to find checked out version for ".".
[hendrixjl#BA-JBCP-HENDRIX mapmgr_decoupled]$ ct unco icondetails_decoupled
cleartool: Error: Element name not found: "icondetails_decoupled".
[hendrixjl#BA-JBCP-HENDRIX mapmgr_decoupled]$
Those directories are checked-out in parent directories which are not visible/selected by your current view, probably because they have been removed (rmnamed).
That means the checked-out versions are not accessible from this view.
However, a potential workaround is to search for those same checked-out directories from the GUI "find checkouts" window: there you can select the checked-out element (file or directory) and select "undo checkout".
Another workaround is to go to the full extended path of that directory in a dynamic view: you will then be able to "cleartool unco" the directory.
cd /vobs/CORE/CORE_APPS/src/mapmgr_decoupled##/main/rel_core_0.5.0.0__int/fea__cr_54__0.5.0.0_decouple_map_manager/3
cleartool unco icondetails_decoupled
In any case, whenever you don't see an element, the first think to do is a version tree of the parent directory of that element, in order to check if the missing element has been rmname'd in one of the version of said parent directory.
I want to check in a directory and all the sub-directories into the clear case.
Is there a specific command to achieve it?
Currently I am going into each directory and manually checking in each file.
I would recommend this question:
Now the problem is to checkin everything that has changed.
It is problematic since often not everything has changed, and ClearCase will trigger an error message when trying to check in an identical file. Meaning you will need 2 commands:
ct lsco -r -cvi -fmt "ci -nc \"%n\"\n" | ct
ct lsco -r -cvi -fmt "unco -rm %n\n" | ct
(with 'ct being 'cleartool' : type 'doskey ct=cleartool $*' on Windows to set that alias)
But if by "checkin" you mean:
"enter into source control for the first time"
"updating a large number of files which may have changed on an existing versionned directory"
I would recommend creating a dynamic view and clearfsimport your snapshot tree (with the new files) in the dynamic view.
See this question or this question.
the clearfsimport script is better equipped to import multiple times the same set of files, and automatically:
add new files,
make new version of existing files previously imported (but modified in the source set of files re-imported)
remove files already imported but no longer present in the source set of files.
make a clear log of all operations made during the import process.
:
clearfsimport -preview -rec -nset c:\sourceDir\* m:\MyView\MyVob\MyDestinationDirectory
did you used -recurse option in the clearfsimport command.
Example: clearfsimport -recurse source_dir .
This should help.
If you're using the Windows client, right-click on the parent folder, select Search, leave the file name field empty, click Search, select all the files in the result window (ctrl-A), right-click on them and select ClearCase -> Add to Source Control
If you are in windows you may try,
for /f "usebackq" %i in (`cleartool lsco -cview -me -r -s`) do cleartool ci -nc %i