A fix for Python and the beginning of the change monitoring.
diff -r 5c169d23828c -r dd73283c4752 vcs/lib/support/git.py
--- a/vcs/lib/support/git.py Thu Jan 22 00:42:24 2009 -0500
+++ b/vcs/lib/support/git.py Fri Jan 23 01:11:53 2009 -0500
@@ -60,3 +60,4 @@
fetch = _git_factory('fetch')
push = _git_factory('push')
pull = _git_factory('pull')
+ show_ref = _git_factory('show-ref')
diff -r 5c169d23828c -r dd73283c4752 vcs/lib/types/bzr.py
--- a/vcs/lib/types/bzr.py Thu Jan 22 00:42:24 2009 -0500
+++ b/vcs/lib/types/bzr.py Fri Jan 23 01:11:53 2009 -0500
@@ -1,8 +1,10 @@
import os
-from django.conf import settings
+
from bzrlib import bzrdir
from bzrlib.plugins.bzrtools import clean_tree
from bzrlib.errors import NotBranchError
+
+from django.conf import settings
from vcs.lib.types import (VCSBrowserMixin, BrowserError)
REPO_PATH = settings.REPO_PATHS['bzr']
@@ -117,3 +119,18 @@
# bzr pull.
self._clean_dir()
self.work_tree.update()
+
+ @need_repo
+ def get_rev(self, obj=None):
+ """
+ Get the current revision of the repository or a specific
+ object.
+ """
+ if not obj:
+ return self.repo.last_revision_info()[0:1]
+ else:
+ m = self.repo.get_revision_id_to_revno_map()
+ t = self.repo.repository.revision_tree(
+ self.repo.last_revision())
+ i = t.inventory[t.path2id(obj)]
+ return m[i.revision]
diff -r 5c169d23828c -r dd73283c4752 vcs/lib/types/cvs.py
--- a/vcs/lib/types/cvs.py Thu Jan 22 00:42:24 2009 -0500
+++ b/vcs/lib/types/cvs.py Fri Jan 23 01:11:53 2009 -0500
@@ -1,5 +1,6 @@
import os
import time
+import os.path
from django.conf import settings
from vcs.lib import RepoError
@@ -109,3 +110,33 @@
cvs up -PdC
"""
self.repo.up(P=True, d=True, C=True)
+
+ @need_repo
+ def get_rev(self, obj=None):
+ """
+ Get the current revision of a file within the repository.
+
+ Commands used:
+ none
+ """
+ if not obj:
+ raise ValueError('CVS repos do not have a global revision')
+ p = os.path.join(self.path, obj)
+ if not os.path.exists(p):
+ return None
+ if not os.path.isfile(p):
+ raise ValueError('Only files have a revision in CVS')
+ d, b = os.path.split(p)
+ e = os.path.join(d, 'CVS', 'Entries')
+ try:
+ ef = open(e, 'r')
+ bs = '/%s/' % b
+ for line in (entry for entry in ef if entry.startswith(bs)):
+ rev = line.split('/')[2]
+ break
+ else:
+ rev = None
+ ef.close()
+ except IOError:
+ return None
+ return tuple(int(p) for p in rev.split('.'))
diff -r 5c169d23828c -r dd73283c4752 vcs/lib/types/git.py
--- a/vcs/lib/types/git.py Thu Jan 22 00:42:24 2009 -0500
+++ b/vcs/lib/types/git.py Fri Jan 23 01:11:53 2009 -0500
@@ -1,5 +1,7 @@
+import os
+
from mercurial.repo import RepoError
-import os
+
from django.conf import settings
from vcs.lib import RepoError
from vcs.lib.types import (VCSBrowserMixin, BrowserError)
@@ -106,3 +108,20 @@
revspec = 'origin/%s' % self.branch
self.repo.fetch('origin')
self.repo.reset(revspec, hard=True)
+
+ @need_repo
+ def get_rev(self, obj=None):
+ """
+ Get the current revision of the repository or a specific
+ object.
+
+ Commands used:
+ git show-ref refs/heads/<branch>
+ git log -1 --pretty=format:%H <obj>
+ """
+ if not obj:
+ refspec = 'refs/heads/%s' % self.branch
+ rev = self.repo.show_ref(refspec).split()[0]
+ else:
+ rev = self.repo.log('-1', '--pretty=format:%H', obj)
+ return (int(rev, 16),)
diff -r 5c169d23828c -r dd73283c4752 vcs/lib/types/hg.py
--- a/vcs/lib/types/hg.py Thu Jan 22 00:42:24 2009 -0500
+++ b/vcs/lib/types/hg.py Fri Jan 23 01:11:53 2009 -0500
@@ -1,6 +1,8 @@
import os
+
from mercurial import ui, hg, commands
from mercurial.repo import RepoError
+
from django.conf import settings
from vcs.lib.types import (VCSBrowserMixin, BrowserError)
@@ -120,3 +122,17 @@
commands.update(self.repo.ui, self.repo, self.branch)
except RepoError, e:
raise BrowserError, e
+
+ @need_repo
+ def get_rev(self, obj=None):
+ """
+ Get the current revision of the repository or a specific
+ object.
+ """
+ if not obj:
+ return (int(self.repo.changectx().node().encode('hex'),
+ 16),)
+ else:
+ f = self.repo.changectx().filectx('NOTES')
+ return (int(f.filectx(f.filerev()).node().encode('hex'),
+ 16),)
diff -r 5c169d23828c -r dd73283c4752 vcs/lib/types/svn.py
--- a/vcs/lib/types/svn.py Thu Jan 22 00:42:24 2009 -0500
+++ b/vcs/lib/types/svn.py Fri Jan 23 01:11:53 2009 -0500
@@ -1,6 +1,9 @@
import os
import time
+import os.path
+
import pysvn
+
from django.conf import settings
from vcs.lib.types import (VCSBrowserMixin, BrowserError)
@@ -97,3 +100,18 @@
"""
self._clean_dir()
self.client.update(self.path)
+
+ @need_repo
+ def get_rev(self, obj=None):
+ """
+ Get the current revision of the repository or a specific
+ object.
+
+ Commands used:
+ svn info
+ """
+ if not obj:
+ entry = self.client.info(self.path)
+ else:
+ entry = self.client.info(os.path.join(self.path, obj))
+ return (entry.commit_revision.number,)
diff -r 900cd8a10b68 -r 5c169d23828c vcs/lib/support/commands.py
--- a/vcs/lib/support/commands.py Tue Dec 30 23:46:51 2008 +0200
+++ b/vcs/lib/support/commands.py Thu Jan 22 00:42:24 2009 -0500
@@ -85,7 +85,9 @@
command = command.split()
# if more kwargs are given, convert them to command line args
- kwarglist = python_to_args(**kw) if kw else []
+ kwarglist = []
+ if kw:
+ kwarglist = python_to_args(**kw)
command += kwarglist + list(args)
# If stdin is a string, create a pipe so we can write the contents
@@ -117,10 +119,13 @@
stdout_value = stdout_value.rstrip()
stderr_value = stderr_value.rstrip()
+ lin = 0
+ if _input:
+ lin = len(_input)
logger.debug(" Status: %(stat)s. "
"std bytes: stdin %(in)s, stdout %(out)s, err %(err)s"
% {'stat': status,
- 'in': len(_input) if _input else 0,
+ 'in': lin,
'out': len(stdout_value),
'err': len(stderr_value)})
if stderr_value:
diff -r 900cd8a10b68 -r 5c169d23828c vcs/lib/types/cvs.py
--- a/vcs/lib/types/cvs.py Tue Dec 30 23:46:51 2008 +0200
+++ b/vcs/lib/types/cvs.py Thu Jan 22 00:42:24 2009 -0500
@@ -51,8 +51,11 @@
"""
# Break root
- self.module = root.split('/')[-1] if not module else module
- self.root = '/'.join(root.split('/')[:-1]) if not module else module
+ self.module = module
+ self.root = module
+ if not module:
+ self.module = root.split('/')[-1]
+ self.root = '/'.join(root.split('/')[:-1])
if not name:
name = self.module
self.name = name
@@ -80,7 +83,9 @@
cvs -d checkout
"""
- branch = self.branch if self.branch != 'HEAD' else None
+ branch = None
+ if self.branch != 'HEAD':
+ branch = self.branch
repo = checkout(root=self.root, module=self.module,
dest=self.path, branch=branch)
return repo