[PATCH hglib] Modified package level init and clone functions to returned an UnopenedClient
Matt Mackall
mpm at selenic.com
Mon Nov 28 17:47:42 CST 2011
On Mon, 2011-11-28 at 11:09 -0500, Jeff Laughlin wrote:
> # HG changeset patch
> # User Jeff Laughlin <jmlaughlin at integrated-informatics.com>
> # Date 1322062528 18000
> # Node ID 90a6c77789f844165a5215d6c0904286f89f26d5
> # Parent 8d491607b3eeb83be001137fd9406f68f935b2dc
> Modified package level init and clone functions to returned an UnopenedClient
> object with a single open method. This permits the user to decide if they want
> to open the repository following an init or clone by simply chaining the open
> call, e.g. "hglib.init()" or "client = hglib.init().open()".
>
> diff -r 8d491607b3ee -r 90a6c77789f8 hglib/__init__.py
> --- a/hglib/__init__.py Wed Nov 23 10:27:57 2011 -0500
> +++ b/hglib/__init__.py Wed Nov 23 10:35:28 2011 -0500
> @@ -8,6 +8,20 @@
> similar to those passed to hg --config. '''
> return client.hgclient(path, encoding, configs)
>
> +_open = open
> +
> +class UnopenedClient(object):
> + def __init__(self, path=None, encoding=None, configs=None):
> + self.path = path
> + self.encoding = encoding
> + self.configs = configs
> +
> + def open(self, path=None, encoding=None, configs=None):
> + if path is None: path = self.path
> + if encoding is None: encoding = self.encoding
> + if configs is None: configs = self.configs
> + return _open(path=path, encoding=encoding, configs=configs)
What's the use case for having a different set of path/encoding/configs
on open vs clone/init? Path in particular seems highly suspect.
ps: we really like newlines after colons in if statements.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list