Re: [StGIT PATCH 3/5] Create a git.Branch class as ancestor of stack.Stack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2008-06-06 09:44:37 +0100, Catalin Marinas wrote:

> 2008/6/5 Karl Hasselström <kha@xxxxxxxxxxx>:
>
> > We'll have to be watchful against attempts to create objects other
> > than via the officially designated factories, though. Python
> > doesn't really have any mechanisms that help us here.
>
> Doesn't need to be enforced. The Stack and Branch objects can be
> initialised by themselves provided that the repository is passed as
> argument at construction. The factory is more for convenience,
> passing the repository to the newly created object.

Those classes cache stuff. So if you have, say, two PatchOrder objects
representing the same underlying files, an update in one will not be
reflected in the other. An important role of the factory is to make
sure that if an object is asked for twice, the _same_ object is
returned to both callers.

The Commit, Tree, and Blob objects produced by Repository are another
example where we rely on there being no more than one Python object
representing the same underlying data.

> If you really want enforcing this, it can probably be done by
> hacking __new__ and __init__.

No, I reckon you're right -- it's overkill. StGit is small enough that
we can probably enforce the relevant restrictions by hand.

-- 
Karl Hasselström, kha@xxxxxxxxxxx
      www.treskal.com/kalle
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux