Commits

Yujie Wu committed d9f8fc3

Refactored code.
Made it more consistent to set attributes (such as msg_prefix, version_prefix, etc.) of `Flow' object, which also makes it harder to write buggy code (such as creating an attribute in a logic branch only -- the execution might crash due to `AttributeError').

Comments (0)

Files changed (1)

         self.autoshelve       = False
         self.warn_uncommitted = True
         self.msg_prefix       = "flow: "
+        self.version_prefix   = "v"
         self.orig_workspace   = Branch( ui, repo )
         self.curr_workspace   = self.orig_workspace     # May be changed whenever `hg update` command is executed.
         self.orig_dir         = os.getcwd()
-        self.version_prefix   = "v"
         
         if (init) : return
         
         if (ui.has_section( "hgflow" )) :
             self._warn( "The [hgflow] section in hg configuration file is deprecated." )
             self._warn( "Please replace the section name from [hgflow] to [flow]." )
-            self.autoshelve       = ui.configbool( "hgflow", "autoshelve",       False )
-            self.warn_uncommitted = ui.configbool( "hgflow", "warn_uncommitted", True  )
+            self.autoshelve       = ui.configbool( "hgflow", "autoshelve",       self.autoshelve        )
+            self.warn_uncommitted = ui.configbool( "hgflow", "warn_uncommitted", self.warn_uncommitted  )
         if (ui.has_section( "flow" )) :
-            self.autoshelve       = ui.configbool( "flow", "autoshelve",       False    )
-            self.warn_uncommitted = ui.configbool( "flow", "warn_uncommitted", True     )
-            self.msg_prefix       = ui.config    ( "flow", "prefix",           "flow: " ).strip( STRIP_CHARS )
-            self.version_prefix   = ui.config    ( "flow", "version_prefix",   "v"      ).strip( STRIP_CHARS )
+            self.autoshelve       = ui.configbool( "flow", "autoshelve",       self.autoshelve       )
+            self.warn_uncommitted = ui.configbool( "flow", "warn_uncommitted", self.warn_uncommitted )
+            self.msg_prefix       = ui.config    ( "flow", "prefix",           self.msg_prefix       ).strip( STRIP_CHARS )
+            self.version_prefix   = ui.config    ( "flow", "version_prefix",   self.version_prefix   ).strip( STRIP_CHARS )
         if (self._has_uncommitted_changes() and self.warn_uncommitted) :
             self._warn( "Your workspace has uncommitted changes." )