Changeset 58

Show
Ignore:
Timestamp:
07/15/04 19:49:48
Author:
DenisG
Message:

[SubversionSharp] Prepare a rougthly similar notify function than

svn cmd-line client for our test program

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/SubversionSharp/test/src/CmdBase.cs

    r56 r58  
    155155        } 
    156156         
    157         public static void NotifyCallback(IntPtr baton, SvnPath Path,   
    158                                           SvnWcNotify.Action action, Svn.NodeKind kind, 
    159                                           AprString mimeType, SvnWcNotify.State contentState, 
    160                                           SvnWcNotify.State propState, int revNum) 
     157         
     158        private bool mInExternal = false; 
     159        private bool mChanged = false; 
     160        private bool mTxDelta = false; 
     161         
     162        public void NotifyCallback(IntPtr baton, SvnPath Path,   
     163                                   SvnWcNotify.Action action, Svn.NodeKind kind, 
     164                                   AprString mimeType, SvnWcNotify.State contentState, 
     165                                   SvnWcNotify.State propState, int revNum) 
    161166        { 
     167            switch(action) 
     168            { 
     169                case SvnWcNotify.Action.Add: 
     170                    if (!mimeType.IsNull && mimeType.ToString().StartsWith("text/")) 
     171                        Console.WriteLine("A  (bin)  {0}", Path); 
     172                    else 
     173                        Console.WriteLine("A         {0}", Path); 
     174                    mChanged = true; 
     175                    break; 
     176                 
     177                case SvnWcNotify.Action.BlameRevision: 
     178                    break; 
     179                 
     180                case SvnWcNotify.Action.CommitAdded: 
     181                    if (!mimeType.IsNull && mimeType.ToString().StartsWith("text/")) 
     182                        Console.WriteLine("Adding  (bin)  {0}", Path); 
     183                    else 
     184                        Console.WriteLine("Adding         {0}", Path); 
     185                    break; 
     186                 
     187                case SvnWcNotify.Action.CommitDeleted: 
     188                        Console.WriteLine("Deleting       {0}", Path); 
     189                    break; 
     190                 
     191                case SvnWcNotify.Action.CommitModified: 
     192                    Console.WriteLine("Sending        {0}", Path); 
     193                    break; 
     194                 
     195                case SvnWcNotify.Action.CommitReplaced: 
     196                        Console.WriteLine("Replacing      {0}", Path); 
     197                    break; 
     198                 
     199                case SvnWcNotify.Action.Copy: 
     200                    break; 
     201                 
     202                case SvnWcNotify.Action.Delete: 
     203                    Console.WriteLine("D         {0}", Path); 
     204                    mChanged = true; 
     205                    break; 
     206                 
     207                case SvnWcNotify.Action.FailedRevert: 
     208                    Console.WriteLine("Failed to revert '{0}' -- try updating instead.", Path); 
     209                    break; 
     210                 
     211                case SvnWcNotify.Action.PostfixTxdelta: 
     212                    if( !mTxDelta ) 
     213                    { 
     214                        Console.Write("Transmitting file data "); 
     215                        mTxDelta = true; 
     216                    } 
     217                    Console.Write("."); 
     218                    break; 
     219                 
     220                case SvnWcNotify.Action.Resolved: 
     221                    Console.WriteLine("Resolved conflicted state of '{0}'", Path); 
     222                    break; 
     223                 
     224                case SvnWcNotify.Action.Restore: 
     225                    Console.WriteLine("Restored '{0}'", Path); 
     226                    break; 
     227                 
     228                case SvnWcNotify.Action.Revert: 
     229                    Console.WriteLine("Reverted '{0}'", Path); 
     230                    break; 
     231                     
     232                case SvnWcNotify.Action.Skip: 
     233                    if (contentState == SvnWcNotify.State.Missing) 
     234                        Console.WriteLine("Skipped missing target: '{0}'", Path); 
     235                    else 
     236                        Console.WriteLine("Skipped '{0}'", Path); 
     237                    break; 
     238                 
     239                case SvnWcNotify.Action.StatusCompleted: 
     240                    if( revNum >= 0 ) 
     241                        Console.WriteLine("Status against revision: {0}", revNum); 
     242                    break; 
     243                 
     244                case SvnWcNotify.Action.StatusExternal: 
     245                    Console.WriteLine("\nPerforming status on external item at '{0}'", Path); 
     246                    break; 
     247                 
     248                case SvnWcNotify.Action.UpdateAdd: 
     249                    Console.WriteLine("A {0}", Path); 
     250                    mChanged = true; 
     251                    break; 
     252                 
     253                case SvnWcNotify.Action.UpdateCompleted: 
     254                    if( revNum >= 0 ) 
     255                    { 
     256                        if( mSubCmd.LongName == "export" ) 
     257                            Console.WriteLine("Exported {0}revision {1}.", 
     258                                                (mInExternal) ? "external at " : "", 
     259                                                revNum); 
     260                        else if( mSubCmd.LongName == "checkout" ) 
     261                            Console.WriteLine("Checked out {0}revision {1}.", 
     262                                                (mInExternal) ? "external at " : "", 
     263                                                revNum); 
     264                        else 
     265                        { 
     266                            if( mChanged ) 
     267                                Console.WriteLine("Updated {0}to revision {1}.", 
     268                                                    (mInExternal) ? "external at " : "", 
     269                                                    revNum); 
     270                            else 
     271                                Console.Write("{0}t revision {1}.", 
     272                                                (mInExternal) ? "External a" : "A", 
     273                                                revNum); 
     274                        } 
     275                    } 
     276                    else  /* no revision */ 
     277                    { 
     278                        if( mSubCmd.LongName == "export" ) 
     279                            Console.WriteLine("{0}xport complete.", 
     280                                                (mInExternal) ? "External e" : "E"); 
     281                        else if( mSubCmd.LongName == "checkout" ) 
     282                            Console.WriteLine("{0}heckout complete.\n", 
     283                                                (mInExternal) ? "External c" : "C"); 
     284                        else 
     285                            Console.WriteLine("{0}pdate complete.\n",  
     286                                                (mInExternal) ? "External u" : "U"); 
     287                    } 
     288                    if( mInExternal ) 
     289                        Console.WriteLine(); 
     290                    mInExternal = false; 
     291                    mChanged = false; 
     292                    break; 
     293                 
     294                case SvnWcNotify.Action.UpdateDelete: 
     295                    Console.WriteLine("D {0}", Path); 
     296                    mChanged = true; 
     297                    break; 
     298                 
     299                case SvnWcNotify.Action.UpdateExternal: 
     300                    Console.WriteLine("\nFetching external item into '{0}'", Path); 
     301                    mInExternal = true; 
     302                    break; 
     303                 
     304                case SvnWcNotify.Action.UpdateUpdate: 
     305                    string s1 = " "; 
     306                    string s2 = " "; 
     307                    if (! ((kind == Svn.NodeKind.Dir) 
     308                            && ((propState == SvnWcNotify.State.Inapplicable) 
     309                             || (propState == SvnWcNotify.State.Unknown) 
     310                             || (propState == SvnWcNotify.State.Unchanged)))) 
     311                    { 
     312                        mChanged = true; 
     313                        if (kind == Svn.NodeKind.File) 
     314                        { 
     315                            if (contentState == SvnWcNotify.State.Conflicted) 
     316                                s1 = "C"; 
     317                            else if (contentState == SvnWcNotify.State.Merged) 
     318                                s1 = "G"; 
     319                            else if (contentState == SvnWcNotify.State.Changed) 
     320                                s1 = "U"; 
     321                        } 
     322             
     323                        if (propState == SvnWcNotify.State.Conflicted) 
     324                            s2 = "C"; 
     325                        else if (propState == SvnWcNotify.State.Merged) 
     326                            s2 = "G"; 
     327                        else if (propState == SvnWcNotify.State.Changed) 
     328                            s2 = "U"; 
     329 
     330                        if (! ((contentState == SvnWcNotify.State.Unchanged 
     331                                || contentState == SvnWcNotify.State.Unknown) 
     332                            && (propState == SvnWcNotify.State.Unchanged 
     333                                || propState == SvnWcNotify.State.Unknown))) 
     334                            Console.WriteLine("{0}{1} {2}", s1, s2, Path); 
     335                    }                    
     336                    break; 
     337            } 
    162338        } 
    163339         
    164         public static SvnError GetCommitLogCallback(out AprString logMessage, out SvnPath tmpFile, 
    165                                                     AprArray commitItems, IntPtr baton, 
    166                                                     AprPool pool) 
     340        public SvnError GetCommitLogCallback(out AprString logMessage, out SvnPath tmpFile, 
     341                                             AprArray commitItems, IntPtr baton, 
     342                                             AprPool pool) 
    167343        { 
    168344            if (!commitItems.IsNull) 
     
    187363 
    188364         
    189         public static SvnError CancelCallback(IntPtr baton) 
     365        public SvnError CancelCallback(IntPtr baton) 
    190366        { 
    191367            return(SvnError.NoError);        
    192368        } 
    193369         
    194         public static SvnError SimpleAuth(out SvnAuthCredSimple cred, IntPtr baton,  
    195                                AprString realm, AprString username,  
    196                                bool maySave, AprPool pool) 
     370        public SvnError SimpleAuth(out SvnAuthCredSimple cred, IntPtr baton,  
     371                                      AprString realm, AprString username,  
     372                                      bool maySave, AprPool pool) 
    197373        { 
    198374            Console.WriteLine("Simple Authentication"); 
     
    232408        } 
    233409         
    234         public static SvnError UsernameAuth(out SvnAuthCredUsername cred, IntPtr baton,  
    235                                            AprString realm, bool maySave, AprPool pool) 
     410        public SvnError UsernameAuth(out SvnAuthCredUsername cred, IntPtr baton,  
     411                                    AprString realm, bool maySave, AprPool pool) 
    236412        { 
    237413            Console.WriteLine("Username Authentication:"); 
     
    261437        } 
    262438         
    263         public static SvnError SslServerTrustAuth(out SvnAuthCredSslServerTrust cred,  
    264                                                  IntPtr baton, AprString realm,  
    265                                                      SvnAuthCredSslServerTrust.CertFailures failures,  
    266                                                      SvnAuthSslServerCertInfo certInfo,  
    267                                                      bool maySave, IntPtr pool) 
     439        public SvnError SslServerTrustAuth(out SvnAuthCredSslServerTrust cred,  
     440                                           IntPtr baton, AprString realm,  
     441                                           SvnAuthCredSslServerTrust.CertFailures failures,  
     442                                           SvnAuthSslServerCertInfo certInfo,  
     443                                           bool maySave, IntPtr pool) 
    268444        { 
    269445            Console.WriteLine("Ssl Server Trust Prompt:");