Hello you all !
This message is about an issue I find annoying. I've even needed to
patch a few code I've written so far as a workaround for the problems
presented below. That's why I'd like you (especially Trac devs ;o) to
consider this in order to either review the ordering of revisions
defined by TracMercurial, or let me (and everybody else interested
in that subject) know why it is correct and how to react when such
problems show up.
Firstly I'll mention part of the contract *I consider* valid
for *ANY* VCS connector (e.g. SVN) and I'll use -> sign to establish
an implication relationship and `r` variable to refer to an instance
of the repository connector:
1. An ordering (total ordering ? partial ordering ?) of revisions
should be implemented. This partially means that :
a. If a revision is older than another then there's no way that
the later be part of the former's ancestors. IOW, let
`previous_revs` be written as follows:
{{{
#!python
def previous_revs(r, rev):
rev = r.normalize_rev(rev)
while (rev):
yield rev
rev = r.previous_rev(rev)
}}}
then :
{{{
r.rev_older_than(rev1, rev2) ->
not any(rev == r.normalize_rev(rev2) for rev in previous_revs(r, rev1))
}}}
2. If a revision has a parent then its parent has a child i.e.
{{{
r.normalize_rev(rev1) == r.previous_rev(rev2) -> r.next_rev(rev1) is not None
}}}
Everything is about revision `-1:000000000000`. The root cause for all
the issues mentionned below is that this revision is considered
in practice as both the oldest and the youngest revision in the Hg
repository, i.e.
{{{
#!python
>>> r.oldest_rev
'-1:000000000000'
>>> r.normalize_rev(r.oldest_rev)
'27:046049125132'
>>> r.youngest_rev
'27:046049125132'
>>> r.normalize_rev(r.oldest_rev) == r.youngest_rev
True
}}}
Here you have a practical example showing how both clauses
are not satisfied by TracMercurial ...
{{{
#!python
# This confirms that 1a. is not satisfied because revision 14 is
# younger than revision 7 and still 14 seems to be an
# ancestor of revision 7.
>>> r.rev_older_than('7', '14')
True
>>> any(rev == r.normalize_rev('14') for rev in previous_revs(r, '7'))
True
# This one confirms that 1b. is not satisfied either
>>> r.normalize_rev('-1')
'27:046049125132'
>>> r.normalize_rev(r.previous_rev('0'))
'27:046049125132'
>>> r.normalize_rev(r.previous_rev('0')) == r.normalize_rev('-1')
True
>>> r.next_rev(r.previous_rev('0')) is None
True
}}}
... but they are satisfied by SVN connector
{{{
#!python
# This is not always true, but it is in the target SVN repos
>>> allrevs = range(0, r.youngest_rev + 1)
>>> allrevs
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
>>> implies = lambda a, b: not a or b
>>> def previous_revs(r, rev):
... rev = r.normalize_rev(rev)
... while (rev):
... yield rev
... rev = r.previous_rev(rev)
...
# 1a. is satisfied
>>> all(implies( \
... r.rev_older_than(rev1, rev2),
... not any(rev == r.normalize_rev(rev2) for rev
in previous_revs(r, rev1)) \
... ) for rev1 in allrevs \
... for rev2 in allrevs)
True
# 1b. is satisfied
>>> all(implies( \
... r.normalize_rev(rev1) == r.previous_rev(rev2), \
... r.next_rev(rev1) is not None \
... ) for rev1 in allrevs \
... for rev2 in allrevs)
True
}}}
After all this being said, my proposal is to implement
`get_oldest_rev` in TracMercurial connector as follows.
{{{
#!python
def get_oldest_rev(self):
return self.normalize_rev('0')
}}}
Is this a bad idea ? Am I wrong ? Am I missing something ?
PS: I know that `previous_rev` in TracMercurial follows
the first parent and `next_rev` a single child.
Implication a -> b :
a = True, b = True, result = True
a = True, b = False, result = False
a = False, b = True, result = True
a = False, b = False, result = True
--
Regards,
Olemis.
Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/
Featured article:
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/trac-users?hl=en
-~----------~----~----~----~------~----~------~--~---