[PATCH 04 of 10] change all opener(...).write() calls to opener.write(...)

Dan Villiom Podlaski Christiansen danchr at gmail.com
Wed Dec 1 15:34:57 CST 2010


# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
# Date 1291227968 -3600
# Node ID 0df64bd75b64f1465c9e3e768373420267078d42
# Parent  86fb0a3d66d582da4a3643963b15a5dba9146a14
change all opener(...).write() calls to opener.write(...)

diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
--- a/hgext/convert/subversion.py
+++ b/hgext/convert/subversion.py
@@ -1021,7 +1021,7 @@ class svn_sink(converter_sink, commandli
                     os.unlink(filename)
             except OSError:
                 pass
-            self.wopener(filename, 'w').write(data)
+            self.wopener.write(data, filename, 'w')
 
             if self.is_exec:
                 was_exec = self.is_exec(self.wjoin(filename))
diff --git a/hgext/extdiff.py b/hgext/extdiff.py
--- a/hgext/extdiff.py
+++ b/hgext/extdiff.py
@@ -96,7 +96,7 @@ def snapshot(ui, repo, files, node, tmpr
         if 'l' in fctx.flags():
             wopener.symlink(data, wfn)
         else:
-            wopener(wfn, 'w').write(data)
+            wopener.write(data, wfn, 'w')
             if 'x' in fctx.flags():
                 util.set_flags(dest, False, True)
         if node is None:
diff --git a/hgext/gpg.py b/hgext/gpg.py
--- a/hgext/gpg.py
+++ b/hgext/gpg.py
@@ -234,7 +234,7 @@ def sign(ui, repo, *revs, **opts):
 
     # write it
     if opts['local']:
-        repo.opener("localsigs", "ab").write(sigmessage)
+        repo.opener.write(sigmessage, "localsigs", "ab")
         return
 
     msigs = match.exact(repo.root, '', ['.hgsigs'])
diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -384,7 +384,7 @@ def demo(ui, repo, *args, **opts):
     demoitems('keyword', ui.configitems('keyword'))
     demoitems('keywordmaps', kwmaps.iteritems())
     keywords = '$' + '$\n$'.join(sorted(kwmaps.keys())) + '$\n'
-    repo.wopener(fn, 'w').write(keywords)
+    repo.wopener.write(keywords, fn, 'w')
     repo[None].add([fn])
     ui.note(_('\nkeywords written to %s:\n') % fn)
     ui.note(keywords)
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2382,7 +2382,8 @@ def import_(ui, repo, patch1, *patches, 
                 raise util.Abort(_('no diffs found'))
 
         if msgs:
-            repo.opener('last-message.txt', 'wb').write('\n* * *\n'.join(msgs))
+            repo.opener.write('\n* * *\n'.join(msgs),
+                              'last-message.txt', 'wb')
     finally:
         release(lock, wlock)
 
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -211,7 +211,7 @@ class dirstate(object):
         if branch in ['tip', '.', 'null']:
             raise util.Abort(_('the name \'%s\' is reserved') % branch)
         self._branch = encoding.fromlocal(branch)
-        self._opener("branch", "w").write(self._branch + '\n')
+        self._opener.write(self._branch + '\n', "branch", "w")
 
     def _read(self):
         self._map = {}
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -56,9 +56,10 @@ class localrepository(repo.repository):
                         if self.ui.configbool('format', 'dotencode', True):
                             requirements.append('dotencode')
                     # create an invalid changelog
-                    self.opener("00changelog.i", "a").write(
+                    self.opener.write(
                         '\0\0\0\2' # represents revlogv2
-                        ' dummy changelog to prevent using the old repo layout'
+                        ' dummy changelog to prevent using the old repo layout',
+                        "00changelog.i", "a"
                     )
                 if self.ui.configbool('format', 'parentdelta', False):
                     requirements.append("parentdelta")
@@ -636,7 +637,7 @@ class localrepository(repo.repository):
         if 'l' in flags:
             self.wopener.symlink(data, filename)
         else:
-            self.wopener(filename, 'w').write(data)
+            fp = self.wopener.write(data, filename, 'w')
             if 'x' in flags:
                 util.set_flags(self.wjoin(filename), False, True)
 
@@ -658,10 +659,11 @@ class localrepository(repo.repository):
             ds = self.opener.read("dirstate")
         except IOError:
             ds = ""
-        self.opener("journal.dirstate", "w").write(ds)
-        self.opener("journal.branch", "w").write(
-            encoding.fromlocal(self.dirstate.branch()))
-        self.opener("journal.desc", "w").write("%d\n%s\n" % (len(self), desc))
+        self.opener.write(ds, "journal.dirstate", "w")
+        self.opener.write(encoding.fromlocal(self.dirstate.branch()),
+                          "journal.branch", "w")
+        self.opener.write("%d\n%s\n" % (len(self), desc),
+                          "journal.desc", "w")
 
         renames = [(self.sjoin("journal"), self.sjoin("undo")),
                    (self.join("journal.dirstate"), self.join("undo.dirstate")),
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -45,7 +45,7 @@ class mergestate(object):
             self._dirty = False
     def add(self, fcl, fco, fca, fd, flags):
         hash = util.sha1(fcl.path()).hexdigest()
-        self._repo.opener("merge/" + hash, "w").write(fcl.data())
+        self._repo.opener.write(fcl.data(), "merge/" + hash, "w")
         self._state[fd] = ['u', hash, fcl.path(), fca.path(),
                            hex(fca.filenode()), fco.path(), flags]
         self._dirty = True
diff --git a/mercurial/store.py b/mercurial/store.py
--- a/mercurial/store.py
+++ b/mercurial/store.py
@@ -274,7 +274,7 @@ class fncache(object):
         if self.entries is None:
             self._load()
         if fn not in self.entries:
-            self.opener('fncache', 'ab').write(encodedir(fn) + '\n')
+            self.opener.write(encodedir(fn) + '\n', 'fncache', 'ab')
             self.entries.add(fn)
 
     def __contains__(self, fn):


More information about the Mercurial-devel mailing list