changeset 994:e90c31a68eb9

buildmeta: write subdir and layout files only if needed
author Bryan O'Sullivan <bryano@fb.com>
date Mon, 04 Feb 2013 13:13:59 -0800
parents b62fff7832c3
children 0274b75af266
files hgsubversion/svncommands.py
diffstat 1 files changed, 2 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/svncommands.py
+++ b/hgsubversion/svncommands.py
@@ -117,9 +117,7 @@ def _buildmeta(ui, repo, args, partial=F
 
     numrevs = len(repo) - startrev
 
-    subdirfile = open(os.path.join(svnmetadir, 'subdir'), 'w')
-    subdirfile.write(subdir.strip('/'))
-    subdirfile.close()
+    write_if_needed(os.path.join(svnmetadir, 'subdir'), subdir.strip('/'))
 
     # ctx.children() visits all revisions in the repository after ctx. Calling
     # it would make us use O(revisions^2) time, so we perform an extra traversal
@@ -195,9 +193,7 @@ def _buildmeta(ui, repo, args, partial=F
                 layout = 'single'
             else:
                 layout = 'standard'
-            f = open(os.path.join(svnmetadir, 'layout'), 'w')
-            f.write(layout)
-            f.close()
+            write_if_needed(os.path.join(svnmetadir, 'layout'), layout)
         elif layout == 'single':
             assert (subdir or '/') == revpath, ('Possible layout detection'
                                                 ' defect in replay')