diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
index 5b48ad1e7f1a0bb6e408993d50eb8959255834ea_bWVyY3VyaWFsL3N1YnJlcG8ucHk=..6fe6defdc924d4ac9f0cbe97f2afd5b97b6e5c1e_bWVyY3VyaWFsL3N1YnJlcG8ucHk= 100644
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -79,9 +79,8 @@
 
 def writestate(repo, state):
     """rewrite .hgsubstate in (outer) repo with these subrepo states"""
-    repo.wwrite('.hgsubstate',
-                ''.join(['%s %s\n' % (state[s][1], s)
-                         for s in sorted(state)]), '')
+    lines = ['%s %s\n' % (state[s][1], s) for s in sorted(state)]
+    repo.wwrite('.hgsubstate', ''.join(lines), '')
 
 def submerge(repo, wctx, mctx, actx, overwrite):
     """delegated from merge.applyupdates: merging of .hgsubstate file