diff hgsubversion/svnmeta.py @ 1152:aa98fdccaa0e

subdir: use util.dump and util.load for writing and reading We need to change both svnmeta and svncommands at the same time since they are heavily tied together. The reason for this change is to remove the duplicate code for reading and writing subdir present in svncommands.py. We will now use the standard util.dump and util.load for writing and reading. Due to the way json reads a string, the old format is still valid for use and will be read correctly.
author Sean Farley <sean.michael.farley@gmail.com>
date Tue, 18 Feb 2014 18:28:33 -0600
parents 510fa46caf9c
children c3c4518e00aa
line wrap: on
line diff
--- a/hgsubversion/svnmeta.py
+++ b/hgsubversion/svnmeta.py
@@ -98,19 +98,17 @@ class SVNMeta(object):
         subdirfile = os.path.join(self.meta_data_dir, 'subdir')
 
         if os.path.isfile(subdirfile):
-            stored_subdir = open(subdirfile).read()
+            stored_subdir = util.load(subdirfile)
             assert stored_subdir is not None
             if subdir is None:
                 self.__subdir = stored_subdir
-            elif subdir != stored_subdir:
+            elif subdir and subdir != stored_subdir:
                 raise hgutil.Abort('unable to work on a different path in the '
                                    'repository')
             else:
                 self.__subdir = subdir
         elif subdir is not None:
-            f = open(subdirfile, 'w')
-            f.write(subdir)
-            f.close()
+            util.dump(subdir, subdirfile)
             self.__subdir = subdir
         else:
             raise hgutil.Abort("hgsubversion metadata unavailable; "