id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc,branch,changelog,apichanges,internalchanges 11851,Raising IntegrityError when repository sync with empty git repository,Jun Omae,Jun Omae,"{{{ 2014-11-28 01:10:13,981 Trac[console] ERROR: Exception in trac-admin command: Traceback (most recent call last): File ""/venv/trac/1.0.2/lib/python2.5/site-packages/trac/admin/console.py"", line 110, in onecmd rv = cmd.Cmd.onecmd(self, line) or 0 File ""/usr/lib/python2.5/cmd.py"", line 218, in onecmd return self.default(line) File ""/venv/trac/1.0.2/lib/python2.5/site-packages/trac/admin/console.py"", line 286, in default return self.cmd_mgr.execute_command(*args) File ""/venv/trac/1.0.2/lib/python2.5/site-packages/trac/admin/api.py"", line 127, in execute_command return f(*fargs) File ""/venv/trac/1.0.2/lib/python2.5/site-packages/trac/versioncontrol/admin.py"", line 155, in _do_sync self._sync(reponame, rev, clean=False) File ""/venv/trac/1.0.2/lib/python2.5/site-packages/trac/versioncontrol/admin.py"", line 139, in _sync repos.sync(self._sync_feedback, clean=clean) File ""/venv/trac/1.0.2/lib/python2.5/site-packages/tracopt/versioncontrol/git/git_fs.py"", line 92, in sync self.save_metadata(metadata) File ""/venv/trac/1.0.2/lib/python2.5/site-packages/trac/versioncontrol/cache.py"", line 267, in save_metadata """""", (self.id, CACHE_YOUNGEST_REV, '')) File ""/venv/trac/1.0.2/lib/python2.5/site-packages/trac/db/util.py"", line 128, in execute cursor.execute(query, params if params is not None else []) File ""/venv/trac/1.0.2/lib/python2.5/site-packages/trac/db/util.py"", line 72, in execute return self.cursor.execute(sql_escape_percent(sql), args) File ""/venv/trac/1.0.2/lib/python2.5/site-packages/trac/db/sqlite_backend.py"", line 80, in execute result = PyFormatCursor.execute(self, *args) File ""/venv/trac/1.0.2/lib/python2.5/site-packages/trac/db/sqlite_backend.py"", line 58, in execute args or []) File ""/venv/trac/1.0.2/lib/python2.5/site-packages/trac/db/sqlite_backend.py"", line 50, in _rollback_on_error return function(self, *args, **kwargs) IntegrityError: columns id, name are not unique }}} After the issue, `NULL` is stored as `youngest_rev` in `repository` table. Instead, empty string should be used for the case. {{{ sqlite> .nullvalue sqlite> SELECT * FROM repository; 1|name| 1|dir|/dev/shm/empty-git 1|type|git 1|repository_dir|git:/dev/shm/empty-git 1|youngest_rev| }}} How to reproduce: {{{ $ git init --bare /dev/shm/empty-git Initialized empty Git repository in /run/shm/empty-git/ $ /venv/trac/1.0.2/bin/trac-admin /dev/shm/tracenv config set logging log_level INFO $ /venv/trac/1.0.2/bin/trac-admin /dev/shm/tracenv config set logging log_type file $ /venv/trac/1.0.2/bin/trac-admin /dev/shm/tracenv config set git cached_repository enabled $ /venv/trac/1.0.2/bin/trac-admin /dev/shm/tracenv config set components 'tracopt.versioncontrol.git.*' enabled $ /venv/trac/1.0.2/bin/trac-admin /dev/shm/tracenv repository add '(default)' /dev/shm/empty-git git $ /venv/trac/1.0.2/bin/trac-admin /dev/shm/tracenv repository sync '(default)' Resyncing repository history for (default)... 0 revisions cached. Done. $ /venv/trac/1.0.2/bin/trac-admin /dev/shm/tracenv repository sync '(default)' Resyncing repository history for (default)... 0 revisions cached. Done. $ /venv/trac/1.0.2/bin/trac-admin /dev/shm/tracenv repository sync '(default)' Resyncing repository history for (default)... IntegrityError: columns id, name are not unique }}}",defect,closed,normal,1.0.3,plugin/git,1.0.2,normal,fixed,,,,Fix raising `IntegrityError` when syncing empty and cached git repository.,,