[PATCH 5 of 5] githelp: lowercase the start of output messages for consistency
# HG changeset patch # User Matt Harbison# Date 1526958268 14400 # Mon May 21 23:04:28 2018 -0400 # Node ID d6ecb77cc36283d5141cef8f87b014619322132a # Parent 8e4cdc86c55f579eac9887bd2bd09a5867232d32 githelp: lowercase the start of output messages for consistency I left 'Mercurial' as a proper name capitalized. diff --git a/hgext/githelp.py b/hgext/githelp.py --- a/hgext/githelp.py +++ b/hgext/githelp.py @@ -196,7 +196,7 @@ def apply(ui, repo, *args, **kwargs): ui.status((bytes(cmd)), "\n") def bisect(ui, repo, *args, **kwargs): -ui.status(_("See 'hg help bisect' for how to use bisect.\n\n")) +ui.status(_("see 'hg help bisect' for how to use bisect.\n\n")) def blame(ui, repo, *args, **kwargs): cmdoptions = [ @@ -456,7 +456,7 @@ def commit(ui, repo, *args, **kwargs): ui.status((bytes(cmd)), "\n") def deprecated(ui, repo, *args, **kwargs): -ui.warn(_('This command has been deprecated in the git project, ' + +ui.warn(_('this command has been deprecated in the git project, ' + 'thus isn\'t supported by this tool.\n\n')) def diff(ui, repo, *args, **kwargs): @@ -656,8 +656,8 @@ def mergebase(ui, repo, *args, **kwargs) cmd = Command("log -T '{node}\\n' -r 'ancestor(%s,%s)'" % (args[0], args[1])) -ui.status(_('NOTE: ancestors() is part of the revset language.\n'), - _("Learn more about revsets with 'hg help revsets'\n\n")) +ui.status(_('note: ancestors() is part of the revset language.\n'), + _("(learn more about revsets with 'hg help revsets')\n\n")) ui.status((bytes(cmd)), "\n") def mergetool(ui, repo, *args, **kwargs): @@ -776,7 +776,7 @@ def rebase(ui, repo, *args, **kwargs): "\n\n")) cmd['-d'] = convert(opts.get('onto')) if len(args) < 2: -raise error.Abort(_("Expected format: git rebase --onto X Y Z")) +raise error.Abort(_("expected format: git rebase --onto X Y Z")) cmd['-s'] = "'::%s - ::%s'" % (convert(args[1]), convert(args[0])) else: if len(args) == 1: @@ -815,10 +815,10 @@ def reset(ui, repo, *args, **kwargs): hard = opts.get('hard') if opts.get('mixed'): -ui.status(_('NOTE: --mixed has no meaning since Mercurial has no ' +ui.status(_('note: --mixed has no meaning since Mercurial has no ' 'staging area\n\n')) if opts.get('soft'): -ui.status(_('NOTE: --soft has no meaning since Mercurial has no ' +ui.status(_('note: --soft has no meaning since Mercurial has no ' 'staging area\n\n')) cmd = Command('update') diff --git a/tests/test-githelp.t b/tests/test-githelp.t --- a/tests/test-githelp.t +++ b/tests/test-githelp.t @@ -165,11 +165,11 @@ githelp for reset, checking ~ in git bec hg update .~3 $ hg githelp -- reset --mixed HEAD - NOTE: --mixed has no meaning since Mercurial has no staging area + note: --mixed has no meaning since Mercurial has no staging area hg update . $ hg githelp -- reset --soft HEAD - NOTE: --soft has no meaning since Mercurial has no staging area + note: --soft has no meaning since Mercurial has no staging area hg update . $ hg githelp -- reset --hard HEAD @@ -221,7 +221,7 @@ githelp for stash drop with name githelp for whatchanged should show deprecated message $ hg githelp -- whatchanged -p - This command has been deprecated in the git project, thus isn't supported by this tool. + this command has been deprecated in the git project, thus isn't supported by this tool. githelp for git branch -m renaming @@ -259,8 +259,8 @@ githelp for apply with directory strip c git merge-base $ hg githelp -- git merge-base --is-ancestor ignoring unknown option --is-ancestor - NOTE: ancestors() is part of the revset language. - Learn more about revsets with 'hg help revsets' + note: ancestors() is part of the revset language. + (learn more about revsets with 'hg help revsets') hg log -T '{node}\n' -r 'ancestor(A,B)' ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 1 of 5] githelp: fail gracefully in a couple cases where arguments are missing
# HG changeset patch # User Matt Harbison# Date 1526956335 14400 # Mon May 21 22:32:15 2018 -0400 # Node ID a34bed7475cc8237665aa8a3febc1237a090bc20 # Parent 90e02bd8c4473fec03639f26f3d1b2d30d9861d3 githelp: fail gracefully in a couple cases where arguments are missing I didn't bother adding tests because the other commands that already handled missing arguments don't test these edge cases. I didn't read over all of the code, rather I scanned for `args` not being checked before indexing. diff --git a/hgext/githelp.py b/hgext/githelp.py --- a/hgext/githelp.py +++ b/hgext/githelp.py @@ -236,6 +236,8 @@ def branch(ui, repo, *args, **kwargs): # shell command to output the active bookmark for the active # revision old = '`hg log -T"{activebookmark}" -r .`' +else: +raise error.Abort(_('missing newbranch argument')) new = args[0] cmd['-m'] = old cmd.append(new) @@ -957,6 +959,8 @@ def status(ui, repo, *args, **kwargs): ui.status((bytes(cmd)), "\n") def svn(ui, repo, *args, **kwargs): +if not args: +raise error.Abort(_('missing svn command')) svncmd = args[0] if not svncmd in gitsvncommands: ui.warn(_("error: unknown git svn command %s\n") % (svncmd)) @@ -988,6 +992,9 @@ def svnfindrev(ui, repo, *args, **kwargs ] args, opts = parseoptions(ui, cmdoptions, args) +if not args: +raise error.Abort(_('missing find-rev argument')) + cmd = Command('log') cmd['-r'] = args[0] @@ -1020,6 +1027,10 @@ def tag(ui, repo, *args, **kwargs): cmd = Command('tags') else: cmd = Command('tag') + +if not args: +raise error.Abort(_('missing tag argument')) + cmd.append(args[0]) if len(args) > 1: cmd['-r'] = args[1] ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 4 of 5] githelp: rewrite a Yoda conditional
# HG changeset patch # User Matt Harbison# Date 1526957825 14400 # Mon May 21 22:57:05 2018 -0400 # Node ID 8e4cdc86c55f579eac9887bd2bd09a5867232d32 # Parent d00bfbf24df05e8b8e21acf1444ea24f265a6123 githelp: rewrite a Yoda conditional diff --git a/hgext/githelp.py b/hgext/githelp.py --- a/hgext/githelp.py +++ b/hgext/githelp.py @@ -962,7 +962,7 @@ def svn(ui, repo, *args, **kwargs): if not args: raise error.Abort(_('missing svn command')) svncmd = args[0] -if not svncmd in gitsvncommands: +if svncmd not in gitsvncommands: raise error.Abort(_('unknown git svn command "%s"') % (svncmd)) args = args[1:] ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 2 of 5] githelp: cleanly abort if the `svn` command is unknown
# HG changeset patch # User Matt Harbison# Date 1526956915 14400 # Mon May 21 22:41:55 2018 -0400 # Node ID c137053c30e3a477d9f27aa72f0f791d5bcbe5b2 # Parent a34bed7475cc8237665aa8a3febc1237a090bc20 githelp: cleanly abort if the `svn` command is unknown Previously, the warning was lost above the sea of KeyError stacktrace output. diff --git a/hgext/githelp.py b/hgext/githelp.py --- a/hgext/githelp.py +++ b/hgext/githelp.py @@ -963,7 +963,7 @@ def svn(ui, repo, *args, **kwargs): raise error.Abort(_('missing svn command')) svncmd = args[0] if not svncmd in gitsvncommands: -ui.warn(_("error: unknown git svn command %s\n") % (svncmd)) +raise error.Abort(_('unknown git svn command "%s"') % (svncmd)) args = args[1:] return gitsvncommands[svncmd](ui, repo, *args, **kwargs) ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 3 of 5] githelp: make several strings localizable
# HG changeset patch # User Matt Harbison# Date 1526957717 14400 # Mon May 21 22:55:17 2018 -0400 # Node ID d00bfbf24df05e8b8e21acf1444ea24f265a6123 # Parent c137053c30e3a477d9f27aa72f0f791d5bcbe5b2 githelp: make several strings localizable diff --git a/hgext/githelp.py b/hgext/githelp.py --- a/hgext/githelp.py +++ b/hgext/githelp.py @@ -67,7 +67,7 @@ def githelp(ui, repo, *args, **kwargs): cmd = args[0] if not cmd in gitcommands: -raise error.Abort("error: unknown git command %s" % (cmd)) +raise error.Abort(_("error: unknown git command %s") % (cmd)) ui.pager('githelp') args = args[1:] @@ -90,7 +90,7 @@ def parseoptions(ui, cmdoptions, args): elif ('-' + ex.opt) in ex.msg: flag = '-' + ex.opt else: -raise error.Abort("unknown option %s" % ex.opt) +raise error.Abort(_("unknown option %s") % ex.opt) try: args.remove(flag) except Exception: @@ -336,7 +336,7 @@ def checkout(ui, repo, *args, **kwargs): cmd = Command('revert') cmd['--all'] = None else: -raise error.Abort("a commit must be specified") +raise error.Abort(_("a commit must be specified")) ui.status((bytes(cmd)), "\n") @@ -386,7 +386,7 @@ def clone(ui, repo, *args, **kwargs): args, opts = parseoptions(ui, cmdoptions, args) if len(args) == 0: -raise error.Abort("a repository to clone must be specified") +raise error.Abort(_("a repository to clone must be specified")) cmd = Command('clone') cmd.append(args[0]) @@ -776,7 +776,7 @@ def rebase(ui, repo, *args, **kwargs): "\n\n")) cmd['-d'] = convert(opts.get('onto')) if len(args) < 2: -raise error.Abort("Expected format: git rebase --onto X Y Z") +raise error.Abort(_("Expected format: git rebase --onto X Y Z")) cmd['-s'] = "'::%s - ::%s'" % (convert(args[1]), convert(args[0])) else: if len(args) == 1: ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH V2] tests: stabilize test-patch.t on Windows
# HG changeset patch # User Matt Harbison# Date 1526871918 14400 # Sun May 20 23:05:18 2018 -0400 # Node ID 589535dae225b24312ef6d86a54865314a9acebd # Parent 6acf41bb8d40c55073e846b81c7466f4b0d390dc tests: stabilize test-patch.t on Windows $PYTHON needs to be quoted when invoking with cmd.exe, because the value expands to c:/Python27/python.exe, which seems to be interpreted as 'c' being a command. We can't just convert to '\', because there are a few places that run $PYTHON directly in MSYS. If unquoted there, it results in c:Python27python.exe being run. I wonder if we should bake the quotes into the environment variable to avoid this. It also wasn't happy with the quoting around exit1.py: c:/Python27/python.exe: can't open file ''$TESTTMP/d/exit1.py'': [Errno 22] Invalid argument diff --git a/tests/test-patch.t b/tests/test-patch.t --- a/tests/test-patch.t +++ b/tests/test-patch.t @@ -97,7 +97,7 @@ Error exit (issue4746) > sys.exit(1) > EOF - $ hg import ../c/p --config ui.patch="$PYTHON '`pwd`/exit1.py'" + $ hg import ../c/p --config ui.patch="\"$PYTHON\" \"`pwd`/exit1.py\"" applying ../c/p abort: patch command failed: exited with status 1 [255] ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 1 of 6] revlog: in _getcandidaterevs, shorten revlog._generaldelta to gdelta
On Mon, May 21, 2018 at 2:47 PM, Paul Morellewrote: > # HG changeset patch > # User Paul Morelle > # Date 1525438855 -7200 > # Fri May 04 15:00:55 2018 +0200 > # Node ID 054469518b3480201e7f8ada16957027009e9f64 > # Parent 514605777244de61b68c7e1503c4f106773913f4 > # EXP-Topic semi-snapshots > # Available At https://bitbucket.org/octobus/mercurial-devel/ > # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r > 054469518b34 > revlog: in _getcandidaterevs, shorten revlog._generaldelta to gdelta > Queued parts 1-4. Thanks. Part 5 failed to apply cleanly. Could you please rebase and resend? > > diff -r 514605777244 -r 054469518b34 mercurial/revlog.py > --- a/mercurial/revlog.py Fri May 11 23:28:02 2018 -0700 > +++ b/mercurial/revlog.py Fri May 04 15:00:55 2018 +0200 > @@ -305,6 +305,7 @@ > grouped by level of easiness. > """ > revlog = self.revlog > +gdelta = revlog._generaldelta > curr = len(revlog) > prev = curr - 1 > p1r, p2r = revlog.rev(p1), revlog.rev(p2) > @@ -316,13 +317,13 @@ > # changegroup data into a generaldelta repo. The only time it > # isn't true is if this is the first revision in a delta chain > # or if ``format.generaldelta=true`` disabled > ``lazydeltabase``. > -if cachedelta and revlog._generaldelta and > revlog._lazydeltabase: > +if cachedelta and gdelta and revlog._lazydeltabase: > # Assume what we received from the server is a good choice > # build delta will reuse the cache > yield (cachedelta[0],) > tested.add(cachedelta[0]) > > -if revlog._generaldelta: > +if gdelta: > # exclude already lazy tested base if any > parents = [p for p in (p1r, p2r) > if p != nullrev and p not in tested] > ___ > 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 6] revlog: make variable name 'd' more explicit in _isgooddeltainfo
# HG changeset patch # User Paul Morelle# Date 1520420407 -3600 # Wed Mar 07 12:00:07 2018 +0100 # Node ID d9a8f10cfaa662c5dc6f64e2726da7d763e7e717 # Parent 3eb11b8fe014f5698a3c857ee670a7892f06fc56 # EXP-Topic semi-snapshots # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r d9a8f10cfaa6 revlog: make variable name 'd' more explicit in _isgooddeltainfo d -> deltainfo diff -r 3eb11b8fe014 -r d9a8f10cfaa6 mercurial/revlog.py --- a/mercurial/revlog.py Thu Apr 19 07:57:06 2018 +0200 +++ b/mercurial/revlog.py Wed Mar 07 12:00:07 2018 +0100 @@ -2086,26 +2086,27 @@ return compressor.decompress(data) -def _isgooddeltainfo(self, d, textlen): +def _isgooddeltainfo(self, deltainfo, textlen): """Returns True if the given delta is good. Good means that it is within the disk span, disk size, and chain length bounds that we know to be performant.""" -if d is None: +if deltainfo is None: return False -# - 'd.distance' is the distance from the base revision -- bounding it -# limits the amount of I/O we need to do. -# - 'd.compresseddeltalen' is the sum of the total size of deltas we -# need to apply -- bounding it limits the amount of CPU we consume. +# - 'deltainfo.distance' is the distance from the base revision -- +# bounding it limits the amount of I/O we need to do. +# - 'deltainfo.compresseddeltalen' is the sum of the total size of +# deltas we need to apply -- bounding it limits the amount of CPU +# we consume. defaultmax = textlen * 4 maxdist = self._maxdeltachainspan if not maxdist: -maxdist = d.distance # ensure the conditional pass +maxdist = deltainfo.distance # ensure the conditional pass maxdist = max(maxdist, defaultmax) -if (d.distance > maxdist or d.deltalen > textlen or -d.compresseddeltalen > textlen * 2 or -(self._maxchainlen and d.chainlen > self._maxchainlen)): +if (deltainfo.distance > maxdist or deltainfo.deltalen > textlen or +deltainfo.compresseddeltalen > textlen * 2 or +(self._maxchainlen and deltainfo.chainlen > self._maxchainlen)): return False return True ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 2 of 6] debugdeltachain: r.start and r.length can be retrieved outside the loop
# HG changeset patch # User Paul Morelle# Date 1524117426 -7200 # Thu Apr 19 07:57:06 2018 +0200 # Node ID 3eb11b8fe014f5698a3c857ee670a7892f06fc56 # Parent 054469518b3480201e7f8ada16957027009e9f64 # EXP-Topic semi-snapshots # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 3eb11b8fe014 debugdeltachain: r.start and r.length can be retrieved outside the loop diff -r 054469518b34 -r 3eb11b8fe014 mercurial/debugcommands.py --- a/mercurial/debugcommands.pyFri May 04 15:00:55 2018 +0200 +++ b/mercurial/debugcommands.pyThu Apr 19 07:57:06 2018 +0200 @@ -629,6 +629,8 @@ opts = pycompat.byteskwargs(opts) r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts) index = r.index +start = r.start +length = r.length generaldelta = r.version & revlog.FLAG_GENERALDELTA withsparseread = getattr(r, '_withsparseread', False) @@ -676,8 +678,6 @@ comp, uncomp, deltatype, chain, chainsize = revinfo(rev) chainbase = chain[0] chainid = chainbases.setdefault(chainbase, len(chainbases) + 1) -start = r.start -length = r.length basestart = start(chainbase) revstart = start(rev) lineardist = revstart + comp - basestart ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 5 of 6] revlog: make getcandidaterevs more consistent about updating tested revs set
# HG changeset patch # User Paul Morelle# Date 1520417422 -3600 # Wed Mar 07 11:10:22 2018 +0100 # Node ID fbb85c011ea4c6ba474dbe616f63543cffb5f909 # Parent 3270177368354d88aba86d5b00b96b7fecadd65b # EXP-Topic semi-snapshots # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r fbb85c011ea4 revlog: make getcandidaterevs more consistent about updating tested revs set Like in previous cases, update the set of tested revisions after yielding diff -r 327017736835 -r fbb85c011ea4 mercurial/revlog.py --- a/mercurial/revlog.py Wed Mar 07 12:00:58 2018 +0100 +++ b/mercurial/revlog.py Wed Mar 07 11:10:22 2018 +0100 @@ -331,13 +331,14 @@ # Pick whichever parent is closer to us (to minimize the # chance of having to build a fulltext). parents = [max(parents)] +yield parents tested.update(parents) -yield parents if prev not in tested: # other approach failed try against prev to hopefully save us a # fulltext. yield (prev,) +tested.add(prev) def buildtext(self, revinfo, fh): """Builds a fulltext version of a revision ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 6 of 6] revlog: make chainbase cache its result for the correct revision
# HG changeset patch # User Paul Morelle# Date 1524324477 -7200 # Sat Apr 21 17:27:57 2018 +0200 # Node ID f7f55d6f2966181f243d69b1afa598c12f6c4220 # Parent fbb85c011ea4c6ba474dbe616f63543cffb5f909 # EXP-Topic semi-snapshots # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r f7f55d6f2966 revlog: make chainbase cache its result for the correct revision Previously, as 'rev' was our iterator, we were always caching the chain base for the second revision of the chain, or for the base itself. diff -r fbb85c011ea4 -r f7f55d6f2966 mercurial/revlog.py --- a/mercurial/revlog.py Wed Mar 07 11:10:22 2018 +0100 +++ b/mercurial/revlog.py Sat Apr 21 17:27:57 2018 +0200 @@ -870,10 +870,11 @@ return base index = self.index -base = index[rev][3] -while base != rev: -rev = base -base = index[rev][3] +iterrev = rev +base = index[iterrev][3] +while base != iterrev: +iterrev = base +base = index[iterrev][3] self._chainbasecache[rev] = base return base ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 4 of 6] revlog: isgooddeltainfo takes the whole revinfo object
# HG changeset patch # User Paul Morelle# Date 1520420458 -3600 # Wed Mar 07 12:00:58 2018 +0100 # Node ID 3270177368354d88aba86d5b00b96b7fecadd65b # Parent d9a8f10cfaa662c5dc6f64e2726da7d763e7e717 # EXP-Topic semi-snapshots # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 327017736835 revlog: isgooddeltainfo takes the whole revinfo object Future changes will need other information about te revision. diff -r d9a8f10cfaa6 -r 327017736835 mercurial/revlog.py --- a/mercurial/revlog.py Wed Mar 07 12:00:07 2018 +0100 +++ b/mercurial/revlog.py Wed Mar 07 12:00:58 2018 +0100 @@ -442,7 +442,7 @@ if revlog.flags(candidaterev) & REVIDX_RAWTEXT_CHANGING_FLAGS: continue candidatedelta = self._builddeltainfo(revinfo, candidaterev, fh) -if revlog._isgooddeltainfo(candidatedelta, revinfo.textlen): +if revlog._isgooddeltainfo(candidatedelta, revinfo): nominateddeltas.append(candidatedelta) if nominateddeltas: deltainfo = min(nominateddeltas, key=lambda x: x.deltalen) @@ -2086,7 +2086,7 @@ return compressor.decompress(data) -def _isgooddeltainfo(self, deltainfo, textlen): +def _isgooddeltainfo(self, deltainfo, revinfo): """Returns True if the given delta is good. Good means that it is within the disk span, disk size, and chain length bounds that we know to be performant.""" @@ -2099,6 +2099,7 @@ # deltas we need to apply -- bounding it limits the amount of CPU # we consume. +textlen = revinfo.textlen defaultmax = textlen * 4 maxdist = self._maxdeltachainspan if not maxdist: ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 1 of 6] revlog: in _getcandidaterevs, shorten revlog._generaldelta to gdelta
# HG changeset patch # User Paul Morelle# Date 1525438855 -7200 # Fri May 04 15:00:55 2018 +0200 # Node ID 054469518b3480201e7f8ada16957027009e9f64 # Parent 514605777244de61b68c7e1503c4f106773913f4 # EXP-Topic semi-snapshots # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 054469518b34 revlog: in _getcandidaterevs, shorten revlog._generaldelta to gdelta diff -r 514605777244 -r 054469518b34 mercurial/revlog.py --- a/mercurial/revlog.py Fri May 11 23:28:02 2018 -0700 +++ b/mercurial/revlog.py Fri May 04 15:00:55 2018 +0200 @@ -305,6 +305,7 @@ grouped by level of easiness. """ revlog = self.revlog +gdelta = revlog._generaldelta curr = len(revlog) prev = curr - 1 p1r, p2r = revlog.rev(p1), revlog.rev(p2) @@ -316,13 +317,13 @@ # changegroup data into a generaldelta repo. The only time it # isn't true is if this is the first revision in a delta chain # or if ``format.generaldelta=true`` disabled ``lazydeltabase``. -if cachedelta and revlog._generaldelta and revlog._lazydeltabase: +if cachedelta and gdelta and revlog._lazydeltabase: # Assume what we received from the server is a good choice # build delta will reuse the cache yield (cachedelta[0],) tested.add(cachedelta[0]) -if revlog._generaldelta: +if gdelta: # exclude already lazy tested base if any parents = [p for p in (p1r, p2r) if p != nullrev and p not in tested] ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3557: commit: add new close-branch command
joerg.sonnenberger added a comment. It doesn't seem to fit the argument schema for `hg branch` at all. I'm open for better places, but I couldn't think of a consistent place. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3557 To: joerg.sonnenberger, #hg-reviewers Cc: pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3642: py3: use encoding.strfromlocal() instead of pycompat.sysstr()
pulkit created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY opts['dateformat'] is provided by the user and can be encoded in local encoding. Thanks to Yuya for catching. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3642 AFFECTED FILES hgext/churn.py CHANGE DETAILS diff --git a/hgext/churn.py b/hgext/churn.py --- a/hgext/churn.py +++ b/hgext/churn.py @@ -52,7 +52,7 @@ def getkey(ctx): t, tz = ctx.date() date = datetime.datetime(*time.gmtime(float(t) - tz)[:6]) -return date.strftime(pycompat.sysstr(opts['dateformat'])) +return date.strftime(encoding.strfromlocal(opts['dateformat'])) else: tmpl = opts.get('oldtemplate') or opts.get('template') tmpl = logcmdutil.maketemplater(ui, repo, tmpl) To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
mercurial@38000: 4 new changesets (1 on stable)
4 new changesets (1 on stable) in mercurial: https://www.mercurial-scm.org/repo/hg/rev/71cf20d47f25 changeset: 37997:71cf20d47f25 user:Matt Harbisondate:Mon May 14 23:00:30 2018 -0400 summary: phabricator: split auth.url into the standard auth.schemes and auth.prefix https://www.mercurial-scm.org/repo/hg/rev/5fa4e29ba3e3 changeset: 37998:5fa4e29ba3e3 user:David Demelier date:Mon May 14 13:11:04 2018 +0200 summary: help: add new deprecated topic https://www.mercurial-scm.org/repo/hg/rev/514605777244 changeset: 37999:514605777244 bookmark:@ user:Martin von Zweigbergk date:Fri May 11 23:28:02 2018 -0700 summary: revlog: handle errors from index_node() in nt_insert() and index_slice_del() https://www.mercurial-scm.org/repo/hg/rev/7c05198cd1ca changeset: 38000:7c05198cd1ca branch: stable tag: tip parent: 37980:273ea09f6550 user:Yuya Nishihara date:Tue May 15 22:12:55 2018 +0900 summary: push: continue without locking on lock failure other than EEXIST (issue5882) -- Repository URL: https://www.mercurial-scm.org/repo/hg ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3641: state: temporary silence pyflakes warning by removing variable assignment
pulkit created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY The variable 'version' is going to be used in upcoming series where we will be using the version number to read a certain state file. However currently, pyflakes fails because of the variable not being used. Let's remove the assignment temporarily so that buildbots and test-suite is happy until I iterate over remaining part of the series. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3641 AFFECTED FILES mercurial/state.py CHANGE DETAILS diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -70,7 +70,7 @@ data in the same format as it was before storing""" with self._repo.vfs(self.fname, 'rb') as fp: try: -version = int(fp.readline()) +int(fp.readline()) except ValueError: raise error.ProgrammingError("unknown version of state file" " found") To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3640: state: fix usage of an unassigned variable
pulkit created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY The variable iv was used in earlier iterations of the patches and was dropped since we made sure 'version' is always int. This usage of 'iv' should have been replaced by 'version' in the original patch only. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3640 AFFECTED FILES mercurial/state.py CHANGE DETAILS diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -62,7 +62,7 @@ " an integer") with self._repo.vfs(self.fname, 'wb', atomictemp=True) as fp: -fp.write('%d\n' % iv) +fp.write('%d\n' % version) cbor.dump(self.opts, fp, canonical=True) def _read(self): To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3618: pathencode: remove unused variable
This revision was automatically updated to reflect the committed changes. Closed by commit rHGf9eaa5cd9ee9: pathencode: remove unused variable (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3618?vs=8790=8861 REVISION DETAIL https://phab.mercurial-scm.org/D3618 AFFECTED FILES mercurial/cext/pathencode.c CHANGE DETAILS diff --git a/mercurial/cext/pathencode.c b/mercurial/cext/pathencode.c --- a/mercurial/cext/pathencode.c +++ b/mercurial/cext/pathencode.c @@ -655,14 +655,7 @@ PyObject *shaobj, *hashobj; if (shafunc == NULL) { - PyObject *hashlib, *name = PyBytes_FromString("hashlib"); - - if (name == NULL) - return -1; - - hashlib = PyImport_ImportModule("hashlib"); - Py_DECREF(name); - + PyObject *hashlib = PyImport_ImportModule("hashlib"); if (hashlib == NULL) { PyErr_SetString(PyExc_ImportError, "pathencode failed to find hashlib"); To: durin42, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3635: py3: add support for NoneType in stringutil.pprint()
This revision was automatically updated to reflect the committed changes. Closed by commit rHG7aeb8aa262eb: py3: add support for NoneType in stringutil.pprint() (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3635?vs=8843=8860 REVISION DETAIL https://phab.mercurial-scm.org/D3635 AFFECTED FILES mercurial/utils/stringutil.py CHANGE DETAILS diff --git a/mercurial/utils/stringutil.py b/mercurial/utils/stringutil.py --- a/mercurial/utils/stringutil.py +++ b/mercurial/utils/stringutil.py @@ -29,6 +29,8 @@ if bprefix: return "b'%s'" % escapestr(o) return "'%s'" % escapestr(o) +elif o is None: +return 'None' elif isinstance(o, bytearray): # codecs.escape_encode() can't handle bytearray, so escapestr fails # without coercion. To: pulkit, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3633: py3: use bytes in tests/printenv.py
This revision was automatically updated to reflect the committed changes. Closed by commit rHGbacbe829c2bf: py3: use bytes in tests/printenv.py (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3633?vs=8841=8858 REVISION DETAIL https://phab.mercurial-scm.org/D3633 AFFECTED FILES tests/printenv.py CHANGE DETAILS diff --git a/tests/printenv.py b/tests/printenv.py --- a/tests/printenv.py +++ b/tests/printenv.py @@ -39,14 +39,15 @@ if k.startswith("HG_") and v] env.sort() -out.write("%s hook: " % name) +out.write(b"%s hook: " % name.encode('ascii')) if os.name == 'nt': filter = lambda x: x.replace('\\', '/') else: filter = lambda x: x -vars = ["%s=%s" % (k, filter(v)) for k, v in env] -out.write(" ".join(vars)) -out.write("\n") +vars = [b"%s=%s" % (k.encode('ascii'), filter(v).encode('ascii')) +for k, v in env] +out.write(b" ".join(vars)) +out.write(b"\n") out.close() sys.exit(exitcode) To: pulkit, #hg-reviewers, indygreg Cc: indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3632: py3: use stringutil.pprint() to prevent b'' prefixes in output
This revision was automatically updated to reflect the committed changes. Closed by commit rHGb0144fc8b681: py3: use stringutil.pprint() to prevent b prefixes in output (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3632?vs=8840=8857 REVISION DETAIL https://phab.mercurial-scm.org/D3632 AFFECTED FILES mercurial/dispatch.py CHANGE DETAILS diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -288,8 +288,8 @@ req.args[2] != 'serve' or req.args[3] != '--stdio'): raise error.Abort( -_('potentially unsafe serve --stdio invocation: %r') % -(req.args,)) +_('potentially unsafe serve --stdio invocation: %s') % +(stringutil.pprint(req.args),)) try: debugger = 'pdb' To: pulkit, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3630: py3: add b'' prefixes in tests/test-ssh.t and tests/test-ssh-bundle1.t
This revision was automatically updated to reflect the committed changes. Closed by commit rHGe69628f36196: py3: add b prefixes in tests/test-ssh.t and tests/test-ssh-bundle1.t (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3630?vs=8838=8855 REVISION DETAIL https://phab.mercurial-scm.org/D3630 AFFECTED FILES tests/test-ssh-bundle1.t tests/test-ssh.t CHANGE DETAILS diff --git a/tests/test-ssh.t b/tests/test-ssh.t --- a/tests/test-ssh.t +++ b/tests/test-ssh.t @@ -457,12 +457,12 @@ > > def wrappedpush(orig, repo, *args, **kwargs): > res = orig(repo, *args, **kwargs) - > repo.ui.write('local stdout\n') + > repo.ui.write(b'local stdout\n') > repo.ui.flush() > return res > > def extsetup(ui): - > extensions.wrapfunction(exchange, 'push', wrappedpush) + > extensions.wrapfunction(exchange, b'push', wrappedpush) > EOF $ cat >> .hg/hgrc << EOF @@ -572,7 +572,7 @@ $ cat > $TESTTMP/failhook << EOF > def hook(ui, repo, **kwargs): - > ui.write('hook failure!\n') + > ui.write(b'hook failure!\n') > ui.flush() > return 1 > EOF diff --git a/tests/test-ssh-bundle1.t b/tests/test-ssh-bundle1.t --- a/tests/test-ssh-bundle1.t +++ b/tests/test-ssh-bundle1.t @@ -444,11 +444,11 @@ > > def wrappedpush(orig, repo, *args, **kwargs): > res = orig(repo, *args, **kwargs) - > repo.ui.write('local stdout\n') + > repo.ui.write(b'local stdout\n') > return res > > def extsetup(ui): - > extensions.wrapfunction(exchange, 'push', wrappedpush) + > extensions.wrapfunction(exchange, b'push', wrappedpush) > EOF $ cat >> .hg/hgrc << EOF @@ -537,7 +537,7 @@ $ cat > $TESTTMP/failhook << EOF > def hook(ui, repo, **kwargs): - > ui.write('hook failure!\n') + > ui.write(b'hook failure!\n') > ui.flush() > return 1 > EOF To: pulkit, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3631: py3: use pycompat.fsencode to convert path to bytes
This revision was automatically updated to reflect the committed changes. Closed by commit rHG666d90ace0bb: py3: use pycompat.fsencode to convert path to bytes (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3631?vs=8839=8856 REVISION DETAIL https://phab.mercurial-scm.org/D3631 AFFECTED FILES contrib/hg-ssh CHANGE DETAILS diff --git a/contrib/hg-ssh b/contrib/hg-ssh --- a/contrib/hg-ssh +++ b/contrib/hg-ssh @@ -39,6 +39,7 @@ from mercurial import ( dispatch, +pycompat, ui as uimod, ) @@ -69,7 +70,7 @@ path = cmdargv[2] repo = os.path.normpath(os.path.join(cwd, os.path.expanduser(path))) if repo in allowed_paths: -cmd = [b'-R', repo, b'serve', b'--stdio'] +cmd = [b'-R', pycompat.fsencode(repo), b'serve', b'--stdio'] req = dispatch.request(cmd) if readonly: if not req.ui: To: pulkit, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3634: py3: add r'' prefixes to fix kwargs handling in hgext/sparse.py
This revision was automatically updated to reflect the committed changes. Closed by commit rHGd7cecea0b254: py3: add r prefixes to fix kwargs handling in hgext/sparse.py (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3634?vs=8842=8859 REVISION DETAIL https://phab.mercurial-scm.org/D3634 AFFECTED FILES hgext/sparse.py CHANGE DETAILS diff --git a/hgext/sparse.py b/hgext/sparse.py --- a/hgext/sparse.py +++ b/hgext/sparse.py @@ -138,9 +138,9 @@ extensions.wrapfunction(logcmdutil, '_initialrevs', _initialrevs) def _clonesparsecmd(orig, ui, repo, *args, **opts): -include_pat = opts.get('include') -exclude_pat = opts.get('exclude') -enableprofile_pat = opts.get('enable_profile') +include_pat = opts.get(r'include') +exclude_pat = opts.get(r'exclude') +enableprofile_pat = opts.get(r'enable_profile') include = exclude = enableprofile = False if include_pat: pat = include_pat @@ -178,7 +178,7 @@ 'also include directories of added files in sparse config')) def _add(orig, ui, repo, *pats, **opts): -if opts.get('sparse'): +if opts.get(r'sparse'): dirs = set() for pat in pats: dirname, basename = util.split(pat) To: pulkit, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3629: py3: add b'' prefixes in contrib/hg-ssh
This revision was automatically updated to reflect the committed changes. Closed by commit rHG44ef9bb7ccd9: py3: add b prefixes in contrib/hg-ssh (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3629?vs=8837=8854 REVISION DETAIL https://phab.mercurial-scm.org/D3629 AFFECTED FILES contrib/hg-ssh CHANGE DETAILS diff --git a/contrib/hg-ssh b/contrib/hg-ssh --- a/contrib/hg-ssh +++ b/contrib/hg-ssh @@ -69,15 +69,15 @@ path = cmdargv[2] repo = os.path.normpath(os.path.join(cwd, os.path.expanduser(path))) if repo in allowed_paths: -cmd = ['-R', repo, 'serve', '--stdio'] +cmd = [b'-R', repo, b'serve', b'--stdio'] req = dispatch.request(cmd) if readonly: if not req.ui: req.ui = uimod.ui.load() -req.ui.setconfig('hooks', 'pretxnopen.hg-ssh', - 'python:__main__.rejectpush', 'hg-ssh') -req.ui.setconfig('hooks', 'prepushkey.hg-ssh', - 'python:__main__.rejectpush', 'hg-ssh') +req.ui.setconfig(b'hooks', b'pretxnopen.hg-ssh', + b'python:__main__.rejectpush', b'hg-ssh') +req.ui.setconfig(b'hooks', b'prepushkey.hg-ssh', + b'python:__main__.rejectpush', b'hg-ssh') dispatch.dispatch(req) else: sys.stderr.write('Illegal repository "%s"\n' % repo) @@ -87,7 +87,7 @@ sys.exit(255) def rejectpush(ui, **kwargs): -ui.warn(("Permission denied\n")) +ui.warn((b"Permission denied\n")) # mercurial hooks use unix process conventions for hook return values # so a truthy return means failure return True To: pulkit, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3633: py3: use bytes in tests/printenv.py
indygreg accepted this revision. indygreg added a comment. This revision is now accepted and ready to land. This one worries me a bit because environment variable values can contain non-ASCII. However, the changed code only operates on `HG_` variables and I //think// those variables are well-sanitized and should be ASCII safe. Also, `os.environ` is `str`/`bytes` on Python 2 and the `.encode()` is nonsensical. But Python 2 doesn't care, so meh. Since this is testing code, the barrier for change is low. And the failure mode is pretty obvious. So I'm OK landing this now and fixing later if it causes problems. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3633 To: pulkit, #hg-reviewers, indygreg Cc: indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3579: state: write the version number in plain text on top of state files
This revision was automatically updated to reflect the committed changes. Closed by commit rHGa0e4d654bceb: state: write the version number in plain text on top of state files (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3579?vs=8787=8853 REVISION DETAIL https://phab.mercurial-scm.org/D3579 AFFECTED FILES mercurial/state.py CHANGE DETAILS diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -22,6 +22,7 @@ from .thirdparty import cbor from . import ( +error, util, ) @@ -51,18 +52,28 @@ """read the existing state file and return a dict of data stored""" return self._read() -def save(self, data): +def save(self, version, data): """write all the state data stored to .hg/ file we use third-party library cbor to serialize data to write in the file. """ +if not isinstance(version, int): +raise error.ProgrammingError("version of state file should be" + " an integer") + with self._repo.vfs(self.fname, 'wb', atomictemp=True) as fp: +fp.write('%d\n' % iv) cbor.dump(self.opts, fp, canonical=True) def _read(self): """reads the state file and returns a dictionary which contain data in the same format as it was before storing""" with self._repo.vfs(self.fname, 'rb') as fp: +try: +version = int(fp.readline()) +except ValueError: +raise error.ProgrammingError("unknown version of state file" + " found") return cbor.load(fp) def delete(self): To: pulkit, #hg-reviewers, martinvonz Cc: martinvonz, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3578: state: set canonical=True to write deterministically
This revision was automatically updated to reflect the committed changes. Closed by commit rHG18c6d8b565bf: state: set canonical=True to write deterministically (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3578?vs=8733=8852 REVISION DETAIL https://phab.mercurial-scm.org/D3578 AFFECTED FILES mercurial/state.py CHANGE DETAILS diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -57,7 +57,7 @@ we use third-party library cbor to serialize data to write in the file. """ with self._repo.vfs(self.fname, 'wb', atomictemp=True) as fp: -cbor.dump(self.opts, fp) +cbor.dump(self.opts, fp, canonical=True) def _read(self): """reads the state file and returns a dictionary which contain To: pulkit, #hg-reviewers, martinvonz Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3572: state: don't have a dict like interface for cmdstate class
This revision was automatically updated to reflect the committed changes. Closed by commit rHG36a5a1239a15: state: dont have a dict like interface for cmdstate class (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3572?vs=8732=8851 REVISION DETAIL https://phab.mercurial-scm.org/D3572 AFFECTED FILES mercurial/state.py CHANGE DETAILS diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -46,31 +46,12 @@ """ self._repo = repo self.fname = fname -if not opts: -self.opts = {} -else: -self.opts = opts - -def __nonzero__(self): -return self.exists() - -def __getitem__(self, key): -return self.opts[key] -def __setitem__(self, key, value): -updates = {key: value} -self.opts.update(updates) +def read(self): +"""read the existing state file and return a dict of data stored""" +return self._read() -def load(self): -"""load the existing state file into the class object""" -op = self._read() -self.opts.update(op) - -def addopts(self, opts): -"""add more key-value pairs to the data stored by the object""" -self.opts.update(opts) - -def save(self): +def save(self, data): """write all the state data stored to .hg/ file we use third-party library cbor to serialize data to write in the file. To: pulkit, #hg-reviewers, martinvonz Cc: martinvonz, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2591: state: import the file to write state files from evolve extension
This revision was automatically updated to reflect the committed changes. Closed by commit rHGa2f83661f721: state: import the file to write state files from evolve extension (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2591?vs=7297=8850 REVISION DETAIL https://phab.mercurial-scm.org/D2591 AFFECTED FILES mercurial/state.py CHANGE DETAILS diff --git a/mercurial/state.py b/mercurial/state.py new file mode 100644 --- /dev/null +++ b/mercurial/state.py @@ -0,0 +1,93 @@ +# state.py - writing and reading state files in Mercurial +# +# Copyright 2018 Pulkit Goyal+# +# This software may be used and distributed according to the terms of the +# GNU General Public License version 2 or any later version. + +""" +This file contains class to wrap the state for commands and other +related logic. + +All the data related to the command state is stored as dictionary in the object. +The class has methods using which the data can be stored to disk in a file under +.hg/ directory. + +We store the data on disk in cbor, for which we use the third party cbor library +to serialize and deserialize data. +""" + +from __future__ import absolute_import + +from .thirdparty import cbor + +from . import ( +util, +) + +class cmdstate(object): +"""a wrapper class to store the state of commands like `rebase`, `graft`, +`histedit`, `shelve` etc. Extensions can also use this to write state files. + +All the data for the state is stored in the form of key-value pairs in a +dictionary. + +The class object can write all the data to a file in .hg/ directory and +can populate the object data reading that file. + +Uses cbor to serialize and deserialize data while writing and reading from +disk. +""" + +def __init__(self, repo, fname, opts=None): +""" repo is the repo object +fname is the file name in which data should be stored in .hg directory +opts is a dictionary of data of the statefile +""" +self._repo = repo +self.fname = fname +if not opts: +self.opts = {} +else: +self.opts = opts + +def __nonzero__(self): +return self.exists() + +def __getitem__(self, key): +return self.opts[key] + +def __setitem__(self, key, value): +updates = {key: value} +self.opts.update(updates) + +def load(self): +"""load the existing state file into the class object""" +op = self._read() +self.opts.update(op) + +def addopts(self, opts): +"""add more key-value pairs to the data stored by the object""" +self.opts.update(opts) + +def save(self): +"""write all the state data stored to .hg/ file + +we use third-party library cbor to serialize data to write in the file. +""" +with self._repo.vfs(self.fname, 'wb', atomictemp=True) as fp: +cbor.dump(self.opts, fp) + +def _read(self): +"""reads the state file and returns a dictionary which contain +data in the same format as it was before storing""" +with self._repo.vfs(self.fname, 'rb') as fp: +return cbor.load(fp) + +def delete(self): +"""drop the state file if exists""" +util.unlinkpath(self._repo.vfs.join(self.fname), ignoremissing=True) + +def exists(self): +"""check whether the state file exists or not""" +return self._repo.vfs.exists(self.fname) To: pulkit, #hg-reviewers, indygreg, martinvonz Cc: yuja, indygreg, martinvonz, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 2 of 2 STABLE] httppeer: declare 'dgb' at the function level
# HG changeset patch # User Boris Feld# Date 1526908486 -7200 # Mon May 21 15:14:46 2018 +0200 # Branch stable # Node ID 06458d4a1ca84506d04280052d0288221b2701f0 # Parent 413f444c264455169af8ff0431a36f9901afc36a # EXP-Topic stable-dbg-bug # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 06458d4a1ca8 httppeer: declare 'dgb' at the function level As we just saw in the previous changeset, having the variable defined into a branch creates bug. This is a cheap to move it at the function level. diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py --- a/mercurial/httppeer.py +++ b/mercurial/httppeer.py @@ -277,9 +277,9 @@ def sendrequest(ui, opener, req): Returns the response object. """ +dbg = ui.debug if (ui.debugflag and ui.configbool('devel', 'debug.peer-request')): -dbg = ui.debug line = 'devel-peer-request: %s\n' dbg(line % '%s %s' % (pycompat.bytesurl(req.get_method()), pycompat.bytesurl(req.get_full_url( ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 1 of 2 STABLE] httppeer: properly gate debug usage behind debug flag check
# HG changeset patch # User Boris Feld# Date 1525453606 -7200 # Fri May 04 19:06:46 2018 +0200 # Branch stable # Node ID 413f444c264455169af8ff0431a36f9901afc36a # Parent 273ea09f65500ea7936afe2983bf6a126c5bf4e6 # EXP-Topic stable-dbg-bug # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 413f444c2644 httppeer: properly gate debug usage behind debug flag check The "dbg" local variable is only defined if the 'debugflag' is set to True. However, it was used indiscriminately later in the function. We hide its usage behind the 'debugflag' value to avoid raising a NameError. diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py --- a/mercurial/httppeer.py +++ b/mercurial/httppeer.py @@ -319,7 +319,7 @@ def sendrequest(ui, opener, req): ui.traceback() raise IOError(None, inst) finally: -if ui.configbool('devel', 'debug.peer-request'): +if ui.debugflag and ui.configbool('devel', 'debug.peer-request'): dbg(line % ' finished in %.4f seconds (%d)' % (util.timer() - start, res.code)) ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: D3614: py3: check for None before comparing with integers
> --- a/mercurial/revlog.py > +++ b/mercurial/revlog.py > @@ -846,7 +846,7 @@ > def rawsize(self, rev): > """return the length of the uncompressed text for a given revision""" > l = self.index[rev][2] > -if l >= 0: > +if l is not None and l >= 0: Ugh, rawsize could be None? It smells like a bug. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3614: py3: check for None before comparing with integers
yuja added a comment. > - a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -846,7 +846,7 @@ def rawsize(self, rev): """return the length of the uncompressed text for a given revision""" l = self.index[rev][2] > - if l >= 0: +if l is not None and l >= 0: Ugh, rawsize could be None? It smells like a bug. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3614 To: pulkit, indygreg, #hg-reviewers Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: D3612: py3: use pycompat.fsencode() to convert tempfile name to bytes
> bundle = None > try: # guards bundle > -bundlepath = "bundle:%s+%s" % (op.repo.root, bundlefile) > +bundlepath = "bundle:%s+%s" % (op.repo.root, > + pycompat.fsencode(bundlefile)) It's probably better to handle this by callers because a filename passed to a Mercurial function should always be bytes. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3612: py3: use pycompat.fsencode() to convert tempfile name to bytes
yuja added a comment. > bundle = None > try: # guards bundle > > - bundlepath = "bundle:%s+%s" % (op.repo.root, bundlefile) + bundlepath = "bundle:%s+%s" % (op.repo.root, + pycompat.fsencode(bundlefile)) It's probably better to handle this by callers because a filename passed to a Mercurial function should always be bytes. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3612 To: pulkit, #hg-reviewers Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: D3590: py3: make sure we pass str to date.strftime()
> -return date.strftime(opts['dateformat']) > +return date.strftime(pycompat.sysstr(opts['dateformat'])) Should be `encoding.strfromlocal()` because `opts['dateformat']` is provided by user. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3590: py3: make sure we pass str to date.strftime()
yuja added a comment. > - return date.strftime(opts['dateformat']) +return date.strftime(pycompat.sysstr(opts['dateformat'])) Should be `encoding.strfromlocal()` because `opts['dateformat']` is provided by user. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3590 To: pulkit, #hg-reviewers Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 1 of 8] hgweb: wrap {entries}* of bookmarks with mappinggenerator
# HG changeset patch # User Yuya Nishihara# Date 1522840791 -32400 # Wed Apr 04 20:19:51 2018 +0900 # Node ID 56e8ac64a7a3d529a596778d16ffc442a87f96e6 # Parent 9bf0bd4d7a2e44be4b15f8e1d51eb6d562e509e8 hgweb: wrap {entries}* of bookmarks with mappinggenerator They were functions returning a generator of mappings. The laziness is handled by the mappinggenerator class. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -648,7 +648,7 @@ def bookmarks(web): i = sorted(i, key=sortkey, reverse=True) parity = paritygen(web.stripecount) -def entries(latestonly, **map): +def entries(context, latestonly): t = i if latestonly: t = i[:1] @@ -667,8 +667,8 @@ def bookmarks(web): 'bookmarks', node=hex(web.repo.changelog.tip()), lastchange=[{'date': web.repo[latestrev].date()}], -entries=lambda **x: entries(latestonly=False, **x), -latestentry=lambda **x: entries(latestonly=True, **x)) +entries=templateutil.mappinggenerator(entries, args=(False,)), +latestentry=templateutil.mappinggenerator(entries, args=(True,))) @webcommand('branches') def branches(web): ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 7 of 8] hgweb: don't use dict(key=value) to build a mapping dict in filelog
# HG changeset patch # User Yuya Nishihara# Date 1522841823 -32400 # Wed Apr 04 20:37:03 2018 +0900 # Node ID dc1e237534cea84c4d501d8b0ceb0dd2f4e7 # Parent 11795e08de913fd3285f9052599e32d3dcde0c0d hgweb: don't use dict(key=value) to build a mapping dict in filelog It wasn't Py3 compatible because mapping keys must be bytes. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -1090,13 +1090,15 @@ def filelog(web): diffs = diff(c, linerange=lr) # follow renames accross filtered (not in range) revisions path = c.path() -entries.append(dict( -parity=next(parity), -filerev=c.rev(), -file=path, -diff=diffs, -linerange=webutil.formatlinerange(*lr), -**pycompat.strkwargs(webutil.commonentry(repo, c +lm = webutil.commonentry(repo, c) +lm.update({ +'parity': next(parity), +'filerev': c.rev(), +'file': path, +'diff': diffs, +'linerange': webutil.formatlinerange(*lr), +}) +entries.append(lm) if i == revcount: break lessvars['linerange'] = webutil.formatlinerange(*lrange) @@ -1107,13 +1109,15 @@ def filelog(web): diffs = None if patch: diffs = diff(iterfctx) -entries.append(dict( -parity=next(parity), -filerev=i, -file=f, -diff=diffs, -rename=webutil.renamelink(iterfctx), -**pycompat.strkwargs(webutil.commonentry(repo, iterfctx +lm = webutil.commonentry(repo, iterfctx) +lm.update({ +'parity': next(parity), +'filerev': i, +'file': f, +'diff': diffs, +'rename': webutil.renamelink(iterfctx), +}) +entries.append(lm) entries.reverse() revnav = webutil.filerevnav(web.repo, fctx.path()) nav = revnav.gen(end - 1, revcount, count) ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 2 of 8] hgweb: wrap {lastchange} of bookmarks with mappinglist
# HG changeset patch # User Yuya Nishihara# Date 1522840889 -32400 # Wed Apr 04 20:21:29 2018 +0900 # Node ID 45d63bc6a089475a963400047b3c9ee8dd75eeeb # Parent 56e8ac64a7a3d529a596778d16ffc442a87f96e6 hgweb: wrap {lastchange} of bookmarks with mappinglist It was an 1-length list of a mapping, can be wrapped with a mappinglist. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -662,11 +662,12 @@ def bookmarks(web): latestrev = i[0][1] else: latestrev = -1 +lastdate = web.repo[latestrev].date() return web.sendtemplate( 'bookmarks', node=hex(web.repo.changelog.tip()), -lastchange=[{'date': web.repo[latestrev].date()}], +lastchange=templateutil.mappinglist([{'date': lastdate}]), entries=templateutil.mappinggenerator(entries, args=(False,)), latestentry=templateutil.mappinggenerator(entries, args=(True,))) ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 3 of 8] hgweb: wrap {bookmarks} of summary with mappinggenerator
# HG changeset patch # User Yuya Nishihara# Date 1522841044 -32400 # Wed Apr 04 20:24:04 2018 +0900 # Node ID 7da55cdf4a0846788d92775adfec37de79c7a925 # Parent 45d63bc6a089475a963400047b3c9ee8dd75eeeb hgweb: wrap {bookmarks} of summary with mappinggenerator No bare generator of mappings should be put in a template mapping. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -727,7 +727,7 @@ def summary(web): 'date': web.repo[n].date(), } -def bookmarks(**map): +def bookmarks(context): parity = paritygen(web.stripecount) marks = [b for b in web.repo._bookmarks.items() if b[1] in web.repo] sortkey = lambda b: (web.repo[b[1]].rev(), b[0]) @@ -769,7 +769,7 @@ def summary(web): owner=get_contact(web.config) or 'unknown', lastchange=tip.date(), tags=templateutil.mappinggenerator(tagentries, name='tagentry'), -bookmarks=bookmarks, +bookmarks=templateutil.mappinggenerator(bookmarks), branches=webutil.branchentries(web.repo, web.stripecount, 10), shortlog=templateutil.mappinggenerator(changelist, name='shortlogentry'), ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 6 of 8] hgweb: wrap {diffopts} of annotate by hybriddict()
# HG changeset patch # User Yuya Nishihara# Date 1522841476 -32400 # Wed Apr 04 20:31:16 2018 +0900 # Node ID 11795e08de913fd3285f9052599e32d3dcde0c0d # Parent e58591b37eada3d982d2db29901c73e8b084c4f9 hgweb: wrap {diffopts} of annotate by hybriddict() The diffopts here is a plain dict, which should be wrapped by hybriddict. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -992,7 +992,7 @@ def annotate(web): rename=webutil.renamelink(fctx), permissions=fctx.manifest().flags(f), ishead=int(ishead), -diffopts=diffopts, +diffopts=templateutil.hybriddict(diffopts), **pycompat.strkwargs(webutil.commonentry(web.repo, fctx))) @webcommand('filelog') ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 5 of 8] hgweb: wrap {parents} of {annotate} with mappinggenerator
# HG changeset patch # User Yuya Nishihara# Date 1522841398 -32400 # Wed Apr 04 20:29:58 2018 +0900 # Node ID e58591b37eada3d982d2db29901c73e8b084c4f9 # Parent 6970d3a9c6a4ee333a1a10abccfa40a8771af471 hgweb: wrap {parents} of {annotate} with mappinggenerator It's a generator of at most two mappings, which has to be wrapped. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -929,7 +929,7 @@ def annotate(web): # TODO there are still redundant operations within basefilectx.parents() # and from the fctx.annotate() call itself that could be cached. parentscache = {} -def parents(f): +def parents(context, f): rev = f.rev() if rev not in parentscache: parentscache[rev] = [] @@ -967,7 +967,7 @@ def annotate(web): "node": f.hex(), "rev": rev, "author": f.user(), - "parents": parents(f), + "parents": templateutil.mappinggenerator(parents, args=(f,)), "desc": f.description(), "extra": f.extra(), "file": f.path(), ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 4 of 8] hgweb: wrap {annotate} with mappinggenerator
# HG changeset patch # User Yuya Nishihara# Date 1522841331 -32400 # Wed Apr 04 20:28:51 2018 +0900 # Node ID 6970d3a9c6a4ee333a1a10abccfa40a8771af471 # Parent 7da55cdf4a0846788d92775adfec37de79c7a925 hgweb: wrap {annotate} with mappinggenerator No bare generator of mappings should be put in a template mapping. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -943,7 +943,7 @@ def annotate(web): for p in parentscache[rev]: yield p -def annotate(**map): +def annotate(context): if fctx.isbinary(): mt = (mimetypes.guess_type(fctx.path())[0] or 'application/octet-stream') @@ -986,7 +986,7 @@ def annotate(web): return web.sendtemplate( 'fileannotate', file=f, -annotate=annotate, +annotate=templateutil.mappinggenerator(annotate), path=webutil.up(f), symrev=webutil.symrevorshortnode(web.req, fctx), rename=webutil.renamelink(fctx), ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 8 of 8] hgweb: wrap {entries}* of filelog with mappinglist
# HG changeset patch # User Yuya Nishihara# Date 1522841872 -32400 # Wed Apr 04 20:37:52 2018 +0900 # Node ID 21a9c92342e6b82473fbaf266b0b95b2bb924245 # Parent dc1e237534cea84c4d501d8b0ceb0dd2f4e7 hgweb: wrap {entries}* of filelog with mappinglist They were lists of mappings. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -1129,10 +1129,10 @@ def filelog(web): file=f, nav=nav, symrev=webutil.symrevorshortnode(web.req, fctx), -entries=entries, +entries=templateutil.mappinglist(entries), descend=descend, patch=patch, -latestentry=latestentry, +latestentry=templateutil.mappinglist(latestentry), linerange=linerange, revcount=revcount, morevars=morevars, ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH] tests: stabilize test-patch.t on Windows
On Sun, 20 May 2018 23:06:44 -0400, Matt Harbison wrote: > # HG changeset patch > # User Matt Harbison> # Date 1526871918 14400 > # Sun May 20 23:05:18 2018 -0400 > # Node ID 341bec645529aa249423f3aa683dac876d9e1510 > # Parent 6acf41bb8d40c55073e846b81c7466f4b0d390dc > tests: stabilize test-patch.t on Windows > > $PYTHON needs to be quoted when invoking with cmd.exe, because the value > expands > to c:/Python27/python.exe, which seems to be interpreted as 'c' being a > command. > We can't just convert to '\', because there are a few places that run $PYTHON > directly in MSYS. If unquoted there, it results in c:Python27python.exe being > run. I wonder if we should bake the quotes into the environment variable to > avoid this. > > It also wasn't happy with the quoting around exit1.py: > > c:/Python27/python.exe: can't open file ''$TESTTMP/d/exit1.py'': [Errno 22] > Invalid argument > > diff --git a/tests/test-patch.t b/tests/test-patch.t > --- a/tests/test-patch.t > +++ b/tests/test-patch.t > @@ -97,7 +97,7 @@ Error exit (issue4746) >> sys.exit(1) >> EOF > > - $ hg import ../c/p --config ui.patch="$PYTHON '`pwd`/exit1.py'" > + $ hg import ../c/p --config ui.patch="\"$PYTHON\" `pwd`/exit1.py" Perhaps \"`pwd`/exit1.py\" would be more correct since theoretically `pwd` may contain whitespace. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH V2] revlog: suggest other parent when a parent was refused for a delta (issue5481)
On Mon, 14 May 2018 14:11:57 +0200, Paul Morelle wrote: > # HG changeset patch > # User Paul Morelle> # Date 1526295914 -7200 > # Mon May 14 13:05:14 2018 +0200 > # Node ID 12fd4a2e154a679a601b8facbb5f15956d427e9e > # Parent 8ba0344f9fb145f5b9b909f1211defc9e0793f68 > # EXP-Topic fallback-to-other-parent > # Available At https://bitbucket.org/octobus/mercurial-devel/ > # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r > 12fd4a2e154a > revlog: suggest other parent when a parent was refused for a delta (issue5481) > > Without aggressivemergedeltas, ensure that when we decline the closest parent > (by revision number), the other parent is examined too. To my knowledge, this looks good to me. It's floating for a week with no comment, so queued. Thanks. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel