[Yum-devel] [PATCH 2/5] Remove unnecessary "magic number" test

seth vidal skvidal at fedoraproject.org
Thu Feb 24 17:31:15 UTC 2011


On Thu, 2011-02-24 at 19:29 +0200, Panu Matilainen wrote:
> On 02/24/2011 07:00 PM, seth vidal wrote:
> > On Thu, 2011-02-24 at 18:20 +0200, Panu Matilainen wrote:
> >> On 02/24/2011 06:06 PM, seth vidal wrote:
> >>> On Thu, 2011-02-24 at 11:18 +0200, Panu Matilainen wrote:
> >>>> RPMCALLBACK_TRANS_START is only issued once. That "bytes" happens
> >>>> to be a magic value of 6 is just an artifact of truly ancient rpm
> >>>> versions from last century issuing RPMCALLBACK_TRANS_START more than once.
> >>>> ---
> >>>>    yum/rpmtrans.py |    9 ++++-----
> >>>>    1 files changed, 4 insertions(+), 5 deletions(-)
> >>>>
> >>>> diff --git a/yum/rpmtrans.py b/yum/rpmtrans.py
> >>>> index 06b484a..30c9dd3 100644
> >>>> --- a/yum/rpmtrans.py
> >>>> +++ b/yum/rpmtrans.py
> >>>> @@ -402,11 +402,10 @@ class RPMTransaction:
> >>>>
> >>>>
> >>>>        def _transStart(self, bytes, total, h):
> >>>> -        if bytes == 6:
> >>>> -            self.total_actions = total
> >>>> -            if self.test: return
> >>>> -            self.trans_running = True
> >>>> -            self.ts_all() # write out what transaction will do
> >>>> +        self.total_actions = total
> >>>> +        if self.test: return
> >>>> +        self.trans_running = True
> >>>> +        self.ts_all() # write out what transaction will do
> >>>>
> >>>>        def _transProgress(self, bytes, total, h):
> >>>>            pass
> >>>
> >>>
> >>> Obviously not THAT ancient, it was added around about rhel 5.0/5.1 era.
> >>>
> >>> What version of rpm are we talking about here?
> >>
> >>    From what I searched rpm git archive, the multiple calls to
> >> RPMCALLBACK_TRANS_START were eliminated in late nineties, so that'd be
> >> rpm 3.x or thereabouts. Certainly rpm 4.4.x only ever calls it once. I
> >> know the test appeared in yum in 2007 with the introduction of
> >> rpmtrans.py, but I just wonder where the heck did it come from :)
> >
> > I have a memory of running into it in rhel4.
> 
> I just fail to see how that could happen (staring at RHEL 4 rpm version 
> right now). There's precisely one place which issues 
> RPMCALLBACK_TRANS_START and it's not in a loop or other construct that 
> /could/ get called multiple times. I double-checked git history and the 
> last place where it would get called with different values of "bytes" 
> got axed in 1999.
> 
> The point here is that RPMCALLBACK_TRANS_START getting called with a 
> "magic" value of 6 in bytes is just a silly artifact from ancient times 
> which has no meaning whatsoever within rpm or otherwise, and 
> unnecessarily checking for it prevents ever changing it to anything else 
> that might more sense (not that I have any immediate plans or reason to 
> change it).
> 


I think I remember why I remember it in that time frame.

I think I remember it in that time frame b/c of someone running into it
on suse.

So - if you're confident we're not going to hit it - that's fine - take
it out.

it was always a fun artifact of the rpmcallback oddness, though. :)

-sv





More information about the Yum-devel mailing list