Improved user-id saving/loading/caching & save user-id into duplicate bugdirs.
authorW. Trevor King <wking@drexel.edu>
Sun, 23 Nov 2008 13:43:40 +0000 (08:43 -0500)
committerW. Trevor King <wking@drexel.edu>
Sun, 23 Nov 2008 13:43:40 +0000 (08:43 -0500)
Fixes the duplicate bugs
  a403de79-8f39-41f2-b9ec-15053b175ee2
  c894f10f-197d-4b22-9c5b-19f394df40d4

.be/bugs/a403de79-8f39-41f2-b9ec-15053b175ee2/values
.be/bugs/c894f10f-197d-4b22-9c5b-19f394df40d4/values
libbe/bugdir.py

index 5ee35f90c98605de00e1b4f10025d696ef2babab..c80f16e740945150bb7a85e4617bb639622398e2 100644 (file)
@@ -15,7 +15,7 @@ severity=minor
 
 
 
-status=open
+status=fixed
 
 
 
index 9992d72820a6be8ccea082a4071af18d03245eee..5aed7295198c4f7292b3dfd1d0565bc0922e6b9c 100644 (file)
@@ -15,7 +15,7 @@ severity=minor
 
 
 
-status=open
+status=fixed
 
 
 
index 8c96cc61e39040b8fef654c80a309a46857f2ed4..2501a277b9b6296d03c25aea2b8721fa0b6300a1 100644 (file)
@@ -168,6 +168,8 @@ class BugDir (list):
     _user_id = setting_property("user-id", doc="The user's prefered name.  Kept seperate to make saving/loading settings easy.  Don't set this attribute.  Set .user_id instead, and ._user_id will be automatically adjusted.  This setting is only saved if ._save_user_id == True")
 
     def _get_user_id(self):
+        if self._user_id == None and self.rcs != None:
+            self._user_id = self.rcs.get_user_id()
         return self._user_id
 
     def _set_user_id(self, user_id):
@@ -181,7 +183,7 @@ class BugDir (list):
 
     def save_user_id(self, user_id=None):
         if user_id == None:
-            user_id = self.rcs.get_user_id()
+            user_id = self.user_id
         self._save_user_id = True
         self.user_id = user_id
 
@@ -215,10 +217,8 @@ class BugDir (list):
             self.settings = self._get_settings(self.get_path("settings"))
             
             self.rcs = rcs_by_name(self.rcs_name)
-            if self.user_id != None: # there was a user name in the settings file
-                self._save_user_id = True
-            else:
-                self.user_id = self.rcs.get_user_id()
+            if self._user_id != None: # there was a user name in the settings file
+                self.save_user_id()
             
             self._clear_bugs()
             for uuid in self.list_uuids():
@@ -242,17 +242,19 @@ class BugDir (list):
         return settings
 
     def _save_settings(self, settings_path, settings):
-        if not os.path.exists(self.get_path()):
-            # don't save settings until the bug directory has been
-            # initialized.  this initialization happens the first time
-            # a bug directory is saved (BugDir.save()).  If the user
-            # is just working with a BugDir in memory, we don't want
-            # to go cluttering up his file system with settings files.
-            return
-        if self._save_user_id == False and settings == self.settings:
-            if "user-id" in settings:
-                settings = copy.copy(settings)
-                del settings["user-id"]
+        this_dir_path = os.path.realpath(self.get_path("settings"))
+        if os.path.realpath(settings_path) == this_dir_path:
+            if not os.path.exists(self.get_path()):
+                # don't save settings until the bug directory has been
+                # initialized.  this initialization happens the first time
+                # a bug directory is saved (BugDir.save()).  If the user
+                # is just working with a BugDir in memory, we don't want
+                # to go cluttering up his file system with settings files.
+                return
+            if self._save_user_id == False:
+                if "user-id" in settings:
+                    settings = copy.copy(settings)
+                    del settings["user-id"]
         try:
             mapfile.map_save(self.rcs, settings_path, settings)
         except PathNotInRoot, e:
@@ -269,6 +271,7 @@ class BugDir (list):
         duplicate_settings = self._get_settings(duplicate_settings_path)
         if "rcs_name" in duplicate_settings:
             duplicate_settings["rcs_name"] = "None"
+            duplicate_settings["user-id"] = self.user_id
             self._save_settings(duplicate_settings_path, duplicate_settings)
 
         return BugDir(duplicate_path, loadNow=True)