Christian Specht avatar Christian Specht committed 2436b14

input new configuration value: timeout for pulling (optional)

Comments (0)

Files changed (8)

src/BitbucketBackup/App.config

       <setting name="BackupFolder" serializeAs="String">
         <value />
       </setting>
+      <setting name="PullTimeout" serializeAs="String">
+        <value>0</value>
+      </setting>
     </BitbucketBackup.Properties.Settings>
   </userSettings>
 </configuration>

src/BitbucketBackup/Config.cs

     internal class Config : IConfig
     {
         /// <summary>
+        /// default timeout for pulling
+        /// </summary>
+        const int DefaultPullTimeout = 60;
+
+        /// <summary>
         /// Bitbucket password
         /// </summary>
         public string PassWord
         }
 
         /// <summary>
+        /// Timeout for pulling (only for Mercurial at the moment)
+        /// </summary>
+        public int PullTimeout
+        {
+            get
+            {
+                return Settings.Default.PullTimeout;
+            }
+        }
+
+        /// <summary>
+        /// Timeout for pulling (setting only)
+        /// </summary>
+        /// <remarks>different property for saving, because input is a string, but needs to be saved as an int</remarks>
+        internal string PullTimeoutInternal
+        {
+            set
+            {
+                int timeout;
+
+                if (String.IsNullOrEmpty(value))
+                {
+                    timeout = DefaultPullTimeout;
+                }
+                else
+                {
+                    if (!int.TryParse(value, out timeout) || timeout < 1)
+                    {
+                        throw new ClientException(Resources.InputPullTimeoutInvalid, null);
+                    }
+                }
+
+                Settings.Default.PullTimeout = timeout;
+                Settings.Default.Save();
+            }
+        }
+
+        /// <summary>
         /// Checks if the config is complete (if none of the settings is empty)
         /// </summary>
         public bool IsComplete()
         {
+            // don't check PullTimeout because it's optional!
             return this.UserName != string.Empty
                 && this.PassWord != string.Empty
                 && this.BackupFolder != string.Empty;
             Console.WriteLine(Resources.InputUser);
             this.UserName = Console.ReadLine();
 
+            Console.WriteLine();
             Console.WriteLine(Resources.InputPassword);
 
             string pw = string.Empty;
 
             this.PassWord = pw;
 
+            Console.WriteLine();
             Console.WriteLine(Resources.InputBackupFolder);
             this.BackupFolder = Console.ReadLine();
+
+            Console.WriteLine();
+            Console.WriteLine(String.Format(Resources.InputPullTimeout, DefaultPullTimeout));
+            this.PullTimeoutInternal = Console.ReadLine();
         }
     }
 }

src/BitbucketBackup/IConfig.cs

         string BackupFolder { get; }
 
         /// <summary>
+        /// Timeout for pulling (only for Mercurial at the moment)
+        /// </summary>
+        int PullTimeout { get; }
+
+        /// <summary>
         /// Checks if the config is complete (if none of the settings is empty)
         /// </summary>
         bool IsComplete();

src/BitbucketBackup/Properties/Settings.Designer.cs

                 this["BackupFolder"] = value;
             }
         }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("0")]
+        public int PullTimeout {
+            get {
+                return ((int)(this["PullTimeout"]));
+            }
+            set {
+                this["PullTimeout"] = value;
+            }
+        }
     }
 }

src/BitbucketBackup/Properties/Settings.settings

     <Setting Name="BackupFolder" Type="System.String" Scope="User">
       <Value Profile="(Default)" />
     </Setting>
+    <Setting Name="PullTimeout" Type="System.Int32" Scope="User">
+      <Value Profile="(Default)">0</Value>
+    </Setting>
   </Settings>
 </SettingsFile>

src/BitbucketBackup/Resources.Designer.cs

         }
         
         /// <summary>
+        ///   Sucht eine lokalisierte Zeichenfolge, die Timeout for pulling, in seconds:
+        ///(Mercurial only, optional, will be set to {0} if omitted) ähnelt.
+        /// </summary>
+        internal static string InputPullTimeout {
+            get {
+                return ResourceManager.GetString("InputPullTimeout", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Sucht eine lokalisierte Zeichenfolge, die Timeout for pulling must be an integer value greater than zero! ähnelt.
+        /// </summary>
+        internal static string InputPullTimeoutInvalid {
+            get {
+                return ResourceManager.GetString("InputPullTimeoutInvalid", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Sucht eine lokalisierte Zeichenfolge, die Your Bitbucket username: ähnelt.
         /// </summary>
         internal static string InputUser {

src/BitbucketBackup/Resources.de.resx

   <data name="InputPasswordInvalid" xml:space="preserve">
     <value>Sie haben kein Passwort eingegeben!</value>
   </data>
+  <data name="InputPullTimeout" xml:space="preserve">
+    <value>Timeout für Pulls, in Sekunden:
+(nur für Mercurial, optional, wird auf {0} gesetzt wenn nicht eingegeben)</value>
+  </data>
+  <data name="InputPullTimeoutInvalid" xml:space="preserve">
+    <value>Timeout für Pulls muß eine ganze Zahl größer als 0 sein!</value>
+  </data>
   <data name="InputUser" xml:space="preserve">
     <value>Ihr Bitbucket-Benutzername:</value>
   </data>

src/BitbucketBackup/Resources.resx

   <data name="InputUserInvalid" xml:space="preserve">
     <value>You didn't enter a username!</value>
   </data>
+  <data name="InputPullTimeout" xml:space="preserve">
+    <value>Timeout for pulling, in seconds:
+(Mercurial only, optional, will be set to {0} if omitted)</value>
+  </data>
+  <data name="InputPullTimeoutInvalid" xml:space="preserve">
+    <value>Timeout for pulling must be an integer value greater than zero!</value>
+  </data>
 </root>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.