meld r979 - trunk/vc
- From: stevek svn gnome org
- To: svn-commits-list gnome org
- Subject: meld r979 - trunk/vc
- Date: Thu, 13 Mar 2008 19:35:40 +0000 (GMT)
Author: stevek
Date: Thu Mar 13 19:35:39 2008
New Revision: 979
URL: http://svn.gnome.org/viewvc/meld?rev=979&view=rev
Log:
Refactor to remove redundancy (Vincent Legoll)
Modified:
trunk/vc/_vc.py
trunk/vc/bzr.py
trunk/vc/cvs.py
trunk/vc/darcs.py
trunk/vc/git.py
trunk/vc/mercurial.py
trunk/vc/monotone.py
trunk/vc/svn.py
trunk/vc/tla.py
Modified: trunk/vc/_vc.py
==============================================================================
--- trunk/vc/_vc.py (original)
+++ trunk/vc/_vc.py Thu Mar 13 19:35:39 2008
@@ -122,3 +122,22 @@
def get_capabilities(self):
return 0
+
+ def lookup_files(self, dirs, files):
+ "Assume all files are in the same dir, files is an array of (name, path) tuples."
+ directory = self._get_directoryname(files, dirs)
+ if directory is None:
+ return [], []
+ else:
+ return self._get_dirsandfiles(directory, dirs, files)
+
+ def _get_directoryname(self, dirs, files):
+ directory = None
+ if len(files):
+ directory = os.path.dirname(files[0][1])
+ elif len(dirs):
+ directory = os.path.dirname(dirs[0][1])
+ return directory
+
+ def _get_dirsandfiles(self, directory, dirs, files):
+ raise NotImplementedError()
Modified: trunk/vc/bzr.py
==============================================================================
--- trunk/vc/bzr.py (original)
+++ trunk/vc/bzr.py Thu Mar 13 19:35:39 2008
@@ -98,14 +98,8 @@
else:
return self._tree_cache
- def lookup_files(self, dirs, files):
- "files is array of (name, path). assume all files in same dir"
- if len(files):
- directory = os.path.dirname(files[0][1])
- elif len(dirs):
- directory = os.path.dirname(dirs[0][1])
- else:
- return [],[]
+ def _get_dirsandfiles(self, directory, dirs, files):
+
tree = self.get_tree(directory)
retfiles = []
Modified: trunk/vc/cvs.py
==============================================================================
--- trunk/vc/cvs.py (original)
+++ trunk/vc/cvs.py Thu Mar 13 19:35:39 2008
@@ -52,14 +52,7 @@
def revert_command(self):
return [self.CMD,"update","-C"]
- def lookup_files(self, dirs, files):
- "files is array of (name, path). assume all files in same dir"
- if len(files):
- directory = os.path.dirname(files[0][1])
- elif len(dirs):
- directory = os.path.dirname(dirs[0][1])
- else:
- return [],[]
+ def _get_dirsandfiles(self, directory, dirs, files):
try:
entries = open( os.path.join(directory, "CVS/Entries")).read()
Modified: trunk/vc/darcs.py
==============================================================================
--- trunk/vc/darcs.py (original)
+++ trunk/vc/darcs.py Thu Mar 13 19:35:39 2008
@@ -84,16 +84,11 @@
def uncache_inventory(self):
self._cached_statuses = None
- def lookup_files(self, dirs, files):
- "files is array of (name, path). assume all files in same dir"
- directory = self._get_directoryname(files, dirs)
- if directory is None:
- return [], []
- else:
- whatsnew = self._get_cached_statuses()
- retfiles, retdirs = (self._get_statuses(whatsnew, files, _vc.File),
- self._get_statuses(whatsnew, dirs, _vc.Dir))
- return retfiles, retdirs
+ def _get_dirsandfiles(self, directory, dirs, files):
+ whatsnew = self._get_cached_statuses()
+ retfiles, retdirs = (self._get_statuses(whatsnew, files, _vc.File),
+ self._get_statuses(whatsnew, dirs, _vc.Dir))
+ return retfiles, retdirs
def _get_cached_statuses(self):
if self._cached_statuses is None:
@@ -145,12 +140,3 @@
if filename != "_darcs":
rets.append(vcfile)
return rets
-
- def _get_directoryname(self, files, dirs):
- directory = None
- if len(files):
- directory = os.path.dirname(files[0][1])
- elif len(dirs):
- directory = os.path.dirname(dirs[0][1])
- return directory
-
Modified: trunk/vc/git.py
==============================================================================
--- trunk/vc/git.py (original)
+++ trunk/vc/git.py Thu Mar 13 19:35:39 2008
@@ -119,16 +119,8 @@
return self.lookup_tree()
else:
return self._tree_cache
-
- def lookup_files(self, dirs, files):
- "files is array of (name, path). assume all files in same dir"
- if len(files):
- directory = os.path.dirname(files[0][1])
- elif len(dirs):
- directory = os.path.dirname(dirs[0][1])
- else:
- return [],[]
+ def _get_dirsandfiles(self, directory, dirs, files):
tree = self.get_tree()
Modified: trunk/vc/mercurial.py
==============================================================================
--- trunk/vc/mercurial.py (original)
+++ trunk/vc/mercurial.py Thu Mar 13 19:35:39 2008
@@ -55,14 +55,7 @@
def get_working_directory(self, workdir):
return self.root
- def lookup_files(self, dirs, files):
- "files is array of (name, path). assume all files in same dir"
- if len(files):
- directory = os.path.dirname(files[0][1])
- elif len(dirs):
- directory = os.path.dirname(dirs[0][1])
- else:
- return [],[]
+ def _get_dirsandfiles(self, directory, dirs, files):
while 1:
try:
Modified: trunk/vc/monotone.py
==============================================================================
--- trunk/vc/monotone.py (original)
+++ trunk/vc/monotone.py Thu Mar 13 19:35:39 2008
@@ -176,16 +176,13 @@
else:
return self._tree_cache
+ # TODO: if get_tree() could be called later,
+ # we wouldn't need this override for lookup_files()
def lookup_files(self, dirs, files):
- "files is array of (name, path). assume all files in same dir"
tree = self.get_tree()
- if len(files):
- directory = os.path.dirname(files[0][1])
- elif len(dirs):
- directory = os.path.dirname(dirs[0][1])
- else:
- return [],[]
+ _vc.Vc.lookup_files(self, dirs, files)
+ def _get_dirsandfiles(self, directory, dirs, files):
retfiles = []
retdirs = []
Modified: trunk/vc/svn.py
==============================================================================
--- trunk/vc/svn.py (original)
+++ trunk/vc/svn.py Thu Mar 13 19:35:39 2008
@@ -49,14 +49,7 @@
def revert_command(self):
return [self.CMD,"revert"]
- def lookup_files(self, dirs, files):
- "files is array of (name, path). assume all files in same dir"
- if len(files):
- directory = os.path.dirname(files[0][1])
- elif len(dirs):
- directory = os.path.dirname(dirs[0][1])
- else:
- return [],[]
+ def _get_dirsandfiles(self, directory, dirs, files):
while 1:
try:
Modified: trunk/vc/tla.py
==============================================================================
--- trunk/vc/tla.py (original)
+++ trunk/vc/tla.py Thu Mar 13 19:35:39 2008
@@ -103,16 +103,11 @@
def uncache_inventory(self):
self._cached_statuses = None
- def lookup_files(self, dirs, files):
- "files is array of (name, path). assume all files in same dir"
- directory = self._get_directoryname(files, dirs)
- if directory is None:
- return [], []
- else:
- whatsnew = self._get_cached_statuses()
- retfiles, retdirs = (self._get_statuses(whatsnew, files, _vc.File),
- self._get_statuses(whatsnew, dirs, _vc.Dir))
- return retfiles, retdirs
+ def _get_dirsandfiles(self, directory, dirs, files):
+ whatsnew = self._get_cached_statuses()
+ retfiles, retdirs = (self._get_statuses(whatsnew, files, _vc.File),
+ self._get_statuses(whatsnew, dirs, _vc.Dir))
+ return retfiles, retdirs
def _get_cached_statuses(self):
if self._cached_statuses is None:
@@ -151,12 +146,3 @@
if filename != "{arch}":
rets.append(vcfile)
return rets
-
- def _get_directoryname(self, files, dirs):
- directory = None
- if len(files):
- directory = os.path.dirname(files[0][1])
- elif len(dirs):
- directory = os.path.dirname(dirs[0][1])
- return directory
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]