changeset 2772:4720e79486d3

mq: simplify save_dirty
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Wed, 02 Aug 2006 20:33:57 -0700
parents 519bf0cd28d2
children 871ca5b9d348
files hgext/mq.py
diffstat 1 files changed, 7 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Wed Aug 02 15:07:37 2006 -0700
+++ b/hgext/mq.py	Wed Aug 02 20:33:57 2006 -0700
@@ -83,20 +83,13 @@
                 self.series.append(s)
 
     def save_dirty(self):
-        if self.applied_dirty:
-            if len(self.applied) > 0:
-                nl = "\n"
-            else:
-                nl = ""
-            f = self.opener(self.status_path, "w")
-            f.write("\n".join(self.applied) + nl)
-        if self.series_dirty:
-            if len(self.full_series) > 0:
-                nl = "\n"
-            else:
-                nl = ""
-            f = self.opener(self.series_path, "w")
-            f.write("\n".join(self.full_series) + nl)
+        def write_list(items, path):
+            fp = self.opener(path, 'w')
+            for i in items:
+                print >> fp, i
+            fp.close()
+        if self.applied_dirty: write_list(self.applied, self.status_path)
+        if self.series_dirty: write_list(self.full_series, self.series_path)
 
     def readheaders(self, patch):
         def eatdiff(lines):