aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/storage
diff options
context:
space:
mode:
Diffstat (limited to 'libbe/storage')
-rw-r--r--libbe/storage/__init__.py3
-rw-r--r--libbe/storage/base.py3
-rw-r--r--libbe/storage/http.py14
-rw-r--r--libbe/storage/util/config.py1
-rw-r--r--libbe/storage/util/mapfile.py1
-rw-r--r--libbe/storage/util/properties.py3
-rw-r--r--libbe/storage/util/settings_object.py3
-rw-r--r--libbe/storage/util/upgrade.py3
-rw-r--r--libbe/storage/vcs/__init__.py3
-rw-r--r--libbe/storage/vcs/arch.py3
-rw-r--r--libbe/storage/vcs/base.py101
-rw-r--r--libbe/storage/vcs/bzr.py55
-rw-r--r--libbe/storage/vcs/darcs.py5
-rw-r--r--libbe/storage/vcs/git.py5
-rw-r--r--libbe/storage/vcs/hg.py19
-rw-r--r--libbe/storage/vcs/monotone.py5
16 files changed, 143 insertions, 84 deletions
diff --git a/libbe/storage/__init__.py b/libbe/storage/__init__.py
index 90e3b0d..46e5bf2 100644
--- a/libbe/storage/__init__.py
+++ b/libbe/storage/__init__.py
@@ -1,4 +1,5 @@
-# Copyright (C) 2009-2011 W. Trevor King <wking@drexel.edu>
+# Copyright (C) 2009-2011 Chris Ball <cjb@laptop.org>
+# W. Trevor King <wking@drexel.edu>
#
# This file is part of Bugs Everywhere.
#
diff --git a/libbe/storage/base.py b/libbe/storage/base.py
index ef42c98..a9c1064 100644
--- a/libbe/storage/base.py
+++ b/libbe/storage/base.py
@@ -1,4 +1,5 @@
-# Copyright (C) 2009-2011 W. Trevor King <wking@drexel.edu>
+# Copyright (C) 2009-2011 Chris Ball <cjb@laptop.org>
+# W. Trevor King <wking@drexel.edu>
#
# This file is part of Bugs Everywhere.
#
diff --git a/libbe/storage/http.py b/libbe/storage/http.py
index 4cf0f84..c2bb65b 100644
--- a/libbe/storage/http.py
+++ b/libbe/storage/http.py
@@ -1,4 +1,5 @@
-# Copyright (C) 2010-2011 W. Trevor King <wking@drexel.edu>
+# Copyright (C) 2010-2011 Chris Ball <cjb@laptop.org>
+# W. Trevor King <wking@drexel.edu>
#
# This file is part of Bugs Everywhere.
#
@@ -334,14 +335,14 @@ if TESTING == True:
class GetPostUrlTestCase (unittest.TestCase):
"""Test cases for get_post_url()"""
def test_get(self):
- url = 'http://bugseverywhere.org/be/show/HomePage'
+ url = 'http://bugseverywhere.org/'
page,final_url,info = get_post_url(url=url)
self.failUnless(final_url == url,
'Redirect?\n Expected: "%s"\n Got: "%s"'
% (url, final_url))
def test_get_redirect(self):
- url = 'http://bugseverywhere.org'
- expected = 'http://bugseverywhere.org/be/show/HomePage'
+ url = 'http://physics.drexel.edu/~wking/code/be/redirect'
+ expected = 'http://physics.drexel.edu/~wking/'
page,final_url,info = get_post_url(url=url)
self.failUnless(final_url == expected,
'Redirect?\n Expected: "%s"\n Got: "%s"'
@@ -355,9 +356,10 @@ if TESTING == True:
storage=self._storage_backend)
HTTP.__init__(self, repo='http://localhost:8000/', *args, **kwargs)
self.intitialized = False
- # duplicated from libbe.storage.serve.WSGITestCase
+ # duplicated from libbe.command.serve.WSGITestCase
self.default_environ = {
'REQUEST_METHOD': 'GET', # 'POST', 'HEAD'
+ 'REMOTE_ADDR': '192.168.0.123',
'SCRIPT_NAME':'',
'PATH_INFO': '',
#'QUERY_STRING':'', # may be empty or absent
@@ -376,7 +378,7 @@ if TESTING == True:
}
def getURL(self, app, path='/', method='GET', data=None,
scheme='http', environ={}):
- # duplicated from libbe.storage.serve.WSGITestCase
+ # duplicated from libbe.command.serve.WSGITestCase
env = copy.copy(self.default_environ)
env['PATH_INFO'] = path
env['REQUEST_METHOD'] = method
diff --git a/libbe/storage/util/config.py b/libbe/storage/util/config.py
index 8a3d7c8..714d4e7 100644
--- a/libbe/storage/util/config.py
+++ b/libbe/storage/util/config.py
@@ -1,4 +1,5 @@
# Copyright (C) 2005-2011 Aaron Bentley <abentley@panoramicfeedback.com>
+# Chris Ball <cjb@laptop.org>
# Gianluca Montecchi <gian@grys.it>
# W. Trevor King <wking@drexel.edu>
#
diff --git a/libbe/storage/util/mapfile.py b/libbe/storage/util/mapfile.py
index 9eca586..abea6c8 100644
--- a/libbe/storage/util/mapfile.py
+++ b/libbe/storage/util/mapfile.py
@@ -1,4 +1,5 @@
# Copyright (C) 2005-2011 Aaron Bentley <abentley@panoramicfeedback.com>
+# Chris Ball <cjb@laptop.org>
# Gianluca Montecchi <gian@grys.it>
# W. Trevor King <wking@drexel.edu>
#
diff --git a/libbe/storage/util/properties.py b/libbe/storage/util/properties.py
index 152f5cc..9b0549a 100644
--- a/libbe/storage/util/properties.py
+++ b/libbe/storage/util/properties.py
@@ -1,5 +1,6 @@
# Bugs Everywhere - a distributed bugtracker
-# Copyright (C) 2008-2011 Gianluca Montecchi <gian@grys.it>
+# Copyright (C) 2008-2011 Chris Ball <cjb@laptop.org>
+# Gianluca Montecchi <gian@grys.it>
# W. Trevor King <wking@drexel.edu>
#
# This file is part of Bugs Everywhere.
diff --git a/libbe/storage/util/settings_object.py b/libbe/storage/util/settings_object.py
index 2026906..7c02734 100644
--- a/libbe/storage/util/settings_object.py
+++ b/libbe/storage/util/settings_object.py
@@ -1,5 +1,6 @@
# Bugs Everywhere - a distributed bugtracker
-# Copyright (C) 2008-2011 Gianluca Montecchi <gian@grys.it>
+# Copyright (C) 2008-2011 Chris Ball <cjb@laptop.org>
+# Gianluca Montecchi <gian@grys.it>
# W. Trevor King <wking@drexel.edu>
#
# This file is part of Bugs Everywhere.
diff --git a/libbe/storage/util/upgrade.py b/libbe/storage/util/upgrade.py
index 45e3058..3a5aa1c 100644
--- a/libbe/storage/util/upgrade.py
+++ b/libbe/storage/util/upgrade.py
@@ -1,4 +1,5 @@
-# Copyright (C) 2009-2011 Gianluca Montecchi <gian@grys.it>
+# Copyright (C) 2009-2011 Chris Ball <cjb@laptop.org>
+# Gianluca Montecchi <gian@grys.it>
# W. Trevor King <wking@drexel.edu>
#
# This file is part of Bugs Everywhere.
diff --git a/libbe/storage/vcs/__init__.py b/libbe/storage/vcs/__init__.py
index 47d92db..1f7166d 100644
--- a/libbe/storage/vcs/__init__.py
+++ b/libbe/storage/vcs/__init__.py
@@ -1,4 +1,5 @@
-# Copyright (C) 2009-2011 W. Trevor King <wking@drexel.edu>
+# Copyright (C) 2009-2011 Chris Ball <cjb@laptop.org>
+# W. Trevor King <wking@drexel.edu>
#
# This file is part of Bugs Everywhere.
#
diff --git a/libbe/storage/vcs/arch.py b/libbe/storage/vcs/arch.py
index 6c519c4..5a40f7c 100644
--- a/libbe/storage/vcs/arch.py
+++ b/libbe/storage/vcs/arch.py
@@ -1,5 +1,6 @@
# Copyright (C) 2005-2011 Aaron Bentley <abentley@panoramicfeedback.com>
# Ben Finney <benf@cybersource.com.au>
+# Chris Ball <cjb@laptop.org>
# Gianluca Montecchi <gian@grys.it>
# James Rowe <jnrowe@ukfsn.org>
# W. Trevor King <wking@drexel.edu>
@@ -437,7 +438,7 @@ class Arch(base.VCS):
def _vcs_changed(self, revision):
return self._parse_diff(self._diff(revision))
-
+
if libbe.TESTING == True:
base.make_vcs_testcase_subclasses(Arch, sys.modules[__name__])
diff --git a/libbe/storage/vcs/base.py b/libbe/storage/vcs/base.py
index aba6159..22874a5 100644
--- a/libbe/storage/vcs/base.py
+++ b/libbe/storage/vcs/base.py
@@ -156,11 +156,11 @@ class CachedPathID (object):
>>> os.mkdir(os.path.join(dir.path, '.be', 'abc', 'bugs', '123', 'comments'))
>>> os.mkdir(os.path.join(dir.path, '.be', 'abc', 'bugs', '123', 'comments', 'def'))
>>> os.mkdir(os.path.join(dir.path, '.be', 'abc', 'bugs', '456'))
- >>> file(os.path.join(dir.path, '.be', 'abc', 'values'),
+ >>> open(os.path.join(dir.path, '.be', 'abc', 'values'),
... 'w').close()
- >>> file(os.path.join(dir.path, '.be', 'abc', 'bugs', '123', 'values'),
+ >>> open(os.path.join(dir.path, '.be', 'abc', 'bugs', '123', 'values'),
... 'w').close()
- >>> file(os.path.join(dir.path, '.be', 'abc', 'bugs', '123', 'comments', 'def', 'values'),
+ >>> open(os.path.join(dir.path, '.be', 'abc', 'bugs', '123', 'comments', 'def', 'values'),
... 'w').close()
>>> c = CachedPathID()
>>> c.root(dir.path)
@@ -521,6 +521,97 @@ class VCS (libbe.storage.base.VersionedStorage):
self._version = self._vcs_version()
return self._version
+ def version_cmp(self, *args):
+ """Compare the installed VCS version `V_i` with another version
+ `V_o` (given in `*args`). Returns
+
+ === ===============
+ 1 if `V_i > V_o`
+ 0 if `V_i == V_o`
+ -1 if `V_i < V_o`
+ === ===============
+
+ Examples
+ --------
+
+ >>> v = VCS(repo='.')
+ >>> v._version = '2.3.1 (release)'
+ >>> v.version_cmp(2,3,1)
+ 0
+ >>> v.version_cmp(2,3,2)
+ -1
+ >>> v.version_cmp(2,3,'a',5)
+ 1
+ >>> v.version_cmp(2,3,0)
+ 1
+ >>> v.version_cmp(2,3,1,'a',5)
+ 1
+ >>> v.version_cmp(2,3,1,1)
+ -1
+ >>> v.version_cmp(3)
+ -1
+ >>> v._version = '2.0.0pre2'
+ >>> v._parsed_version = None
+ >>> v.version_cmp(3)
+ -1
+ >>> v.version_cmp(2,0,1)
+ -1
+ >>> v.version_cmp(2,0,0,'pre',1)
+ 1
+ >>> v.version_cmp(2,0,0,'pre',2)
+ 0
+ >>> v.version_cmp(2,0,0,'pre',3)
+ -1
+ >>> v.version_cmp(2,0,0,'a',3)
+ 1
+ >>> v.version_cmp(2,0,0,'rc',1)
+ -1
+ """
+ if not hasattr(self, '_parsed_version') \
+ or self._parsed_version == None:
+ num_part = self.version().split(' ')[0]
+ self._parsed_version = []
+ for num in num_part.split('.'):
+ try:
+ self._parsed_version.append(int(num))
+ except ValueError, e:
+ # bzr version number might contain non-numerical tags
+ splitter = re.compile(r'[\D]') # Match non-digits
+ splits = splitter.split(num)
+ # if len(tag) > 1 some splits will be empty; remove
+ splits = filter(lambda s: s != '', splits)
+ tag_starti = len(splits[0])
+ num_starti = num.find(splits[1], tag_starti)
+ tag = num[tag_starti:num_starti]
+ self._parsed_version.append(int(splits[0]))
+ self._parsed_version.append(tag)
+ self._parsed_version.append(int(splits[1]))
+ for current,other in zip(self._parsed_version, args):
+ if type(current) != type (other):
+ # one of them is a pre-release string
+ if type(current) != types.IntType:
+ return -1
+ else:
+ return 1
+ c = cmp(current,other)
+ if c != 0:
+ return c
+ # see if one is longer than the other
+ verlen = len(self._parsed_version)
+ arglen = len(args)
+ if verlen == arglen:
+ return 0
+ elif verlen > arglen:
+ if type(self._parsed_version[arglen]) != types.IntType:
+ return -1 # self is a prerelease
+ else:
+ return 1
+ else:
+ if type(args[verlen]) != types.IntType:
+ return 1 # args is a prerelease
+ else:
+ return -1
+
def installed(self):
if self.version() != None:
return True
@@ -537,7 +628,7 @@ class VCS (libbe.storage.base.VersionedStorage):
self.user_id = self._vcs_get_user_id()
if self.user_id == None:
# guess missing info
- name = libbe.ui.util.user.get_fallback_username()
+ name = libbe.ui.util.user.get_fallback_fullname()
email = libbe.ui.util.user.get_fallback_email()
self.user_id = libbe.ui.util.user.create_user_id(name, email)
return self.user_id
@@ -1003,7 +1094,7 @@ class VCS (libbe.storage.base.VersionedStorage):
libbe.storage.STORAGE_VERSION+'\n')
self._vcs_add(self._u_rel_path(path))
-
+
if libbe.TESTING == True:
class VCSTestCase (unittest.TestCase):
"""
diff --git a/libbe/storage/vcs/bzr.py b/libbe/storage/vcs/bzr.py
index 9464d1d..c01b6c7 100644
--- a/libbe/storage/vcs/bzr.py
+++ b/libbe/storage/vcs/bzr.py
@@ -1,5 +1,6 @@
# Copyright (C) 2005-2011 Aaron Bentley <abentley@panoramicfeedback.com>
# Ben Finney <benf@cybersource.com.au>
+# Chris Ball <cjb@laptop.org>
# Gianluca Montecchi <gian@grys.it>
# Marien Zwart <marien.zwart@gmail.com>
# W. Trevor King <wking@drexel.edu>
@@ -39,7 +40,6 @@ import re
import shutil
import StringIO
import sys
-import types
import libbe
import base
@@ -67,57 +67,6 @@ class Bzr(base.VCS):
return None
return bzrlib.__version__
- def version_cmp(self, *args):
- """Compare the installed Bazaar version `V_i` with another version
- `V_o` (given in `*args`). Returns
-
- === ===============
- 1 if `V_i > V_o`
- 0 if `V_i == V_o`
- -1 if `V_i < V_o`
- === ===============
-
- Examples
- --------
-
- >>> b = Bzr(repo='.')
- >>> b._version = '2.3.1 (release)'
- >>> b.version_cmp(2,3,1)
- 0
- >>> b.version_cmp(2,3,2)
- -1
- >>> b.version_cmp(2,3,0)
- 1
- >>> b.version_cmp(3)
- -1
- >>> b._version = '2.0.0pre2'
- >>> b._parsed_version = None
- >>> b.version_cmp(3)
- -1
- >>> b.version_cmp(2,0,1)
- Traceback (most recent call last):
- ...
- NotImplementedError: Cannot parse non-integer portion "0pre2" of Bzr version "2.0.0pre2"
- """
- if not hasattr(self, '_parsed_version') \
- or self._parsed_version == None:
- num_part = self.version().split(' ')[0]
- self._parsed_version = []
- for num in num_part.split('.'):
- try:
- self._parsed_version.append(int(num))
- except ValueError, e:
- self._parsed_version.append(num)
- for current,other in zip(self._parsed_version, args):
- if type(current) != types.IntType:
- raise NotImplementedError(
- 'Cannot parse non-integer portion "%s" of Bzr version "%s"'
- % (current, self.version()))
- c = cmp(current,other)
- if c != 0:
- return c
- return 0
-
def _vcs_get_user_id(self):
# excerpted from bzrlib.builtins.cmd_whoami.run()
try:
@@ -378,7 +327,7 @@ class Bzr(base.VCS):
def _vcs_changed(self, revision):
return self._parse_diff(self._diff(revision))
-
+
if libbe.TESTING == True:
base.make_vcs_testcase_subclasses(Bzr, sys.modules[__name__])
diff --git a/libbe/storage/vcs/darcs.py b/libbe/storage/vcs/darcs.py
index 4a19d1d..aef89cd 100644
--- a/libbe/storage/vcs/darcs.py
+++ b/libbe/storage/vcs/darcs.py
@@ -1,4 +1,5 @@
-# Copyright (C) 2009-2011 Gianluca Montecchi <gian@grys.it>
+# Copyright (C) 2009-2011 Chris Ball <cjb@laptop.org>
+# Gianluca Montecchi <gian@grys.it>
# W. Trevor King <wking@drexel.edu>
#
# This file is part of Bugs Everywhere.
@@ -402,7 +403,7 @@ class Darcs(base.VCS):
def _vcs_changed(self, revision):
return self._parse_diff(self._diff(revision))
-
+
if libbe.TESTING == True:
base.make_vcs_testcase_subclasses(Darcs, sys.modules[__name__])
diff --git a/libbe/storage/vcs/git.py b/libbe/storage/vcs/git.py
index 5c17303..f23f0ea 100644
--- a/libbe/storage/vcs/git.py
+++ b/libbe/storage/vcs/git.py
@@ -1,6 +1,7 @@
# Copyright (C) 2008-2011 Ben Finney <benf@cybersource.com.au>
# Chris Ball <cjb@laptop.org>
# Gianluca Montecchi <gian@grys.it>
+# Robert Lehmann <mail@robertlehmann.de>
# W. Trevor King <wking@drexel.edu>
#
# This file is part of Bugs Everywhere.
@@ -74,7 +75,7 @@ class Git(base.VCS):
if name != '' or email != '': # got something!
# guess missing info, if necessary
if name == '':
- name = _user.get_fallback_username()
+ name = _user.get_fallback_fullname()
if email == '':
email = _user.get_fallback_email()
return _user.create_user_id(name, email)
@@ -265,7 +266,7 @@ class Git(base.VCS):
def _vcs_changed(self, revision):
return self._parse_diff(self._diff(revision))
-
+
if libbe.TESTING == True:
base.make_vcs_testcase_subclasses(Git, sys.modules[__name__])
diff --git a/libbe/storage/vcs/hg.py b/libbe/storage/vcs/hg.py
index d610352..b61e796 100644
--- a/libbe/storage/vcs/hg.py
+++ b/libbe/storage/vcs/hg.py
@@ -1,5 +1,6 @@
# Copyright (C) 2005-2011 Aaron Bentley <abentley@panoramicfeedback.com>
# Ben Finney <benf@cybersource.com.au>
+# Chris Ball <cjb@laptop.org>
# Gianluca Montecchi <gian@grys.it>
# Marien Zwart <marien.zwart@gmail.com>
# W. Trevor King <wking@drexel.edu>
@@ -82,14 +83,18 @@ class Hg(base.VCS):
assert len(kwargs) == 1, kwargs
fullargs = ['--cwd', kwargs['cwd']]
fullargs.extend(args)
- stdout = sys.stdout
- tmp_stdout = StringIO.StringIO()
- sys.stdout = tmp_stdout
cwd = os.getcwd()
- mercurial.dispatch.dispatch(fullargs)
+ output = StringIO.StringIO()
+ if self.version_cmp(1,9):
+ req = mercurial.dispatch.request(fullargs, fout=output)
+ mercurial.dispatch.dispatch(req)
+ else:
+ stdout = sys.stdout
+ sys.stdout = output
+ mercurial.dispatch.dispatch(fullargs)
+ sys.stdout = stdout
os.chdir(cwd)
- sys.stdout = stdout
- return tmp_stdout.getvalue().rstrip('\n')
+ return output.getvalue().rstrip('\n')
def _vcs_get_user_id(self):
output = self._u_invoke_client(
@@ -251,7 +256,7 @@ class Hg(base.VCS):
def _vcs_changed(self, revision):
return self._parse_diff(self._diff(revision))
-
+
if libbe.TESTING == True:
base.make_vcs_testcase_subclasses(Hg, sys.modules[__name__])
diff --git a/libbe/storage/vcs/monotone.py b/libbe/storage/vcs/monotone.py
index e99a6ec..9f4e278 100644
--- a/libbe/storage/vcs/monotone.py
+++ b/libbe/storage/vcs/monotone.py
@@ -1,4 +1,5 @@
-# Copyright (C) 2010-2011 W. Trevor King <wking@drexel.edu>
+# Copyright (C) 2010-2011 Chris Ball <cjb@laptop.org>
+# W. Trevor King <wking@drexel.edu>
#
# This file is part of Bugs Everywhere.
#
@@ -366,7 +367,7 @@ class Monotone (base.VCS):
def _vcs_changed(self, revision):
return self._parse_diff(self._diff(revision))
-
+
if libbe.TESTING == True:
base.make_vcs_testcase_subclasses(Monotone, sys.modules[__name__])