/loggerhead/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerhead/trunk

« back to all changes in this revision

Viewing changes to loggerhead/controllers/inventory_ui.py

  • Committer: Martin Pool
  • Date: 2011-11-23 08:33:12 UTC
  • mto: This revision was merged to the branch mainline in revision 461.
  • Revision ID: mbp@canonical.com-20111123083312-4stzhfv5843jxv2k
Bump version to 1.18.1; compatible with bzr 2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#
16
16
# You should have received a copy of the GNU General Public License
17
17
# along with this program; if not, write to the Free Software
18
 
# Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335  USA
 
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
19
#
20
20
 
21
21
import logging
24
24
 
25
25
from paste.httpexceptions import HTTPNotFound, HTTPMovedPermanently
26
26
 
27
 
from breezy import errors
28
 
from breezy.revision import is_null as is_null_rev
 
27
from bzrlib import errors
 
28
from bzrlib.revision import is_null as is_null_rev
29
29
 
30
30
from loggerhead import util
31
31
from loggerhead.controllers import TemplatedBranchView
35
35
def dirname(path):
36
36
    if path is not None:
37
37
        path = path.rstrip('/')
38
 
        path = urllib.quote(posixpath.dirname(path).encode('utf-8'))
 
38
        path = urllib.quote(posixpath.dirname(path))
39
39
    return path
40
40
 
41
41
 
44
44
    template_path = 'loggerhead.templates.inventory'
45
45
    supports_json = True
46
46
 
47
 
    def get_filelist(self, tree, path, sort_type, revno_url):
 
47
    def get_filelist(self, inv, path, sort_type, revno_url):
48
48
        """
49
49
        return the list of all files (and their attributes) within a given
50
50
        path subtree.
51
51
 
52
 
        @param tree: The tree
53
 
        @param path: The path of a directory within the tree.
 
52
        @param inv: The inventory.
 
53
        @param path: The path of a directory within the inventory.
54
54
        @param sort_type: How to sort the results... XXX.
55
55
        """
 
56
        file_id = inv.path2id(path)
 
57
        dir_ie = inv[file_id]
56
58
        file_list = []
57
59
 
58
 
        if tree.kind(path) != 'directory':
 
60
        if dir_ie.kind != 'directory':
59
61
            raise HTTPMovedPermanently(self._branch.context_url(['/view', revno_url, path]))
60
62
 
61
63
        revid_set = set()
62
64
 
63
 
        child_entries = list(tree.iter_child_entries(path))
64
 
 
65
 
        for entry in child_entries:
 
65
        for filename, entry in dir_ie.children.iteritems():
66
66
            revid_set.add(entry.revision)
67
67
 
68
68
        change_dict = {}
69
69
        for change in self._history.get_changes(list(revid_set)):
70
70
            change_dict[change.revid] = change
71
71
 
72
 
        for entry in child_entries:
73
 
            pathname = entry.name
 
72
        for filename, entry in dir_ie.children.iteritems():
 
73
            pathname = filename
74
74
            if entry.kind == 'directory':
75
75
                pathname += '/'
76
76
            if path == '':
85
85
            # including the revision id and having a separate request to get
86
86
            # back the revision info.
87
87
            file = util.Container(
88
 
                filename=entry.name, executable=entry.executable,
 
88
                filename=filename, executable=entry.executable,
89
89
                kind=entry.kind, absolutepath=absolutepath,
90
90
                file_id=entry.file_id, size=entry.text_size, revid=revid,
91
91
                change=change_dict[revid])
144
144
            else:
145
145
                revno_url = history.get_revno(revid)
146
146
            history.add_branch_nicks(change)
147
 
            filelist = self.get_filelist(rev_tree, path, sort_type, revno_url)
 
147
            filelist = self.get_filelist(rev_tree.inventory, path, sort_type, revno_url)
148
148
 
149
149
        else:
150
150
            start_revid = None