Sean Farley  committed aa98fdc

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 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.

  • Participants
  • Parent commits e5818c7
  • Branches default

Comments (0)

Files changed (2)

File hgsubversion/

     if subdir is None:
         svn = svnrepo.svnremoterepo(ui, url).svn
         subdir = svn.subdir
-        open(subdirpath, 'wb').write(subdir.strip('/'))
+        util.dump(subdir.strip('/'), subdirpath)
     youngest = 0
     startrev = 0

File hgsubversion/

         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 '
                 self.__subdir = subdir
         elif subdir is not None:
-            f = open(subdirfile, 'w')
-            f.write(subdir)
-            f.close()
+            util.dump(subdir, subdirfile)
             self.__subdir = subdir
             raise hgutil.Abort("hgsubversion metadata unavailable; "