--- /home/aswartz/chump2/chump-1.02/src/dailychump.py	Thu Jul 12 17:21:55 2001
+++ dailychump.py       Sun Dec 16 19:57:49 2001
@@ -101,7 +81,6 @@
 
 class Churn:
     def __init__(self,directory):
+	self.archiver = FileArchiver(directory)
         self.database = {}
         self.directory = directory
         self.labelcount = 0
@@ -232,10 +219,6 @@
             os.remove(self._filename())
         shutil.copy(name,self._filename())
         os.unlink(name)
+	newFile = self.archiver.prepare_filename(self._filename(), needNew=0)
+	if not os.path.isfile(newFile):
+		os.symlink(self._filename(), newFile)
 
     def deserialize(self,data):
         c = ChurnParser()
@@ -683,7 +625,7 @@
         else:
             return 1
 
-    def prepare_filename(self,old_filename):
+    def prepare_filename(self,old_filename, needNew=1):
         date = self.get_date(old_filename)
         date_components = time.gmtime(date)
         year = "%d" % date_components[0]
@@ -637,9 +695,11 @@
 
         filename = string.join([year, month, day],"-")
         filename = dir + os.sep + filename
-        if os.path.isfile(filename + ".xml"):
+        if needNew and (os.path.isfile(filename + ".xml") and 
+          not os.path.islink(filename + '.xml')):
             count = 1
-            while os.path.isfile(filename + "-" + "%d" % count + ".xml"):
+            while (os.path.isfile(filename + "-" + `count` + ".xml")
+              and not os.path.islink(filename + "-" + `count` + ".xml")):
                 count = count + 1
             filename = filename + "-" + "%d" % count
         filename = filename + ".xml"

