Skip to content

Commit

Permalink
Add option to resolve symlinks to avoid redundancies (#49)
Browse files Browse the repository at this point in the history
Fixes #48.
  • Loading branch information
Joseph Reagle authored and FichteFoll committed Mar 28, 2019
1 parent 069ea3d commit 068559b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion FileHistory.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
// Should the history file be nicely formatted?
"prettify_history": false,

// Use the real path, so as to avoid symlink redundancies
"real_path": false,

// List of path regexs to exclude from the history tracking.
// Can be extended in project settings (in a "file_histoy" dict).
//
Expand All @@ -87,5 +90,5 @@
"max_backup_count": 3,

// Print out debug text?
"debug": false
"debug": false,
}
11 changes: 9 additions & 2 deletions file_history.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import hashlib
import json
import os
import time
import re
import shutil
Expand Down Expand Up @@ -82,6 +83,7 @@ def __refresh_settings(self, first_load=False):
self.HISTORY_FILE = os.path.normpath(os.path.join(sublime.packages_path(), history_path))

self.USE_MONOSPACE = self.__ensure_setting('monospace_font', False)
self.REAL_PATH = self.__ensure_setting('real_path', False)

self.TIMESTAMP_SHOW = self.__ensure_setting('timestamp_show', True)
self.TIMESTAMP_FORMAT = self.__ensure_setting('timestamp_format', self.DEFAULT_TIMESTAMP_FORMAT)
Expand Down Expand Up @@ -316,11 +318,16 @@ def add_view(self, window, view, history_type):
if self.is_transient_view(window, view):
return

# Only keep track of files that have a filename
filename = view.file_name()
# Only keep track of files that have a filename
if filename is not None:
if self.REAL_PATH:
realname = os.path.realpath(view.file_name())
if realname != filename:
self.debug("Resolved '%s' to '%s'" % (filename, realname))
filename = realname

project_name = self.get_current_project_key()

if self.is_suppressed(view, filename):
# If filename matches 'path_exclude_patterns' then abort the history tracking
# and remove any references to this file from the history
Expand Down

0 comments on commit 068559b

Please sign in to comment.