ClearCase Snapshot Views

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hugh
    Enthusiast
    • Jan 2008
    • 31

    ClearCase Snapshot Views

    Hi,

    I’ve been trying to get BC3 to work with ClearCase snapshot views. These are the ones that CC provides the diff/merge tool with temp files and “-fname blabla” real name labels. These extra arguments confuse BC3. So that, for example, a version tree difference comes out as a 3-way diff not a 2 way compare, also merge goes completely mad with both left and right BC3 panes empty!

    I read the other BC3+CC threads, but most people are trying to get it to work with dynamic views and there seems to be some support for this. I only use snapshot views so my workaround might not work if you use both.

    Im using windows, but I figure the problem will be the same for linux if snapshot views are used there too.

    Basically, my workaround for now, is to write a little wrapper called “ccbc3.exe” which you put in the libs/mgrs file in the same place as the “bcomp.exe” is meant to go. My workaround wrapper simply discards parameters and re-arranges those left to give either 2 or 4 to bcomp.exe, but it also puts back in the original names as “/title<N>=bla” options for the UI.

    It’s a complete hack, but it might help start proper CC support. Compile this program and put it in the same directory as bcomp.exe so that it can find it to exec it, and then edit libs/mgrs to call it.

    any better ideas welcome!

    -- hugh.

    ccbc3.cpp
    ------------------------------

    Code:
    #include <process.h>
    #include <windows.h>
    #include <iostream>
    
    using namespace std;
    
    //#define EXENAME "c:\\bc3\\bcomp.exe"
    #define EXENAME "bcomp.exe"
    #define MAX_ARGS 16
    #define BUFSIZE 4096
    
    int main(int argc, char** argv)
    {
        
        char* argv2[MAX_ARGS];
        char* fnames[MAX_ARGS];
    
        char* buf = new char[BUFSIZE];
    
        int i;
        int j = 0;
        int f = 0;
        
        argv2[j++] = EXENAME;
        for (i = 1; i < argc; ++i)
        {
            // remember the real names
            if (!strcmp(argv[i], "-fname"))
            {
                fnames[f++] = argv[i+1];
                ++i; // skip this and next.
            }
    
            // skip a bunch of stuff
            else if (!strcmp(argv[i], "-base"))
            {
                // skip
            }
            else if (!strcmp(argv[i], "-abort"))
            {
                // skip
            }
            else if (!strcmp(argv[i], "-out"))
            {
                // skip
            }
            else if (!strcmp(argv[i], "-serial"))
            {
                // skip
            }
            else
            {
                // keep all other args
                argv2[j++] = argv[i];
            }
        }
    
        if (j == 3) //  A B
        {
            // 2 way diff
    
            // each one has names, put them in
            char* p = buf;
            for (int k = 0; k < f; ++k)
            {
                sprintf(p, "/title%d=%s", k+1, fnames[k]);
                argv2[j++] = p;
                p = p + strlen(p) + 1;
            }
        }
        else if (j == 5)
        {
            // 3 way
    
            // BASE OUT A B
            // 1    2   3 4
    
            char* base = argv2[1];
            char* left = argv2[3];
            char* right = argv2[4];
            char* out = argv2[2];
            
            j = 1;
            argv2[j++] = left;
            argv2[j++] = right;
            argv2[j++] = base;
            argv2[j++] = out;
    
            char* p = buf;
            sprintf(p, "/title1=%s", fnames[1]);
            argv2[j++] = p;
            p = p + strlen(p) + 1;
            sprintf(p, "/title3=%s", fnames[0]);
            argv2[j++] = p;
    
            // the merge title is left alone
        }
        
        argv2[j] = 0;
    
        // exec BC3 and wait
        intptr_t pro = _spawnv(_P_WAIT,
                               EXENAME,
                               argv2);
    
        if (pro == -1)
        {
            const char* e = strerror(errno);
            cerr << "Problem exec (" << hex << errno << dec
                 << "): " << e << endl;
        }
    
        delete buf;
    
        // return result of BC3 as our result
        return pro;
    }
    Last edited by hugh; 17-Aug-2008, 04:46 PM. Reason: nobby formatting
  • Zoë
    Team Scooter
    • Oct 2007
    • 2666

    #2
    BC3 already has support for snapshot views and internally does exactly what you're doing. Did you follow the directions in the Version Control knowledge base article?
    Zoë P Scooter Software

    Comment

    • hugh
      Enthusiast
      • Jan 2008
      • 31

      #3
      CC + BC3

      I edited the mgrs file as described.

      so, why didn't it work then?

      Comment

      • Andy Stevenson
        Journeyman
        • Nov 2007
        • 11

        #4
        I use both Dynamic and Snapshot views all the time with Clearcase on Windows.
        If you are able to actually get CC to launch BC3 (say with a "Compare to Previous", for instance)... then you could use Process Explorer from SysInternals to verify the command-line parameters that are being passed to BC3.

        Comment

        • hugh
          Enthusiast
          • Jan 2008
          • 31

          #5
          fname translation

          this is what i get from CC when i do a "compare to previous version":

          xcompare -fname C:\cc_snaproot\hugh_bgan\project_bgan\g_output\Tri gHost.cpp@@\main\int\int_hugh\17 -fname C:\cc_snaproot\hugh_bgan\project_bgan\g_output\Tri gHost.cpp@@\main\int\int_hugh\18 "C:\DOCUME~1\HUGHST~1\LOCALS~1\Temp\mvfsless07 184" "C:\DOCUME~1\HUGHST~1\LOCALS~1\Temp\mvfsless07 185"

          and this is what i translate it into:

          c:\bc3\bcomp.exe C:\DOCUME~1\HUGHST~1\LOCALS~1\Temp\mvfsless07184 C:\DOCUME~1\HUGHST~1\LOCALS~1\Temp\mvfsless07185 /title1=C:\cc_snaproot\hugh_bgan\project_bgan\g_out put\TrigHost.cpp@@\main\int\int_hugh\17 /title2=C:\cc_snaproot\hugh_bgan\project_bgan\g_out put\TrigHost.cpp@@\main\int\int_hugh\18

          Comment

          • JohanR
            Visitor
            • Feb 2008
            • 6

            #6
            I have the same problem in my snapshot views.
            I get the 3-way merge view instead of the 2-way comparison when doing a regular "Compare with previous version" in ClearCase.

            From Process Explorer I get:
            xcompare -fname D:\CCViews\ESTRO-2008\MFC-GTK\Views\MFC_GTK_DataWnd.cpp@@\main\WorkStation-1-Int\Workstation-2-Int\ORBITWIP-1-Int\ESTRO-2008\4 -fname D:\CCViews\ESTRO-2008\MFC-GTK\Views\MFC_GTK_DataWnd.cpp C:\Users\jridd\AppData\Local\Temp\mvfsless11586 D:\CCViews\ESTRO-2008\MFC-GTK\Views\MFC_GTK_DataWnd.cpp

            Is this a known bug that will be handled soon? I did not have this problem in the beta version.

            Comment

            • Zoë
              Team Scooter
              • Oct 2007
              • 2666

              #7
              I think the problem might actually be in the registry. We currently check HKEY_LOCAL_MACHINE\Software\Atria\ClearCase\Curren tVersion for a string value named "HistoryModeSuffix", and that's required before we enable ClearCase support. If that's been moved you'll probably see what you're seeing. Check and see if that's present, and if not see if you can find "HistoryModeSuffix" somewhere else.
              Zoë P Scooter Software

              Comment

              • JohanR
                Visitor
                • Feb 2008
                • 6

                #8
                I find
                HKEY_LOCAL_MACHINE\Software\Atria\ClearCase\Curren t Version in my registry but no HistoryModeSuffix is located there.
                When I search the registry HistoryModeSuffix is not present anywhere!

                I run Windows Vista and have ClearCase LT v7.0.1

                Comment

                • Lutz
                  Veteran
                  • Oct 2007
                  • 356

                  #9
                  Have a look at your ClearCase Properties/MVFS-Tab/Extended Naming Suffix.
                  This field shows the default value "@@" on your system (part of the -fname you posted).

                  Search your registry for the value "@@" to find the appropriate key.

                  If not present, perhaps your CC-installation stores settings in files.

                  Greetings Lutz

                  Comment

                  • JohanR
                    Visitor
                    • Feb 2008
                    • 6

                    #10
                    I'm not sure where to look to see my ClearCase Properties.
                    In HKEY_LOCAL_MACHINE\Software\Atria\ClearCase\Curren t Version I have a xnsuffix key with @@ as data.

                    Where to go from that?

                    Comment

                    • Lutz
                      Veteran
                      • Oct 2007
                      • 356

                      #11
                      Add the Value HistoryModeSuffix with the data "@@" (identical to xnsuffix) and try again the comparision.

                      On my system I have both values (HistoryModeSuffix and xnsuffix with the same data "@@"). Maybe they come from different ClearCase versions (I upgraded from CC5 to CC7 the past years).

                      @Scooter: Perhaps it's possible to look for both values.

                      PS: ClearCase Properties are located in the Control Panel/ClearCase.
                      Last edited by Lutz; 03-Sep-2008, 04:28 AM.

                      Comment

                      • Lutz
                        Veteran
                        • Oct 2007
                        • 356

                        #12
                        I found an explanation from IBM at ftp://ftp.software.ibm.com/software/...dme_vsnet.html

                        Missing > extended naming suffix after -extNamingSuffix parameter Workarounds: Have ClearCase create the registry key now, or create it manually yourself.



                        To have ClearCase create the registry key:
                        1. Click Start > Settings > Control Panel.
                        2. Double-click the ClearCase icon to display the ClearCase Properties dialog box.
                        3. On the MVFS tab, delete the contents of the Extended Naming Suffix text box, which activates the Apply button.
                        4. Enter @@ in the Extended Naming Suffix text box, and click Apply to cause ClearCase to create the appropriate registry key.
                        To manually create the registry key, go to the registry, and do one of the following:
                        • For ClearCase LT, set the value of HKLM\SOFTWARE\Atria\ClearCase\CurrentVersion\xnsuf fix to @@.
                        • For ClearCase, set the value of HKLM\SOFTWARE\Atria\ClearCase\CurrentVersion\Histo ryModeSuffix to @@.

                        Comment

                        • JohanR
                          Visitor
                          • Feb 2008
                          • 6

                          #13
                          Perfect, now it works.
                          My only problem now is that I will have to make sure that all developers in our company (~40) add that registry key... or that the Scooter developers look for either of the two keys in a patch that comes out real soon ;-)

                          Do I need to file this as a bug somewhere or do the developers look here in the forums often enough?

                          Comment

                          • Zoë
                            Team Scooter
                            • Oct 2007
                            • 2666

                            #14
                            The next release will have this fixed. Thank you both for your help tracking it down.
                            Zoë P Scooter Software

                            Comment

                            Working...