meld r1343 - trunk/vc
- From: vincele svn gnome org
- To: svn-commits-list gnome org
- Subject: meld r1343 - trunk/vc
- Date: Sat, 11 Apr 2009 23:22:07 +0000 (UTC)
Author: vincele
Date: Sat Apr 11 23:22:07 2009
New Revision: 1343
URL: http://svn.gnome.org/viewvc/meld?rev=1343&view=rev
Log:
Factorize VC constructor code
This patch should be a no-op, behavior-wise
and remove some duplicated code in VC constructors.
CVS, RCS & SVN, now don't need one any more.
The remaining specific constructors are:
- git: handle tree cache, GIT_DIR
- monotone: tree cache, find mtn version
- bzr, darcs, tla: tree cache
Modified:
trunk/vc/_vc.py
trunk/vc/cvs.py
trunk/vc/monotone.py
trunk/vc/rcs.py
trunk/vc/svn.py
Modified: trunk/vc/_vc.py
==============================================================================
--- trunk/vc/_vc.py (original)
+++ trunk/vc/_vc.py Sat Apr 11 23:22:07 2009
@@ -71,10 +71,14 @@
PATCH_STRIP_NUM = 0
PATCH_INDEX_RE = ''
VC_DIR = None
+ VC_ROOT_WALK = True
VC_METADATA = None
def __init__(self, location):
- self.root = self.find_repo_root(location)
+ if self.VC_ROOT_WALK:
+ self.root = self.find_repo_root(location)
+ else:
+ self.root = self.is_repo_root(location)
def commit_command(self, message):
raise NotImplementedError()
@@ -91,14 +95,19 @@
def patch_command(self, workdir):
return ["patch","--strip=%i"%self.PATCH_STRIP_NUM,"--reverse","--directory=%s" % workdir]
- def find_repo_root(self, start):
+ def is_repo_root(self, location):
+ if not os.path.isdir(os.path.join(location, self.VC_DIR)):
+ raise ValueError
+ return location
+
+ def find_repo_root(self, location):
while True:
- if os.path.isdir(os.path.join(start, self.VC_DIR)):
- return start
- tmp = os.path.dirname(start)
- if tmp == start:
+ if os.path.isdir(os.path.join(location, self.VC_DIR)):
+ return location
+ tmp = os.path.dirname(location)
+ if tmp == location:
break
- start = tmp
+ location = tmp
raise ValueError()
def get_working_directory(self, workdir):
Modified: trunk/vc/cvs.py
==============================================================================
--- trunk/vc/cvs.py (original)
+++ trunk/vc/cvs.py Sat Apr 11 23:22:07 2009
@@ -33,13 +33,9 @@
CMD = "cvs"
NAME = "CVS"
VC_DIR = "CVS"
+ VC_ROOT_WALK = False
PATCH_INDEX_RE = "^Index:(.*)$"
- def __init__(self, location):
- if not os.path.isdir(os.path.join(location, self.VC_DIR)):
- raise ValueError
- self.root = location
-
def commit_command(self, message):
return [self.CMD,"commit","-m",message]
def diff_command(self):
Modified: trunk/vc/monotone.py
==============================================================================
--- trunk/vc/monotone.py (original)
+++ trunk/vc/monotone.py Sat Apr 11 23:22:07 2009
@@ -27,7 +27,6 @@
import errno
class Vc(_vc.Vc):
- CMD = "mtn"
NAME = "Monotone"
VC_METADATA = ['MT', '_MTN']
PATCH_STRIP_NUM = 0
@@ -35,22 +34,22 @@
def __init__(self, location):
self._tree_cache = None
- location = os.path.normpath(location)
+ self.interface_version = 0.0
+ self.choose_monotone_version()
+ super(Vc, self).__init__(os.path.normpath(location))
+ def choose_monotone_version(self):
try:
# for monotone >= 0.26
self.VC_DIR = "_MTN"
- self.root = self.find_repo_root(location)
- self.interface_version = float(os.popen("mtn" + " automate interface_version").read())
+ self.CMD = "mtn"
+ self.interface_version = float(os.popen(self.CMD + " automate interface_version").read())
if self.interface_version > 9.0:
print "WARNING: Unsupported interface version (please report any problems to the meld mailing list)"
- return
except ValueError:
- # for monotone <= 0.25 (different metadata directory, different executable)
+ # for monotone <= 0.25
self.VC_DIR = "MT"
self.CMD = "monotone"
- self.root = self.find_repo_root(location)
- return
def commit_command(self, message):
return [self.CMD,"commit","-m",message]
Modified: trunk/vc/rcs.py
==============================================================================
--- trunk/vc/rcs.py (original)
+++ trunk/vc/rcs.py Sat Apr 11 23:22:07 2009
@@ -29,14 +29,10 @@
CMD = "rcs"
NAME = "RCS"
VC_DIR = "RCS"
+ VC_ROOT_WALK = False
PATCH_STRIP_NUM = 0
PATCH_INDEX_RE = "^[+]{3} ([^\t]*)\t.*$"
- def __init__(self, location):
- if not os.path.isdir(os.path.join(location, self.VC_DIR)):
- raise ValueError
- self.root = location
-
def commit_command(self, message):
return ["ci", "-l", "-m", message]
Modified: trunk/vc/svn.py
==============================================================================
--- trunk/vc/svn.py (original)
+++ trunk/vc/svn.py Sat Apr 11 23:22:07 2009
@@ -31,6 +31,7 @@
CMD = "svn"
NAME = "Subversion"
VC_DIR = ".svn"
+ VC_ROOT_WALK = False
PATCH_INDEX_RE = "^Index:(.*)$"
state_map = {
"?": _vc.STATE_NONE,
@@ -43,11 +44,6 @@
"C": _vc.STATE_CONFLICT,
}
- def __init__(self, location):
- if not os.path.isdir(os.path.join(location, self.VC_DIR)):
- raise ValueError()
- self.root = location
-
def commit_command(self, message):
return [self.CMD,"commit","-m",message]
def diff_command(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]