# HG changeset patch # User Bryan O'Sullivan # Date 1360012223 28800 # Node ID b62fff7832c360384717564335f8daa2caf5924f # Parent 110794582448c483e2c408458fc4fdc0487613ff buildmeta: only write the uuid file if needed We used to write it unconditionally. diff --git a/hgsubversion/svncommands.py b/hgsubversion/svncommands.py --- a/hgsubversion/svncommands.py +++ b/hgsubversion/svncommands.py @@ -38,6 +38,20 @@ def rebuildmeta(ui, repo, args, unsafe_s return _buildmeta(ui, repo, args, partial=False, skipuuid=unsafe_skip_uuid_check) +def write_if_needed(path, content): + try: + fp = open(path) + mustwrite = fp.read() != content + fp.close() + except IOError, err: + if err.errno != errno.ENOENT: + raise + mustwrite = True + if mustwrite: + fp = open(path, 'w') + fp.write(content) + fp.close() + def _buildmeta(ui, repo, args, partial=False, skipuuid=False): if repo is None: @@ -195,9 +209,7 @@ def _buildmeta(ui, repo, args, partial=F if uuid != svn.uuid: raise hgutil.Abort('remote svn repository identifier ' 'does not match') - uuidfile = open(os.path.join(svnmetadir, 'uuid'), 'w') - uuidfile.write(svn.uuid) - uuidfile.close() + write_if_needed(os.path.join(svnmetadir, 'uuid'), uuid) # don't reflect closed branches if (ctx.extra().get('close') and not ctx.files() or