]> arthur.barton.de Git - bup.git/commitdiff
index.py: factor out an Entry._fixup_time method.
authorAaron M. Ucko <amu@alum.mit.edu>
Mon, 30 May 2011 23:02:59 +0000 (19:02 -0400)
committerAvery Pennarun <apenwarr@gmail.com>
Tue, 31 May 2011 04:31:33 +0000 (00:31 -0400)
Factor Entry._fixup_time out of Entry._fixup to reduce (minor) logic
duplication and prepare for upcoming tweaks to timestamp indexing.

lib/bup/index.py

index 460a52f18de76f5bb60a2ccf45329a83e03f8e14..10f83098e1d733aadd0c85618b91eb4dd97a4654 100644 (file)
@@ -120,14 +120,16 @@ class Entry:
             self.gid += 0x100000000
         assert(self.uid >= 0)
         assert(self.gid >= 0)
-        if self.mtime < -0x80000000:  # can happen in NTFS on 64-bit linux
-            self.mtime = 0
-        if self.ctime < -0x80000000:
-            self.ctime = 0
-        if self.mtime > 0x7fffffff:
-            self.mtime = 0x7fffffff
-        if self.ctime > 0x7fffffff:
-            self.ctime = 0x7fffffff
+        self.mtime = self._fixup_time(self.mtime)
+        self.ctime = self._fixup_time(self.ctime)
+
+    def _fixup_time(self, t):
+        if t < -0x80000000:  # can happen in NTFS on 64-bit linux
+            return 0
+        elif t > 0x7fffffff:
+            return 0x7fffffff
+        else:
+            return t
 
     def is_valid(self):
         f = IX_HASHVALID|IX_EXISTS