﻿ticket,summary,type,release,owner,status,created,modified,_description,_reporter
11732,Support for git submodules,defect,,Jun Omae,new,2014-05-06T10:17:25+02:00,2014-05-06T21:56:50+02:00,"Right now when a git repository contains submodules, the plugin raises an internal error in `GitNode.__init__()` because `git_repos.get()` returns `None` for those entries.

I know that there's already a [http://trac.edgewall.org/ticket/10603 Trac ticket] about this, but I wonder if it would be reasonable to handle the case without raising an error in the meantime, for example

{{{
#!diff
--- tracext/pygit2/git_fs.py	(revision 13902)
+++ tracext/pygit2/git_fs.py	(working copy)
@@ -952,8 +952,13 @@
                 if tree_entry is None:
                     raise NoSuchNode(path, rev)
                 git_object = repos.git_repos.get(tree_entry.oid)
-            if git_object.type == GIT_OBJ_TREE:
+            if git_object is None and oct(tree_entry.filemode).startswith('016'):
                 kind = Node.DIRECTORY
+                git_object = None
+                tree = None
+                blob = None
+            elif git_object.type == GIT_OBJ_TREE:
+                kind = Node.DIRECTORY
                 tree = git_object
                 blob = None
             elif git_object.type == GIT_OBJ_BLOB:
@@ -1046,7 +1051,9 @@
         return annotations
 
     def get_entries(self):
-        if self.commit is None or not self.isdir:
+        if self.commit is None or not self.isdir or (
+                self.tree is None and
+                oct(self.tree_entry.filemode).startswith('016')):
             return
 
         repos = self.repos
}}}

Ideally, such nodes could return a property (say 'hint') with ''This is the mount point of a git submodule''...

What do you think?",Lele Gaifax
13400,Missing package namespace declaration,defect,,Jun Omae,new,2018-04-04T22:03:23+02:00,2018-04-05T19:45:49+02:00,"Is TracPygit2Plugin intended to be a namespace package?

I'm still trying to understand namespace packages. The [https://packaging.python.org/guides/packaging-namespace-packages/#pkgutil-style-namespace-packages packaging documentation] says:

> Every distribution that uses the namespace package must include an identical `__init__.py`. If any distribution does not, it will cause the namespace logic to fail and the other sub-packages will not be importable. Any additional code in `__init__.py` will be inaccessible.

Here is the layout for TracMercurial:
{{{#!sh
$ cat tracext/__init__.py
__import__('pkg_resources').declare_namespace(__name__)
$ python setup.py bdist_wheel
[...]
$ pip install dist/TracMercurial-0.12.0.31.dev0-py2-none-any.whl
[...]
$ find pve/lib/python2.7/site-packages/tracext/ -name ""*.py""
pve/lib/python2.7/site-packages/tracext/hg/hooks.py
pve/lib/python2.7/site-packages/tracext/hg/backend.py
pve/lib/python2.7/site-packages/tracext/hg/__init__.py
}}}

Note there is no `__init__.py` in `pve/lib/python2.7/site-packages/tracext`.

TracPygit2Plugin yields:
{{{#!sh
$ cat tracext/__init__.py
$ python setup.py bdist_wheel
[...]
$ pip install dist/TracPygit2Plugin-0.12.0.1-py2-none-any.whl
[...]
$ find pve/lib/python2.7/site-packages/tracext/ -name ""*.py""
$ pve/lib/python2.7/site-packages/tracext/pygit2/pygit2_fs.py
$ pve/lib/python2.7/site-packages/tracext/pygit2/__init__.py
$ pve/lib/python2.7/site-packages/tracext/pygit2/translation.py
$ pve/lib/python2.7/site-packages/tracext/__init__.py
$ pve/lib/python2.7/site-packages/tracext/hg/hooks.py
$ pve/lib/python2.7/site-packages/tracext/hg/backend.py
$ pve/lib/python2.7/site-packages/tracext/hg/__init__.py
}}}

With patch, now there is again no `__init__.py` in `pve/lib/python2.7/site-packages/tracext`.
{{{#!diff
Index: setup.py
===================================================================
--- setup.py	(revision 17091)
+++ setup.py	(working copy)
@@ -14,6 +14,7 @@
         'author': 'Jun Omae',
         'author_email': 'jun66j5@gmail.com',
         'packages': find_packages(exclude=['*.tests*']),
+        'namespace_packages': ['tracext'],
         'package_data': {
             'tracext.pygit2': ['locale/*/LC_MESSAGES/*.mo'],
         },
Index: tracext/__init__.py
===================================================================
--- tracext/__init__.py	(revision 17091)
+++ tracext/__init__.py	(working copy)
@@ -0,0 +1 @@
+__import__('pkg_resources').declare_namespace(__name__)
}}}

