aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/comments/cf0b0155-0f1b-4863-a4c0-8cfc0494b280/body4
-rw-r--r--.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/comments/cf0b0155-0f1b-4863-a4c0-8cfc0494b280/values11
-rw-r--r--.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/comments/cfea9568-a52d-4587-b803-823877dba0de/body31
-rw-r--r--.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/comments/cfea9568-a52d-4587-b803-823877dba0de/values8
-rw-r--r--.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/values17
-rw-r--r--.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/bc1e6ff4-478f-4afe-b2a1-86e25ee448b7/comments/a3c3bae1-12fe-4282-bc14-26f09ced8f89/body15
-rw-r--r--.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/bc1e6ff4-478f-4afe-b2a1-86e25ee448b7/comments/a3c3bae1-12fe-4282-bc14-26f09ced8f89/values8
-rw-r--r--.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/bc1e6ff4-478f-4afe-b2a1-86e25ee448b7/values17
-rw-r--r--AUTHORS3
-rw-r--r--doc/install.txt8
-rwxr-xr-xinterfaces/email/interactive/be-handle-mail2
-rw-r--r--libbe/command/base.py2
-rw-r--r--libbe/command/html.py2
-rw-r--r--libbe/storage/http.py6
-rw-r--r--libbe/storage/util/config.py4
-rw-r--r--libbe/storage/vcs/base.py95
-rw-r--r--libbe/storage/vcs/bzr.py53
-rw-r--r--libbe/storage/vcs/hg.py17
-rw-r--r--libbe/ui/command_line.py5
-rw-r--r--libbe/ui/util/editor.py2
-rw-r--r--libbe/util/encoding.py17
-rwxr-xr-xupdate_copyright.py2
22 files changed, 249 insertions, 80 deletions
diff --git a/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/comments/cf0b0155-0f1b-4863-a4c0-8cfc0494b280/body b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/comments/cf0b0155-0f1b-4863-a4c0-8cfc0494b280/body
new file mode 100644
index 0000000..f9a00a5
--- /dev/null
+++ b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/comments/cf0b0155-0f1b-4863-a4c0-8cfc0494b280/body
@@ -0,0 +1,4 @@
+Trying to write to a bug repository to which you do not have write
+access should be uncommon enough that hiding the traceback seems like
+overkill. The final error message is clear enough...
+
diff --git a/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/comments/cf0b0155-0f1b-4863-a4c0-8cfc0494b280/values b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/comments/cf0b0155-0f1b-4863-a4c0-8cfc0494b280/values
new file mode 100644
index 0000000..a676fa0
--- /dev/null
+++ b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/comments/cf0b0155-0f1b-4863-a4c0-8cfc0494b280/values
@@ -0,0 +1,11 @@
+Author: '"W. Trevor King" <wking@drexel.edu>'
+
+
+Content-type: text/plain
+
+
+Date: Thu, 08 Sep 2011 03:27:28 +0000
+
+
+In-reply-to: cfea9568-a52d-4587-b803-823877dba0de
+
diff --git a/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/comments/cfea9568-a52d-4587-b803-823877dba0de/body b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/comments/cfea9568-a52d-4587-b803-823877dba0de/body
new file mode 100644
index 0000000..1487e6b
--- /dev/null
+++ b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/comments/cfea9568-a52d-4587-b803-823877dba0de/body
@@ -0,0 +1,31 @@
+Ugly "exception" crash when permissions are not properly set.
+
+$ sudo chown -R root:root .be
+$ be new "Unauthorized"
+Traceback (most recent call last):
+ File "/usr/local/bin/be", line 26, in <module>
+ sys.exit(libbe.ui.command_line.main())
+ File "/usr/local/lib/python2.7/dist-packages/libbe/ui/command_line.py", line 332, in main
+ ret = dispatch(ui, command, args)
+ File "/usr/local/lib/python2.7/dist-packages/libbe/ui/command_line.py", line 264, in dispatch
+ ret = ui.run(command, options, args)
+ File "/usr/local/lib/python2.7/dist-packages/libbe/command/base.py", line 534, in run
+ return command.run(options, args)
+ File "/usr/local/lib/python2.7/dist-packages/libbe/command/base.py", line 262, in run
+ self.status = self._run(**params)
+ File "/usr/local/lib/python2.7/dist-packages/libbe/command/new.py", line 92, in _run
+ bug = bugdir.new_bug(summary=summary.strip())
+ File "/usr/local/lib/python2.7/dist-packages/libbe/bugdir.py", line 247, in new_bug
+ from_storage=False)
+ File "/usr/local/lib/python2.7/dist-packages/libbe/bug.py", line 257, in __init__
+ self.save()
+ File "/usr/local/lib/python2.7/dist-packages/libbe/bug.py", line 663, in save
+ self.storage.add(self.id.storage(), parent=parent, directory=True)
+ File "/usr/local/lib/python2.7/dist-packages/libbe/storage/base.py", line 249, in add
+ self._add(id, *args, **kwargs)
+ File "/usr/local/lib/python2.7/dist-packages/libbe/storage/vcs/base.py", line 654, in _add
+ self._add_path(path, **kwargs)
+ File "/usr/local/lib/python2.7/dist-packages/libbe/storage/vcs/base.py", line 643, in _add_path
+ os.mkdir(dir)
+OSError: [Errno 13] Permission denied: '/home/tanguy/tmp/test/.be/7c416fb1-ab04-4144-97f4-6fded55524bc/bugs'
+
diff --git a/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/comments/cfea9568-a52d-4587-b803-823877dba0de/values b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/comments/cfea9568-a52d-4587-b803-823877dba0de/values
new file mode 100644
index 0000000..27b2027
--- /dev/null
+++ b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/comments/cfea9568-a52d-4587-b803-823877dba0de/values
@@ -0,0 +1,8 @@
+Author: Tanguy LE CARROUR <tanguy.lecarrour@gmail.com>
+
+
+Content-type: text/plain
+
+
+Date: Mon, 06 Jun 2011 18:48:16 +0000
+
diff --git a/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/values b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/values
new file mode 100644
index 0000000..1ffb891
--- /dev/null
+++ b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/03d07e61-f10b-4dc9-9bd8-3e4c14d6b47b/values
@@ -0,0 +1,17 @@
+creator: Tanguy LE CARROUR <tanguy.lecarrour@gmail.com>
+
+
+reporter: Tanguy LE CARROUR <tanguy.lecarrour@gmail.com>
+
+
+severity: minor
+
+
+status: wontfix
+
+
+summary: Crash on permission problems
+
+
+time: Mon, 06 Jun 2011 18:45:39 +0000
+
diff --git a/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/bc1e6ff4-478f-4afe-b2a1-86e25ee448b7/comments/a3c3bae1-12fe-4282-bc14-26f09ced8f89/body b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/bc1e6ff4-478f-4afe-b2a1-86e25ee448b7/comments/a3c3bae1-12fe-4282-bc14-26f09ced8f89/body
new file mode 100644
index 0000000..94f5afb
--- /dev/null
+++ b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/bc1e6ff4-478f-4afe-b2a1-86e25ee448b7/comments/a3c3bae1-12fe-4282-bc14-26f09ced8f89/body
@@ -0,0 +1,15 @@
+BE crashes when too many arguments are provided.
+
+Ex: be list extra_arg
+WARNING:root:unable to import libbe._version: No module named _version
+Traceback (most recent call last):
+ File "/usr/local/bin/be", line 26, in <module>
+ sys.exit(libbe.ui.command_line.main())
+ File "/home/tanguy/Documents/Repositories/Bugs-Everywhere/tlecarrours-be-reports/libbe/ui/command_line.py", line 331, in main
+ ret = dispatch(ui, command, args)
+ File "/home/tanguy/Documents/Repositories/Bugs-Everywhere/tlecarrours-be-reports/libbe/ui/command_line.py", line 262, in dispatch
+ options,args = parser.parse_args(args)
+ File "/home/tanguy/Documents/Repositories/Bugs-Everywhere/tlecarrours-be-reports/libbe/ui/command_line.py", line 128, in parse_args
+ and self.command.args[-1].repeatable == False:
+IndexError: list index out of range
+
diff --git a/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/bc1e6ff4-478f-4afe-b2a1-86e25ee448b7/comments/a3c3bae1-12fe-4282-bc14-26f09ced8f89/values b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/bc1e6ff4-478f-4afe-b2a1-86e25ee448b7/comments/a3c3bae1-12fe-4282-bc14-26f09ced8f89/values
new file mode 100644
index 0000000..6154e2e
--- /dev/null
+++ b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/bc1e6ff4-478f-4afe-b2a1-86e25ee448b7/comments/a3c3bae1-12fe-4282-bc14-26f09ced8f89/values
@@ -0,0 +1,8 @@
+Author: Tanguy LE CARROUR <tanguy.lecarrour@gmail.com>
+
+
+Content-type: text/plain
+
+
+Date: Mon, 06 Jun 2011 18:06:47 +0000
+
diff --git a/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/bc1e6ff4-478f-4afe-b2a1-86e25ee448b7/values b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/bc1e6ff4-478f-4afe-b2a1-86e25ee448b7/values
new file mode 100644
index 0000000..d06c54c
--- /dev/null
+++ b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/bc1e6ff4-478f-4afe-b2a1-86e25ee448b7/values
@@ -0,0 +1,17 @@
+creator: Tanguy LE CARROUR <tanguy.lecarrour@gmail.com>
+
+
+reporter: Tanguy LE CARROUR <tanguy.lecarrour@gmail.com>
+
+
+severity: minor
+
+
+status: fixed
+
+
+summary: Crashes when too many arguments are provided
+
+
+time: Mon, 06 Jun 2011 18:04:41 +0000
+
diff --git a/AUTHORS b/AUTHORS
index c7823e4..a4f003f 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -14,10 +14,13 @@ James Rowe <jnrowe@ukfsn.org>
Jelmer Vernooij <jelmer@samba.org>
Marien Zwart <marien.zwart@gmail.com>
Mathieu Clabaut <mathieu.clabaut@gmail.com>
+Michel Alexandre Salim <salimma@fedoraproject.org>
Moritz Barsnick (at dot) <moritzbarsnicknet>
Oleg Romanyshyn <oromanyshyn@panoramicfeedback.com>
+Phil Schumm <philschumm@gmail.com>
Robert Lehmann <mail@robertlehmann.de>
Steve Losh <steve@stevelosh.com>
+Tanguy Le Carrour <tanguy.lecarrour@gmail.com>
Thomas Gerigk <tgerigk@gmx.de>
Thomas Habets <thomas@habets.pp.se>
Thomas Keller <me@thomaskeller.biz>
diff --git a/doc/install.txt b/doc/install.txt
index c428087..33d5dae 100644
--- a/doc/install.txt
+++ b/doc/install.txt
@@ -9,6 +9,7 @@ Dependencies
Package Role Debian Gentoo
============== ======================= =============== ===========================
PyYAML_ serialized data storage python-yaml dev-python/pyyaml
+Jinja_ HTML templating python-jinja2 deb-python/jinja
Sphinx_ see :doc:`doc` python-sphinx dev-python/sphinx
numpydoc_ see :doc:`doc` dev-python/numpydoc [#npd]_
Docutils_ manpage generation python-docutils dev-python/docutils
@@ -17,6 +18,7 @@ Docutils_ manpage generation python-docutils dev-python/docutils
.. [#npd] In the science_ overlay.
.. _PyYAML: http://pyyaml.org/
+.. _Jinja: http://jinja.pocoo.org/
.. _Sphinx: http://sphinx.pocoo.org/
.. _numpydoc: http://pypi.python.org/pypi/numpydoc
.. _Docutils: http://docutils.sourceforge.net/
@@ -39,8 +41,10 @@ to build some auto-generated files (e.g. :mod:`libbe._version`), and::
$ make install
to install BE. By default BE will install into your home directory,
-but you can tweak the ``PREFIX`` variable in ``Makefile`` to install
-to another location.
+but you can tweak the ``INSTALL_OPTIONS`` variable in ``Makefile`` to
+install to another location. With the default installation, you may
+need to add ``~/.local/bin/`` to your ``PATH`` so that your shell can
+find the installed ``be`` script.
By default, ``make`` builds both a man page for ``be`` and the HTML
Sphinx documentation (:doc:`doc`). You can customize the
diff --git a/interfaces/email/interactive/be-handle-mail b/interfaces/email/interactive/be-handle-mail
index e20934a..1a48ead 100755
--- a/interfaces/email/interactive/be-handle-mail
+++ b/interfaces/email/interactive/be-handle-mail
@@ -721,7 +721,7 @@ def open_logfile(logpath=None):
LOGPATH = os.path.join(_THIS_DIR, logpath)
if LOGFILE == None and LOGPATH != u'none':
LOGFILE = codecs.open(LOGPATH, u'a+',
- libbe.util.encoding.get_filesystem_encoding())
+ libbe.util.encoding.get_text_file_encoding())
def close_logfile():
if LOGFILE != None and LOGPATH not in [u'stderr', u'none']:
diff --git a/libbe/command/base.py b/libbe/command/base.py
index 311791f..ab98cb1 100644
--- a/libbe/command/base.py
+++ b/libbe/command/base.py
@@ -1,4 +1,5 @@
# Copyright (C) 2009-2011 Chris Ball <cjb@laptop.org>
+# Phil Schumm <philschumm@gmail.com>
# Robert Lehmann <mail@robertlehmann.de>
# W. Trevor King <wking@drexel.edu>
#
@@ -73,6 +74,7 @@ def get_command(command_name):
... except UnknownCommand, e:
... print e
Unknown command 'asdf'
+ (No module named asdf)
>>> repr(get_command('list')).startswith("<module 'libbe.command.list' from ")
True
"""
diff --git a/libbe/command/html.py b/libbe/command/html.py
index 7420ce8..a6bd2a2 100644
--- a/libbe/command/html.py
+++ b/libbe/command/html.py
@@ -149,7 +149,7 @@ class HTMLGen (object):
if encoding != None:
self.encoding = encoding
else:
- self.encoding = libbe.util.encoding.get_filesystem_encoding()
+ self.encoding = libbe.util.encoding.get_text_file_encoding()
self._load_templates(template_dir)
self.min_id_length = min_id_length
diff --git a/libbe/storage/http.py b/libbe/storage/http.py
index f7af3e7..c2bb65b 100644
--- a/libbe/storage/http.py
+++ b/libbe/storage/http.py
@@ -335,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"'
diff --git a/libbe/storage/util/config.py b/libbe/storage/util/config.py
index 714d4e7..d138bf4 100644
--- a/libbe/storage/util/config.py
+++ b/libbe/storage/util/config.py
@@ -31,10 +31,10 @@ if libbe.TESTING == True:
import doctest
-default_encoding = libbe.util.encoding.get_filesystem_encoding()
+default_encoding = libbe.util.encoding.get_text_file_encoding()
"""Default filesystem encoding.
-Initialized with :func:`libbe.util.encoding.get_filesystem_encoding`.
+Initialized with :func:`libbe.util.encoding.get_text_file_encoding`.
"""
def path():
diff --git a/libbe/storage/vcs/base.py b/libbe/storage/vcs/base.py
index d377398..eaaf2d8 100644
--- a/libbe/storage/vcs/base.py
+++ b/libbe/storage/vcs/base.py
@@ -199,7 +199,7 @@ class CachedPathID (object):
>>> dir.cleanup()
"""
def __init__(self, encoding=None):
- self.encoding = libbe.util.encoding.get_filesystem_encoding()
+ self.encoding = libbe.util.encoding.get_text_file_encoding()
self._spacer_dirs = ['.be', 'bugs', 'comments']
def root(self, path):
@@ -350,7 +350,7 @@ class VCS (libbe.storage.base.VersionedStorage):
def __init__(self, *args, **kwargs):
if 'encoding' not in kwargs:
- kwargs['encoding'] = libbe.util.encoding.get_filesystem_encoding()
+ kwargs['encoding'] = libbe.util.encoding.get_text_file_encoding()
libbe.storage.base.VersionedStorage.__init__(self, *args, **kwargs)
self.versioned = False
self.interspersed_vcs_files = False
@@ -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
diff --git a/libbe/storage/vcs/bzr.py b/libbe/storage/vcs/bzr.py
index 0a4275b..865df6b 100644
--- a/libbe/storage/vcs/bzr.py
+++ b/libbe/storage/vcs/bzr.py
@@ -3,6 +3,7 @@
# Chris Ball <cjb@laptop.org>
# Gianluca Montecchi <gian@grys.it>
# Marien Zwart <marien.zwart@gmail.com>
+# Michel Alexandre Salim <salimma@fedoraproject.org>
# W. Trevor King <wking@drexel.edu>
#
# This file is part of Bugs Everywhere.
@@ -40,7 +41,6 @@ import re
import shutil
import StringIO
import sys
-import types
import libbe
import base
@@ -68,57 +68,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:
diff --git a/libbe/storage/vcs/hg.py b/libbe/storage/vcs/hg.py
index d2274ee..eade02e 100644
--- a/libbe/storage/vcs/hg.py
+++ b/libbe/storage/vcs/hg.py
@@ -3,6 +3,7 @@
# Chris Ball <cjb@laptop.org>
# Gianluca Montecchi <gian@grys.it>
# Marien Zwart <marien.zwart@gmail.com>
+# Phil Schumm <philschumm@gmail.com>
# W. Trevor King <wking@drexel.edu>
#
# This file is part of Bugs Everywhere.
@@ -83,14 +84,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) >= 0:
+ 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(
diff --git a/libbe/ui/command_line.py b/libbe/ui/command_line.py
index d5719a6..f579a19 100644
--- a/libbe/ui/command_line.py
+++ b/libbe/ui/command_line.py
@@ -133,8 +133,9 @@ class CmdOptionParser(optparse.OptionParser):
else:
value = self.process_raw_argument(argument=argument, value=arg)
parsed_args[i] = value
- if len(parsed_args) > len(self.command.args) \
- and self.command.args[-1].repeatable == False:
+ if (len(parsed_args) > len(self.command.args) and
+ (len(self.command.args) == 0 or
+ self.command.args[-1].repeatable == False)):
raise libbe.command.UserError('Too many arguments')
for arg in self.command.args[len(parsed_args):]:
if arg.optional == False:
diff --git a/libbe/ui/util/editor.py b/libbe/ui/util/editor.py
index 206e9c4..fb51159 100644
--- a/libbe/ui/util/editor.py
+++ b/libbe/ui/util/editor.py
@@ -65,7 +65,7 @@ def editor_string(comment=None, encoding=None):
>>> del os.environ["VISUAL"]
"""
if encoding == None:
- encoding = libbe.util.encoding.get_filesystem_encoding()
+ encoding = libbe.util.encoding.get_text_file_encoding()
editor = None
for name in ('VISUAL', 'EDITOR'):
if name in os.environ and os.environ[name] != '':
diff --git a/libbe/util/encoding.py b/libbe/util/encoding.py
index 22a2e30..949b3ce 100644
--- a/libbe/util/encoding.py
+++ b/libbe/util/encoding.py
@@ -23,6 +23,7 @@ Support input/output/filesystem encodings (e.g. UTF-8).
import codecs
import locale
+import os
import sys
import types
@@ -31,7 +32,8 @@ if libbe.TESTING == True:
import doctest
-ENCODING = None # override get_encoding() output by setting this
+ENCODING = os.environ.get('BE_ENCODING', None)
+"override get_encoding() output"
def get_encoding():
"""
@@ -41,18 +43,17 @@ def get_encoding():
if ENCODING != None:
return ENCODING
encoding = locale.getpreferredencoding() or sys.getdefaultencoding()
- if sys.platform != 'win32' or sys.version_info[:2] > (2, 3):
- encoding = locale.getlocale(locale.LC_TIME)[1] or encoding
- # Python 2.3 on windows doesn't know about 'XYZ' alias for 'cpXYZ'
return encoding
def get_input_encoding():
- return get_encoding()
+ return sys.__stdin__.encoding or get_encoding()
def get_output_encoding():
return sys.__stdout__.encoding or get_encoding()
-def get_filesystem_encoding():
+def get_text_file_encoding():
+ """Return the encoding that should be used for file contents
+ """
return get_encoding()
def get_argv_encoding():
@@ -74,7 +75,7 @@ def known_encoding(encoding):
def get_file_contents(path, mode='r', encoding=None, decode=False):
if decode == True:
if encoding == None:
- encoding = get_filesystem_encoding()
+ encoding = get_text_file_encoding()
f = codecs.open(path, mode, encoding)
else:
f = open(path, mode)
@@ -85,7 +86,7 @@ def get_file_contents(path, mode='r', encoding=None, decode=False):
def set_file_contents(path, contents, mode='w', encoding=None):
if type(contents) == types.UnicodeType:
if encoding == None:
- encoding = get_filesystem_encoding()
+ encoding = get_text_file_encoding()
f = codecs.open(path, mode, encoding)
else:
f = open(path, mode)
diff --git a/update_copyright.py b/update_copyright.py
index c4f606b..ac9ced4 100755
--- a/update_copyright.py
+++ b/update_copyright.py
@@ -89,6 +89,8 @@ ALIASES = {
'gianluca <gian@galactica>'],
'Marien Zwart <marien.zwart@gmail.com>':
['Marien Zwart <marienz@gentoo.org>'],
+ 'Tanguy Le Carrour <tanguy.lecarrour@gmail.com>':
+ ['Tanguy LE CARROUR <tanguy.lecarrour@gmail.com>'],
'W. Trevor King <wking@drexel.edu>':
['wking <wking@mjolnir>',
'wking <wking@thialfi>'],