Edgewall Software
Modify

Opened 11 years ago

Closed 11 years ago

#11467 closed defect (fixed)

Reversed order of events in git repository on timeline

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 1.0.2
Component: plugin/git Version:
Severity: normal Keywords: timeline
Cc: Branch:
Release Notes:

Fix reverse order git changesets on timeline view if the changesets have the same committer-time and off-by-one error on stop argument of GitRepository.get_changesets().

API Changes:
Internal Changes:

Description

The changesets in git repository might have the same commit timestamp. That sometimes occurs by git rebase command and its resolution is 1s. Timeline view shows those events in reversed-order.

GitRepository.get_changesets currently return its changesets from oldest to newest. It should return from newest to oldest to fix.

The issue would be fixed by the following patch. But, if [git] cached_repository is enabled, the issue still occurs.

  • tracopt/versioncontrol/git/PyGIT.py

    diff --git a/tracopt/versioncontrol/git/PyGIT.py b/tracopt/versioncontrol/git/PyGIT.py
    index f26e51a..bb8b448 100644
    a b class Storage(object):  
    968968
    969969    def history_timerange(self, start, stop):
    970970        return [ rev.strip() for rev in \
    971                      self.repo.rev_list('--reverse',
     971                     self.repo.rev_list('--date-order',
    972972                                        '--max-age=%d' % start,
    973973                                        '--min-age=%d' % stop,
    974974                                        '--all').splitlines() ]

Attachments (0)

Change History (5)

comment:1 by Jun Omae, 11 years ago

Owner: set to Jun Omae
Status: newassigned

Proposed changes are in jomae.git@t11467. It fixes even if cached_repository is enabled.

comment:2 by Jun Omae, 11 years ago

In [3d20a9b0/jomae.git], I revised the patch. If cached_repository is enabled, don't use git rev-list via self.repos.git.history_timerange().

Also, I found off-by-one error on GitRepository.get_changesets(). [1cd360a6d/jomae.git] is proposed changes for it.

I'll push the changes soon.

comment:3 by Jun Omae, 11 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed in [12503-12504] and merged to trunk in [12505].

comment:4 by Jun Omae, 11 years ago

Resolution: fixed
Status: closedreopened

Oops. The unit tests pass with git 1.8.2.1. But, if git 1.7.1, the tests fail.

$ git --version
git version 1.7.1
$ TZ=Asia/Tokyo make python=26 test=tracopt/versioncontrol/git/tests/git_fs.py
Python version: Python 2.6.6
figleaf:
coverage: /home/jun66j5/bin/coverage
PYTHONPATH=.:
TRAC_TEST_DB_URI=
server-options= -p 3000 -a '*,/home/jun66j5/src/trac-htdigest.txt,auth' -s -r -e
python tracopt/versioncontrol/git/tests/git_fs.py
.......FF
======================================================================
FAIL: test_with_cache (__main__.HistoryTimeRangeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 163, in test_with_cache
    self._test_timerange('enabled')
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 191, in _test_timerange
    self.assertEqual(1, len(csets))
AssertionError: 1 != 4

======================================================================
FAIL: test_without_cache (__main__.HistoryTimeRangeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 160, in test_without_cache
    self._test_timerange('disabled')
  File "tracopt/versioncontrol/git/tests/git_fs.py", line 191, in _test_timerange
    self.assertEqual(1, len(csets))
AssertionError: 1 != 4

----------------------------------------------------------------------
Ran 9 tests in 0.590s

FAILED (failures=2)
make: *** [all] Error 1

It seems that git 1.7.1 ignores timezone of date format in GIT_COMMITTER_DATE and GIT_AUTHOR_DATE.

$ TZ=UTC make python=26 test=tracopt/versioncontrol/git/tests/git_fs.py
Python version: Python 2.6.6
figleaf:
coverage: /home/jun66j5/bin/coverage
PYTHONPATH=.:
TRAC_TEST_DB_URI=
server-options= -p 3000 -a '*,/home/jun66j5/src/trac-htdigest.txt,auth' -s -r -e
python tracopt/versioncontrol/git/tests/git_fs.py
.........
----------------------------------------------------------------------
Ran 9 tests in 0.673s

OK

It would be fixed to use Git internal date format, e.g. <unixtime> <tzoffset>, instead of iso 8601 format.

-        env['GIT_COMMITTER_DATE'] = ts.isoformat()
-        env['GIT_AUTHOR_DATE'] = ts.isoformat()
+        env['GIT_COMMITTER_DATE'] = '%d +0000' % to_timestamp(ts)
+        env['GIT_AUTHOR_DATE'] = '%d +0000' % to_timestamp(ts)

comment:5 by Jun Omae, 11 years ago

Resolution: fixed
Status: reopenedclosed

Committed and merged in [12518-12519], fixed again.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.