Skip to content

Commit ab25807

Browse files
committed
Convert Svk VCS
1 parent 5d6ece8 commit ab25807

File tree

2 files changed

+60
-38
lines changed

2 files changed

+60
-38
lines changed

src/main.py

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
from diffuse.vcs.hg import Hg
6262
from diffuse.vcs.mtn import Mtn
6363
from diffuse.vcs.rcs import Rcs
64+
from diffuse.vcs.svk import Svk
6465
from diffuse.vcs.svn import Svn
6566

6667
if not hasattr(__builtins__, 'WindowsError'):
@@ -1291,43 +1292,6 @@ def _get_svn_repo(path, prefs):
12911292
if p:
12921293
return Svn(p)
12931294

1294-
class _Svk(_Svn):
1295-
def __init__(self, root):
1296-
_Svn.__init__(self, root)
1297-
1298-
def _getVcs(self):
1299-
return 'svk'
1300-
1301-
def _getURLPrefix(self):
1302-
return 'Depot Path: '
1303-
1304-
def _parseStatusLine(self, s):
1305-
if len(s) < 4 or s[0] not in 'ACDMR':
1306-
return
1307-
return s[0], s[4:]
1308-
1309-
def _getPreviousRevision(self, rev):
1310-
if rev is None:
1311-
return 'HEAD'
1312-
if rev.endswith('@'):
1313-
return str(int(rev[:-1]) - 1) + '@'
1314-
return str(int(rev) - 1)
1315-
1316-
def getRevision(self, prefs, name, rev):
1317-
return utils.popenRead(
1318-
self.root,
1319-
[
1320-
prefs.getString('svk_bin'),
1321-
'cat',
1322-
'-r',
1323-
rev,
1324-
'{}/{}'.format(
1325-
self._getURL(prefs),
1326-
utils.relpath(self.root, os.path.abspath(name)).replace(os.sep, '/'))
1327-
],
1328-
prefs,
1329-
'svk_bash')
1330-
13311295
def _get_svk_repo(path, prefs):
13321296
name = path
13331297
# parse the ~/.svk/config file to discover which directories are part of
@@ -1386,7 +1350,7 @@ def _get_svk_repo(path, prefs):
13861350
break
13871351
# check if the file belongs to one of the project directories
13881352
if FolderSet(projs).contains(name):
1389-
return _Svk(path)
1353+
return Svk(path)
13901354
except IOError:
13911355
utils.logError(_('Error parsing %s.') % (svkconfig, ))
13921356

src/vcs/svk.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Diffuse: a graphical tool for merging and comparing text files.
2+
#
3+
# Copyright (C) 2019 Derrick Moser <[email protected]>
4+
# Copyright (C) 2021 Romain Failliot <[email protected]>
5+
#
6+
# This program is free software; you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation; either version 2 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License along
17+
# with this program; if not, write to the Free Software Foundation, Inc.,
18+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19+
20+
import os
21+
import glob
22+
23+
from diffuse import utils
24+
from diffuse.vcs.svn import Svn
25+
26+
class Svk(Svn):
27+
def _getVcs(self):
28+
return 'svk'
29+
30+
def _getURLPrefix(self):
31+
return 'Depot Path: '
32+
33+
def _parseStatusLine(self, s):
34+
if len(s) < 4 or s[0] not in 'ACDMR':
35+
return
36+
return s[0], s[4:]
37+
38+
def _getPreviousRevision(self, rev):
39+
if rev is None:
40+
return 'HEAD'
41+
if rev.endswith('@'):
42+
return str(int(rev[:-1]) - 1) + '@'
43+
return str(int(rev) - 1)
44+
45+
def getRevision(self, prefs, name, rev):
46+
return utils.popenRead(
47+
self.root,
48+
[
49+
prefs.getString('svk_bin'),
50+
'cat',
51+
'-r',
52+
rev,
53+
'{}/{}'.format(
54+
self._getURL(prefs),
55+
utils.relpath(self.root, os.path.abspath(name)).replace(os.sep, '/'))
56+
],
57+
prefs,
58+
'svk_bash')

0 commit comments

Comments
 (0)