Largefiles - moving basestore._openstore somewhere else

Yuya Nishihara yuya at tcha.org
Thu May 5 03:53:38 EDT 2016


On Wed, 4 May 2016 16:47:17 +0200, Piotr Listkiewicz wrote:
> Function basestore._openstore causes cyclic references:
> basestore -> localstore -> basestore
> basestore -> wirestore -> basestore
> 
> Function _openstore cant be moved to lfutil because it is used in
> localstore and wirestore modules. Other place where function could be moved
> is lfcommands and it does not cause cyclic reference, but IMHO this place
> doesn't seem right.
> 
> Its probable that this function should be moved to new module, but i have
> no idea what abstraction this module can represent beside containing this
> function.
> 
> Im looking forward for ideas whats the best way to resolve this.

Two other ideas came to me:

a) move utility functions to basestore or storeutil, and move the factory to
   lfutil

% grep 'lfutil\.' hgext/largefiles/*store.py
hgext/largefiles/basestore.py:        util.makedirs(lfutil.storepath(self.repo, ''))
hgext/largefiles/basestore.py:        storefilename = lfutil.storepath(self.repo, hash)
hgext/largefiles/basestore.py:        lfutil.linktousercache(self.repo, hash)
hgext/largefiles/basestore.py:                filename = lfutil.splitstandin(standin)
hgext/largefiles/basestore.py:        except lfutil.storeprotonotcapable:
hgext/largefiles/localstore.py:        if lfutil.instore(self.remote, hash):
hgext/largefiles/localstore.py:        lfutil.link(source, lfutil.storepath(self.remote, hash))
hgext/largefiles/localstore.py:            retval[hash] = lfutil.instore(self.remote, hash)
hgext/largefiles/localstore.py:        path = lfutil.findfile(self.remote, hash)
hgext/largefiles/localstore.py:            return lfutil.copyandhash(fd, tmpfile)
hgext/largefiles/localstore.py:            storepath, exists = lfutil.findstorepath(self.remote, expectedhash)
hgext/largefiles/localstore.py:                actualhash = lfutil.hashfile(storepath)
hgext/largefiles/remotestore.py:            fd = lfutil.httpsendfile(self.ui, filename)
hgext/largefiles/remotestore.py:        return lfutil.copyandhash(chunks, tmpfile)
hgext/largefiles/wirestore.py:            raise lfutil.storeprotonotcapable([])
hgext/largefiles/wirestore.py:            raise lfutil.storeprotonotcapable(storetypes)

b) merge *store.py as they are small

% wc -l hgext/largefiles/*store.py
  226 hgext/largefiles/basestore.py
   61 hgext/largefiles/localstore.py
  108 hgext/largefiles/remotestore.py
   36 hgext/largefiles/wirestore.py
  431 total


More information about the Mercurial-devel mailing list