{{{#!sh
$ python setup.py bdist_wheel
[...]
$ pip install dist/TracPygit2Plugin-0.12.0.1-py2-none-any.whl
[...]
$ find pve/lib/python2.7/site-packages/tracext/ -name ""*.py""
pve/lib/python2.7/site-packages/tracext/pygit2/pygit2_fs.py
pve/lib/python2.7/site-packages/tracext/pygit2/__init__.py
pve/lib/python2.7/site-packages/tracext/pygit2/translation.py
pve/lib/python2.7/site-packages/tracext/hg/hooks.py
pve/lib/python2.7/site-packages/tracext/hg/backend.py
pve/lib/python2.7/site-packages/tracext/hg/__init__.py
}}}
",Ryan J Ollos
12897,AttributeError: '_pygit2.Patch' object has no attribute 'status',defect,1.0,Jun Omae,accepted,2016-10-11T13:01:35+02:00,2016-10-12T10:56:02+02:00,"I have set up Trac on Ubuntu 16.04 system, with Git, Python 2.7 and most of its packages installed from Ubuntu repositories, and Trac & Trac hacks/plugins installed by pip from their respective sites.
I had problems in browsing repository using 'git' type since it contained a reference to a git submodule/subrepository, which looked like infinitely-nested folder in Trac browser. So I decided to install python-pygit2 from Ubuntu repo. and TracPygit2Plugin by pip, then  switched Trac repo. type from 'git' to 'pygit2' (also tried 'cached-pygit2' and 'direct-pygit2'). After this switch I synced the repo. by 'trac-admin' as it requested, and after this change found that I can not view changesets in Trac repo. browser: I get  an exception like {{{ AttributeError: '_pygit2.Patch' object has no attribute 'status' }}} in file pygit2_fs.py.

Full stack :
{{{
Python Traceback

Most recent call last:
File ""/usr/local/lib/python2.7/dist-packages/trac/web/main.py"", line 554, in _dispatch_request
File ""/usr/local/lib/python2.7/dist-packages/trac/web/main.py"", line 247, in dispatch
File ""/usr/local/lib/python2.7/dist-packages/trac/versioncontrol/web_ui/changeset.py"", line 353, in process_request
File ""/usr/local/lib/python2.7/dist-packages/trac/versioncontrol/web_ui/changeset.py"", line 580, in _render_html
File ""/usr/local/lib/python2.7/dist-packages/trac/versioncontrol/web_ui/changeset.py"", line 396, in get_changes
File ""/usr/local/lib/python2.7/dist-packages/tracext/pygit2/pygit2_fs.py"", line 1376, in get_changes
File ""/usr/local/lib/python2.7/dist-packages/tracext/pygit2/pygit2_fs.py"", line 827, in _get_changes
File ""/usr/local/lib/python2.7/dist-packages/tracext/pygit2/pygit2_fs.py"", line 827, in <genexpr>
}}}
{{{
System Information:

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/53.0.2785.143 Chrome/53.0.2785.143 Safari/537.36

Trac	1.0.10
Docutils	0.12
Genshi	0.7 (with speedups)
GIT	2.7.4
mod_wsgi	4.3.0 (WSGIProcessGroup WSGIApplicationGroup s1.platform20k.org|/trac/p20k)
pygit2	0.24.0 (compiled with libgit2 0.24.0)
Pygments	2.1
pysqlite	2.6.0
Python	2.7.12 (default, Jul 1 2016, 15:12:24) [GCC 5.4.0 20160609]
pytz	2014.10
setuptools	20.7.0
SQLite	3.11.0
jQuery	1.7.2
jQuery UI	1.8.21
jQuery Timepicker	1.0.1

Enabled Plugins:

Budgeting-Plugin	0.6.5	/usr/local/lib/python2.7/dist-packages
gantt	0.3dev-r0	/usr/local/lib/python2.7/dist-packages
TicketValidator	0.2dev-r0	/usr/local/lib/python2.7/dist-packages
timingandestimationplugin	1.4.8b0	/usr/local/lib/python2.7/dist-packages
Trac-jsGantt	0.11.post0	/usr/local/lib/python2.7/dist-packages/Trac_jsGantt-0.11.post0-py2.7.egg
TracAccountManager	0.4.4	/usr/local/lib/python2.7/dist-packages
TracCustomFieldAdmin	0.2.12	/usr/local/lib/python2.7/dist-packages
TracDateField	3.0.0	/usr/local/lib/python2.7/dist-packages/TracDateField-3.0.0-py2.7.egg
TracGanttCalendarPlugin	0.6.4.post0	/usr/local/lib/python2.7/dist-packages/TracGanttCalendarPlugin-0.6.4.post0-py2.7.egg
TracKanbanBoard	0.2	/usr/local/lib/python2.7/dist-packages
TracPygit2Plugin	0.12.0.1	/usr/local/lib/python2.7/dist-packages
TracWysiwyg	0.12.0.5.post0	/usr/local/lib/python2.7/dist-packages/TracWysiwyg-0.12.0.5.post0-py2.7.egg
}}}

This is what I get from Trac itself. Please ask if you need more information. Thanks in advance for your help, I would like to be able to make this module useful again.",mwg@…
13401,AttributeError: '_pygit2.Patch' object has no attribute 'status',defect,,Jun Omae,new,2018-04-04T22:26:06+02:00,2018-04-04T22:26:06+02:00,"Error syncing a clone of the Trac repository:

{{{#!sh
$ git --version
git version 2.17.0
$ python -c ""import pygit2; print(pygit2.__version__)""
0.26.4
}}}

{{{#!sh
$ trac-admin ""/Users/rjollos/Documents/Workspace/trac-dev/tracenvs/proj-1.2"" repository list
Name                      Type          Alias  Directory
-------------------------------------------------------------------------------------------------------------------------
[...]
teo                       pygit2               /Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git

$ trac-admin ""/Users/rjollos/Documents/Workspace/trac-dev/tracenvs/proj-1.2"" repository resync ""teo""
[...]
13:20:58 Trac[pygit2_fs] INFO: Trying to sync revision [044e4497b50ae868e38f4060ead26c08171d9d0d]
AttributeError: '_pygit2.Patch' object has no attribute 'status'
13:20:58 Trac[console] ERROR: Exception in trac-admin command: u'repository resync teo'
Traceback (most recent call last):
  File ""/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/admin/console.py"", line 112, in onecmd
    rv = cmd.Cmd.onecmd(self, line) or 0
  File ""/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/cmd.py"", line 220, in onecmd
    return self.default(line)
  File ""/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/admin/console.py"", line 291, in default
    return self.cmd_mgr.execute_command(*args)
  File ""/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/admin/api.py"", line 127, in execute_command
    return f(*fargs)
  File ""/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/versioncontrol/admin.py"", line 162, in _do_resync
    self._sync(reponame, rev, clean=True)
  File ""/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/versioncontrol/admin.py"", line 149, in _sync
    repos.sync(self._sync_feedback, clean=clean)
  File ""/Users/rjollos/Documents/Workspace/trac-dev/trac-hacks/tracpygit2plugin/trunk/tracext/pygit2/pygit2_fs.py"", line 243, in sync
    @self.env.with_transaction()
  File ""/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/db/api.py"", line 97, in transaction_wrapper
    fn(ldb)
  File ""/Users/rjollos/Documents/Workspace/trac-dev/trac-hacks/tracpygit2plugin/trunk/tracext/pygit2/pygit2_fs.py"", line 246, in do_insert
    self._insert_cset(db, rev, cset)
  File ""/Users/rjollos/Documents/Workspace/trac-dev/trac-hacks/tracpygit2plugin/trunk/tracext/pygit2/pygit2_fs.py"", line 335, in _insert_cset
    return self.insert_changeset(rev, cset)
  File ""/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/versioncontrol/cache.py"", line 273, in insert_changeset
    self._insert_changeset(db, rev, cset)
  File ""/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/versioncontrol/cache.py"", line 290, in _insert_changeset
    for path, kind, action, bpath, brev in cset.get_changes():
  File ""/Users/rjollos/Documents/Workspace/trac-dev/trac-hacks/tracpygit2plugin/trunk/tracext/pygit2/pygit2_fs.py"", line 1386, in get_changes
    files = self.repos._get_changes(parent.tree, commit.tree)
  File ""/Users/rjollos/Documents/Workspace/trac-dev/trac-hacks/tracpygit2plugin/trunk/tracext/pygit2/pygit2_fs.py"", line 837, in _get_changes
    for patch in diff) <= _diff_find_rename_limit:
  File ""/Users/rjollos/Documents/Workspace/trac-dev/trac-hacks/tracpygit2plugin/trunk/tracext/pygit2/pygit2_fs.py"", line 837, in <genexpr>
    for patch in diff) <= _diff_find_rename_limit:
AttributeError: '_pygit2.Patch' object has no attribute 'status'
}}}",Ryan J Ollos
