Re: [PATCH] keyword: replace map() with list comprehension
* Yuya Nishihara on Sunday, January 21, 2018 at 11:46:12 +0900 On Sat, 20 Jan 2018 14:46:49 +0100, Christian Ebert wrote: * Yuya Nishihara on Saturday, January 20, 2018 at 21:29:37 +0900 On Sat, 20 Jan 2018 12:00:00 +0100, Christian Ebert wrote: keyword: replace map() with list comprehension for what? I was under the impression that this is (considered) faster? Their performance characteristics wouldn't differ. It's rather a cosmetic issue whether to use map() or not. Personally I like map() when it can get rid of a parameter. Me too, actually. Let's leave it at that then. Thanks for the feedback. -- LAST SHIP HOME Die Weltumsegelung der Peter von Danzig Ein Film von Michael Weber und Christian Ebert --->> https://lastshiphome.de ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH] keyword: replace map() with list comprehension
* Yuya Nishihara on Saturday, January 20, 2018 at 21:29:37 +0900 On Sat, 20 Jan 2018 12:00:00 +0100, Christian Ebert wrote: # HG changeset patch # User Christian Ebert <blacktr...@gmx.net> # Date 1516442383 -3600 # Sat Jan 20 10:59:43 2018 +0100 # Node ID f1d6d72008e373c24b8057bebe999544f7a45711 # Parent 2384523cee4dcc83f67b73bf1862c68ddf1afc49 keyword: replace map() with list comprehension for what? I was under the impression that this is (considered) faster? Anyway, we're in code freeze. Please resend on February 1st. Sorry. diff --git a/hgext/keyword.py b/hgext/keyword.py --- a/hgext/keyword.py +++ b/hgext/keyword.py @@ -238,7 +238,7 @@ class kwtemplater(object): @util.propertycache def escape(self): '''Returns bar-separated and escaped keywords.''' -return '|'.join(map(re.escape, self.templates.keys())) +return '|'.join([re.escape(k) for k in self.templates.keys()]) Nit: [] isn't needed. Thanks. -- LAST SHIP HOME Die Weltumsegelung der Peter von Danzig Ein Film von Michael Weber und Christian Ebert --->> https://lastshiphome.de ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH] keyword: use context manager for rollback locking
# HG changeset patch # User Christian Ebert <blacktr...@gmx.net> # Date 1497959496 -3600 # Tue Jun 20 12:51:36 2017 +0100 # Node ID 8d47bf86d05de2bff7cd2b3abeb7ae1de66d2848 # Parent 661025fd3e1cd5d5e2dee12b7f64312d6cd48a0b keyword: use context manager for rollback locking diff --git a/hgext/keyword.py b/hgext/keyword.py --- a/hgext/keyword.py +++ b/hgext/keyword.py @@ -639,22 +639,21 @@ def reposetup(ui, repo): return n def rollback(self, dryrun=False, force=False): -wlock = self.wlock() -origrestrict = kwt.restrict -try: -if not dryrun: -changed = self['.'].files() -ret = super(kwrepo, self).rollback(dryrun, force) -if not dryrun: -ctx = self['.'] -modified, added = _preselect(ctx.status(), changed) -kwt.restrict = False -kwt.overwrite(ctx, modified, True, True) -kwt.overwrite(ctx, added, True, False) -return ret -finally: -kwt.restrict = origrestrict -wlock.release() +with self.wlock(): +origrestrict = kwt.restrict +try: +if not dryrun: +changed = self['.'].files() +ret = super(kwrepo, self).rollback(dryrun, force) +if not dryrun: +ctx = self['.'] +modified, added = _preselect(ctx.status(), changed) +kwt.restrict = False +kwt.overwrite(ctx, modified, True, True) +kwt.overwrite(ctx, added, True, False) +return ret +finally: +kwt.restrict = origrestrict # monkeypatches def kwpatchfile_init(orig, self, ui, gp, backend, store, eolmode=None): ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH] keyword: handle filectx _customcmp
# HG changeset patch # User Christian Ebert <blacktr...@gmx.net> # Date 1476718966 -7200 # Mon Oct 17 17:42:46 2016 +0200 # Node ID 94e42c8808cdd96891a9f375f02a0760670e33d8 # Parent d06c049695e6ad3219e7479c65ce98a2f123e878 keyword: handle filectx _customcmp Suggested by Yuya Nishihara: https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-October/089461.html Related to issue5364. diff --git a/hgext/keyword.py b/hgext/keyword.py --- a/hgext/keyword.py +++ b/hgext/keyword.py @@ -737,6 +737,8 @@ def reposetup(ui, repo): return ret def kwfilectx_cmp(orig, self, fctx): +if fctx._customcmp: +return fctx.cmp(self) # keyword affects data size, comparing wdir and filelog size does # not make sense if (fctx._filenode is None and ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH] keyword: handle filectx _customcmp
* Pierre-Yves David on Tuesday, October 18, 2016 at 00:27:21 +0200 > On 10/17/2016 05:52 PM, Christian Ebert wrote: >> # HG changeset patch >> # User Christian Ebert <blacktr...@gmx.net> >> # Date 1476718966 -7200 >> # Mon Oct 17 17:42:46 2016 +0200 >> # Node ID ebef6b5593fa812e907fb4dae920a0c8b2ee00a0 >> # Parent b85fa6bf298be07804a74d8fdec0d19fdbc6d740 >> keyword: handle filectx _customcmp > > I'm not sure why this is an improvement. Can you elaborate on what > this changes do and why this is the way to go ? It was suggested by Yuya: https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-October/089461.html > Adding a test case to show what it fixes would be helpful. > >> Related to issue5364. I have no scenario where this has come up. The scenario of issue5364 was caused by an outdated version of the extension. I presume it could be seen as a precaution as kwfilectx_cmp basically mimics filectx.cmp. I already admitted cluelessnees regarding the _customcmp idea, so for lack of time to dig deeper I relied on Yuya's judgement. -- Was heißt hier Dogma, ich bin Underdogma! [ What the hell do you mean dogma, I am underdogma. ] free movies --->>> https://blacktrash.org/underdogma http://itunes.apple.com/podcast/underdogma-movies/id363423596 ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH] keyword: handle filectx _customcmp
# HG changeset patch # User Christian Ebert <blacktr...@gmx.net> # Date 1476718966 -7200 # Mon Oct 17 17:42:46 2016 +0200 # Node ID ebef6b5593fa812e907fb4dae920a0c8b2ee00a0 # Parent b85fa6bf298be07804a74d8fdec0d19fdbc6d740 keyword: handle filectx _customcmp Related to issue5364. diff --git a/hgext/keyword.py b/hgext/keyword.py --- a/hgext/keyword.py +++ b/hgext/keyword.py @@ -737,6 +737,8 @@ def reposetup(ui, repo): return ret def kwfilectx_cmp(orig, self, fctx): +if fctx._customcmp: +return fctx.cmp(self) # keyword affects data size, comparing wdir and filelog size does # not make sense if (fctx._filenode is None and ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH STABLE] keyword: use fctx.filenode() instead of internal var (issue5364)
* Yuya Nishihara on Friday, September 09, 2016 at 21:50:31 +0900 > On Thu, 08 Sep 2016 17:12:34 +0100, Christian Ebert wrote: >> # HG changeset patch >> # User Christian Ebert <blacktr...@gmx.net> >> # Date 1473350741 -3600 >> # Thu Sep 08 17:05:41 2016 +0100 >> # Branch stable >> # Node ID d4f2b7b5b2e382dcc34409ddcb89b9280262c2d0 >> # Parent e7766022a61a66a7c4218526b647f96bd442a4ce >> keyword: use fctx.filenode() instead of internal var (issue5364) >> >> I caved in to the proposal to use internal _filenode variable: >> https://www.mercurial-scm.org/pipermail/mercurial-devel/2010-October/025237.html > > Ah, I got the point why internal _filenode was preferred. I think Nicolas > was right. Since kwfilectx_cmp() heavily depends on the internal of the > filectx, > using _filenode would catch more bugs. As mentioned in the bug tracker, the current version uses _filenode since 4a65c9c6cd3f, and I actually cannot repro the issue with it. >> --- a/hgext/keyword.py >> +++ b/hgext/keyword.py >> @@ -739,7 +739,7 @@ def reposetup(ui, repo): >> def kwfilectx_cmp(orig, self, fctx): > > Maybe we'll have to handle _customcmp instead? > > https://selenic.com/repo/hg/log?rev=bd19561b98d9%3A%3A7b038ec6c5fd To be honest, I can't wrap my head around that. But do you simply mean something like: diff --git a/hgext/keyword.py b/hgext/keyword.py --- a/hgext/keyword.py +++ b/hgext/keyword.py @@ -737,6 +737,8 @@ def reposetup(ui, repo): return ret def kwfilectx_cmp(orig, self, fctx): +if fctx._customcmp: +return fctx.comp(self) # keyword affects data size, comparing wdir and filelog size does # not make sense if (fctx.filenode() is None and -- theatre - books - texts - movies Black Trash Productions at home: https://blacktrash.org Black Trash Productions on Facebook: https://www.facebook.com/blacktrashproductions ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH STABLE] keyword: use fctx.filenode() instead of internal var (issue5364)
# HG changeset patch # User Christian Ebert <blacktr...@gmx.net> # Date 1473350741 -3600 # Thu Sep 08 17:05:41 2016 +0100 # Branch stable # Node ID d4f2b7b5b2e382dcc34409ddcb89b9280262c2d0 # Parent e7766022a61a66a7c4218526b647f96bd442a4ce keyword: use fctx.filenode() instead of internal var (issue5364) I caved in to the proposal to use internal _filenode variable: https://www.mercurial-scm.org/pipermail/mercurial-devel/2010-October/025237.html Use the exposed filenode() function instead. diff --git a/hgext/keyword.py b/hgext/keyword.py --- a/hgext/keyword.py +++ b/hgext/keyword.py @@ -739,7 +739,7 @@ def reposetup(ui, repo): def kwfilectx_cmp(orig, self, fctx): # keyword affects data size, comparing wdir and filelog size does # not make sense -if (fctx._filenode is None and +if (fctx.filenode() is None and (self._repo._encodefilterpats or kwt.match(fctx.path()) and 'l' not in fctx.flags() or self.size() - 4 == fctx.size()) or ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel