aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/01e7151c-6113-4c8f-9fc5-4d594431bd2b/comments/2f9beed6-4008-442a-8d44-a45cb7ce0a36/body9
-rw-r--r--.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/01e7151c-6113-4c8f-9fc5-4d594431bd2b/comments/2f9beed6-4008-442a-8d44-a45cb7ce0a36/values8
-rw-r--r--.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/01e7151c-6113-4c8f-9fc5-4d594431bd2b/values2
-rw-r--r--.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/d9959864-ea91-475a-a075-f39aa6760f98/comments/1f25cba2-03ee-43e1-a042-ef6724938ad8/body77
-rw-r--r--.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/d9959864-ea91-475a-a075-f39aa6760f98/comments/1f25cba2-03ee-43e1-a042-ef6724938ad8/values14
-rw-r--r--NEWS3
-rw-r--r--doc/man/module.mk44
-rw-r--r--libbe/command/close.py9
-rw-r--r--libbe/command/email_bugs.py239
-rw-r--r--libbe/command/html.py100
-rw-r--r--libbe/command/open.py9
11 files changed, 364 insertions, 150 deletions
diff --git a/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/01e7151c-6113-4c8f-9fc5-4d594431bd2b/comments/2f9beed6-4008-442a-8d44-a45cb7ce0a36/body b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/01e7151c-6113-4c8f-9fc5-4d594431bd2b/comments/2f9beed6-4008-442a-8d44-a45cb7ce0a36/body
new file mode 100644
index 0000000..d20af30
--- /dev/null
+++ b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/01e7151c-6113-4c8f-9fc5-4d594431bd2b/comments/2f9beed6-4008-442a-8d44-a45cb7ce0a36/body
@@ -0,0 +1,9 @@
+I'm not sure that changing the URLs is a good idea. I'd rather use
+.htaccess and mod_rewrite to redirect short URLs to their permanent
+long equivalents. Nobody else seems to mind though, so I've merged
+Gianluca's solution with a few changes:
+ * Since we're truncating bug IDs, truncate comment IDs too.
+ * Use libbe.util.id._truncate to generate the short IDs, so that `be
+ html` truncation is consistent with general BE truncation.
+ * Updated cross-linking code to match.
+
diff --git a/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/01e7151c-6113-4c8f-9fc5-4d594431bd2b/comments/2f9beed6-4008-442a-8d44-a45cb7ce0a36/values b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/01e7151c-6113-4c8f-9fc5-4d594431bd2b/comments/2f9beed6-4008-442a-8d44-a45cb7ce0a36/values
new file mode 100644
index 0000000..c7365f5
--- /dev/null
+++ b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/01e7151c-6113-4c8f-9fc5-4d594431bd2b/comments/2f9beed6-4008-442a-8d44-a45cb7ce0a36/values
@@ -0,0 +1,8 @@
+Author: W. Trevor King <wking@drexel.edu>
+
+
+Content-type: text/plain
+
+
+Date: Sat, 20 Feb 2010 18:10:42 +0000
+
diff --git a/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/01e7151c-6113-4c8f-9fc5-4d594431bd2b/values b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/01e7151c-6113-4c8f-9fc5-4d594431bd2b/values
index 673423e..9efe209 100644
--- a/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/01e7151c-6113-4c8f-9fc5-4d594431bd2b/values
+++ b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/01e7151c-6113-4c8f-9fc5-4d594431bd2b/values
@@ -7,7 +7,7 @@ reporter: Gianluca Montecchi <gian@grys.it>
severity: minor
-status: open
+status: fixed
summary: Short the files name used by the be html command
diff --git a/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/d9959864-ea91-475a-a075-f39aa6760f98/comments/1f25cba2-03ee-43e1-a042-ef6724938ad8/body b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/d9959864-ea91-475a-a075-f39aa6760f98/comments/1f25cba2-03ee-43e1-a042-ef6724938ad8/body
deleted file mode 100644
index d2ef28c..0000000
--- a/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/d9959864-ea91-475a-a075-f39aa6760f98/comments/1f25cba2-03ee-43e1-a042-ef6724938ad8/body
+++ /dev/null
@@ -1,77 +0,0 @@
-Those are beautiful templates -- can you share those? I'd love to
-study the HTML and CSS behind them.
-
-On Sat, Feb 7, 2009 at 5:48 PM, Steve Losh <steve@stevelosh.com> wrote:
-> Hey Chris, thanks for the comments.
->
->>
->> My initial impression is that this looks good enough already to merge as
->> a replacement for the turbogears site. What does everyone else think?
->>
->
-> I'm not quite sure it's there yet. There are a bunch of bugs I've got
-> marked as "beta" that I'd like to see fixed before it's ready for real use.
-> Hopefully they shouldn't be too tough to fix. You can point CFBE at itself
-> to see them. :)
->
->> Could you explain a little about how you handle authorship of bug
->> changes at the moment, and if it looks plausible to try making it
->> multiuser? (Having it handle more than one "user" logged in at once.)
->>
->
-> That's something I need advice on. Right now CFBE is pretty much only
-> suitable for local use - you check out whatever you're working on and use it
-> as a local interface to the bugs in the repository. Change those, check in,
-> etc. It's effectively just a pretty version of the command line be tool.
->
-> I haven't used CherryPy's session/authentication support before. This might
-> be a good time for me to learn. One way it might be able to handle multiple
-> users hitting a central server:
->
-> * Each user has to register with the server and be approved by an admin.
-> * Each account would be mapped to a contributor string, the same one that
-> would show up if you were going to commit to the repository.
-> * Once you have an account, you'd login to make any changes.
->
->
-> Aside from all that, I'm a little fuzzy on how a centralized interface to a
-> distributed bug tracking system should work. A read-only interface to a
-> central "main" repository would be easy. Run the server in read-only mode
-> pointing at the main repository. People can use it to look at the bugs in
-> the tip of that repository.
->
-> If it's not read-only, what happens when a user changes/adds/whatevers a
-> bug? Should CFBE commit that change to the repository right then and there?
-> Should it never commit, just update the bugdir and let the commits happen
-> manually?
->
-> What happens when you have multiple branches for a repository? Should there
-> be one CFBE instance for each branch, or a single one that lets you switch
-> between branches (effectively switching between revisions)?
->
-> Those are the kind of things that don't really apply when CFBE is just a
-> local interface to a single repository. If anyone has any advice on how a
-> multi-user interface should work I'd love to hear it!
->
-> --
-> Steve Losh
-> http://stevelosh.com/
->
->
-> _______________________________________________
-> Be-devel mailing list
-> Be-devel@bugseverywhere.org
-> http://void.printf.net/cgi-bin/mailman/listinfo/be-devel
->
-
-
-
---
-Matthew Wilson
-matt@tplus1.com
-http://tplus1.com
-
-_______________________________________________
-Be-devel mailing list
-Be-devel@bugseverywhere.org
-http://void.printf.net/cgi-bin/mailman/listinfo/be-devel
diff --git a/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/d9959864-ea91-475a-a075-f39aa6760f98/comments/1f25cba2-03ee-43e1-a042-ef6724938ad8/values b/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/d9959864-ea91-475a-a075-f39aa6760f98/comments/1f25cba2-03ee-43e1-a042-ef6724938ad8/values
deleted file mode 100644
index ca3efd0..0000000
--- a/.be/bea86499-824e-4e77-b085-2d581fa9ccab/bugs/d9959864-ea91-475a-a075-f39aa6760f98/comments/1f25cba2-03ee-43e1-a042-ef6724938ad8/values
+++ /dev/null
@@ -1,14 +0,0 @@
-Alt-id: <f6f643a20902071531y6aa3d7a6k7c5a4bd4aa5a04f6@mail.gmail.com>
-
-
-Author: Matthew Wilson <matt@tplus1.com>
-
-
-Content-type: text/plain
-
-
-Date: Sat, 07 Feb 2009 18:31:04 -0500
-
-
-In-reply-to: 21c90231-d7f2-49bb-97d9-99e16459d799
-
diff --git a/NEWS b/NEWS
index 46eeb37..2defeb0 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+February 20, 2010
+ * `be html` uses truncated IDs in comment and bug URLs and anchors.
+
January 27, 2010
* `be html` links (<a href="...) #-delimited references in text/*
comment bodies.
diff --git a/doc/man/module.mk b/doc/man/module.mk
new file mode 100644
index 0000000..ea4eacc
--- /dev/null
+++ b/doc/man/module.mk
@@ -0,0 +1,44 @@
+# :vim: filetype=make : -*- makefile; coding: utf-8; -*-
+
+# doc/module.mk
+# Part of Bugs Everywhere, a distributed bug tracking system.
+#
+# Copyright (C) 2008-2010 Chris Ball <cjb@laptop.org>
+# Gianluca Montecchi <gian@grys.it>
+# W. Trevor King <wking@drexel.edu>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# Makefile module for documentation
+
+MODULE_DIR := doc/src
+
+MANPAGES = be.1
+manpage_files = $(patsubst %,${MODULE_DIR}/%,${MANPAGES})
+
+GENERATED_FILES += ${manpage_files}
+
+
+.PHONY: doc
+doc: man
+
+build: doc
+
+
+.PHONY: man
+man: ${manpage_files}
+
+%.1: %.1.sgml
+ docbook-to-man $< > $@
diff --git a/libbe/command/close.py b/libbe/command/close.py
index 0532ed2..026c605 100644
--- a/libbe/command/close.py
+++ b/libbe/command/close.py
@@ -1,4 +1,5 @@
# Copyright (C) 2005-2009 Aaron Bentley and Panometrics, Inc.
+# Gianluca Montecchi <gian@grys.it>
# Marien Zwart <marienz@gentoo.org>
# Thomas Gerigk <tgerigk@gmx.de>
# W. Trevor King <wking@drexel.edu>
@@ -20,7 +21,8 @@
from libbe import cmdutil, bugdir
__desc__ = __doc__
-def execute(args, manipulate_encodings=True):
+def execute(args, manipulate_encodings=True, restrict_file_access=False,
+ dir="."):
"""
>>> from libbe import bugdir
>>> import os
@@ -43,8 +45,9 @@ def execute(args, manipulate_encodings=True):
if len(args) > 1:
raise cmdutil.UsageError("Too many arguments.")
bd = bugdir.BugDir(from_disk=True,
- manipulate_encodings=manipulate_encodings)
- bug = cmdutil.bug_from_shortname(bd, args[0])
+ manipulate_encodings=manipulate_encodings,
+ root=dir)
+ bug = cmdutil.bug_from_id(bd, args[0])
bug.status = "closed"
bd.save()
diff --git a/libbe/command/email_bugs.py b/libbe/command/email_bugs.py
new file mode 100644
index 0000000..f6641e3
--- /dev/null
+++ b/libbe/command/email_bugs.py
@@ -0,0 +1,239 @@
+# Copyright (C) 2009 W. Trevor King <wking@drexel.edu>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+"""Email specified bugs in a be-handle-mail compatible format."""
+
+import copy
+from cStringIO import StringIO
+from email import Message
+from email.mime.text import MIMEText
+from email.generator import Generator
+import sys
+import time
+
+from libbe import cmdutil, bugdir
+from libbe.subproc import invoke
+from libbe.utility import time_to_str
+from libbe.vcs import detect_vcs, installed_vcs
+import show
+
+__desc__ = __doc__
+
+sendmail='/usr/sbin/sendmail -t'
+
+def execute(args, manipulate_encodings=True, restrict_file_access=False,
+ dir="."):
+ """
+ >>> import os
+ >>> from libbe import bug
+ >>> bd = bugdir.SimpleBugDir()
+ >>> bd.encoding = 'utf-8'
+ >>> os.chdir(bd.root)
+ >>> import email.charset as c
+ >>> c.add_charset('utf-8', c.SHORTEST, c.QP, 'utf-8')
+ >>> execute(["-o", "--to", "a@b.com", "--from", "b@c.edu", "a", "b"],
+ ... manipulate_encodings=False) # doctest: +ELLIPSIS
+ Content-Type: text/xml; charset="utf-8"
+ MIME-Version: 1.0
+ Content-Transfer-Encoding: quoted-printable
+ From: b@c.edu
+ To: a@b.com
+ Date: ...
+ Subject: [be-bug:xml] Updates to a, b
+ <BLANKLINE>
+ <?xml version=3D"1.0" encoding=3D"utf-8" ?>
+ <be-xml>
+ <version>
+ <tag>...</tag>
+ <branch-nick>...</branch-nick>
+ <revno>...</revno>
+ <revision-id>...
+ </version>
+ <bug>
+ <uuid>a</uuid>
+ <short-name>a</short-name>
+ <severity>minor</severity>
+ <status>open</status>
+ <creator>John Doe &lt;jdoe@example.com&gt;</creator>
+ <created>Thu, 01 Jan 1970 00:00:00 +0000</created>
+ <summary>Bug A</summary>
+ </bug>
+ <bug>
+ <uuid>b</uuid>
+ <short-name>b</short-name>
+ <severity>minor</severity>
+ <status>closed</status>
+ <creator>Jane Doe &lt;jdoe@example.com&gt;</creator>
+ <created>Thu, 01 Jan 1970 00:00:00 +0000</created>
+ <summary>Bug B</summary>
+ </bug>
+ </be-xml>
+ >>> bd.cleanup()
+
+ Note that the '=3D' bits in
+ <?xml version=3D"1.0" encoding=3D"utf-8" ?>
+ are the way quoted-printable escapes '='.
+
+ The unclosed <revision-id>... is because revision ids can be long
+ enough to cause line wraps, and we want to ensure we match even if
+ the closing </revision-id> is split by the wrapping.
+ """
+ parser = get_parser()
+ options, args = parser.parse_args(args)
+ cmdutil.default_complete(options, args, parser,
+ bugid_args={-1: lambda bug : bug.active==True})
+ if len(args) == 0:
+ raise cmdutil.UsageError
+ bd = bugdir.BugDir(from_disk=True,
+ manipulate_encodings=manipulate_encodings,
+ root=dir)
+ xml = show.output(args, bd, as_xml=True, with_comments=True)
+ subject = options.subject
+ if subject == None:
+ subject = '[be-bug:xml] Updates to %s' % ', '.join(args)
+ submit_email = TextEmail(to_address=options.to_address,
+ from_address=options.from_address,
+ subject=subject,
+ body=xml,
+ encoding=bd.encoding,
+ subtype='xml')
+ if options.output == True:
+ print submit_email
+ else:
+ submit_email.send()
+
+def get_parser():
+ parser = cmdutil.CmdOptionParser("be email-bugs [options] ID [ID ...]")
+ parser.add_option("-t", "--to", metavar="EMAIL", dest="to_address",
+ help="Submission email address (%default)",
+ default="be-devel@bugseverywhere.org")
+ parser.add_option("-f", "--from", metavar="EMAIL", dest="from_address",
+ help="Senders email address, overriding auto-generated default",
+ default=None)
+ parser.add_option("-s", "--subject", metavar="STRING", dest="subject",
+ help="Subject line, overriding auto-generated default. If you use this option, remember that be-handle-mail probably want something like '[be-bug:xml] ...'",
+ default=None)
+ parser.add_option('-o', '--output', dest='output', action='store_true',
+ help="Don't mail the generated message, print it to stdout instead. Useful for testing functionality.")
+ return parser
+
+longhelp="""
+Email specified bugs in a be-handle-mail compatible format. This is
+the prefered method for reporting bugs if you did not install bzr by
+branching a bzr repository.
+
+If you _did_ install bzr by branching a bzr repository, we suggest you
+commit any new bug information with
+ bzr commit --message "Reported bug in demuxulizer"
+and then email a bzr merge directive with
+ bzr send --mail-to "be-devel@bugseverywhere.org"
+rather than using this command.
+"""
+
+def help():
+ return get_parser().help_str() + longhelp
+
+class TextEmail (object):
+ """
+ Make it very easy to compose and send single-part text emails.
+ >>> msg = TextEmail(to_address='Monty <monty@a.com>',
+ ... from_address='Python <python@b.edu>',
+ ... subject='Parrots',
+ ... header={'x-special-header':'your info here'},
+ ... body="Remarkable bird, id'nit, squire?\\nLovely plumage!")
+ >>> print msg # doctest: +ELLIPSIS
+ Content-Type: text/plain; charset="utf-8"
+ MIME-Version: 1.0
+ Content-Transfer-Encoding: base64
+ From: Python <python@b.edu>
+ To: Monty <monty@a.com>
+ Date: ...
+ Subject: Parrots
+ x-special-header: your info here
+ <BLANKLINE>
+ UmVtYXJrYWJsZSBiaXJkLCBpZCduaXQsIHNxdWlyZT8KTG92ZWx5IHBsdW1hZ2Uh
+ <BLANKLINE>
+ >>> import email.charset as c
+ >>> c.add_charset('utf-8', c.SHORTEST, c.QP, 'utf-8')
+ >>> print msg # doctest: +ELLIPSIS
+ Content-Type: text/plain; charset="utf-8"
+ MIME-Version: 1.0
+ Content-Transfer-Encoding: quoted-printable
+ From: Python <python@b.edu>
+ To: Monty <monty@a.com>
+ Date: ...
+ Subject: Parrots
+ x-special-header: your info here
+ <BLANKLINE>
+ Remarkable bird, id'nit, squire?
+ Lovely plumage!
+ """
+ def __init__(self, to_address, from_address=None, subject=None,
+ header=None, body=None, encoding='utf-8', subtype='plain'):
+ self.to_address = to_address
+ self.from_address = from_address
+ if self.from_address == None:
+ self.from_address = self._guess_from_address()
+ self.subject = subject
+ self.header = header
+ if self.header == None:
+ self.header = {}
+ self.body = body
+ self.encoding = encoding
+ self.subtype = subtype
+ def _guess_from_address(self):
+ vcs = detect_vcs('.')
+ if vcs.name == "None":
+ vcs = installed_vcs()
+ return vcs.get_user_id()
+ def encoded_MIME_body(self):
+ return MIMEText(self.body.encode(self.encoding),
+ self.subtype,
+ self.encoding)
+ def message(self):
+ response = self.encoded_MIME_body()
+ response['From'] = self.from_address
+ response['To'] = self.to_address
+ response['Date'] = time_to_str(time.time())
+ response['Subject'] = self.subject
+ for k,v in self.header.items():
+ response[k] = v
+ return response
+ def flatten(self, to_unicode=False):
+ """
+ This is a simplified version of send_pgp_mime.flatten().
+ """
+ fp = StringIO()
+ g = Generator(fp, mangle_from_=False)
+ g.flatten(self.message())
+ text = fp.getvalue()
+ if to_unicode == True:
+ encoding = msg.get_content_charset() or "utf-8"
+ text = unicode(text, encoding=encoding)
+ return text
+ def __str__(self):
+ return self.flatten()
+ def __unicode__(self):
+ return self.flatten(to_unicode=True)
+ def send(self, sendmail=None):
+ """
+ This is a simplified version of send_pgp_mime.mail().
+
+ Send an email Message instance on its merry way by shelling
+ out to the user specified sendmail.
+ """
+ if sendmail == None:
+ sendmail = SENDMAIL
+ invoke(sendmail, stdin=self.flatten())
diff --git a/libbe/command/html.py b/libbe/command/html.py
index 4b878e0..43d4683 100644
--- a/libbe/command/html.py
+++ b/libbe/command/html.py
@@ -53,9 +53,9 @@ class HTML (libbe.command.Command):
True
>>> os.path.exists(os.path.join(bd.storage.repo, 'html_export', 'bugs'))
True
- >>> os.path.exists(os.path.join(bd.storage.repo, 'html_export', 'bugs', 'a.html'))
+ >>> os.path.exists(os.path.join(bd.storage.repo, 'html_export', 'bugs', 'a', 'index.html'))
True
- >>> os.path.exists(os.path.join(bd.storage.repo, 'html_export', 'bugs', 'b.html'))
+ >>> os.path.exists(os.path.join(bd.storage.repo, 'html_export', 'bugs', 'b', 'index.html'))
True
>>> ui.cleanup()
>>> bd.cleanup()
@@ -124,6 +124,7 @@ class HTMLGen (object):
def __init__(self, bd, template=None,
title="Site Title", index_header="Index Header",
verbose=False, encoding=None, stdout=None,
+ min_id_length=3
):
self.generation_time = time.ctime()
self.bd = bd
@@ -142,8 +143,8 @@ class HTMLGen (object):
self._load_default_templates()
if template != None:
self._load_user_templates()
- self.bug_list_dict = {}
-
+ self.min_id_length = min_id_length
+
def run(self, out_dir):
if self.verbose == True:
print >> self.stdout, \
@@ -164,8 +165,7 @@ class HTMLGen (object):
up_link = '../index.html'
else:
up_link = '../index_inactive.html'
- fname = self._create_file_name(b.uuid)
- self._write_bug_file(b, up_link, fname)
+ self._write_bug_file(b, up_link)
self._write_index_file(
bugs_active, title=self.title,
index_header=self.index_header, bug_type='active')
@@ -173,31 +173,15 @@ class HTMLGen (object):
bugs_inactive, title=self.title,
index_header=self.index_header, bug_type='inactive')
- def _create_file_name(self, bugid):
- s = 4
- if not self.bug_list_dict.has_key(bugid[0:3]):
- self.bug_list_dict[bugid[0:3]] = bugid
- fname = bugid[0:3]
- else:
- for i in range(s, s+6):
- if not self.bug_list_dict.has_key(bugid[0:s]):
- self.bug_list_dict[bugid[0:s]] = bugid
- fname = bugid[0:s]
- break
- if s == 8:
- self.bug_list_dict[bugid] = bugid
- fname = bugid
- fpath = os.path.join(self.out_dir_bugs, fname)
- return fpath
-
- def _find_file_name(self, bugid):
- name = ""
- for k in self.bug_list_dict:
- if self.bug_list_dict[k] == bugid:
- name = k
- self.bug_list_dict.pop(k)
- break
- return name
+ def _truncated_bug_id(self, bug):
+ return libbe.util.id._truncate(
+ bug.uuid, bug.sibling_uuids(),
+ min_length=self.min_id_length)
+
+ def _truncated_comment_id(self, comment):
+ return libbe.util.id._truncate(
+ comment.uuid, comment.sibling_uuids(),
+ min_length=self.min_id_length)
def _create_output_directories(self, out_dir):
if self.verbose:
@@ -214,7 +198,7 @@ class HTMLGen (object):
self._write_file(self.css_file,
[self.out_dir,'style.css'])
- def _write_bug_file(self, bug, up_link, fname):
+ def _write_bug_file(self, bug, up_link):
if self.verbose:
print >> self.stdout, '\tCreating bug file for %s' % bug.id.user()
assert hasattr(self, 'out_dir_bugs'), \
@@ -222,8 +206,8 @@ class HTMLGen (object):
bug.load_comments(load_full=True)
comment_entries = self._generate_bug_comment_entries(bug)
- filename = '%s.html' % fname
- fullpath = os.path.join(self.out_dir_bugs, filename)
+ dirname = self._truncated_bug_id(bug)
+ fullpath = os.path.join(self.out_dir_bugs, dirname, 'index.html')
template_info = {'title':self.title,
'charset':self.encoding,
'up_link':up_link,
@@ -233,6 +217,9 @@ class HTMLGen (object):
for attr in ['uuid', 'severity', 'status', 'assigned',
'reporter', 'creator', 'time_string', 'summary']:
template_info[attr] = self._escape(getattr(bug, attr))
+ fulldir = os.path.join(self.out_dir_bugs, dirname)
+ if not os.path.exists(fulldir):
+ os.mkdir(fulldir)
self._write_file(self.bug_file % template_info, [fullpath])
def _generate_bug_comment_entries(self, bug):
@@ -255,7 +242,9 @@ class HTMLGen (object):
else:
comment_entries.append(
'<div class="comment" id="%s">' % comment.uuid)
- template_info = {'shortname': comment.id.user()}
+ template_info = {
+ 'shortname': comment.id.user(),
+ 'truncated_id': self._truncated_comment_id(comment)}
for attr in ['uuid', 'author', 'date', 'body']:
value = getattr(comment, attr)
if attr == 'body':
@@ -269,11 +258,14 @@ class HTMLGen (object):
elif comment.content_type.startswith('image/'):
save_body = True
value = '<img src="./%s/%s" />' \
- % (bug.uuid, comment.uuid)
+ % (self._truncated_bug_id(bug),
+ self._truncated_comment_id(comment))
else:
save_body = True
value = '<a href="./%s/%s">Link to %s file</a>.' \
- % (bug.uuid, comment.uuid, comment.content_type)
+ % (self._truncated_bug_id(bug),
+ self._truncated_comment_id(comment),
+ comment.content_type)
if link_long_ids == True:
value = self._long_to_linked_user(value)
if save_body == True:
@@ -302,7 +294,7 @@ class HTMLGen (object):
>>> bd = libbe.bugdir.SimpleBugDir(memory=False)
>>> h = HTMLGen(bd)
>>> h._long_to_linked_user('A link #abc123/a#, and a non-link #x#y#.')
- 'A link <a href="./a.html">abc/a</a>, and a non-link #x#y#.'
+ 'A link <a href="./a/">abc/a</a>, and a non-link #x#y#.'
>>> bd.cleanup()
"""
replacer = libbe.util.id.IDreplacer(
@@ -326,9 +318,9 @@ class HTMLGen (object):
>>> h._long_to_linked_user_replacer([bd], 'abc123')
'#abc123#'
>>> h._long_to_linked_user_replacer([bd], 'abc123/a')
- '<a href="./a.html">abc/a</a>'
+ '<a href="./a/">abc/a</a>'
>>> h._long_to_linked_user_replacer([bd], 'abc123/a/0123')
- '<a href="./a.html#0123">abc/a/012</a>'
+ '<a href="./a/#012">abc/a/012</a>'
>>> h._long_to_linked_user_replacer([bd], 'x')
'#x#'
>>> h._long_to_linked_user_replacer([bd], '')
@@ -337,7 +329,6 @@ class HTMLGen (object):
"""
try:
p = libbe.util.id.parse_user(bugdirs[0], long_id)
- short_id = libbe.util.id.long_to_short_user(bugdirs, long_id)
except (libbe.util.id.MultipleIDMatches,
libbe.util.id.NoIDMatches,
libbe.util.id.InvalidIDStructure), e:
@@ -345,11 +336,17 @@ class HTMLGen (object):
if p['type'] == 'bugdir':
return '#%s#' % long_id
elif p['type'] == 'bug':
- return '<a href="./%s.html">%s</a>' \
- % (p['bug'], short_id)
+ bug,comment = libbe.command.util.bug_comment_from_user_id(
+ bugdirs[0], long_id)
+ return '<a href="./%s/">%s</a>' \
+ % (self._truncated_bug_id(bug), bug.id.user())
elif p['type'] == 'comment':
- return '<a href="./%s.html#%s">%s</a>' \
- % (p['bug'], p['comment'], short_id)
+ bug,comment = libbe.command.util.bug_comment_from_user_id(
+ bugdirs[0], long_id)
+ return '<a href="./%s/#%s">%s</a>' \
+ % (self._truncated_bug_id(bug),
+ self._truncated_comment_id(comment),
+ comment.id.user())
raise Exception('Invalid id type %s for "%s"'
% (p['type'], long_id))
@@ -387,11 +384,10 @@ class HTMLGen (object):
if self.verbose:
print >> self.stdout, '\tCreating bug entry for %s' % bug.id.user()
template_info = {'shortname':bug.id.user()}
- fn = self._find_file_name(bug.uuid)
for attr in ['uuid', 'severity', 'status', 'assigned',
'reporter', 'creator', 'time_string', 'summary']:
template_info[attr] = self._escape(getattr(bug, attr))
- template_info['uuid'] = fn
+ template_info['dir'] = self._truncated_bug_id(bug)
bug_entries.append(self.index_bug_entry % template_info)
return '\n'.join(bug_entries)
@@ -624,11 +620,11 @@ class HTMLGen (object):
self.index_bug_entry ="""
<tr class="%(severity)s">
- <td><a href="bugs/%(uuid)s.html">%(shortname)s</a></td>
- <td><a href="bugs/%(uuid)s.html">%(status)s</a></td>
- <td><a href="bugs/%(uuid)s.html">%(severity)s</a></td>
- <td><a href="bugs/%(uuid)s.html">%(summary)s</a></td>
- <td><a href="bugs/%(uuid)s.html">%(time_string)s</a></td>
+ <td><a href="bugs/%(dir)s/">%(shortname)s</a></td>
+ <td><a href="bugs/%(dir)s/">%(status)s</a></td>
+ <td><a href="bugs/%(dir)s/">%(severity)s</a></td>
+ <td><a href="bugs/%(dir)s/">%(summary)s</a></td>
+ <td><a href="bugs/%(dir)s/">%(time_string)s</a></td>
</tr>
"""
diff --git a/libbe/command/open.py b/libbe/command/open.py
index 0c6bf05..a6fe48d 100644
--- a/libbe/command/open.py
+++ b/libbe/command/open.py
@@ -1,4 +1,5 @@
# Copyright (C) 2005-2009 Aaron Bentley and Panometrics, Inc.
+# Gianluca Montecchi <gian@grys.it>
# Marien Zwart <marienz@gentoo.org>
# Thomas Gerigk <tgerigk@gmx.de>
# W. Trevor King <wking@drexel.edu>
@@ -20,7 +21,8 @@
from libbe import cmdutil, bugdir
__desc__ = __doc__
-def execute(args, manipulate_encodings=True):
+def execute(args, manipulate_encodings=True, restrict_file_access=False,
+ dir="."):
"""
>>> import os
>>> bd = bugdir.SimpleBugDir()
@@ -42,8 +44,9 @@ def execute(args, manipulate_encodings=True):
if len(args) > 1:
raise cmdutil.UsageError, "Too many arguments."
bd = bugdir.BugDir(from_disk=True,
- manipulate_encodings=manipulate_encodings)
- bug = cmdutil.bug_from_shortname(bd, args[0])
+ manipulate_encodings=manipulate_encodings,
+ root=dir)
+ bug = cmdutil.bug_from_id(bd, args[0])
bug.status = "open"
def get_parser():