aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/storage/vcs/darcs.py
diff options
context:
space:
mode:
Diffstat (limited to 'libbe/storage/vcs/darcs.py')
-rw-r--r--libbe/storage/vcs/darcs.py28
1 files changed, 17 insertions, 11 deletions
diff --git a/libbe/storage/vcs/darcs.py b/libbe/storage/vcs/darcs.py
index 41262f5..5ec9a26 100644
--- a/libbe/storage/vcs/darcs.py
+++ b/libbe/storage/vcs/darcs.py
@@ -39,11 +39,17 @@ import libbe
from ...util.subproc import CommandError
from . import base
-if libbe.TESTING == True:
+if libbe.TESTING:
import doctest
import unittest
+# https://stackoverflow.com/a/56719588/164233
+def cmp(a, b):
+ return (int(a) > int(b)) - (int(a) < int(b))
+
+
+
def new():
return Darcs()
@@ -98,7 +104,7 @@ class Darcs(base.VCS):
NotImplementedError: Cannot parse non-integer portion "0pre2" of Darcs version "2.0.0pre2"
"""
if not hasattr(self, '_parsed_version') \
- or self._parsed_version == None:
+ or self._parsed_version is None:
num_part = self.version().split(' ')[0]
self._parsed_version = []
for num in num_part.split('.'):
@@ -119,12 +125,12 @@ class Darcs(base.VCS):
def _vcs_get_user_id(self):
# following http://darcs.net/manual/node4.html#SECTION00410030000000000000
# as of June 22th, 2010
- if self.repo == None:
+ if self.repo is None:
return None
for pref_file in ['author', 'email']:
for prefs_dir in [os.path.join(self.repo, '_darcs', 'prefs'),
os.path.expanduser(os.path.join('~', '.darcs'))]:
- if prefs_dir == None:
+ if prefs_dir is None:
continue
pref_path = os.path.join(prefs_dir, pref_file)
if os.path.exists(pref_path):
@@ -135,7 +141,7 @@ class Darcs(base.VCS):
return None
def _vcs_detect(self, path):
- if self._u_search_parent_directories(path, "_darcs") != None :
+ if self._u_search_parent_directories(path, "_darcs") is not None :
return True
return False
@@ -146,7 +152,7 @@ class Darcs(base.VCS):
if os.path.isdir(path) != True:
path = os.path.dirname(path)
darcs_dir = self._u_search_parent_directories(path, '_darcs')
- if darcs_dir == None:
+ if darcs_dir is None:
return None
return os.path.dirname(darcs_dir)
@@ -175,7 +181,7 @@ class Darcs(base.VCS):
pass # darcs notices changes
def _vcs_get_file_contents(self, path, revision=None):
- if revision == None:
+ if revision is None:
return base.VCS._vcs_get_file_contents(self, path, revision)
if self.version_cmp(2, 0, 0) == 1:
status,output,error = self._u_invoke_client( \
@@ -266,7 +272,7 @@ class Darcs(base.VCS):
else:
revline = re.compile("Finished recording patch '(.*)'")
match = revline.search(output)
- assert match != None, output+error
+ assert match is not None, output+error
assert len(match.groups()) == 1
revision = match.groups()[0]
return revision
@@ -308,7 +314,7 @@ class Darcs(base.VCS):
if i+1 < len(revisions):
next_rev = revisions[i+1]
args.extend(['--from-patch', next_rev])
- if path != None:
+ if path is not None:
args.append(path)
kwargs = {'unicode_output':unicode_output}
status,output,error = self._u_invoke_client(
@@ -356,7 +362,7 @@ class Darcs(base.VCS):
@@ -1 +0,0 @@
-this entry will be deleted
\ No newline at end of file
-
+
"""
new = []
modified = []
@@ -404,7 +410,7 @@ class Darcs(base.VCS):
return self._parse_diff(self._diff(revision))
-if libbe.TESTING == True:
+if libbe.TESTING:
base.make_vcs_testcase_subclasses(Darcs, sys.modules[__name__])
unitsuite =unittest.TestLoader().loadTestsFromModule(sys.modules[__name__])