Re: [PATCH 05 of 12 topics] flake8: fix W503 style
On Tue, 30 Aug 2016 20:58:11 -0700 Sean Farleywrote: > # HG changeset patch > # User Sean Farley > # Date 1472595240 25200 > # Tue Aug 30 15:14:00 2016 -0700 > # Node ID 752a62b50ba31b768c52c6b423cd1a36d0c6eae2 > # Parent 8f1e18702ba107ffcb35be04dc8a1e650e5c1e7f > # EXP-Topic flake8 > flake8: fix W503 style > > diff --git a/hgext3rd/topic/destination.py b/hgext3rd/topic/destination.py > --- a/hgext3rd/topic/destination.py > +++ b/hgext3rd/topic/destination.py > @@ -72,12 +72,12 @@ def _destupdatetopic(repo, clean, check) > if bookmarks.isactivewdirparent(repo): > movemark = repo['.'].node() > return node, movemark, None > > def desthistedit(orig, ui, repo): > -if not (ui.config('histedit', 'defaultrev', None) is None > -and repo.currenttopic): > +if not (ui.config('histedit', 'defaultrev', None) is None and > +repo.currenttopic): > return orig(ui, repo) > revs = repo.revs('::. and stack()') > if revs: > return revs.min() > return None > @@ -104,13 +104,13 @@ def modsetup(ui): > extensions.wrapfunction(destutil, '_destmergebranch', > _destmergebranch) > try: > rebase = extensions.find('rebase') > except KeyError: > rebase = None > -if (util.safehasattr(rebase, '_destrebase') > +if (util.safehasattr(rebase, '_destrebase') and > # logic not shared with merge yet < hg-3.8 > -and not util.safehasattr(rebase, '_definesets')): > +not util.safehasattr(rebase, '_definesets')): > extensions.wrapfunction(rebase, '_destrebase', _destmergebranch) > if util.safehasattr(destutil, 'destupdatesteps'): > bridx = destutil.destupdatesteps.index('branch') > destutil.destupdatesteps.insert(bridx, 'topic') > destutil.destupdatestepmap['topic'] = _destupdatetopic > diff --git a/hgext3rd/topic/discovery.py b/hgext3rd/topic/discovery.py > --- a/hgext3rd/topic/discovery.py > +++ b/hgext3rd/topic/discovery.py > @@ -14,12 +14,12 @@ from mercurial import ( > ) > > from . import topicmap > > def _headssummary(orig, repo, remote, outgoing): > -publishing = ('phases' not in remote.listkeys('namespaces') > - or bool(remote.listkeys('phases').get('publishing', > False))) > +publishing = ('phases' not in remote.listkeys('namespaces') or > + bool(remote.listkeys('phases').get('publishing', False))) > if publishing or not remote.capable('topics'): > return orig(repo, remote, outgoing) > oldrepo = repo.__class__ > oldbranchcache = branchmap.branchcache > oldfilename = branchmap._filename > diff --git a/hgext3rd/topic/topicmap.py b/hgext3rd/topic/topicmap.py > --- a/hgext3rd/topic/topicmap.py > +++ b/hgext3rd/topic/topicmap.py > @@ -124,12 +124,12 @@ class topiccache(oldbranchcache): > try: > if (self.tipnode == repo.changelog.node(self.tiprev)): > fh = scmutil.filteredhash(repo, self.tiprev) > if fh is None: > fh = nullid > -if ((self.filteredhash == fh) > -and (self.phaseshash == _phaseshash(repo, self.tiprev))): > +if ((self.filteredhash == fh) and > +(self.phaseshash == _phaseshash(repo, self.tiprev))): > return True > return False > except IndexError: > return False > > diff --git a/setup.cfg b/setup.cfg > --- a/setup.cfg > +++ b/setup.cfg > @@ -1,2 +1,2 @@ > [flake8] > -ignore = E261, E266, E302, E129, E731, E124, E713, E301, E501, E111, E123, > E222, W503 > +ignore = E261, E266, E302, E129, E731, E124, E713, E301, E501, E111, E123, > E222 W503 is actually disabled in pep8/pycodestyle by default [0], because the PEP is kinda on the fence about it [1]. [0] https://pep8.readthedocs.io/en/latest/intro.html#error-codes [1] https://www.python.org/dev/peps/pep-0008/#should-a-line-break-before-or-after-a-binary-operator ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 09 of 12 topics] flake8: fix E501 style
On Tue, 30 Aug 2016 20:58:15 -0700 Sean Farleywrote: > diff --git a/hgext3rd/topic/evolvebits.py b/hgext3rd/topic/evolvebits.py > --- a/hgext3rd/topic/evolvebits.py > +++ b/hgext3rd/topic/evolvebits.py > @@ -40,14 +40,13 @@ def _orderrevs(repo, revs): > > def builddependencies(repo, revs): > """returns dependency graphs giving an order to solve instability of revs > (see _orderrevs for more information on usage)""" > > -# For each troubled revision we keep track of what instability if any > should > -# be resolved in order to resolve it. Example: > -# dependencies = {3: [6], 6:[]} > -# Means that: 6 has no dependency, 3 depends on 6 to be solved > +# For each troubled revision we keep track of what instability if any > +# should be resolved in order to resolve it. Example: dependencies = {3: > +# [6], 6:[]} Means that: 6 has no dependency, 3 depends on 6 to be solved > dependencies = {} > # rdependencies is the inverted dict of dependencies > rdependencies = collections.defaultdict(set) I would say line breaks in the original version help readability. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 8 of 8 v2] help: mark boolean flags with a ^ and explain that they can be negated (RFC)
In principle you shouldn't use multi occur to guard this. if multioccur: -header += (_(" ([+] can be repeated)")) +m = _( +" ([+] can be repeated, flags marked ^ can be negated with --no-)") +header += (m) It's too hard for me you write the correct logic (you can use a set and dictionary). ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 12 of 12 topics] flake8: fix E124 style
Sean Farleywrites: > # HG changeset patch > # User Sean Farley > # Date 1472595848 25200 > # Tue Aug 30 15:24:08 2016 -0700 > # Node ID c0064f048058b35713d7262b578a7fa5e216f195 > # Parent b579ff9e41931a26ded12b409925d0fa40d9b05d > # EXP-Topic flake8 > flake8: fix E124 style This patch series is meant as a take-the-rules-you-want (so if you want to keep ignoring E124, just drop this patch). I hope some are taken because I like clean code. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 09 of 12 topics] flake8: fix E501 style
# HG changeset patch # User Sean Farley# Date 1472595675 25200 # Tue Aug 30 15:21:15 2016 -0700 # Node ID 4f3c71461d1b799bb26a4409d22eb6a458cb9d44 # Parent fbceb43849d91459925dabb8c5f1683744ec320b # EXP-Topic flake8 flake8: fix E501 style My favorite of them all. diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py +++ b/hgext3rd/topic/__init__.py @@ -174,11 +174,12 @@ def reposetup(ui, repo): def destroyed(self, *args, **kwargs): with topicmap.usetopicmap(self): return super(topicrepo, self).destroyed(*args, **kwargs) def invalidatevolatilesets(self): -# XXX we might be able to move this to something invalidated less often +# XXX we might be able to move this to something invalidated less +# often super(topicrepo, self).invalidatevolatilesets() self._topics = None if '_topiccaches' in vars(self.unfiltered()): self.unfiltered()._topiccaches.clear() @@ -217,11 +218,12 @@ def topics(ui, repo, topic='', clear=Fal if change: if not obsolete.isenabled(repo, obsolete.createmarkersopt): raise error.Abort(_('must have obsolete enabled to use --change')) if not topic and not clear: -raise error.Abort('changing topic requires a topic name or --clear') +raise error.Abort('changing topic requires a topic name or ' + '--clear') if any(not c.mutable() for c in repo.set('%r and public()', change)): raise error.Abort("can't change topic of a public change") rewrote = 0 needevolve = False l = repo.lock() @@ -321,11 +323,12 @@ def _listtopics(ui, repo, opts): if ui.verbose: # XXX we should include the data even when not verbose data = stack.stackdata(repo, topic) fm.plain(' (') fm.write('branches+', 'on branch: %s', - '+'.join(data['branches']), # XXX use list directly after 4.0 is released + # XXX use list directly after 4.0 is released + '+'.join(data['branches']), label='topic.list.branches') fm.plain(', ') fm.write('changesetcount', '%d changesets', data['changesetcount'], label='topic.list.changesetcount') if data['troubledcount']: diff --git a/hgext3rd/topic/evolvebits.py b/hgext3rd/topic/evolvebits.py --- a/hgext3rd/topic/evolvebits.py +++ b/hgext3rd/topic/evolvebits.py @@ -40,14 +40,13 @@ def _orderrevs(repo, revs): def builddependencies(repo, revs): """returns dependency graphs giving an order to solve instability of revs (see _orderrevs for more information on usage)""" -# For each troubled revision we keep track of what instability if any should -# be resolved in order to resolve it. Example: -# dependencies = {3: [6], 6:[]} -# Means that: 6 has no dependency, 3 depends on 6 to be solved +# For each troubled revision we keep track of what instability if any +# should be resolved in order to resolve it. Example: dependencies = {3: +# [6], 6:[]} Means that: 6 has no dependency, 3 depends on 6 to be solved dependencies = {} # rdependencies is the inverted dict of dependencies rdependencies = collections.defaultdict(set) for r in revs: diff --git a/hgext3rd/topic/stack.py b/hgext3rd/topic/stack.py --- a/hgext3rd/topic/stack.py +++ b/hgext3rd/topic/stack.py @@ -38,14 +38,16 @@ def showstack(ui, repo, topic, opts): fm.plain(_('### branch: %s') % '+'.join(data['branches']), # XXX handle multi branches label='topic.stack.summary.branches') if data['behindcount'] == -1: fm.plain(', ') -fm.plain('ambigious rebase destination', label='topic.stack.summary.behinderror') +fm.plain('ambigious rebase destination', + label='topic.stack.summary.behinderror') elif data['behindcount']: fm.plain(', ') -fm.plain('%d behind' % data['behindcount'], label='topic.stack.summary.behindcount') +fm.plain('%d behind' % data['behindcount'], + label='topic.stack.summary.behindcount') fm.plain('\n') for idx, r in enumerate(getstack(repo, topic), 1): ctx = repo[r] p1 = ctx.p1() diff --git a/setup.cfg b/setup.cfg --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ [flake8] -ignore = E261, E266, E302, E129, E731, E124, E713, E301, E501 +ignore = E261, E266, E302, E129, E731, E124, E713, E301 ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 11 of 12 topics] flake8: fix E713 style
# HG changeset patch # User Sean Farley# Date 1472595783 25200 # Tue Aug 30 15:23:03 2016 -0700 # Node ID b579ff9e41931a26ded12b409925d0fa40d9b05d # Parent b4d2daf39a825e02d0afcd62471b1e6c2d6b2b84 # EXP-Topic flake8 flake8: fix E713 style diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py +++ b/hgext3rd/topic/__init__.py @@ -82,11 +82,11 @@ def _namemap(repo, name): r = revs[idx - 1] except IndexError: msg = _('cannot resolve "%s": topic "%s" has only %d changesets') raise error.Abort(msg % (name, topic, len(revs))) return [repo[r].node()] -if not name in repo.topics: +if name not in repo.topics: return [] return [ctx.node() for ctx in repo.set('not public() and extra(topic, %s)', name)] def _nodemap(repo, node): diff --git a/setup.cfg b/setup.cfg --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ [flake8] -ignore = E261, E266, E302, E129, E731, E124, E713 +ignore = E261, E266, E302, E129, E731, E124 ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 10 of 12 topics] flake8: fix E301 style
# HG changeset patch # User Sean Farley# Date 1472595744 25200 # Tue Aug 30 15:22:24 2016 -0700 # Node ID b4d2daf39a825e02d0afcd62471b1e6c2d6b2b84 # Parent 4f3c71461d1b799bb26a4409d22eb6a458cb9d44 # EXP-Topic flake8 flake8: fix E301 style diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py +++ b/hgext3rd/topic/__init__.py @@ -116,10 +116,11 @@ def uisetup(ui): def reposetup(ui, repo): orig = repo.__class__ if not isinstance(repo, localrepo.localrepository): return # this can be a peer in the ssh case (puzzling) + class topicrepo(repo.__class__): def _restrictcapabilities(self, caps): caps = super(topicrepo, self)._restrictcapabilities(caps) caps.add('topics') diff --git a/setup.cfg b/setup.cfg --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ [flake8] -ignore = E261, E266, E302, E129, E731, E124, E713, E301 +ignore = E261, E266, E302, E129, E731, E124, E713 ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 04 of 12 topics] flake8: fix W391 style
# HG changeset patch # User Sean Farley# Date 1472591569 25200 # Tue Aug 30 14:12:49 2016 -0700 # Node ID 8f1e18702ba107ffcb35be04dc8a1e650e5c1e7f # Parent a6f4b32f655ba895875640534b051c5ebe632695 # EXP-Topic flake8 flake8: fix W391 style diff --git a/hgext3rd/topic/stack.py b/hgext3rd/topic/stack.py --- a/hgext3rd/topic/stack.py +++ b/hgext3rd/topic/stack.py @@ -117,6 +117,5 @@ def stackdata(repo, topic): except error.ManyMergeDestAbort: data['behindcount'] = -1 data['branches'] = sorted(set(repo[r].branch() for r in revs)) return data - diff --git a/setup.cfg b/setup.cfg --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ [flake8] -ignore = E261, E266, E302, E129, E731, E124, E713, E301, E501, E111, E123, E222, W503, W391 +ignore = E261, E266, E302, E129, E731, E124, E713, E301, E501, E111, E123, E222, W503 ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 02 of 12 topics] tests: add flake8 check
# HG changeset patch # User Sean Farley# Date 1472591136 25200 # Tue Aug 30 14:05:36 2016 -0700 # Node ID 78dd9f1db1b1cf5a869e1240bb4ed523e930c907 # Parent 103df0c9da1af239431530cd44eec1826d411f0a # EXP-Topic flake8 tests: add flake8 check This test will hopefully help prevent style errors. To be determined: which errors / warnings to ignore? diff --git a/tests/test-check-pyflakes.t b/tests/test-check-pyflakes.t --- a/tests/test-check-pyflakes.t +++ b/tests/test-check-pyflakes.t @@ -8,5 +8,8 @@ run pyflakes on all tracked files ending (skipping binary file random-seed) $ hg locate 'set:**.py or grep("^!#.*python")' 2>/dev/null \ > | xargs pyflakes 2>/dev/null +run flake8 if it exists; if it doesn't, then just skip + + $ type flake8 >/dev/null 2>/dev/null && hg files -0 'glob:**.py' | xargs -0 flake8 || true ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 08 of 12 topics] flake8: fix E111 style
# HG changeset patch # User Sean Farley# Date 1472595523 25200 # Tue Aug 30 15:18:43 2016 -0700 # Node ID fbceb43849d91459925dabb8c5f1683744ec320b # Parent 8eb5de0920f5dce2fbf4d511b73ea6bcc7d6fe8e # EXP-Topic flake8 flake8: fix E111 style OFF BY ONE ERRORS ARE THE WORST diff --git a/hgext3rd/topic/destination.py b/hgext3rd/topic/destination.py --- a/hgext3rd/topic/destination.py +++ b/hgext3rd/topic/destination.py @@ -13,15 +13,15 @@ from .evolvebits import builddependencie def _destmergebranch(orig, repo, action='merge', sourceset=None, onheadcheck=True, destspace=None): # XXX: take destspace into account if sourceset is None: - p1 = repo['.'] +p1 = repo['.'] else: # XXX: using only the max here is flacky. That code should eventually # be updated to take care of the whole sourceset. - p1 = repo[max(sourceset)] +p1 = repo[max(sourceset)] top = p1.topic() if top: revs = repo.revs('topic(%s) - obsolete()', top) deps, rdeps = builddependencies(repo, revs) heads = [r for r in revs if not rdeps[r]] diff --git a/setup.cfg b/setup.cfg --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ [flake8] -ignore = E261, E266, E302, E129, E731, E124, E713, E301, E501, E111 +ignore = E261, E266, E302, E129, E731, E124, E713, E301, E501 ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 05 of 12 topics] flake8: fix W503 style
# HG changeset patch # User Sean Farley# Date 1472595240 25200 # Tue Aug 30 15:14:00 2016 -0700 # Node ID 752a62b50ba31b768c52c6b423cd1a36d0c6eae2 # Parent 8f1e18702ba107ffcb35be04dc8a1e650e5c1e7f # EXP-Topic flake8 flake8: fix W503 style diff --git a/hgext3rd/topic/destination.py b/hgext3rd/topic/destination.py --- a/hgext3rd/topic/destination.py +++ b/hgext3rd/topic/destination.py @@ -72,12 +72,12 @@ def _destupdatetopic(repo, clean, check) if bookmarks.isactivewdirparent(repo): movemark = repo['.'].node() return node, movemark, None def desthistedit(orig, ui, repo): -if not (ui.config('histedit', 'defaultrev', None) is None -and repo.currenttopic): +if not (ui.config('histedit', 'defaultrev', None) is None and +repo.currenttopic): return orig(ui, repo) revs = repo.revs('::. and stack()') if revs: return revs.min() return None @@ -104,13 +104,13 @@ def modsetup(ui): extensions.wrapfunction(destutil, '_destmergebranch', _destmergebranch) try: rebase = extensions.find('rebase') except KeyError: rebase = None -if (util.safehasattr(rebase, '_destrebase') +if (util.safehasattr(rebase, '_destrebase') and # logic not shared with merge yet < hg-3.8 -and not util.safehasattr(rebase, '_definesets')): +not util.safehasattr(rebase, '_definesets')): extensions.wrapfunction(rebase, '_destrebase', _destmergebranch) if util.safehasattr(destutil, 'destupdatesteps'): bridx = destutil.destupdatesteps.index('branch') destutil.destupdatesteps.insert(bridx, 'topic') destutil.destupdatestepmap['topic'] = _destupdatetopic diff --git a/hgext3rd/topic/discovery.py b/hgext3rd/topic/discovery.py --- a/hgext3rd/topic/discovery.py +++ b/hgext3rd/topic/discovery.py @@ -14,12 +14,12 @@ from mercurial import ( ) from . import topicmap def _headssummary(orig, repo, remote, outgoing): -publishing = ('phases' not in remote.listkeys('namespaces') - or bool(remote.listkeys('phases').get('publishing', False))) +publishing = ('phases' not in remote.listkeys('namespaces') or + bool(remote.listkeys('phases').get('publishing', False))) if publishing or not remote.capable('topics'): return orig(repo, remote, outgoing) oldrepo = repo.__class__ oldbranchcache = branchmap.branchcache oldfilename = branchmap._filename diff --git a/hgext3rd/topic/topicmap.py b/hgext3rd/topic/topicmap.py --- a/hgext3rd/topic/topicmap.py +++ b/hgext3rd/topic/topicmap.py @@ -124,12 +124,12 @@ class topiccache(oldbranchcache): try: if (self.tipnode == repo.changelog.node(self.tiprev)): fh = scmutil.filteredhash(repo, self.tiprev) if fh is None: fh = nullid -if ((self.filteredhash == fh) -and (self.phaseshash == _phaseshash(repo, self.tiprev))): +if ((self.filteredhash == fh) and +(self.phaseshash == _phaseshash(repo, self.tiprev))): return True return False except IndexError: return False diff --git a/setup.cfg b/setup.cfg --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ [flake8] -ignore = E261, E266, E302, E129, E731, E124, E713, E301, E501, E111, E123, E222, W503 +ignore = E261, E266, E302, E129, E731, E124, E713, E301, E501, E111, E123, E222 ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 07 of 12 topics] flake8: fix E123 style
# HG changeset patch # User Sean Farley# Date 1472595476 25200 # Tue Aug 30 15:17:56 2016 -0700 # Node ID 8eb5de0920f5dce2fbf4d511b73ea6bcc7d6fe8e # Parent e32ae663d1dcbcd21bcce74e58ddfdf8dcc7368c # EXP-Topic flake8 flake8: fix E123 style diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py +++ b/hgext3rd/topic/__init__.py @@ -201,11 +201,11 @@ def reposetup(ui, repo): @command('topics [TOPIC]', [ ('', 'clear', False, 'clear active topic if any'), ('', 'change', '', 'revset of existing revisions to change topic'), ('l', 'list', False, 'show the stack of changeset in the topic'), -] + commands.formatteropts) +] + commands.formatteropts) def topics(ui, repo, topic='', clear=False, change=None, list=False, **opts): """View current topic, set current topic, or see all topics.""" if list: if clear or change: raise error.Abort(_("cannot use --clear or --change with --list")) diff --git a/setup.cfg b/setup.cfg --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ [flake8] -ignore = E261, E266, E302, E129, E731, E124, E713, E301, E501, E111, E123 +ignore = E261, E266, E302, E129, E731, E124, E713, E301, E501, E111 ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 06 of 12 topics] flake8: fix E222 style
# HG changeset patch # User Sean Farley# Date 1472595305 25200 # Tue Aug 30 15:15:05 2016 -0700 # Node ID e32ae663d1dcbcd21bcce74e58ddfdf8dcc7368c # Parent 752a62b50ba31b768c52c6b423cd1a36d0c6eae2 # EXP-Topic flake8 flake8: fix E222 style diff --git a/hgext3rd/topic/destination.py b/hgext3rd/topic/destination.py --- a/hgext3rd/topic/destination.py +++ b/hgext3rd/topic/destination.py @@ -17,11 +17,11 @@ def _destmergebranch(orig, repo, action= if sourceset is None: p1 = repo['.'] else: # XXX: using only the max here is flacky. That code should eventually # be updated to take care of the whole sourceset. - p1 = repo[max(sourceset)] + p1 = repo[max(sourceset)] top = p1.topic() if top: revs = repo.revs('topic(%s) - obsolete()', top) deps, rdeps = builddependencies(repo, revs) heads = [r for r in revs if not rdeps[r]] diff --git a/setup.cfg b/setup.cfg --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ [flake8] -ignore = E261, E266, E302, E129, E731, E124, E713, E301, E501, E111, E123, E222 +ignore = E261, E266, E302, E129, E731, E124, E713, E301, E501, E111, E123 ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 03 of 12 topics] flake8: fix E127 style
# HG changeset patch # User Sean Farley# Date 1472591416 25200 # Tue Aug 30 14:10:16 2016 -0700 # Node ID a6f4b32f655ba895875640534b051c5ebe632695 # Parent 78dd9f1db1b1cf5a869e1240bb4ed523e930c907 # EXP-Topic flake8 flake8: fix E127 style diff --git a/hgext3rd/topic/topicmap.py b/hgext3rd/topic/topicmap.py --- a/hgext3rd/topic/topicmap.py +++ b/hgext3rd/topic/topicmap.py @@ -125,11 +125,11 @@ class topiccache(oldbranchcache): if (self.tipnode == repo.changelog.node(self.tiprev)): fh = scmutil.filteredhash(repo, self.tiprev) if fh is None: fh = nullid if ((self.filteredhash == fh) - and (self.phaseshash == _phaseshash(repo, self.tiprev))): +and (self.phaseshash == _phaseshash(repo, self.tiprev))): return True return False except IndexError: return False diff --git a/setup.cfg b/setup.cfg --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ [flake8] -ignore = E261, E266, E302, E129, E731, E124, E713, E301, E501, E111, E123, E222, W503, W391, E127 +ignore = E261, E266, E302, E129, E731, E124, E713, E301, E501, E111, E123, E222, W503, W391 ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 1 of 4] manifest: add treemanifestctx class
# HG changeset patch # User Durham Goode# Date 1472518307 25200 # Mon Aug 29 17:51:47 2016 -0700 # Node ID a6f968072eb72212bf8e16fb74114654aca98330 # Parent 318e2b600b80e4ed3c6f37df46ec7544f60d4c0b manifest: add treemanifestctx class Before we start using repo.manifestlog in the rest of the code base, we need to make sure that it's capable of returning treemanifests. As we add new functionality to manifestctx, we'll add it to treemanifestctx at the same time. diff --git a/mercurial/manifest.py b/mercurial/manifest.py --- a/mercurial/manifest.py +++ b/mercurial/manifest.py @@ -944,21 +944,24 @@ class manifestlog(object): """Retrieves the manifest instance for the given node. Throws a KeyError if not found. """ -if (self._oldmanifest._treeondisk -or self._oldmanifest._treeinmem): -# TODO: come back and support tree manifests directly -return self._oldmanifest.read(node) +if node == revlog.nullid: +if self._oldmanifest._treeinmem: +return treemanifest() +else: +return manifestdict() -if node == revlog.nullid: -return manifestdict() if node in self._mancache: cachemf = self._mancache[node] # The old manifest may put non-ctx manifests in the cache, so skip # those since they don't implement the full api. -if isinstance(cachemf, manifestctx): +if (isinstance(cachemf, manifestctx) or +isinstance(cachemf, treemanifestctx)): return cachemf -m = manifestctx(self._revlog, node) +if self._oldmanifest._treeinmem: +m = treemanifestctx(self._revlog, node, dir='') +else: +m = manifestctx(self._revlog, node) self._mancache[node] = m return m @@ -984,6 +987,35 @@ class manifestctx(manifestdict): def node(self): return self._node +class treemanifestctx(treemanifest): +def __init__(self, revlog, node, dir=''): +revlog = revlog.dirlog(dir) +self._revlog = revlog +self._dir = dir + +self._node = node + +# TODO: Load p1/p2/linkrev lazily. They need to be lazily loaded so that +# we can instantiate treemanifestctx objects for directories we don't +# have on disk. +#self.p1, self.p2 = revlog.parents(node) +#rev = revlog.rev(node) +#self.linkrev = revlog.linkrev(rev) + +if revlog._treeondisk: +super(treemanifestctx, self).__init__(dir=dir) +def gettext(): +return revlog.revision(node) +def readsubtree(dir, subm): +return revlog.dirlog(dir).read(subm) +self.read(gettext, readsubtree) +self.setnode(node) +else: +data = revlog.revision(node) +arraytext = array.array('c', data) +revlog.fulltextcache[node] = arraytext +super(treemanifestctx, self).__init__(dir=dir, text=data) + class manifest(manifestrevlog): def __init__(self, opener, dir='', dirlogcache=None): '''The 'dir' and 'dirlogcache' arguments are for internal use by ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 4 of 4] manifest: change manifestctx to not inherit from manifestdict
# HG changeset patch # User Durham Goode# Date 1472519937 25200 # Mon Aug 29 18:18:57 2016 -0700 # Node ID 8076d529408e977951286dbd58e81066f97a9b8d # Parent 4b26b5cd815a717ee0ee930f4deef0959ef7c492 manifest: change manifestctx to not inherit from manifestdict If manifestctx inherits from manifestdict, it requires some weird logic to lazily load the dict if a piece of information is asked for. This ended up being complicated and unintuitive to use. Let's move the dict creation to .read(). This will make even more sense once we start adding readdelta() and other similar methods to manifestctx. diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -528,7 +528,7 @@ class changectx(basectx): @propertycache def _manifest(self): -return self._repo.manifestlog[self._changeset.manifest] +return self._repo.manifestlog[self._changeset.manifest].read() @propertycache def _manifestdelta(self): diff --git a/mercurial/manifest.py b/mercurial/manifest.py --- a/mercurial/manifest.py +++ b/mercurial/manifest.py @@ -948,9 +948,9 @@ class manifestlog(object): """ if node == revlog.nullid: if self._oldmanifest._treeinmem: -return treemanifest() +return treemanifestctx(self._revlog, node, dir='') else: -return manifestdict() +return manifestctx(self._revlog, node) if node in self._mancache: cachemf = self._mancache[node] @@ -967,33 +967,38 @@ class manifestlog(object): self._mancache[node] = m return m -class manifestctx(manifestdict): +class manifestctx(object): """A class representing a single revision of a manifest, including its contents, its parent revs, and its linkrev. """ def __init__(self, revlog, node): self._revlog = revlog +self._data = None self._node = node self.p1, self.p2 = revlog.parents(node) rev = revlog.rev(node) self.linkrev = revlog.linkrev(rev) -# This should eventually be made lazy loaded, so consumers can access -# the node/p1/linkrev data without having to parse the whole manifest. -data = revlog.revision(node) -arraytext = array.array('c', data) -revlog._fulltextcache[node] = arraytext -super(manifestctx, self).__init__(data) - def node(self): return self._node -class treemanifestctx(treemanifest): +def read(self): +if self._node == revlog.nullid: +return manifestdict() +if not self._data: +data = self._revlog.revision(self._node) +arraytext = array.array('c', data) +self._revlog._fulltextcache[self._node] = arraytext +self._data = manifestdict(data) +return self._data + +class treemanifestctx(object): def __init__(self, revlog, node, dir=''): revlog = revlog.dirlog(dir) self._revlog = revlog self._dir = dir +self._data = None self._node = node @@ -1004,19 +1009,27 @@ class treemanifestctx(treemanifest): #rev = revlog.rev(node) #self.linkrev = revlog.linkrev(rev) -if revlog._treeondisk: -super(treemanifestctx, self).__init__(dir=dir) -def gettext(): -return revlog.revision(node) -def readsubtree(dir, subm): -return revlog.dirlog(dir).read(subm) -self.read(gettext, readsubtree) -self.setnode(node) -else: -data = revlog.revision(node) -arraytext = array.array('c', data) -revlog.fulltextcache[node] = arraytext -super(treemanifestctx, self).__init__(dir=dir, text=data) +def read(self): +if self._node == revlog.nullid: +return treemanifest() + +if not self._data: +if self._revlog._treeondisk: +treemf = treemanifest(dir=self._dir) +def gettext(): +return self._revlog.revision(self._node) +def readsubtree(dir, subm): +return treemanifestctx(self._revlog, subm, dir).read() +treemf.read(gettext, readsubtree) +treemf.setnode(self._node) +self._data = treemf +else: +data = self._revlog.revision(self._node) +arraytext = array.array('c', data) +self._revlog.fulltextcache[self._node] = arraytext +self._data = treemanifest(dir=self._dir, text=data) + +return self._data class manifest(manifestrevlog): def __init__(self, opener, dir='', dirlogcache=None): ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH V2] dirstate: rebuild should update dirstate properly
On Tue, 2016-08-30 at 15:17 -0700, Mateusz Kwapich wrote: > # HG changeset patch > # User Mateusz Kwapich> # Date 1472595388 25200 > # Tue Aug 30 15:16:28 2016 -0700 > # Node ID aff2b9911d78a3d427e3ba18a565e76215971948 > # Parent 12f8bef59bfa2739d0c5d8425ab494fd2fe38a81 > dirstate: rebuild should update dirstate properly Is this appropriate for stable? > Updating dirstate by simply adding and dropping files from self._map doesn't > keep the other maps updated (think: _dirs, _copymap, _foldmap, _nonormalset) > thus introducing cache inconsistency. > > This is also affecting the debugstate tests since now we don't even try to set > correct mode and mtime for the files because they are marked dirty anyway and > will be checked during next status call. > > diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py > --- a/mercurial/dirstate.py > +++ b/mercurial/dirstate.py > @@ -680,21 +680,15 @@ class dirstate(object): > self.clear() > self._lastnormaltime = lastnormaltime > > -for f in changedfiles: > -mode = 0o666 > -if f in allfiles and 'x' in allfiles.flags(f): > -mode = 0o777 > - > -if f in allfiles: > -self._map[f] = dirstatetuple('n', mode, -1, 0) > -else: > -self._map.pop(f, None) > -if f in self._nonnormalset: > -self._nonnormalset.remove(f) > - > if self._origpl is None: > self._origpl = self._pl > self._pl = (parent, nullid) > +for f in changedfiles: > +if f in allfiles: > +self.normallookup(f) > +else: > +self.drop(f) > + > self._dirty = True > > def write(self, tr): > diff --git a/tests/test-rebuildstate.t b/tests/test-rebuildstate.t > --- a/tests/test-rebuildstate.t > +++ b/tests/test-rebuildstate.t > @@ -48,8 +48,8 @@ basic test for hg debugrebuildstate > state dump after > > $ hg debugstate --nodates | sort > - n 644 -1 set bar > - n 644 -1 set foo > + n 0 -1 unset bar > + n 0 -1 unset foo > > $ hg debugadddrop --normal-lookup file1 file2 > $ hg debugadddrop --drop bar > @@ -57,7 +57,7 @@ state dump after > $ hg debugstate --nodates > n 0 -1 unset file1 > n 0 -1 unset file2 > - n 644 -1 set foo > + n 0 -1 unset foo > $ hg debugrebuildstate > > status > @@ -115,7 +115,7 @@ dirstate > $ hg debugrebuilddirstate --minimal > $ hg debugdirstate --nodates > r 0 0 * bar (glob) > - n 644 -1 * foo (glob) > + n 0 -1 * foo (glob) > a 0 -1 * qux (glob) > $ hg status -A > A qux > ___ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel -- Mathematics is the supreme nostalgia of our time. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH V2] dirstate: rebuild should update dirstate properly
# HG changeset patch # User Mateusz Kwapich# Date 1472595388 25200 # Tue Aug 30 15:16:28 2016 -0700 # Node ID aff2b9911d78a3d427e3ba18a565e76215971948 # Parent 12f8bef59bfa2739d0c5d8425ab494fd2fe38a81 dirstate: rebuild should update dirstate properly Updating dirstate by simply adding and dropping files from self._map doesn't keep the other maps updated (think: _dirs, _copymap, _foldmap, _nonormalset) thus introducing cache inconsistency. This is also affecting the debugstate tests since now we don't even try to set correct mode and mtime for the files because they are marked dirty anyway and will be checked during next status call. diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -680,21 +680,15 @@ class dirstate(object): self.clear() self._lastnormaltime = lastnormaltime -for f in changedfiles: -mode = 0o666 -if f in allfiles and 'x' in allfiles.flags(f): -mode = 0o777 - -if f in allfiles: -self._map[f] = dirstatetuple('n', mode, -1, 0) -else: -self._map.pop(f, None) -if f in self._nonnormalset: -self._nonnormalset.remove(f) - if self._origpl is None: self._origpl = self._pl self._pl = (parent, nullid) +for f in changedfiles: +if f in allfiles: +self.normallookup(f) +else: +self.drop(f) + self._dirty = True def write(self, tr): diff --git a/tests/test-rebuildstate.t b/tests/test-rebuildstate.t --- a/tests/test-rebuildstate.t +++ b/tests/test-rebuildstate.t @@ -48,8 +48,8 @@ basic test for hg debugrebuildstate state dump after $ hg debugstate --nodates | sort - n 644 -1 set bar - n 644 -1 set foo + n 0 -1 unset bar + n 0 -1 unset foo $ hg debugadddrop --normal-lookup file1 file2 $ hg debugadddrop --drop bar @@ -57,7 +57,7 @@ state dump after $ hg debugstate --nodates n 0 -1 unset file1 n 0 -1 unset file2 - n 644 -1 set foo + n 0 -1 unset foo $ hg debugrebuildstate status @@ -115,7 +115,7 @@ dirstate $ hg debugrebuilddirstate --minimal $ hg debugdirstate --nodates r 0 0 * bar (glob) - n 644 -1 * foo (glob) + n 0 -1 * foo (glob) a 0 -1 * qux (glob) $ hg status -A A qux ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 2 of 3] debugextensions: show raw testedwith value (BC)
On Wed, Aug 31, 2016 at 12:10:13AM +0900, Yuya Nishihara wrote: > # HG changeset patch > # User Yuya Nishihara> # Date 1472221877 -32400 > # Fri Aug 26 23:31:17 2016 +0900 > # Node ID 8bae198823d55c18e640f22df8c8ef89f50fd998 > # Parent 4c32b2f6aa852fc6260d63bb359d6b2129b8bede > debugextensions: show raw testedwith value (BC) > > Otherwise we would see no difference between "internal" liar and real > "ships-with-hg-core". I did this on purpose, so that the shown-to-users string wouldn't be the magic string we actually care about. We could change it from "internal" to something else that still isn't the magic string though... > > This is a debug command. There would be no need to keep backward > compatibility. Agreed. > > diff --git a/mercurial/commands.py b/mercurial/commands.py > --- a/mercurial/commands.py > +++ b/mercurial/commands.py > @@ -2397,10 +2397,6 @@ def debugextensions(ui, **opts): > isinternal = extensions.ismoduleinternal(extmod) > extsource = extmod.__file__ > exttestedwith = getattr(extmod, 'testedwith', '').split() > -if isinternal: > -showtestedwith = ['internal'] > -else: > -showtestedwith = exttestedwith > extbuglink = getattr(extmod, 'buglink', None) > > fm.startitem() > @@ -2420,9 +2416,9 @@ def debugextensions(ui, **opts): > fm.condwrite(ui.verbose and extsource, 'source', > _(' location: %s\n'), extsource or "") > > -fm.condwrite(ui.verbose and showtestedwith, 'testedwith', > +fm.condwrite(ui.verbose and exttestedwith, 'testedwith', > _(' tested with: %s\n'), > - fm.formatlist(showtestedwith, name='ver')) > + fm.formatlist(exttestedwith, name='ver')) > > fm.condwrite(ui.verbose and extbuglink, 'buglink', > _(' bug reporting: %s\n'), extbuglink or "") > diff --git a/tests/test-debugextensions.t b/tests/test-debugextensions.t > --- a/tests/test-debugextensions.t > +++ b/tests/test-debugextensions.t > @@ -26,21 +26,21 @@ >$ hg debugextensions -v >color > location: */hgext/color.py* (glob) > -tested with: internal > +tested with: ships-with-hg-core >ext1 > location: */extwithoutinfos.py* (glob) >histedit > location: */hgext/histedit.py* (glob) > -tested with: internal > +tested with: ships-with-hg-core >mq > location: */hgext/mq.py* (glob) > -tested with: internal > +tested with: ships-with-hg-core >patchbomb > location: */hgext/patchbomb.py* (glob) > -tested with: internal > +tested with: ships-with-hg-core >rebase > location: */hgext/rebase.py* (glob) > -tested with: internal > +tested with: ships-with-hg-core > >$ hg debugextensions -Tjson | sed 's||/|g' >[ > @@ -48,7 +48,7 @@ > "buglink": "", > "name": "color", > "source": "*/hgext/color.py*", (glob) > -"testedwith": ["internal"] > +"testedwith": ["ships-with-hg-core"] > }, > { > "buglink": "", > @@ -60,27 +60,28 @@ > "buglink": "", > "name": "histedit", > "source": "*/hgext/histedit.py*", (glob) > -"testedwith": ["internal"] > +"testedwith": ["ships-with-hg-core"] > }, > { > "buglink": "", > "name": "mq", > "source": "*/hgext/mq.py*", (glob) > -"testedwith": ["internal"] > +"testedwith": ["ships-with-hg-core"] > }, > { > "buglink": "", > "name": "patchbomb", > "source": "*/hgext/patchbomb.py*", (glob) > -"testedwith": ["internal"] > +"testedwith": ["ships-with-hg-core"] > }, > { > "buglink": "", > "name": "rebase", > "source": "*/hgext/rebase.py*", (glob) > -"testedwith": ["internal"] > +"testedwith": ["ships-with-hg-core"] > } >] > > - $ hg debugextensions -T '{ifcontains("internal", testedwith, "", > "{name}\n")}' > + $ hg debugextensions \ > + > -T '{ifcontains("ships-with-hg-core", testedwith, "", "{name}\n")}' >ext1 > ___ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH] formatter: add context manager interface for convenience
On Wed, Aug 31, 2016 at 12:05:58AM +0900, Yuya Nishihara wrote: > # HG changeset patch > # User Yuya Nishihara> # Date 1472396405 -32400 > # Mon Aug 29 00:00:05 2016 +0900 > # Node ID 41fea255bd1cda8d0f482b2582aec8a29f86c303 > # Parent 90af59b40d8a007fb8811daf0c3e64aca43aa6b0 > formatter: add context manager interface for convenience Nice, queued. > > And port "hg files" to test it. > > As you can see, extra indent is necessary to port to this API. I don't think > we should switch every fm.formatter() call to "with" statement. Agreed, but for simple cases it's a nice readability and correctness win. > > diff --git a/mercurial/commands.py b/mercurial/commands.py > --- a/mercurial/commands.py > +++ b/mercurial/commands.py > @@ -3963,15 +3963,11 @@ def files(ui, repo, *pats, **opts): > end = '\n' > if opts.get('print0'): > end = '\0' > -fm = ui.formatter('files', opts) > fmt = '%s' + end > > m = scmutil.match(ctx, pats, opts) > -ret = cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos')) > - > -fm.end() > - > -return ret > +with ui.formatter('files', opts) as fm: > +return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos')) > > @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True) > def forget(ui, repo, *pats, **opts): > diff --git a/mercurial/formatter.py b/mercurial/formatter.py > --- a/mercurial/formatter.py > +++ b/mercurial/formatter.py > @@ -52,6 +52,11 @@ class baseformatter(object): > self._item = None > # function to convert node to string suitable for this output > self.hexfunc = hex > +def __enter__(self): > +return self > +def __exit__(self, exctype, excvalue, traceback): > +if exctype is None: > +self.end() > def __nonzero__(self): > '''return False if we're not doing real templating so we can > skip extra work''' > ___ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 3 of 8 v2] rebase: cope with the notion that flag defaults might be None
# HG changeset patch # User Augie Fackler# Date 1472585699 14400 # Tue Aug 30 15:34:59 2016 -0400 # Node ID 69d84366fa224f5dedfdd18a9f5e2413060a8121 # Parent e88fe4eb4e8cc3c956ed50b35744a585d51a0e18 rebase: cope with the notion that flag defaults might be None diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -1072,9 +1072,9 @@ def storestatus(repo, originalwd, target f.write(repo[originalwd].hex() + '\n') f.write(repo[target].hex() + '\n') f.write(repo[external].hex() + '\n') -f.write('%d\n' % int(collapse)) -f.write('%d\n' % int(keep)) -f.write('%d\n' % int(keepbranches)) +f.write('%d\n' % int(bool(collapse))) +f.write('%d\n' % int(bool(keep))) +f.write('%d\n' % int(bool(keepbranches))) f.write('%s\n' % (activebookmark or '')) for d, v in state.iteritems(): oldrev = repo[d].hex() ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 2 of 8 v2] fancyopts: disallow true as a boolean flag default (API)
# HG changeset patch # User Augie Fackler# Date 1472584421 14400 # Tue Aug 30 15:13:41 2016 -0400 # Node ID e88fe4eb4e8cc3c956ed50b35744a585d51a0e18 # Parent 4f76e8b136581d750cf98395ea8034dbb9666b96 fancyopts: disallow true as a boolean flag default (API) This was nonsense, as there's not been a way for the user to un-specify the flag. Restricting this behavior will open the door to some nice fit-and-finish functionality in a later patch, and shouldn't break any third party extensions. This is marked as (API) since it might break a third party extension, but given the fact that it was silly before that's mostly a formality. Due to how early parsing of global options works, we have to add some extra coupling between fancyopts and dispatch so that we can provide a "default" of True for already-parsed boolean flags when doing command-level flag parsing. diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -555,7 +555,10 @@ def _parse(ui, args): # combine global options into local for o in commands.globalopts: -c.append((o[0], o[1], options[o[1]], o[3])) +# Passing a tuple of length six through into the option parser +# allows otherwise-illegal defaults to survive, which is how +# we handle global options like --quiet. +c.append((o[0], o[1], options[o[1]], o[3], '', True)) try: args = fancyopts.fancyopts(args, c, cmdoptions, gnu=True) diff --git a/mercurial/fancyopts.py b/mercurial/fancyopts.py --- a/mercurial/fancyopts.py +++ b/mercurial/fancyopts.py @@ -67,10 +67,22 @@ def fancyopts(args, options, state, gnu= notnegated = set() for option in options: -if len(option) == 5: +boolok = False +if len(option) == 6: +# If the tuple is of length 6, then it's a global option +# that was already parsed, so we're really just passing +# its "default" through the second phase of flags parsing +# (for command-level flags). As a result, we have to allow +# defaults of True and not rewrite defaults of False. +short, name, default, comment, dummy, dummy = option +boolok = True +elif len(option) == 5: short, name, default, comment, dummy = option else: short, name, default, comment = option +if default is True and not boolok: +raise ValueError('fancyopts does not support default-true ' + 'boolean flags: %r' % name) # convert opts to getopt format oname = name name = name.replace('-', '_') ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 5 of 8 v2] fancyopts: notice default of false and rewrite it to None (API)
# HG changeset patch # User Augie Fackler# Date 1472583470 14400 # Tue Aug 30 14:57:50 2016 -0400 # Node ID 120b94374a1226a152e46f42df00bcc477f38240 # Parent c65c0181a9885d3c95e808272c2f609c3a9c8749 fancyopts: notice default of false and rewrite it to None (API) This opens the door to noticing the difference between "flag not specified false" and "explicitly false" in an upcoming patch. Marked as an internal API change since I did have to tweak a couple of spots in our code that were making assumptions about the nature of falseness. diff --git a/mercurial/fancyopts.py b/mercurial/fancyopts.py --- a/mercurial/fancyopts.py +++ b/mercurial/fancyopts.py @@ -80,9 +80,15 @@ def fancyopts(args, options, state, gnu= short, name, default, comment, dummy = option else: short, name, default, comment = option -if default is True and not boolok: -raise ValueError('fancyopts does not support default-true ' - 'boolean flags: %r' % name) +if not boolok: +if default is True: +raise ValueError('fancyopts does not support default-true ' + 'boolean flags: %r' % name) +if default is False: +# So higher layers of hg can identify the difference +# between unspecified and explicitly-false, set this to +# None here. +default = None # convert opts to getopt format oname = name name = name.replace('-', '_') ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 8 of 8 v2] help: mark boolean flags with a ^ and explain that they can be negated (RFC)
# HG changeset patch # User Augie Fackler# Date 147258 14400 # Tue Aug 30 15:14:04 2016 -0400 # Node ID 5efc13a760938ff5fd8e4553dd8e06d06b98025b # Parent fd68fb86c29873eb32c4a2bd28f7ac0abe3dc172 help: mark boolean flags with a ^ and explain that they can be negated (RFC) This patch is an RFC - it does not update test expectations other than in one file so the changes can be bikeshod. I'm not really in love with this solution, but I don't have anything better either (credit and/or blame for this idea actually goes to timeless.) diff --git a/mercurial/help.py b/mercurial/help.py --- a/mercurial/help.py +++ b/mercurial/help.py @@ -87,11 +87,16 @@ def optrst(header, options, verbose): multioccur = True elif (default is not None) and not isinstance(default, bool): lo += " %s" % optlabel +else: +lo += '^' +multioccur = True data.append((so, lo, desc)) if multioccur: -header += (_(" ([+] can be repeated)")) +m = _( +" ([+] can be repeated, flags marked ^ can be negated with --no-)") +header += (m) rst = ['\n%s:\n\n' % header] rst.extend(minirst.maketable(data, 1)) diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -311,26 +311,27 @@ Test short command list with verbose opt update, up, checkout, co update working directory (or switch revisions) - global options ([+] can be repeated): + global options ([+] can be repeated, flags marked ^ can be negated with + --no-): -R --repository REPO repository root directory or name of overlay bundle file --cwd DIR change working directory - -y --noninteractivedo not prompt, automatically pick the first choice for + -y --noninteractive^ do not prompt, automatically pick the first choice for all prompts - -q --quiet suppress output - -v --verbose enable additional output + -q --quiet^suppress output + -v --verbose^ enable additional output --config CONFIG [+] set/override config option (use 'section.name=value') - --debug enable debugging output - --debugger start debugger + --debug^enable debugging output + --debugger^ start debugger --encoding ENCODE set the charset encoding (default: ascii) --encodingmode MODE set the charset encoding mode (default: strict) - --traceback always print a traceback on exception - --time time how long the command takes - --profile print command execution profile - --version output version information and exit - -h --help display help and exit - --hiddenconsider hidden changesets + --traceback^always print a traceback on exception + --time^ time how long the command takes + --profile^ print command execution profile + --version^ output version information and exit + -h --help^ display help and exit + --hidden^ consider hidden changesets (use "hg help" for the full list of commands) @@ -349,12 +350,12 @@ Test short command list with verbose opt Returns 0 if all files are successfully added. - options ([+] can be repeated): + options ([+] can be repeated, flags marked ^ can be negated with --no-): -I --include PATTERN [+] include names matching the given patterns -X --exclude PATTERN [+] exclude names matching the given patterns - -S --subreposrecurse into subrepositories - -n --dry-run do not perform actions, just print output + -S --subrepos^ recurse into subrepositories + -n --dry-run^do not perform actions, just print output (some details hidden, use --verbose to show complete help) @@ -400,33 +401,34 @@ Verbose help for add Returns 0 if all files are successfully added. - options ([+] can be repeated): + options ([+] can be repeated, flags marked ^ can be negated with --no-): -I --include PATTERN [+] include names matching the given patterns -X --exclude PATTERN [+] exclude names matching the given patterns - -S --subreposrecurse into subrepositories - -n --dry-run do not perform actions, just print output - - global options ([+] can be repeated): + -S --subrepos^ recurse into subrepositories + -n --dry-run^do not perform actions, just print output + + global options ([+] can be repeated, flags marked ^ can be negated with + --no-): -R --repository REPO repository root directory or name of overlay bundle file --cwd DIR change working directory - -y
[PATCH 1 of 8 v2] flags: allow specifying --no-boolean-flag on the command line (BC)
# HG changeset patch # User Augie Fackler# Date 1472586362 14400 # Tue Aug 30 15:46:02 2016 -0400 # Node ID 4f76e8b136581d750cf98395ea8034dbb9666b96 # Parent 12f8bef59bfa2739d0c5d8425ab494fd2fe38a81 flags: allow specifying --no-boolean-flag on the command line (BC) This makes it much easier to enable some anti-foot-shooting features (like update --check) by default, because now all boolean flags can be explicitly disabled on the command line without having to use HGPLAIN or similar. This doesn't (yet) update help output, because I'm not quite sure how to do that cleanly. diff --git a/mercurial/fancyopts.py b/mercurial/fancyopts.py --- a/mercurial/fancyopts.py +++ b/mercurial/fancyopts.py @@ -64,6 +64,7 @@ def fancyopts(args, options, state, gnu= shortlist = '' argmap = {} defmap = {} +notnegated = set() for option in options: if len(option) == 5: @@ -87,10 +88,18 @@ def fancyopts(args, options, state, gnu= # does it take a parameter? if not (default is None or default is True or default is False): +if oname.startswith('no-'): +notnegated.add(oname) +# Note slight weirdness: this means flags like --no-backup +# for revert can be negated with --no-no-backup. This +# seems fine. +namelist.append('no-' + oname) if short: short += ':' if oname: oname += '=' +else: +namelist.append('no-' + oname) if short: shortlist += short if name: @@ -105,6 +114,10 @@ def fancyopts(args, options, state, gnu= # transfer result to state for opt, val in opts: +negated = False +if opt.startswith('--no-') and opt[2:] not in notnegated: +opt = '--' + opt[5:] +negated = True name = argmap[opt] obj = defmap[name] t = type(obj) @@ -121,7 +134,7 @@ def fancyopts(args, options, state, gnu= elif t is type([]): state[name].append(val) elif t is type(None) or t is type(False): -state[name] = True +state[name] = False if negated else True # return unparsed args return args diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t --- a/tests/test-update-branches.t +++ b/tests/test-update-branches.t @@ -379,3 +379,14 @@ Test experimental revset support $ hg log -r '_destupdate()' 2:bd10386d478c 2 (no-eol) + +Test that boolean flags allow --flag=false specification to override [defaults] + $ cat >> $HGRCPATH < [defaults] + > update = --check + > EOF + $ hg co 2 + abort: uncommitted changes + [255] + $ hg co --no-check 2 + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH] update: do not remove cwd
Makes sense. But Durham's idea about warning seems legit. When i ran into this problem when doing 'hg split', i spent a few minutes figuring out where the problem came from. If i had warning like 'your cwd was deleted; if it causes problems go to the root' i'd found the solution sooner. Sent from Samsung Mobile on O2 Original message From: Matt MackallDate: 30/08/2016 20:23 (GMT+00:00) To: Stanislau Hlebik , mercurial-devel@mercurial-scm.org Subject: Re: [PATCH] update: do not remove cwd On Mon, 2016-08-29 at 11:50 -0700, Stanislau Hlebik wrote: > # HG changeset patch > # User Stanislau Hlebik > # Date 1472496038 25200 > # Mon Aug 29 11:40:38 2016 -0700 > # Node ID e1962781ce84040746ef79c0084b8fd70cfcd4b4 > # Parent 318e2b600b80e4ed3c6f37df46ec7544f60d4c0b > update: do not remove cwd > > During update directories are deleted as soon as they have no entries. > But current working directory shouldn't be deleted because it > causes problems for users after hg finishes. It is a perfectly valid state that POSIX allows. So we shouldn't make those problems our problems. > Also it makes complex commands > like 'hg split' fail. Those failures are also arguably bugs in their own right. But this approach introduces new complexities. For instance, what happens if the current directory gets replaced by a symlink? Whether that works depends on where you run the command. And how does the not-deleted directory get cleaned up so as not to interfere with future operations? If we wanted to disallow this, we'd ideally abort early so the user could run the operation in a sane location. But that's not generally easy to discover. And aborting later is likely to make a mess. (Alternate idea: rename the current directory to .oh-no-you-ran-an-hg-command- that-deleted-your-current-directory-please-clean-up-your-mess-kthxbye.) -- Mathematics is the supreme nostalgia of our time. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH] update: do not remove cwd
On Mon, 2016-08-29 at 11:50 -0700, Stanislau Hlebik wrote: > # HG changeset patch > # User Stanislau Hlebik> # Date 1472496038 25200 > # Mon Aug 29 11:40:38 2016 -0700 > # Node ID e1962781ce84040746ef79c0084b8fd70cfcd4b4 > # Parent 318e2b600b80e4ed3c6f37df46ec7544f60d4c0b > update: do not remove cwd > > During update directories are deleted as soon as they have no entries. > But current working directory shouldn't be deleted because it > causes problems for users after hg finishes. It is a perfectly valid state that POSIX allows. So we shouldn't make those problems our problems. > Also it makes complex commands > like 'hg split' fail. Those failures are also arguably bugs in their own right. But this approach introduces new complexities. For instance, what happens if the current directory gets replaced by a symlink? Whether that works depends on where you run the command. And how does the not-deleted directory get cleaned up so as not to interfere with future operations? If we wanted to disallow this, we'd ideally abort early so the user could run the operation in a sane location. But that's not generally easy to discover. And aborting later is likely to make a mess. (Alternate idea: rename the current directory to .oh-no-you-ran-an-hg-command- that-deleted-your-current-directory-please-clean-up-your-mess-kthxbye.) -- Mathematics is the supreme nostalgia of our time. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[Bug 5355] New: interactive record failed with abort patch failed to apply
https://bz.mercurial-scm.org/show_bug.cgi?id=5355 Bug ID: 5355 Summary: interactive record failed with abort patch failed to apply Product: Mercurial Version: unspecified Hardware: PC OS: Linux Status: UNCONFIRMED Severity: bug Priority: wish Component: record Assignee: bugzi...@selenic.com Reporter: timel...@gmail.com CC: mercurial-de...@selenic.com hg version is o 35485[default/default][@] 997e8cf4d0a2 + unrelated changes $ hg commit -i -m 'spellings: display messages' src/Microsoft.PackageManagement.NuGetProvider/resources/Microsoft.PackageManagement.NuGetProvider.Resources.Messages.resx src/Microsoft.PackageManagement.PackageSourceListProvider/resources/Microsoft.PackageManagement.PackageSourceListProvider.Resources.Messages.resx src/Microsoft.PackageManagement/resources/Microsoft.PackageManagement.Resources.Messages.resx src/Microsoft.PowerShell.Activities/resources/ActivityResources.resx src/Microsoft.PowerShell.Commands.Diagnostics/resources/GetEventResources.* `hg st -n |grep resx` starting interactive selection patching file src/Microsoft.PowerShell.Commands.Management/resources/ClearRecycleBinResources.resx Hunk #1 FAILED at 138 1 out of 1 hunks FAILED -- saving rejects to file src/Microsoft.PowerShell.Commands.Management/resources/ClearRecycleBinResources.resx.rej abort: patch failed to apply Expected results: Return me to the interactive selection UI and let me deal with the failure. Actual results: All the work I took to select hunks was lost. -- You are receiving this mail because: You are on the CC list for the bug. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH] update: do not remove cwd
Yes, but it will help users of histedit, split etc. Maybe we can even combine warning and restoring cwd. Sent from Samsung Mobile on O2 Original message From: Augie FacklerDate: 30/08/2016 18:51 (GMT+00:00) To: Stanislau Hlebik Cc: Durham Goode , mercurial-devel@mercurial-scm.org, Ryan McElroy Subject: Re: [PATCH] update: do not remove cwd On Tue, Aug 30, 2016 at 1:41 PM, Stanislau Hlebik wrote: > Yeap, Augie already noted it. > Warning is probably fine (it’s better than nothing). > Another option is to try to save cwd before update and try to restore it > after. That won't help the user, since their cwd won't be altered by changes made in the subprocess. (Unless you mean "try to recreate cwd as a directory if it appears to have been removed", in which case that *might* work, but I don't think so because the directory's inode will change out from under the user and I think they'll still be in a busted state.) ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH] update: do not remove cwd
Yeap, Augie already noted it. Warning is probably fine (it’s better than nothing). Another option is to try to save cwd before update and try to restore it after. On 8/30/16, 5:45 PM, "Durham Goode"wrote: On 8/29/16 11:50 AM, Stanislau Hlebik wrote: > # HG changeset patch > # User Stanislau Hlebik > # Date 1472496038 25200 > # Mon Aug 29 11:40:38 2016 -0700 > # Node ID e1962781ce84040746ef79c0084b8fd70cfcd4b4 > # Parent 318e2b600b80e4ed3c6f37df46ec7544f60d4c0b > update: do not remove cwd > > During update directories are deleted as soon as they have no entries. > But current working directory shouldn't be deleted because it > causes problems for users after hg finishes. Also it makes complex commands > like 'hg split' fail. Won't this cause update to fail if the parent directory is to be deleted and replaced with a file? I'd almost err towards just printing a warning message when the current working directory is deleted (and recommending they cd to the root of their repo). > > diff --git a/mercurial/merge.py b/mercurial/merge.py > --- a/mercurial/merge.py > +++ b/mercurial/merge.py > @@ -1043,7 +1043,7 @@ > repo.ui.note(_("removing %s\n") % f) > audit(f) > try: > -unlink(wjoin(f), ignoremissing=True) > +unlink(wjoin(f), ignoremissing=True, donotremovecwd=True) > except OSError as inst: > repo.ui.warn(_("update failed to remove %s: %s!\n") % >(f, inst.strerror)) > diff --git a/mercurial/posix.py b/mercurial/posix.py > --- a/mercurial/posix.py > +++ b/mercurial/posix.py > @@ -23,6 +23,7 @@ > from .i18n import _ > from . import ( > encoding, > +osutil, > ) > > posixfile = open > @@ -496,7 +497,31 @@ > def makedir(path, notindexed): > os.mkdir(path) > > -def unlinkpath(f, ignoremissing=False): > +def removedirs(name, donotremovecwd=False): > +"""special version of os.removedirs that does not remove symlinked This mentions symlinks are also affected. That seems unrelated to the purpose of this patch though, and I think we do want to allow symlinks to be deleted if their target contains files. > +directories or junction points if they actually contain files""" > +if not donotremovecwd: > +return os.removedirs(name) > + > +cwd = os.getcwd() > +if cwd == name: > +return > +if osutil.listdir(name): > +return > +os.rmdir(name) > +head, tail = os.path.split(name) > +if not tail: > +head, tail = os.path.split(head) > +while head and tail: > +try: > +if osutil.listdir(head) or cwd == head: > +return > +os.rmdir(head) > +except (ValueError, OSError): > +break > +head, tail = os.path.split(head) > + > +def unlinkpath(f, ignoremissing=False, donotremovecwd=False): > """unlink and remove the directory if it is empty""" > try: > os.unlink(f) > @@ -505,7 +530,7 @@ > raise > # try removing directories that might now be empty > try: > -os.removedirs(os.path.dirname(f)) > +removedirs(os.path.dirname(f), donotremovecwd) > except OSError: > pass > > diff --git a/mercurial/windows.py b/mercurial/windows.py > --- a/mercurial/windows.py > +++ b/mercurial/windows.py > @@ -369,11 +369,14 @@ > If gid is None, return the name of the current group.""" > return None > > -def removedirs(name): > +def removedirs(name, donotremovecwd=False): > """special version of os.removedirs that does not remove symlinked > directories or junction points if they actually contain files""" > if osutil.listdir(name): > return > +cwd = os.getcwd() > +if donotremovecwd and cwd == name: > +return > os.rmdir(name) > head, tail = os.path.split(name) > if not tail: > @@ -382,12 +385,14 @@ > try: > if osutil.listdir(head): > return > +if donotremovecwd and cwd == head: > +return > os.rmdir(head) > except (ValueError, OSError): > break > head, tail = os.path.split(head) > > -def unlinkpath(f, ignoremissing=False): > +def unlinkpath(f, ignoremissing=False, donotremovecwd=False): > """unlink and remove the directory if it is empty""" > try: > unlink(f)
Re: [PATCH] formatter: add context manager interface for convenience
On Wed, Aug 31, 2016 at 12:05:58AM +0900, Yuya Nishihara wrote: > # HG changeset patch > # User Yuya Nishihara> # Date 1472396405 -32400 > # Mon Aug 29 00:00:05 2016 +0900 > # Node ID 41fea255bd1cda8d0f482b2582aec8a29f86c303 > # Parent 90af59b40d8a007fb8811daf0c3e64aca43aa6b0 > formatter: add context manager interface for convenience > > And port "hg files" to test it. > > As you can see, extra indent is necessary to port to this API. I don't think > we should switch every fm.formatter() call to "with" statement. > LGTM ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH] histedit: correct output of error when 'base' is from the edit list
# HG changeset patch # User Augie Fackler# Date 1472577230 14400 # Tue Aug 30 13:13:50 2016 -0400 # Node ID 4e6fc4921eca722aa5c7967408d93ca3c59b1593 # Parent 12f8bef59bfa2739d0c5d8425ab494fd2fe38a81 histedit: correct output of error when 'base' is from the edit list This was made more obvious by marmoute's recent rearrangement of this code. diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -789,9 +789,10 @@ class base(histeditaction): def _verifynodeconstraints(self, prev, expected, seen): # base can only be use with a node not in the edited set if self.node in expected: -msg = _('%s "%s" changeset was not an edited list candidate') -raise error.ParseError(msg % (self.verb, node.short(self.node)), - hint=_('only use listed changesets')) +msg = _('%s "%s" changeset was an edited list candidate') +raise error.ParseError( +msg % (self.verb, node.short(self.node)), +hint=_('base must only use unlisted changesets')) @action(['_multifold'], _( diff --git a/tests/test-histedit-base.t b/tests/test-histedit-base.t --- a/tests/test-histedit-base.t +++ b/tests/test-histedit-base.t @@ -235,8 +235,8 @@ base on a previously picked changeset > base d273e35dcdf2 B > pick b2f90fd8aa85 I > EOF - hg: parse error: base "d273e35dcdf2" changeset was not an edited list candidate - (only use listed changesets) + hg: parse error: base "d273e35dcdf2" changeset was an edited list candidate + (base must only use unlisted changesets) $ hg --config experimental.histeditng=False histedit 5 --commands - 2>&1 << EOF | fixbundle > base cd010b8cd998 A ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 8 of 8 cleanup] histedit: remove now unused 'constraints' related code
On Fri, Aug 26, 2016 at 09:35:33PM +0200, Pierre-Yves David wrote: > # HG changeset patch > # User Pierre-Yves David> # Date 1472238391 -7200 > # Fri Aug 26 21:06:31 2016 +0200 > # Node ID 7366faf468f2eb037ea1ce4ef9919786a564bf9d > # Parent c4809d82bb0ae1b068a0fdac1e1012d8182624df > # EXP-Topic histedit.constraint > histedit: remove now unused 'constraints' related code I've finally gotten the time to look this over and copy-edit the commit messages. I'm not really a fan of the new shape of the code (movement towards inheritance and overriding methods), but given that there was so much inheritance in here already (past Augie was young and foolish), that's not really a reason to reject this. And it did help me spot a bug in an abort message (patch forthcoming shortly), so that's an argument in its favor. Queued. > > Now that the one action that need different logic handle that using > inheritance > and overriding, we can remove that code. > > diff --git a/hgext/histedit.py b/hgext/histedit.py > --- a/hgext/histedit.py > +++ b/hgext/histedit.py > @@ -201,18 +201,6 @@ release = lock.release > cmdtable = {} > command = cmdutil.command(cmdtable) > > -class _constraints(object): > -# aborts if there are multiple rules for one node > -noduplicates = 'noduplicates' > -# abort if the node does belong to edited stack > -forceother = 'forceother' > -# abort if the node doesn't belong to edited stack > -noother = 'noother' > - > -@classmethod > -def known(cls): > -return set([v for k, v in cls.__dict__.items() if k[0] != '_']) > - > # Note for extension authors: ONLY specify testedwith = 'internal' for > # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should > # be specifying the version(s) of Mercurial they are tested with, or > @@ -392,8 +380,6 @@ class histeditaction(object): > self.repo = state.repo > self.node = node > > -constraints = set([_constraints.noduplicates, _constraints.noother]) > - > @classmethod > def fromrule(cls, state, rule): > """Parses the given rule, returning an instance of the > histeditaction. > @@ -786,7 +772,6 @@ class fold(histeditaction): > return repo[n], replacements > > class base(histeditaction): > -constraints = set([_constraints.forceother]) > > def run(self): > if self.repo['.'].node() != self.node: > ___ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH] test-gpg: start gpg-agent by gpg-connect-agent only if GnuPG v2.1+ detected
On Mon, Aug 29, 2016 at 11:57:37PM +0900, Yuya Nishihara wrote: > # HG changeset patch > # User Yuya Nishihara> # Date 1472479179 -32400 > # Mon Aug 29 22:59:39 2016 +0900 > # Node ID eee93fb483588ed1f0ff26898e06cb3713d2afa4 > # Parent b1f69dbdd76be170429185c3b0f50027f55e4f07 > test-gpg: start gpg-agent by gpg-connect-agent only if GnuPG v2.1+ detected Queued this, thanks > > Danek Duvall found that gpg-connect-agent of GnuPG 2.0 never starts gpg-agent > daemon. The 2.1 way is documented as "gpg-coonect-agent /bye" [1], which > appears to be different from the 2.0 way [2]. > > [1]: > https://www.gnupg.org/documentation/manuals/gnupg/Invoking-GPG_002dAGENT.html > [2]: > https://www.gnupg.org/documentation/manuals/gnupg-2.0/Invoking-GPG_002dAGENT.html > > Since "gpg-agent --daemon" of GnuPG 2.1 never prints environment variables, > "eval $(gpg-agent --daemon)" would be valid only for GnuPG < 2.1, and we'll > need a different workaround for 2.0. I have no 2.0 environment, I won't > implement it. > > diff --git a/tests/hghave.py b/tests/hghave.py > --- a/tests/hghave.py > +++ b/tests/hghave.py > @@ -353,6 +353,10 @@ def has_gpg(): > def has_gpg2(): > return matchoutput('gpg --version 2>&1', br'GnuPG[^0-9]+2\.') > > +@check("gpg21", "gpg client v2.1+") > +def has_gpg21(): > +return matchoutput('gpg --version 2>&1', br'GnuPG[^0-9]+2\.(?!0)') > + > @check("unix-permissions", "unix-style permissions") > def has_unix_permissions(): > d = tempfile.mkdtemp(dir='.', prefix=tempprefix) > diff --git a/tests/test-gpg.t b/tests/test-gpg.t > --- a/tests/test-gpg.t > +++ b/tests/test-gpg.t > @@ -12,11 +12,16 @@ Test the GPG extension >$ GNUPGHOME="$TESTTMP/gpg"; export GNUPGHOME >$ cp -R "$TESTDIR/gpg" "$GNUPGHOME" > > -Start gpg-agent, which is required by GnuPG v2, and migrate secret keys > +Start gpg-agent, which is required by GnuPG v2 > + > +#if gpg21 > + $ gpg-connect-agent -q --subst /serverpid '/echo ${get serverpid}' /bye \ > + > >> $DAEMON_PIDS > +#endif > + > +and migrate secret keys > > #if gpg2 > - $ gpg-connect-agent -q --subst /serverpid '/echo ${get serverpid}' /bye \ > - > >> $DAEMON_PIDS >$ gpg --no-permission-warning --no-secmem-warning --list-secret-keys \ >> > /dev/null 2>&1 > #endif > ___ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH] update: do not remove cwd
On Mon, Aug 29, 2016 at 11:50:28AM -0700, Stanislau Hlebik wrote: > # HG changeset patch > # User Stanislau Hlebik> # Date 1472496038 25200 > # Mon Aug 29 11:40:38 2016 -0700 > # Node ID e1962781ce84040746ef79c0084b8fd70cfcd4b4 > # Parent 318e2b600b80e4ed3c6f37df46ec7544f60d4c0b > update: do not remove cwd I like it! Good improvement. However, see below for a concern. [...] > > diff --git a/tests/test-update-names.t b/tests/test-update-names.t > --- a/tests/test-update-names.t > +++ b/tests/test-update-names.t > @@ -72,3 +72,13 @@ >$ cd .. > > #endif > + > +Test that cwd is not deleted during update > + $ hg init r4 && cd r4 > + $ mkdir dir > + $ cd dir > + $ echo a > a > + $ hg add a > + $ hg ci -m "file and dir" > + $ hg up -q null > + $ cd . This wants to be 'cd ..' What happens in this case: $ hg init r5 && cd r5 $ echo foo > foo $ hg addr && hg ci -m foo $ hg co null $ mkdir foo $ echo bar > foo/bar $ hg addr && hg ci -m foo/bar $ cd foo Move from r1 to r0, which will want to replace cwd with a file $ hg co 0 I suspect this is broken somehow, but didn't test it myself. > ___ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH] formatter: add context manager interface for convenience
# HG changeset patch # User Yuya Nishihara# Date 1472396405 -32400 # Mon Aug 29 00:00:05 2016 +0900 # Node ID 41fea255bd1cda8d0f482b2582aec8a29f86c303 # Parent 90af59b40d8a007fb8811daf0c3e64aca43aa6b0 formatter: add context manager interface for convenience And port "hg files" to test it. As you can see, extra indent is necessary to port to this API. I don't think we should switch every fm.formatter() call to "with" statement. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3963,15 +3963,11 @@ def files(ui, repo, *pats, **opts): end = '\n' if opts.get('print0'): end = '\0' -fm = ui.formatter('files', opts) fmt = '%s' + end m = scmutil.match(ctx, pats, opts) -ret = cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos')) - -fm.end() - -return ret +with ui.formatter('files', opts) as fm: +return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos')) @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True) def forget(ui, repo, *pats, **opts): diff --git a/mercurial/formatter.py b/mercurial/formatter.py --- a/mercurial/formatter.py +++ b/mercurial/formatter.py @@ -52,6 +52,11 @@ class baseformatter(object): self._item = None # function to convert node to string suitable for this output self.hexfunc = hex +def __enter__(self): +return self +def __exit__(self, exctype, excvalue, traceback): +if exctype is None: +self.end() def __nonzero__(self): '''return False if we're not doing real templating so we can skip extra work''' ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 3 of 3] version: change "place" field of extension to "bundled" flag
# HG changeset patch # User Yuya Nishihara# Date 147332 -32400 # Fri Aug 26 23:38:52 2016 +0900 # Node ID 88a3a36023ed943455d4663583531d7f63aa9521 # Parent 8bae198823d55c18e640f22df8c8ef89f50fd998 version: change "place" field of extension to "bundled" flag The name "place" sounds odd. We can simply expose raw boolean values instead of switching external/internal literals. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -7293,14 +7293,13 @@ def version_(ui, **opts): fn = fm.nested("extensions") if names: namefmt = " %%-%ds " % max(len(n) for n in names) -if fn: -places = ["external", "internal"] -else: -places = [_("external"), _("internal")] +places = [_("external"), _("internal")] for n, v, p in zip(names, vers, isinternals): fn.startitem() fn.condwrite(ui.verbose, "name", namefmt, n) -fn.condwrite(ui.verbose, "place", "%s ", places[p]) +if ui.verbose: +fn.plain("%s " % places[p]) +fn.data(bundled=p) fn.condwrite(ui.verbose and v, "ver", "%s", v) if ui.verbose: fn.plain("\n") diff --git a/tests/test-extension.t b/tests/test-extension.t --- a/tests/test-extension.t +++ b/tests/test-extension.t @@ -1253,15 +1253,15 @@ Test JSON output of version: $ hg version --config extensions.throw=throw.py -Tjson [ { -"extensions": [{"name": "throw", "place": "external", "ver": "1.twentythree"}], +"extensions": [{"bundled": false, "name": "throw", "ver": "1.twentythree"}], "ver": "3.2.2" } ] - $ LANGUAGE= LC_ALL=ja_JP.UTF-8 hg version --config extensions.strip= -Tjson + $ hg version --config extensions.strip= -Tjson [ { -"extensions": [{"name": "strip", "place": "internal", "ver": null}], +"extensions": [{"bundled": true, "name": "strip", "ver": null}], "ver": "*" (glob) } ] @@ -1269,7 +1269,7 @@ Test JSON output of version: Test template output of version: $ hg version --config extensions.throw=throw.py --config extensions.strip= \ - > -T'{extensions % "{name} {pad(ver, 16)} ({place})\n"}' + > -T'{extensions % "{name} {pad(ver, 16)} ({if(bundled, "internal", "external")})\n"}' throw 1.twentythree (external) strip(internal) ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 3 of 3] commands: add template support for config
On Mon, 29 Aug 2016 12:52:43 -0500, Mathias De Maré wrote: > # HG changeset patch > # User Mathias De Maré> # Date 1472447235 -7200 > # Mon Aug 29 07:07:15 2016 +0200 > # Node ID dd7b8ff51af615e1a44d32b103d23e8cd34d5dd9 > # Parent e348c87b33d73a590bee53b74def915b1ce8c6fe > commands: add template support for config > -for f in scmutil.rcpath(): > -ui.debug('read config from: %s\n' % f) > +fm = ui.formatter('config', opts) > +if ui.debugflag: > +for f in scmutil.rcpath(): > +fm.plain('read config from: %s\n' % f) This is a real debug message. We'll need another workaround, so please keep it as ui.debug(). https://www.mercurial-scm.org/wiki/GenericTemplatingPlan#Sanity_check_output > @@ -1859,25 +1861,31 @@ > raise error.Abort(_('only one config item permitted')) > matched = False > for section, name, value in ui.walkconfig(untrusted=untrusted): > -value = str(value).replace('\n', '\\n') > -sectname = section + '.' + name > +if fm.isplain(): > +value = str(value).replace('\n', '\\n') > +entryname = section + '.' + name I think we can always convert value to str because config values should be strings in the public (i.e. command) API. > +++ b/tests/test-config.t > @@ -54,6 +54,20 @@ >Section.KeY=Case Sensitive >Section.key=lower case > > + $ hg showconfig Section -Tjson > + [ > + { > +"name": "Section.KeY", > +"source": "*.hgrc:16", (glob) > +"value": "Case Sensitive" > + }, > + { > +"name": "Section.key", > +"source": "*.hgrc:17", (glob) > +"value": "lower case" > + } > + ] Can you add more tests to cover all "if"s ? ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 2 of 3] formatter: add specific check for plain formatting
On Mon, 29 Aug 2016 12:52:42 -0500, Mathias De Maré wrote: > # HG changeset patch > # User Mathias De Maré> # Date 1472483949 -7200 > # Mon Aug 29 17:19:09 2016 +0200 > # Node ID e348c87b33d73a590bee53b74def915b1ce8c6fe > # Parent fb88d0c87c2746bd84983f1005ed83276c6e9c68 > formatter: add specific check for plain formatting > > diff --git a/mercurial/formatter.py b/mercurial/formatter.py > --- a/mercurial/formatter.py > +++ b/mercurial/formatter.py > @@ -91,6 +91,9 @@ > def plain(self, text, **opts): > '''show raw text for non-templated mode''' > pass > +def isplain(self): > +'''check for plain formatter usage''' > +return False I like this, but there's bool(fm), which equals to "not fm.isplain()". Can you replace all fm.__nonzero__() calls by fm.isplain() ? ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 1 of 3] formatter: add support for functions in json
On Mon, 29 Aug 2016 12:52:41 -0500, Mathias De Maré wrote: > # HG changeset patch > # User Mathias De Maré> # Date 1472483920 -7200 > # Mon Aug 29 17:18:40 2016 +0200 > # Node ID fb88d0c87c2746bd84983f1005ed83276c6e9c68 > # Parent 318e2b600b80e4ed3c6f37df46ec7544f60d4c0b > formatter: add support for functions in json > > Some extensions (like largefiles) assign functions to configuration entries. > This was only possible without formatting so far. > > diff --git a/mercurial/formatter.py b/mercurial/formatter.py > --- a/mercurial/formatter.py > +++ b/mercurial/formatter.py > @@ -193,6 +193,8 @@ > elif isinstance(v, (int, float)): > return str(v) > else: > +if callable(v): > +v = "" % v.func_name It should be stringified by the caller. A callable isn't always serializable, and it would be actually called in templater. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
mercurial@29847: new changeset (1 on stable)
New changeset (1 on stable) in mercurial: http://selenic.com/repo/hg//rev/9a9629b9416c changeset: 29847:9a9629b9416c branch: stable tag: tip parent: 29766:5004ef47f437 user:Gregory Szorcdate:Thu Aug 25 19:53:14 2016 -0700 summary: bundle2: fail faster when interrupted -- Repository URL: http://selenic.com/repo/hg/ ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel