]> source.dussan.org Git - jgit.git/commitdiff
Implement FileSnapshot.toString() to help debugging 01/37701/1
authorMatthias Sohn <matthias.sohn@sap.com>
Sat, 6 Dec 2014 00:09:02 +0000 (01:09 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Sat, 6 Dec 2014 01:38:23 +0000 (02:38 +0100)
Change-Id: Ic18d051327e491d5834929ff7fa28381f0f972c4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java

index 02e2cb47d10b13e7ee5116f21f31853c900aa3a5..e3f1e53dc212f3ff3baecf33eb3b5adfd7b36f92 100644 (file)
 package org.eclipse.jgit.internal.storage.file;
 
 import java.io.File;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
 
 import org.eclipse.jgit.util.FS;
 
@@ -143,7 +147,7 @@ public class FileSnapshot {
 
        /**
         * Check if the path may have been modified since the snapshot was saved.
-        * 
+        *
         * @param path
         *            the path the snapshot describes.
         * @return true if the path needs to be read again.
@@ -207,6 +211,18 @@ public class FileSnapshot {
                return (int) lastModified;
        }
 
+       @Override
+       public String toString() {
+               if (this == DIRTY)
+                       return "DIRTY"; //$NON-NLS-1$
+               if (this == MISSING_FILE)
+                       return "MISSING_FILE"; //$NON-NLS-1$
+               DateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", //$NON-NLS-1$
+                               Locale.US);
+               return "FileSnapshot[modified: " + f.format(new Date(lastModified)) //$NON-NLS-1$
+                               + ", read: " + f.format(new Date(lastRead)) + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+       }
+
        private boolean notRacyClean(final long read) {
                // The last modified time granularity of FAT filesystems is 2 seconds.
                // Using 2.5 seconds here provides a reasonably high assurance that