Skip to content

Commit

Permalink
Generate files with unique names (#27)
Browse files Browse the repository at this point in the history
Ref #26
  • Loading branch information
facelessuser authored Feb 6, 2018
1 parent cbcf7fa commit ad627e1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
1 change: 1 addition & 0 deletions .dictionary
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Ctrl
DeltaWalker
EasyDiff
EasyDiff's
Feb
MERCHANTABILITY
MkDocs
NONINFRINGEMENT
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# EasyDiff 2.0.3

> Released Feb 5, 2017
- **FIX**: More unique name for generated version control files #26.

# EasyDiff 2.0.2

> Released Nov 19, 2017
Expand Down
34 changes: 23 additions & 11 deletions easy_diff_version_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
import sublime
import sublime_plugin
import os
from os.path import basename, splitext, join, exists
import EasyDiff.lib.svn as svn
import EasyDiff.lib.git as git
Expand Down Expand Up @@ -268,11 +269,15 @@ def get_files(self, name, **kwargs):
rev = None
if kwargs.get("last", False):
rev = "PREV"
f1 = join(self.temp_folder, "%s-r%s-LEFT%s" % (root, rev, ext))
else:
rev = "BASE"
f1 = join(self.temp_folder, "%s-r%s-LEFT%s" % (root, rev, ext))
svn.export(f2, f1, rev=rev)
for x in range(1000):
file_path = join(self.temp_folder, "%s-r%s-LEFT-%03d%s" % (root, rev, x, ext))
if not os.path.exists(file_path):
f1 = file_path
break
if f1 is not None:
svn.export(f2, f1, rev=rev)
else:
log("View not versioned under SVN!", status=True)
return f1, f2
Expand Down Expand Up @@ -338,11 +343,14 @@ def get_files(self, name, **kwargs):
revs = git.getrevision(f2, 2)
if revs is not None and len(revs) == 2:
rev = revs[1]
if rev is not None:
f1 = join(self.temp_folder, "%s-r%s-LEFT%s" % (root, rev, ext))
else:
rev = "HEAD"
f1 = join(self.temp_folder, "%s-r%s-LEFT%s" % (root, rev, ext))
if rev is not None:
for x in range(1000):
file_path = join(self.temp_folder, "%s-r%s-LEFT-%03d%s" % (root, rev, x, ext))
if not os.path.exists(file_path):
f1 = file_path
break
if f1 is not None:
with open(f1, "wb") as f:
bfr = git.show(f2, rev)
Expand Down Expand Up @@ -420,11 +428,15 @@ def get_files(self, name, **kwargs):
revs = hg.getrevision(f2, 2)
if revs is not None and len(revs) == 2:
rev = revs[1]
if rev is not None:
f1 = join(self.temp_folder, "%s-r%s-LEFT%s" % (root, rev, ext))
else:
# Leave rev as None
f1 = join(self.temp_folder, "%s-r%s-LEFT%s" % (root, "BASE", ext))
if not kwargs.get("last", False) or rev is not None:
for x in range(1000):
if rev is not None:
file_path = join(self.temp_folder, "%s-r%s-LEFT-%03d%s" % (root, rev, x, ext))
else:
file_path = join(self.temp_folder, "%s-rBASE-LEFT-%03d%s" % (root, x, ext))
if not os.path.exists(file_path):
f1 = file_path
break
if f1 is not None:
with open(f1, "wb") as f:
bfr = hg.cat(f2, rev)
Expand Down
2 changes: 1 addition & 1 deletion support.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import webbrowser
import re

__version__ = "2.0.2"
__version__ = "2.0.3"
__pc_name__ = 'EasyDiff'

CSS = '''
Expand Down

0 comments on commit ad627e1

Please sign in to comment.