# HG changeset patch # User Bryan O'Sullivan # Date 1360012439 28800 # Node ID e90c31a68eb9da48b5280faacce9525dd90b9798 # Parent b62fff7832c360384717564335f8daa2caf5924f buildmeta: write subdir and layout files only if needed diff --git a/hgsubversion/svncommands.py b/hgsubversion/svncommands.py --- 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')