[PATCH 06 of 11] hgk: preserve working directory
Eric M. Hopper
hopper at omnifarious.org
Mon Jun 25 19:30:38 UTC 2007
On Mon, 2007-06-25 at 14:50 +0200, Markus F.X.J. Oberhumer wrote:
> # HG changeset patch
> # User Markus F.X.J. Oberhumer <markus at oberhumer.com>
> # Date 1182775580 -7200
> # Node ID 627752dddfa1b3d83363f9153b463034c3041ea5
> # Parent b8ae71e5e6bb46709df839d7e5f73d03902cea18
> hgk: preserve working directory.
>
> diff --git a/hgext/hgk.py b/hgext/hgk.py
> --- a/hgext/hgk.py
> +++ b/hgext/hgk.py
> @@ -268,11 +268,15 @@ def revlist(ui, repo, *revs, **opts):
>
> def view(ui, repo, *etc, **opts):
> "start interactive history viewer"
> - os.chdir(repo.root)
> - optstr = ' '.join(['--%s %s' % (k, v) for k, v in opts.iteritems() if v])
> - cmd = ui.config("hgk", "path", "hgk") + " %s %s" % (optstr, " ".join(etc))
> - ui.debug("running %s\n" % cmd)
> - util.system(cmd)
> + cwd = os.getcwd()
> + try:
> + os.chdir(repo.root)
> + optstr = ' '.join(['--%s %s' % (k, v) for k, v in opts.iteritems() if v])
> + cmd = ui.config("hgk", "path", "hgk") + " %s %s" % (optstr, " ".join(etc))
> + ui.debug("running %s\n" % cmd)
> + util.system(cmd)
> + finally:
> + os.chdir(cwd)
I don't know if this patch is really worth it or not, but IMHO, the
os.chdir should be wrapped in:
try:
os.chrdir(cwd)
except:
pass
Mostly to avoid having the attempt to go back to the original directory
not obscure any exception thrown from the outer try:.
--
The best we can hope for concerning the people at large is that they
be properly armed. -- Alexander Hamilton
-- Eric Hopper (hopper at omnifarious.org http://www.omnifarious.org/~hopper) --
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 185 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20070625/f79c2ed8/attachment.asc>
More information about the Mercurial-devel
mailing list