Re: hg archive (files) performance regression.

2018-03-01 Thread Vincent Parrett

On 2/03/2018 4:31 PM, Vincent Parrett wrote:
I'm not a python dev (mostly c# and delphi), so still getting my head 
around the hg code base, but I'm curious why the atomictemp=true is 
used in fileit.addfile? I get that it's in the vfs to work around file 
locking issues, but with the archive command with type files, it's 
likely that the archive is going to an empty target directory and this 
seems wasteful. 


So I just knocked up an extension (ciarchive) using the code from 
archival.py (hg-stable repo) - and in class fileit.addfile :


changed

    f = self.opener(name, "w", atomictemp=True)

to

    f = self.opener(name, "w", atomictemp=False)

hg.exe archive --time --subrepos --no-decode --quiet c:\temp\archive27
time: real 22.224 secs (user 6.203+0.000 sys 12.078+0.000)

hg.exe ciarchive --time --subrepos --no-decode --quiet c:\temp\archive28
time: real 17.316 secs (user 6.609+0.000 sys 7.453+0.000)

The repo has the following files :
    9438 File(s)    531,462,248 bytes
    2039 Dir(s)

That's a substantial performance increase (our customers have very large 
repos where this will make a large difference in build times).  Of 
course I'd much rather not be maintaining an extension that uses the 
internal api of hg, any chance this change can be made in the archive 
command, or at least be made configurable (assuming this change is safe!)?


--
Regards

Vincent Parrett

CEO - VSoft Technologies Pty Ltd
https://www.finalbuilder.com
Blog: https://www.finalbuilder.com/resources/blogs
Automate your Software builds with FinalBuilder.
Open Source : https://github.com/VSoftTechnologies


___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2394: histedit: make histedit's commands accept revsets (issue5746)

2018-03-01 Thread sangeet259 (Sangeet Kumar Mishra)
sangeet259 updated this revision to Diff 6324.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2394?vs=6008=6324

REVISION DETAIL
  https://phab.mercurial-scm.org/D2394

AFFECTED FILES
  hgext/histedit.py
  tests/test-histedit-arguments.t

CHANGE DETAILS

diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
--- a/tests/test-histedit-arguments.t
+++ b/tests/test-histedit-arguments.t
@@ -236,10 +236,10 @@
 
   $ HGEDITOR=cat hg histedit "tip^^" --commands - << EOF
   > pick eb57da33312f 2 three
-  > pick 0
+  > pick 0u98
   > pick 08d98a8350f3 4 five
   > EOF
-  hg: parse error: invalid changeset 0
+  hg: parse error: invalid changeset 0u98
   [255]
 
 Test short version of command
@@ -552,3 +552,39 @@
   #
 
   $ cd ..
+
+Check that histedit's commands accept revsets
+  $ hg init bar
+  $ cd bar
+  $ echo w >> a
+  $ hg ci -qAm "adds a"
+  $ echo x >> b
+  $ hg ci -qAm "adds b"
+  $ echo y >> c
+  $ hg ci -qAm "adds c"
+  $ echo z >> d
+  $ hg ci -qAm "adds d"
+  $ hg log -G -T '{rev} {desc}\n'
+  @  3 adds d
+  |
+  o  2 adds c
+  |
+  o  1 adds b
+  |
+  o  0 adds a
+  
+  $ HGEDITOR=cat hg histedit "2" --commands - << EOF
+  > base -4 adds c
+  > pick 2 adds c
+  > pick tip adds d
+  > EOF
+  $ hg log -G -T '{rev} {desc}\n'
+  @  5 adds d
+  |
+  o  4 adds c
+  |
+  | o  1 adds b
+  |/
+  o  0 adds a
+  
+
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -422,11 +422,18 @@
 def fromrule(cls, state, rule):
 """Parses the given rule, returning an instance of the histeditaction.
 """
-rulehash = rule.strip().split(' ', 1)[0]
+ruleid = rule.strip().split(' ', 1)[0]
+# ruleid can be anything from rev numbers, hashes, "bookmarks" etc
+# Check for validation of rule ids and get the rulehash
 try:
-rev = node.bin(rulehash)
+rev = node.bin(ruleid)
 except TypeError:
-raise error.ParseError("invalid changeset %s" % rulehash)
+try:
+_ctx = scmutil.revsingle(state.repo, ruleid)
+rulehash = _ctx.hex()
+rev = node.bin(rulehash)
+except error.RepoLookupError:
+raise error.ParseError("invalid changeset %s" % ruleid)
 return cls(state, rev)
 
 def verify(self, prev, expected, seen):



To: sangeet259, durin42, #hg-reviewers
Cc: tom.prince, krbullock, rishabhmadan96, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


hg archive (files) performance regression.

2018-03-01 Thread Vincent Parrett


Somewhere between hg 4.2.2 and 4.5 the archive (files, to empty folder) 
command gotten around 10-13% slower.


Testing on windows 10 x64 (latest updates), between two ssd drives :

hg 4.5 :
-
"C:\Program Files\Mercurial\hg.exe" archive --time --subrepos 
--no-decode --quiet --profile c:\temp\archive9

Total time: 20.218750 seconds
time: real 23.745 secs (user 8.109+0.000 sys 12.688+0.000)
-

hg 4.2.2
-

"C:\Program Files\Mercurial-422\hg.exe" archive --time --subrepos 
--no-decode --quiet --profile c:\temp\archive10

Total time: 15.984375 seconds
time: real 20.678 secs (user 7.234+0.000 sys 9.297+0.000)
-

I've confirmed this with a few different repos, the example above has 
lots of large files, I tested with others with thousands of source files 
and the slow down is is still around the 10-13% mark.


I'm not a python dev (mostly c# and delphi), so still getting my head 
around the hg code base, but I'm curious why the atomictemp=true is used 
in fileit.addfile? I get that it's in the vfs to work around file 
locking issues, but with the archive command with type files, it's 
likely that the archive is going to an empty target directory and this 
seems wasteful.


Is there anything else that can be done to speed up the archive (to 
files) command?


--

Regards

Vincent Parrett

CEO - VSoft Technologies Pty Ltd
https://www.finalbuilder.com
Blog: https://www.finalbuilder.com/resources/blogs
Automate your Software builds with FinalBuilder.
Open Source : https://github.com/VSoftTechnologies


___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 2 of 2 V2] revset: skip old style lookup if external whitespace are detected

2018-03-01 Thread Yuya Nishihara
On Thu, 1 Mar 2018 15:48:47 -0500, Feld Boris wrote:
> On 26/02/2018 08:11, Yuya Nishihara wrote:
> > On Mon, 26 Feb 2018 11:45:03 +0100, Feld Boris wrote:
> >> On 13/02/2018 12:47, Yuya Nishihara wrote:
> >>> On Mon, 12 Feb 2018 18:00:52 +0100, Boris Feld wrote:
>  # HG changeset patch
>  # User Boris Feld 
>  # Date 1518448909 -3600
>  #  Mon Feb 12 16:21:49 2018 +0100
>  # Node ID b0f45e1376e2d0f32023e197c51802bc21c60490
>  # Parent  f02fd7ca256d044c4a51c3f3fc0ecaf95d23e03d
>  # EXP-Topic noname
>  # Available At https://bitbucket.org/octobus/mercurial-devel/
>  #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
>  b0f45e1376e2
>  revset: skip old style lookup if external whitespace are detected
> 
>  Since label cannot contains leading or trailing whitespace we can skip 
>  looking
>  for them. This is useful in repository with slow labels (eg: special 
>  type of
>  tags). Short command running on a specific revision can benefit from such
>  shortcut.
> 
>  eg on a repository where loading tags take 0.4s:
> 
>  1: hg log --template '{node}\n' --rev 'rev(0)'
>   0.560 seconds
> 
>  2: hg log --template '{node}\n' --rev ' rev(0)'
>   0.109 seconds
> >>> Seems okay, but isn't it too obscure that prefixing with ' ' is the fast
> >>> way of querying?
> >> Yes, it is a bit obscure but it's the best solution we came up with
> >> existing code. I sent a new patch that implements the fast path at the
> >> individual name-space level in a way that seems cleaner and more useful.
> >>
> >> Another solution is we could force revset evaluation using a `set:` (or
> >> `revset:`) prefix. This way we could have both a clean and explicit way
> >> of implementing the fast path.
> > That isn't possible because "set:whatever" can be a range between "set"
> > and whatever. ;)
> 
> The proposal here is to define a prefix for which we break backward 
> compatibility. If we do so, people with a "" label will have to use:
> 
>    "":whatever
> 
> to get a similar effect.

IIRC x:y was the most important syntax that needed a strong BC guarantee, so
this proposal doesn't sound good.

> >>> Alternatively, we could add
> >>> a config knob to switch off the old-style range support.
> >> Having a config knob for this seems weird. We don't expect users to find
> >> it and really understand what the config is about. It would be useful
> >> for large corporate users with centralized config, but they would need
> >> to set the flag on every one of their scripts/servers involving Mercurial.
> > IMHO, config knob is easier to learn than using the ' ' prefix. I would say
> > WTF if I taught to use the ' ' to make hg fast. And I think this config can
> > be switched on by tweakdefaults because lookup() exists only for backward
> > compatibility. (We might still want to allow dashes in symbols, though.)
> Dropping the older lookup methods seems impractical. Right now, `rev(0)` 
> is a valid tag. So dropping legacy lookup means all these things will 
> have to be heavily quoted: (eg: hg log -r '"version-4(candidate2)"').

Yes. I assume that "foo(bar)" tags or branches wouldn't be used widely.

Since "foo(bar)" needs quotes in revset query (except for x and x:y), it would
makes some sense to add an option to disable the compatibility hack at all.

> A longer terms solution would be to support configuring constraints on 
> labels. If tags can be configured to only match a specific pattern we 
> could skip lookup for data that does not match it very quickly. To be 
> fully enforced it probably need to a part of the .hg/requires so it is a 
> heavier change. It also needs to be more than just a hook so that the 
> lookup logic is aware of it and can fast path it. Such approach work in 
> our use-case but is also more specific and requires more 
> configuration(work?).
> We could use the same approach as the V2 series proposed here: 
> https://www.mercurial-scm.org/pipermail/mercurial-devel/2018-February/112087.html

Just curious. Can't we make the name lookup instant?

> However, we think it still makes sense to have an easy and standard way 
> to force something to be evaluated as a revset as it's not possible as 
> of today.
> 
> Here is a summary of the idea we've discussed so far:
> 
> 1) Using some kind of prefix, breaking BC for people using the prefix as 
> a label:
> 
>    `revs:rev(42)` → directly evaluated as `rev(42)`
>    `"revs":rev(42)` → force "revs" as a label
> 
> 2) Adding a special revset for revset evaluation.
> 
>    `revset("rev(42)")` → directly evaluated `rev(42)`
> 
> 3) adding strange special case: (leading space, parents).
> 
>    ` rev(42)` → directly evaluated as `rev(42)`
>    `(rev(42))` → directly evaluated as `rev(42)`
> 
> 4) Config flag to disable legacy parsing (force quote for strange labels).
> 
> 5) Full-featured label patterns enforcement as 

Re: [PATCH] Fix for Bug #5807

2018-03-01 Thread Yuya Nishihara
On Thu, 1 Mar 2018 11:06:59 +0100, Sascha Nemecek wrote:
> # HG changeset patch
> # User Sascha Nemecek 
> # Date 1519831479 -3600
> #  Wed Feb 28 16:24:39 2018 +0100
> # Node ID 42ddf4ee4f91d76f19ca0c3efc4c8e4c1c6fa96c
> # Parent  1bd132a021dd00f96604e33a8fb5306d37e56007
> Don't close 'fp' (= 'ui.fout') stream to prevent 'ValueError: I/O 
> operation on closed file' (Bug #5807).
> 
> Regression of changeset 30261:6bed17ba00a1 
> (https://www.mercurial-scm.org/repo/hg/rev/6bed17ba00a1)
> 
> diff -r 1bd132a021dd -r 42ddf4ee4f91 hgext/convert/subversion.py
> --- a/hgext/convert/subversion.py Wed Feb 21 14:36:42 2018 +0530
> +++ b/hgext/convert/subversion.py Wed Feb 28 16:24:39 2018 +0100
> @@ -149,7 +149,7 @@
>   pickle.dump(str(inst), fp, protocol)
>   else:
>   pickle.dump(None, fp, protocol)
> -fp.close()
> +fp.flush()
>   # With large history, cleanup process goes crazy and suddenly
>   # consumes *huge* amount of memory. The output file being closed,
>   # there is no need for clean termination.

I don't think fp.close() was the source of the problem. Here the process
_exit()s so no cleanup would be run.

I suspect that some hidden bug was disclosed by the change 3a4c0905f357,
"util: always force line buffered stdout when stdout is a tty." Before,
ui.fout.close() just called fflush() because sys.stdout.close() doesn't
close the underlying file stream. This no longer applies to the current
ui.fout as it is created by fdopen(1).
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2438: util: use pycompat.bytestr() on repr() in date parse abort

2018-03-01 Thread yuja (Yuya Nishihara)
yuja added a comment.


  repr() should be applied to a bytestr object to get bytestr.__repr__() 
working.
  Fixed in flight.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2438

To: durin42, #hg-reviewers, pulkit
Cc: pulkit, yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2529: convert: fix two %r output formats with pycompat.bytestr() wrapping

2018-03-01 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGee0192854bb4: convert: fix two %r output formats with 
pycompat.bytestr() wrapping (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2529?vs=6305=6322

REVISION DETAIL
  https://phab.mercurial-scm.org/D2529

AFFECTED FILES
  hgext/convert/filemap.py

CHANGE DETAILS

diff --git a/hgext/convert/filemap.py b/hgext/convert/filemap.py
--- a/hgext/convert/filemap.py
+++ b/hgext/convert/filemap.py
@@ -11,6 +11,7 @@
 from mercurial.i18n import _
 from mercurial import (
 error,
+pycompat,
 )
 from . import common
 SKIPREV = common.SKIPREV
@@ -67,7 +68,8 @@
 name.endswith('/') or
 '//' in name):
 self.ui.warn(_('%s:%d: superfluous / in %s %r\n') %
- (lex.infile, lex.lineno, listname, name))
+ (lex.infile, lex.lineno, listname,
+  pycompat.bytestr(name)))
 return 1
 return 0
 lex = common.shlexer(
@@ -92,7 +94,7 @@
 errs += self.parse(normalize(lex.get_token()))
 else:
 self.ui.warn(_('%s:%d: unknown directive %r\n') %
- (lex.infile, lex.lineno, cmd))
+ (lex.infile, lex.lineno, pycompat.bytestr(cmd)))
 errs += 1
 cmd = lex.get_token()
 return errs



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2530: py3: whitelist three more passing tests

2018-03-01 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG9bc76f38defa: py3: whitelist three more passing tests 
(authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2530?vs=6306=6323

REVISION DETAIL
  https://phab.mercurial-scm.org/D2530

AFFECTED FILES
  contrib/python3-whitelist

CHANGE DETAILS

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -45,6 +45,8 @@
 test-convert-authormap.t
 test-convert-clonebranches.t
 test-convert-datesort.t
+test-convert-filemap.t
+test-convert-hg-sink.t
 test-convert-hg-startrev.t
 test-copy-move-merge.t
 test-copytrace-heuristics.t
@@ -194,6 +196,7 @@
 test-narrow-copies.t
 test-narrow-debugrebuilddirstate.t
 test-narrow-exchange-merges.t
+test-narrow-exchange.t
 test-narrow-merge.t
 test-narrow-patch.t
 test-narrow-patterns.t



To: durin42, pulkit, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2535: py3: use pycompat.bytestr() to convert error messages to bytes

2018-03-01 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2535

AFFECTED FILES
  hgext/convert/subversion.py
  hgext/gpg.py
  hgext/journal.py
  hgext/largefiles/overrides.py
  hgext/mq.py
  hgext/narrow/narrowbundle2.py
  hgext/relink.py

CHANGE DETAILS

diff --git a/hgext/relink.py b/hgext/relink.py
--- a/hgext/relink.py
+++ b/hgext/relink.py
@@ -187,7 +187,7 @@
 relinked += 1
 savedbytes += sz
 except OSError as inst:
-ui.warn('%s: %s\n' % (tgt, str(inst)))
+ui.warn('%s: %s\n' % (tgt, pycompat.bytestr(inst)))
 
 ui.progress(_('relinking'), None)
 
diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -25,6 +25,7 @@
 exchange,
 extensions,
 narrowspec,
+pycompat,
 repair,
 util,
 wireproto,
@@ -449,7 +450,7 @@
 except OSError as e:
 if e.errno != errno.ENOENT:
 ui.warn(_('error removing %s: %s\n') %
-(undovfs.join(undofile), str(e)))
+(undovfs.join(undofile), pycompat.bytestr(e)))
 
 # Remove partial backup only if there were no exceptions
 vfs.unlink(chgrpfile)
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -722,7 +722,8 @@
 try:
 os.unlink(undo)
 except OSError as inst:
-self.ui.warn(_('error removing undo: %s\n') % str(inst))
+self.ui.warn(_('error removing undo: %s\n') % \
+ pycompat.bytestr(inst))
 
 def backup(self, repo, files, copy=False):
 # backup local changes in --force case
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -598,7 +598,7 @@
 try:
 result = orig(ui, repo, pats, opts, rename)
 except error.Abort as e:
-if str(e) != _('no files to copy'):
+if pycompat.bytestr(e) != _('no files to copy'):
 raise e
 else:
 nonormalfiles = True
@@ -705,7 +705,7 @@
 lfdirstate.add(destlfile)
 lfdirstate.write()
 except error.Abort as e:
-if str(e) != _('no files to copy'):
+if pycompat.bytestr(e) != _('no files to copy'):
 raise e
 else:
 nolfiles = True
diff --git a/hgext/journal.py b/hgext/journal.py
--- a/hgext/journal.py
+++ b/hgext/journal.py
@@ -507,7 +507,7 @@
 ctx = repo[hash]
 displayer.show(ctx)
 except error.RepoLookupError as e:
-fm.write('repolookuperror', "%s\n\n", str(e))
+fm.write('repolookuperror', "%s\n\n", pycompat.bytestr(e))
 displayer.close()
 
 fm.end()
diff --git a/hgext/gpg.py b/hgext/gpg.py
--- a/hgext/gpg.py
+++ b/hgext/gpg.py
@@ -317,7 +317,7 @@
 repo.commit(message, opts['user'], opts['date'], match=msigs,
 editor=editor)
 except ValueError as inst:
-raise error.Abort(str(inst))
+raise error.Abort(pycompat.bytestr(inst))
 
 def node2txt(repo, node, ver):
 """map a manifest into some text"""
diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
--- a/hgext/convert/subversion.py
+++ b/hgext/convert/subversion.py
@@ -146,7 +146,7 @@
 # Caller may interrupt the iteration
 pickle.dump(None, fp, protocol)
 except Exception as inst:
-pickle.dump(str(inst), fp, protocol)
+pickle.dump(pycompat.bytestr(inst), fp, protocol)
 else:
 pickle.dump(None, fp, protocol)
 fp.flush()



To: pulkit, durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2536: py3: use util.forcebytestr() to convert IOErrors to bytes

2018-03-01 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2536

AFFECTED FILES
  hgext/largefiles/remotestore.py

CHANGE DETAILS

diff --git a/hgext/largefiles/remotestore.py b/hgext/largefiles/remotestore.py
--- a/hgext/largefiles/remotestore.py
+++ b/hgext/largefiles/remotestore.py
@@ -52,23 +52,25 @@
 except IOError as e:
 raise error.Abort(
 _('remotestore: could not open file %s: %s')
-% (filename, str(e)))
+% (filename, util.forcebytestr(e)))
 
 def _getfile(self, tmpfile, filename, hash):
 try:
 chunks = self._get(hash)
 except urlerr.httperror as e:
 # 401s get converted to error.Aborts; everything else is fine being
 # turned into a StoreError
-raise basestore.StoreError(filename, hash, self.url, str(e))
+raise basestore.StoreError(filename, hash, self.url,
+   util.forcebytestr(e))
 except urlerr.urlerror as e:
 # This usually indicates a connection problem, so don't
 # keep trying with the other files... they will probably
 # all fail too.
 raise error.Abort('%s: %s' %
  (util.hidepassword(self.url), e.reason))
 except IOError as e:
-raise basestore.StoreError(filename, hash, self.url, str(e))
+raise basestore.StoreError(filename, hash, self.url,
+   util.forcebytestr(e))
 
 return lfutil.copyandhash(chunks, tmpfile)
 



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


[PATCH 08 of 10] templatekw: switch manifest template keyword to new API

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519559753 -32400
#  Sun Feb 25 20:55:53 2018 +0900
# Node ID 852829295891f2decb6132113f1f1d437c376f6a
# Parent  69d82c25f62751f65cbc40f225f7a1b3f5326a1f
templatekw: switch manifest template keyword to new API

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -646,18 +646,20 @@ def _showchangessincetag(context, mappin
 # teach templater latesttags.changes is switched to (context, mapping) API
 _showchangessincetag._requires = {'repo', 'ctx'}
 
-@templatekeyword('manifest')
-def showmanifest(**args):
-repo, ctx, templ = args[r'repo'], args[r'ctx'], args[r'templ']
+@templatekeyword('manifest', requires={'repo', 'ctx', 'templ'})
+def showmanifest(context, mapping):
+repo = context.resource(mapping, 'repo')
+ctx = context.resource(mapping, 'ctx')
+templ = context.resource(mapping, 'templ')
 mnode = ctx.manifestnode()
 if mnode is None:
 # just avoid crash, we might want to use the 'ff...' hash in future
 return
 mrev = repo.manifestlog._revlog.rev(mnode)
 mhex = hex(mnode)
-args = args.copy()
-args.update({r'rev': mrev, r'node': mhex})
-f = templ('manifest', **args)
+mapping = mapping.copy()
+mapping.update({'rev': mrev, 'node': mhex})
+f = templ('manifest', **pycompat.strkwargs(mapping))
 # TODO: perhaps 'ctx' should be dropped from mapping because manifest
 # rev and node are completely different from changeset's.
 return _mappable(f, None, f, lambda x: {'rev': mrev, 'node': mhex})
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 10 of 10] templatekw: deprecate showdict() and showlist() (API)

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519554875 -32400
#  Sun Feb 25 19:34:35 2018 +0900
# Node ID d6bbe8dfafaeb32e48b38c1815dda69ca0854a5e
# Parent  0e49bbe25cdc0eb0898737dd4f584e89f8b8eb6a
templatekw: deprecate showdict() and showlist() (API)

.. api::

   templatekw.showdict() and showlist() are deprecated in favor of new
   (context, mapping) API. Switch the keyword function to new API and use
   templatekw.compatdict() and compatlist() instead.

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -161,11 +161,19 @@ def compatlist(context, mapping, name, d
 
 def showdict(name, data, mapping, plural=None, key='key', value='value',
  fmt='%s=%s', separator=' '):
+ui = mapping.get('ui')
+if ui:
+ui.deprecwarn("templatekw.showdict() is deprecated, use compatdict()",
+  '4.6')
 c = [{key: k, value: v} for k, v in data.iteritems()]
 f = _showlist(name, c, mapping['templ'], mapping, plural, separator)
 return hybriddict(data, key=key, value=value, fmt=fmt, gen=f)
 
 def showlist(name, values, mapping, plural=None, element=None, separator=' '):
+ui = mapping.get('ui')
+if ui:
+ui.deprecwarn("templatekw.showlist() is deprecated, use compatlist()",
+  '4.6')
 if not element:
 element = name
 f = _showlist(name, values, mapping['templ'], mapping, plural, separator)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 09 of 10] templatekw: switch remainder of _showlist template keywords to new API

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519554314 -32400
#  Sun Feb 25 19:25:14 2018 +0900
# Node ID 0e49bbe25cdc0eb0898737dd4f584e89f8b8eb6a
# Parent  852829295891f2decb6132113f1f1d437c376f6a
templatekw: switch remainder of _showlist template keywords to new API

diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py
--- a/hgext/lfs/__init__.py
+++ b/hgext/lfs/__init__.py
@@ -356,11 +356,12 @@ def lfsfileset(mctx, x):
 return [f for f in mctx.subset
 if wrapper.pointerfromctx(mctx.ctx, f, removed=True) is not None]
 
-@templatekeyword('lfs_files')
-def lfsfiles(repo, ctx, **args):
+@templatekeyword('lfs_files', requires={'ctx', 'templ'})
+def lfsfiles(context, mapping):
 """List of strings. All files modified, added, or removed by this
 changeset."""
-args = pycompat.byteskwargs(args)
+ctx = context.resource(mapping, 'ctx')
+templ = context.resource(mapping, 'templ')
 
 pointers = wrapper.pointersfromctx(ctx, removed=True) # {path: pointer}
 files = sorted(pointers.keys())
@@ -378,7 +379,7 @@ def lfsfiles(repo, ctx, **args):
 }
 
 # TODO: make the separator ', '?
-f = templatekw._showlist('lfs_file', files, args['templ'], args)
+f = templatekw._showlist('lfs_file', files, templ, mapping)
 return templatekw._hybrid(f, files, makemap, pycompat.identity)
 
 @command('debuglfsupload',
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -399,17 +399,18 @@ def showbranches(context, mapping):
   plural='branches')
 return compatlist(context, mapping, 'branch', [], plural='branches')
 
-@templatekeyword('bookmarks')
-def showbookmarks(**args):
+@templatekeyword('bookmarks', requires={'repo', 'ctx', 'templ'})
+def showbookmarks(context, mapping):
 """List of strings. Any bookmarks associated with the
 changeset. Also sets 'active', the name of the active bookmark.
 """
-args = pycompat.byteskwargs(args)
-repo = args['ctx']._repo
-bookmarks = args['ctx'].bookmarks()
+repo = context.resource(mapping, 'repo')
+ctx = context.resource(mapping, 'ctx')
+templ = context.resource(mapping, 'templ')
+bookmarks = ctx.bookmarks()
 active = repo._activebookmark
 makemap = lambda v: {'bookmark': v, 'active': active, 'current': active}
-f = _showlist('bookmark', bookmarks, args['templ'], args)
+f = _showlist('bookmark', bookmarks, templ, mapping)
 return _hybrid(f, bookmarks, makemap, pycompat.identity)
 
 @templatekeyword('children', requires={'ctx', 'templ'})
@@ -471,16 +472,17 @@ def showenvvars(context, mapping):
 env = util.sortdict((k, env[k]) for k in sorted(env))
 return compatdict(context, mapping, 'envvar', env, plural='envvars')
 
-@templatekeyword('extras')
-def showextras(**args):
+@templatekeyword('extras', requires={'ctx', 'templ'})
+def showextras(context, mapping):
 """List of dicts with key, value entries of the 'extras'
 field of this changeset."""
-args = pycompat.byteskwargs(args)
-extras = args['ctx'].extra()
+ctx = context.resource(mapping, 'ctx')
+templ = context.resource(mapping, 'templ')
+extras = ctx.extra()
 extras = util.sortdict((k, extras[k]) for k in sorted(extras))
 makemap = lambda k: {'key': k, 'value': extras[k]}
 c = [makemap(k) for k in extras]
-f = _showlist('extra', c, args['templ'], args, plural='extras')
+f = _showlist('extra', c, templ, mapping, plural='extras')
 return _hybrid(f, extras, makemap,
lambda k: '%s=%s' % (k, util.escapestr(extras[k])))
 
@@ -873,21 +875,21 @@ def showp2node(context, mapping):
 ctx = context.resource(mapping, 'ctx')
 return ctx.p2().hex()
 
-@templatekeyword('parents')
-def showparents(**args):
+@templatekeyword('parents', requires={'repo', 'ctx', 'templ'})
+def showparents(context, mapping):
 """List of strings. The parents of the changeset in "rev:node"
 format. If the changeset has only one "natural" parent (the predecessor
 revision) nothing is shown."""
-args = pycompat.byteskwargs(args)
-repo = args['repo']
-ctx = args['ctx']
+repo = context.resource(mapping, 'repo')
+ctx = context.resource(mapping, 'ctx')
+templ = context.resource(mapping, 'templ')
 pctxs = scmutil.meaningfulparents(repo, ctx)
 prevs = [p.rev() for p in pctxs]
 parents = [[('rev', p.rev()),
 ('node', p.hex()),
 ('phase', p.phasestr())]
for p in pctxs]
-f = _showlist('parent', parents, args['templ'], args)
+f = _showlist('parent', parents, templ, mapping)
 return _hybrid(f, prevs, lambda x: {'ctx': repo[x], 'revcache': {}},
lambda x: scmutil.formatchangeid(repo[x]), keytype=int)
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org

[PATCH 04 of 10] templatekw: switch namespace template keywords to new API

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519552371 -32400
#  Sun Feb 25 18:52:51 2018 +0900
# Node ID 5600b9bc3e406a1523b81688fded42b090defa0d
# Parent  00b4baafd47b4fb77c7946ccadefb69bc1525e41
templatekw: switch namespace template keywords to new API

diff --git a/mercurial/namespaces.py b/mercurial/namespaces.py
--- a/mercurial/namespaces.py
+++ b/mercurial/namespaces.py
@@ -89,9 +89,9 @@ class namespaces(object):
 # we only generate a template keyword if one does not already exist
 if namespace.name not in templatekw.keywords:
 templatekeyword = registrar.templatekeyword(templatekw.keywords)
-@templatekeyword(namespace.name)
-def generatekw(**args):
-return templatekw.shownames(namespace.name, **args)
+@templatekeyword(namespace.name, requires={'repo', 'ctx', 'templ'})
+def generatekw(context, mapping):
+return templatekw.shownames(context, mapping, namespace.name)
 
 def singlenode(self, repo, name):
 """
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -674,22 +674,22 @@ def showobsfate(**args):
 
 return showlist("fate", values, args)
 
-def shownames(namespace, **args):
+def shownames(context, mapping, namespace):
 """helper method to generate a template keyword for a namespace"""
-args = pycompat.byteskwargs(args)
-ctx = args['ctx']
-repo = ctx.repo()
+repo = context.resource(mapping, 'repo')
+ctx = context.resource(mapping, 'ctx')
 ns = repo.names[namespace]
 names = ns.names(repo, ctx.node())
-return showlist(ns.templatename, names, args, plural=namespace)
+return compatlist(context, mapping, ns.templatename, names,
+  plural=namespace)
 
-@templatekeyword('namespaces')
-def shownamespaces(**args):
+@templatekeyword('namespaces', requires={'repo', 'ctx', 'templ'})
+def shownamespaces(context, mapping):
 """Dict of lists. Names attached to this changeset per
 namespace."""
-args = pycompat.byteskwargs(args)
-ctx = args['ctx']
-repo = ctx.repo()
+repo = context.resource(mapping, 'repo')
+ctx = context.resource(mapping, 'ctx')
+templ = context.resource(mapping, 'templ')
 
 namespaces = util.sortdict()
 def makensmapfn(ns):
@@ -698,10 +698,10 @@ def shownamespaces(**args):
 
 for k, ns in repo.names.iteritems():
 names = ns.names(repo, ctx.node())
-f = _showlist('name', names, args['templ'], args)
+f = _showlist('name', names, templ, mapping)
 namespaces[k] = _hybrid(f, names, makensmapfn(ns), pycompat.identity)
 
-f = _showlist('namespace', list(namespaces), args['templ'], args)
+f = _showlist('namespace', list(namespaces), templ, mapping)
 
 def makemap(ns):
 return {
@@ -931,10 +931,10 @@ def showsubrepos(context, mapping):
 # don't remove "showtags" definition, even though namespaces will put
 # a helper function for "tags" keyword into "keywords" map automatically,
 # because online help text is built without namespaces initialization
-@templatekeyword('tags')
-def showtags(**args):
+@templatekeyword('tags', requires={'repo', 'ctx', 'templ'})
+def showtags(context, mapping):
 """List of strings. Any tags associated with the changeset."""
-return shownames('tags', **args)
+return shownames(context, mapping, 'tags')
 
 @templatekeyword('termwidth', requires={'ui'})
 def showtermwidth(context, mapping):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 03 of 10] namespace: use registrar to add template keyword

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519552566 -32400
#  Sun Feb 25 18:56:06 2018 +0900
# Node ID 00b4baafd47b4fb77c7946ccadefb69bc1525e41
# Parent  d82d2b2d91a5742b57f0b29d7ce3bcb0cd5da90b
namespace: use registrar to add template keyword

Prepares for switching to the new API.

diff --git a/mercurial/namespaces.py b/mercurial/namespaces.py
--- a/mercurial/namespaces.py
+++ b/mercurial/namespaces.py
@@ -2,6 +2,7 @@ from __future__ import absolute_import
 
 from .i18n import _
 from . import (
+registrar,
 templatekw,
 util,
 )
@@ -87,11 +88,11 @@ class namespaces(object):
 
 # we only generate a template keyword if one does not already exist
 if namespace.name not in templatekw.keywords:
+templatekeyword = registrar.templatekeyword(templatekw.keywords)
+@templatekeyword(namespace.name)
 def generatekw(**args):
 return templatekw.shownames(namespace.name, **args)
 
-templatekw.keywords[namespace.name] = generatekw
-
 def singlenode(self, repo, name):
 """
 Return the 'best' node for the given name. Best means the first node
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 01 of 10] templatekw: switch showdict template keywords to new API

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519543375 -32400
#  Sun Feb 25 16:22:55 2018 +0900
# Node ID 503e54575af502019158b1bcbf877029a6b601fe
# Parent  d40cfe72b79d3f6e548990faf98ba9b6fbe5027c
templatekw: switch showdict template keywords to new API

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -493,17 +493,19 @@ def showfileadds(**args):
 args = pycompat.byteskwargs(args)
 return _showfilesbystat(args, 'file_add', 1)
 
-@templatekeyword('file_copies')
-def showfilecopies(**args):
+@templatekeyword('file_copies',
+ requires={'repo', 'ctx', 'cache', 'revcache', 'templ'})
+def showfilecopies(context, mapping):
 """List of strings. Files copied in this changeset with
 their sources.
 """
-args = pycompat.byteskwargs(args)
-cache, ctx = args['cache'], args['ctx']
-copies = args['revcache'].get('copies')
+repo = context.resource(mapping, 'repo')
+ctx = context.resource(mapping, 'ctx')
+cache = context.resource(mapping, 'cache')
+copies = context.resource(mapping, 'revcache').get('copies')
 if copies is None:
 if 'getrenamed' not in cache:
-cache['getrenamed'] = getrenamedfn(args['repo'])
+cache['getrenamed'] = getrenamedfn(repo)
 copies = []
 getrenamed = cache['getrenamed']
 for fn in ctx.files():
@@ -512,22 +514,23 @@ def showfilecopies(**args):
 copies.append((fn, rename[0]))
 
 copies = util.sortdict(copies)
-return showdict('file_copy', copies, args, plural='file_copies',
-key='name', value='source', fmt='%s (%s)')
+return compatdict(context, mapping, 'file_copy', copies,
+  key='name', value='source', fmt='%s (%s)',
+  plural='file_copies')
 
 # showfilecopiesswitch() displays file copies only if copy records are
 # provided before calling the templater, usually with a --copies
 # command line switch.
-@templatekeyword('file_copies_switch')
-def showfilecopiesswitch(**args):
+@templatekeyword('file_copies_switch', requires={'revcache', 'templ'})
+def showfilecopiesswitch(context, mapping):
 """List of strings. Like "file_copies" but displayed
 only if the --copied switch is set.
 """
-args = pycompat.byteskwargs(args)
-copies = args['revcache'].get('copies') or []
+copies = context.resource(mapping, 'revcache').get('copies') or []
 copies = util.sortdict(copies)
-return showdict('file_copy', copies, args, plural='file_copies',
-key='name', value='source', fmt='%s (%s)')
+return compatdict(context, mapping, 'file_copy', copies,
+  key='name', value='source', fmt='%s (%s)',
+  plural='file_copies')
 
 @templatekeyword('file_dels')
 def showfiledels(**args):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 05 of 10] templatekw: switch obsfate-related template keywords to new API

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519553157 -32400
#  Sun Feb 25 19:05:57 2018 +0900
# Node ID fcf9fc91b3a946757e70171f388e6ea5e23db50f
# Parent  5600b9bc3e406a1523b81688fded42b090defa0d
templatekw: switch obsfate-related template keywords to new API

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -352,12 +352,16 @@ def linerange(req):
 def formatlinerange(fromline, toline):
 return '%d:%d' % (fromline + 1, toline)
 
-def succsandmarkers(repo, ctx, **args):
-for item in templatekw.showsuccsandmarkers(repo, ctx, **args):
+def succsandmarkers(context, mapping):
+repo = context.resource(mapping, 'repo')
+for item in templatekw.showsuccsandmarkers(context, mapping):
 item['successors'] = _siblings(repo[successor]
for successor in item['successors'])
 yield item
 
+# teach templater succsandmarkers is switched to (context, mapping) API
+succsandmarkers._requires = {'repo', 'ctx', 'templ'}
+
 def commonentry(repo, ctx):
 node = ctx.node()
 return {
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -656,23 +656,21 @@ def showmanifest(**args):
 # rev and node are completely different from changeset's.
 return _mappable(f, None, f, lambda x: {'rev': mrev, 'node': mhex})
 
-@templatekeyword('obsfate')
-def showobsfate(**args):
+@templatekeyword('obsfate', requires={'ui', 'repo', 'ctx', 'templ'})
+def showobsfate(context, mapping):
 # this function returns a list containing pre-formatted obsfate strings.
 #
 # This function will be replaced by templates fragments when we will have
 # the verbosity templatekw available.
-succsandmarkers = showsuccsandmarkers(**args)
+succsandmarkers = showsuccsandmarkers(context, mapping)
 
-args = pycompat.byteskwargs(args)
-ui = args['ui']
-
+ui = context.resource(mapping, 'ui')
 values = []
 
 for x in succsandmarkers:
 values.append(obsutil.obsfateprinter(x['successors'], x['markers'], 
ui))
 
-return showlist("fate", values, args)
+return compatlist(context, mapping, "fate", values)
 
 def shownames(context, mapping, namespace):
 """helper method to generate a template keyword for a namespace"""
@@ -794,13 +792,16 @@ def showsuccessorssets(context, mapping)
 return _hybrid(gen(data), data, lambda x: {'successorset': x},
pycompat.identity)
 
-@templatekeyword("succsandmarkers")
-def showsuccsandmarkers(repo, ctx, **args):
+@templatekeyword("succsandmarkers", requires={'repo', 'ctx', 'templ'})
+def showsuccsandmarkers(context, mapping):
 """Returns a list of dict for each final successor of ctx. The dict
 contains successors node id in "successors" keys and the list of
 obs-markers from ctx to the set of successors in "markers".
 (EXPERIMENTAL)
 """
+repo = context.resource(mapping, 'repo')
+ctx = context.resource(mapping, 'ctx')
+templ = context.resource(mapping, 'templ')
 
 values = obsutil.successorsandmarkers(repo, ctx)
 
@@ -831,8 +832,7 @@ def showsuccsandmarkers(repo, ctx, **arg
 
 data.append({'successors': successors, 'markers': finalmarkers})
 
-args = pycompat.byteskwargs(args)
-f = _showlist('succsandmarkers', data, args['templ'], args)
+f = _showlist('succsandmarkers', data, templ, mapping)
 return _hybrid(f, data, lambda x: x, pycompat.identity)
 
 @templatekeyword('p1rev', requires={'ctx'})
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 06 of 10] templatekw: switch revset() to new API

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519553282 -32400
#  Sun Feb 25 19:08:02 2018 +0900
# Node ID 2918050dfb1503e9ebcba830e4584288e4ab4a40
# Parent  fcf9fc91b3a946757e70171f388e6ea5e23db50f
templatekw: switch revset() to new API

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -901,12 +901,12 @@ def showrev(context, mapping):
 ctx = context.resource(mapping, 'ctx')
 return scmutil.intrev(ctx)
 
-def showrevslist(name, revs, **args):
+def showrevslist(context, mapping, name, revs):
 """helper to generate a list of revisions in which a mapped template will
 be evaluated"""
-args = pycompat.byteskwargs(args)
-repo = args['ctx'].repo()
-f = _showlist(name, ['%d' % r for r in revs], args['templ'], args)
+repo = context.resource(mapping, 'repo')
+templ = context.resource(mapping, 'templ')
+f = _showlist(name, ['%d' % r for r in revs], templ, mapping)
 return _hybrid(f, revs,
lambda x: {name: x, 'ctx': repo[x], 'revcache': {}},
pycompat.identity, keytype=int)
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -1129,12 +1129,7 @@ def revset(context, mapping, args):
 revs = query(raw)
 revs = list(revs)
 revsetcache[raw] = revs
-
-# TODO: pass (context, mapping) pair to keyword function
-props = context._resources.copy()
-props.update(mapping)
-return templatekw.showrevslist("revision", revs,
-   **pycompat.strkwargs(props))
+return templatekw.showrevslist(context, mapping, "revision", revs)
 
 @templatefunc('rstdoc(text, style)')
 def rstdoc(context, mapping, args):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 02 of 10] templatekw: switch most of showlist template keywords to new API (issue5779)

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519544744 -32400
#  Sun Feb 25 16:45:44 2018 +0900
# Node ID d82d2b2d91a5742b57f0b29d7ce3bcb0cd5da90b
# Parent  503e54575af502019158b1bcbf877029a6b601fe
templatekw: switch most of showlist template keywords to new API (issue5779)

Non-trivial changes will follow.

diff --git a/hgext/remotenames.py b/hgext/remotenames.py
--- a/hgext/remotenames.py
+++ b/hgext/remotenames.py
@@ -32,7 +32,6 @@ from mercurial.node import (
 from mercurial import (
 logexchange,
 namespaces,
-pycompat,
 registrar,
 revsetlang,
 smartset,
@@ -225,11 +224,11 @@ def reposetup(ui, repo):
 repo._remotenames.nodetobranch().get(node, []))
 repo.names.addnamespace(remotebranchns)
 
-@templatekeyword('remotenames')
-def remotenameskw(**args):
+@templatekeyword('remotenames', requires={'repo', 'ctx', 'templ'})
+def remotenameskw(context, mapping):
 """List of strings. Remote names associated with the changeset."""
-args = pycompat.byteskwargs(args)
-repo, ctx = args['repo'], args['ctx']
+repo = context.resource(mapping, 'repo')
+ctx = context.resource(mapping, 'ctx')
 
 remotenames = []
 if 'remotebookmarks' in repo.names:
@@ -238,34 +237,34 @@ def remotenameskw(**args):
 if 'remotebranches' in repo.names:
 remotenames += repo.names['remotebranches'].names(repo, ctx.node())
 
-return templatekw.showlist('remotename', remotenames, args,
-   plural='remotenames')
+return templatekw.compatlist(context, mapping, 'remotename', remotenames,
+ plural='remotenames')
 
-@templatekeyword('remotebookmarks')
-def remotebookmarkskw(**args):
+@templatekeyword('remotebookmarks', requires={'repo', 'ctx', 'templ'})
+def remotebookmarkskw(context, mapping):
 """List of strings. Remote bookmarks associated with the changeset."""
-args = pycompat.byteskwargs(args)
-repo, ctx = args['repo'], args['ctx']
+repo = context.resource(mapping, 'repo')
+ctx = context.resource(mapping, 'ctx')
 
 remotebmarks = []
 if 'remotebookmarks' in repo.names:
 remotebmarks = repo.names['remotebookmarks'].names(repo, ctx.node())
 
-return templatekw.showlist('remotebookmark', remotebmarks, args,
-   plural='remotebookmarks')
+return templatekw.compatlist(context, mapping, 'remotebookmark',
+ remotebmarks, plural='remotebookmarks')
 
-@templatekeyword('remotebranches')
-def remotebrancheskw(**args):
+@templatekeyword('remotebranches', requires={'repo', 'ctx', 'templ'})
+def remotebrancheskw(context, mapping):
 """List of strings. Remote branches associated with the changeset."""
-args = pycompat.byteskwargs(args)
-repo, ctx = args['repo'], args['ctx']
+repo = context.resource(mapping, 'repo')
+ctx = context.resource(mapping, 'ctx')
 
 remotebranches = []
 if 'remotebranches' in repo.names:
 remotebranches = repo.names['remotebranches'].names(repo, ctx.node())
 
-return templatekw.showlist('remotebranch', remotebranches, args,
-   plural='remotebranches')
+return templatekw.compatlist(context, mapping, 'remotebranch',
+ remotebranches, plural='remotebranches')
 
 def _revsetutil(repo, subset, x, rtypes):
 """utility function to return a set of revs based on the rtypes"""
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -383,17 +383,18 @@ def showbranch(context, mapping):
 ctx = context.resource(mapping, 'ctx')
 return ctx.branch()
 
-@templatekeyword('branches')
-def showbranches(**args):
+@templatekeyword('branches', requires={'ctx', 'templ'})
+def showbranches(context, mapping):
 """List of strings. The name of the branch on which the
 changeset was committed. Will be empty if the branch name was
 default. (DEPRECATED)
 """
-args = pycompat.byteskwargs(args)
-branch = args['ctx'].branch()
+ctx = context.resource(mapping, 'ctx')
+branch = ctx.branch()
 if branch != 'default':
-return showlist('branch', [branch], args, plural='branches')
-return showlist('branch', [], args, plural='branches')
+return compatlist(context, mapping, 'branch', [branch],
+  plural='branches')
+return compatlist(context, mapping, 'branch', [], plural='branches')
 
 @templatekeyword('bookmarks')
 def showbookmarks(**args):
@@ -480,18 +481,19 @@ def showextras(**args):
 return _hybrid(f, extras, makemap,
lambda k: '%s=%s' % (k, util.escapestr(extras[k])))
 
-def _showfilesbystat(args, name, index):
-repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
+def _showfilesbystat(context, mapping, name, index):
+repo = context.resource(mapping, 'repo')
+ctx = 

[PATCH 07 of 10] templatekw: switch latesttags template keywords to new API

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519554186 -32400
#  Sun Feb 25 19:23:06 2018 +0900
# Node ID 69d82c25f62751f65cbc40f225f7a1b3f5326a1f
# Parent  2918050dfb1503e9ebcba830e4584288e4ab4a40
templatekw: switch latesttags template keywords to new API

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -238,8 +238,11 @@ def _showlist(name, values, templ, mappi
 if endname in templ:
 yield templ(endname, **strmapping)
 
-def getlatesttags(repo, ctx, cache, pattern=None):
+def getlatesttags(context, mapping, pattern=None):
 '''return date, distance and name for the latest tag of rev'''
+repo = context.resource(mapping, 'repo')
+ctx = context.resource(mapping, 'ctx')
+cache = context.resource(mapping, 'cache')
 
 cachename = 'latesttags'
 if pattern is not None:
@@ -587,20 +590,17 @@ def showindex(context, mapping):
 # just hosts documentation; should be overridden by template mapping
 raise error.Abort(_("can't use index in this context"))
 
-@templatekeyword('latesttag')
-def showlatesttag(**args):
+@templatekeyword('latesttag', requires={'repo', 'ctx', 'cache', 'templ'})
+def showlatesttag(context, mapping):
 """List of strings. The global tags on the most recent globally
 tagged ancestor of this changeset.  If no such tags exist, the list
 consists of the single string "null".
 """
-return showlatesttags(None, **args)
+return showlatesttags(context, mapping, None)
 
-def showlatesttags(pattern, **args):
+def showlatesttags(context, mapping, pattern):
 """helper method for the latesttag keyword and function"""
-args = pycompat.byteskwargs(args)
-repo, ctx = args['repo'], args['ctx']
-cache = args['cache']
-latesttags = getlatesttags(repo, ctx, cache, pattern)
+latesttags = getlatesttags(context, mapping, pattern)
 
 # latesttag[0] is an implementation detail for sorting csets on different
 # branches in a stable manner- it is the date the tagged cset was created,
@@ -613,25 +613,28 @@ def showlatesttags(pattern, **args):
 }
 
 tags = latesttags[2]
-f = _showlist('latesttag', tags, args['templ'], args, separator=':')
+templ = context.resource(mapping, 'templ')
+f = _showlist('latesttag', tags, templ, mapping, separator=':')
 return _hybrid(f, tags, makemap, pycompat.identity)
 
-@templatekeyword('latesttagdistance')
-def showlatesttagdistance(repo, ctx, templ, cache, **args):
+@templatekeyword('latesttagdistance', requires={'repo', 'ctx', 'cache'})
+def showlatesttagdistance(context, mapping):
 """Integer. Longest path to the latest tag."""
-return getlatesttags(repo, ctx, cache)[1]
+return getlatesttags(context, mapping)[1]
 
-@templatekeyword('changessincelatesttag')
-def showchangessincelatesttag(repo, ctx, templ, cache, **args):
+@templatekeyword('changessincelatesttag', requires={'repo', 'ctx', 'cache'})
+def showchangessincelatesttag(context, mapping):
 """Integer. All ancestors not in the latest tag."""
-latesttag = getlatesttags(repo, ctx, cache)[2][0]
+mapping = mapping.copy()
+mapping['tag'] = getlatesttags(context, mapping)[2][0]
+return _showchangessincetag(context, mapping)
 
-return _showchangessincetag(repo, ctx, tag=latesttag, **args)
-
-def _showchangessincetag(repo, ctx, **args):
+def _showchangessincetag(context, mapping):
+repo = context.resource(mapping, 'repo')
+ctx = context.resource(mapping, 'ctx')
 offset = 0
 revs = [ctx.rev()]
-tag = args[r'tag']
+tag = context.symbol(mapping, 'tag')
 
 # The only() revset doesn't currently support wdir()
 if ctx.rev() is None:
@@ -640,6 +643,9 @@ def _showchangessincetag(repo, ctx, **ar
 
 return len(repo.revs('only(%ld, %s)', revs, tag)) + offset
 
+# teach templater latesttags.changes is switched to (context, mapping) API
+_showchangessincetag._requires = {'repo', 'ctx'}
+
 @templatekeyword('manifest')
 def showmanifest(**args):
 repo, ctx, templ = args[r'repo'], args[r'ctx'], args[r'templ']
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -942,11 +942,7 @@ def latesttag(context, mapping, args):
 pattern = None
 if len(args) == 1:
 pattern = evalstring(context, mapping, args[0])
-
-# TODO: pass (context, mapping) pair to keyword function
-props = context._resources.copy()
-props.update(mapping)
-return templatekw.showlatesttags(pattern, **pycompat.strkwargs(props))
+return templatekw.showlatesttags(context, mapping, pattern)
 
 @templatefunc('localdate(date[, tz])')
 def localdate(context, mapping, args):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2526: convcmd: use our shlex wrapper to avoid Python 3 tracebacks

2018-03-01 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGfdd783a7e515: convcmd: use our shlex wrapper to avoid 
Python 3 tracebacks (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2526?vs=6302=6318

REVISION DETAIL
  https://phab.mercurial-scm.org/D2526

AFFECTED FILES
  hgext/convert/convcmd.py

CHANGE DETAILS

diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py
--- a/hgext/convert/convcmd.py
+++ b/hgext/convert/convcmd.py
@@ -8,7 +8,6 @@
 
 import collections
 import os
-import shlex
 import shutil
 
 from mercurial.i18n import _
@@ -211,9 +210,7 @@
 # Ignore blank lines
 continue
 # split line
-lex = shlex.shlex(line, posix=True)
-lex.whitespace_split = True
-lex.whitespace += ','
+lex = common.shlexer(data=line, whitespace=',')
 line = list(lex)
 # check number of parents
 if not (2 <= len(line) <= 3):



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2527: convert: use our shlex wrapper in filemap to avoid Python 3 tracebacks

2018-03-01 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGc48c3da88e6c: convert: use our shlex wrapper in filemap to 
avoid Python 3 tracebacks (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2527?vs=6303=6319

REVISION DETAIL
  https://phab.mercurial-scm.org/D2527

AFFECTED FILES
  hgext/convert/filemap.py

CHANGE DETAILS

diff --git a/hgext/convert/filemap.py b/hgext/convert/filemap.py
--- a/hgext/convert/filemap.py
+++ b/hgext/convert/filemap.py
@@ -7,7 +7,6 @@
 from __future__ import absolute_import, print_function
 
 import posixpath
-import shlex
 
 from mercurial.i18n import _
 from mercurial import (
@@ -71,8 +70,8 @@
  (lex.infile, lex.lineno, listname, name))
 return 1
 return 0
-lex = shlex.shlex(open(path, 'rb'), path, True)
-lex.wordchars += '!@#$%^&*()-=+[]{}|;:,./<>?'
+lex = common.shlexer(
+filepath=path, wordchars='!@#$%^&*()-=+[]{}|;:,./<>?')
 cmd = lex.get_token()
 while cmd:
 if cmd == 'include':



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2525: convert: add some utility code for working with shlex on Python 3

2018-03-01 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG52a44d7f998b: convert: add some utility code for working 
with shlex on Python 3 (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2525?vs=6301=6317

REVISION DETAIL
  https://phab.mercurial-scm.org/D2525

AFFECTED FILES
  hgext/convert/common.py

CHANGE DETAILS

diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -11,6 +11,7 @@
 import errno
 import os
 import re
+import shlex
 import subprocess
 
 from mercurial.i18n import _
@@ -25,6 +26,58 @@
 pickle = util.pickle
 propertycache = util.propertycache
 
+def _encodeornone(d):
+if d is None:
+return
+return d.encode('latin1')
+
+class _shlexpy3proxy(object):
+
+def __init__(self, l):
+self._l = l
+
+def __iter__(self):
+return (_encodeornone(v) for v in self._l)
+
+def get_token(self):
+return _encodeornone(self._l.get_token())
+
+@property
+def infile(self):
+return self._l.infile or ''
+
+@property
+def lineno(self):
+return self._l.lineno
+
+def shlexer(data=None, filepath=None, wordchars=None, whitespace=None):
+if data is None:
+if pycompat.ispy3:
+data = open(filepath, 'r', encoding=r'latin1')
+else:
+data = open(filepath, 'r')
+else:
+if filepath is not None:
+raise error.ProgrammingError(
+'shlexer only accepts data or filepath, not both')
+if pycompat.ispy3:
+data = data.decode('latin1')
+l = shlex.shlex(data, infile=filepath, posix=True)
+if whitespace is not None:
+l.whitespace_split = True
+if pycompat.ispy3:
+l.whitespace += whitespace.decode('latin1')
+else:
+l.whitespace += whitespace
+if wordchars is not None:
+if pycompat.ispy3:
+l.wordchars += wordchars.decode('latin1')
+else:
+l.wordchars += wordchars
+if pycompat.ispy3:
+return _shlexpy3proxy(l)
+return l
+
 def encodeargs(args):
 def encodearg(s):
 lines = base64.encodestring(s)



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2524: pycompat: add support for encoding argument to our wrapper

2018-03-01 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG3396586abdc1: pycompat: add support for encoding argument 
to our wrapper (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2524?vs=6300=6316

REVISION DETAIL
  https://phab.mercurial-scm.org/D2524

AFFECTED FILES
  mercurial/pycompat.py

CHANGE DETAILS

diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -224,8 +224,8 @@
 xrange = builtins.range
 unicode = str
 
-def open(name, mode='r', buffering=-1):
-return builtins.open(name, sysstr(mode), buffering)
+def open(name, mode='r', buffering=-1, encoding=None):
+return builtins.open(name, sysstr(mode), buffering, encoding)
 
 def _getoptbwrapper(orig, args, shortlist, namelist):
 """



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2533: py3: use pycompat.bytestr() to convert None to bytes

2018-03-01 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG32b3d050d997: py3: use pycompat.bytestr() to convert None 
to bytes (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2533?vs=6312=6314

REVISION DETAIL
  https://phab.mercurial-scm.org/D2533

AFFECTED FILES
  mercurial/localrepo.py

CHANGE DETAILS

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -191,7 +191,9 @@
 
 def debugwireargs(self, one, two, three=None, four=None, five=None):
 """Used to test argument passing over the wire"""
-return "%s %s %s %s %s" % (one, two, three, four, five)
+return "%s %s %s %s %s" % (one, two, pycompat.bytestr(three),
+   pycompat.bytestr(four),
+   pycompat.bytestr(five))
 
 def getbundle(self, source, heads=None, common=None, bundlecaps=None,
   **kwargs):
@@ -2231,7 +2233,9 @@
 
 def debugwireargs(self, one, two, three=None, four=None, five=None):
 '''used to test argument passing over the wire'''
-return "%s %s %s %s %s" % (one, two, three, four, five)
+return "%s %s %s %s %s" % (one, two, pycompat.bytestr(three),
+   pycompat.bytestr(four),
+   pycompat.bytestr(five))
 
 def savecommitmessage(self, text):
 fp = self.vfs('last-message.txt', 'wb')



To: pulkit, #hg-reviewers, durin42
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2534: py3: port tests/test-wireproto.py to Python 3

2018-03-01 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb5821f9745ca: py3: port tests/test-wireproto.py to Python 3 
(authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2534?vs=6313=6315

REVISION DETAIL
  https://phab.mercurial-scm.org/D2534

AFFECTED FILES
  tests/test-wireproto.py

CHANGE DETAILS

diff --git a/tests/test-wireproto.py b/tests/test-wireproto.py
--- a/tests/test-wireproto.py
+++ b/tests/test-wireproto.py
@@ -2,6 +2,7 @@
 
 from mercurial import (
 error,
+pycompat,
 util,
 wireproto,
 wireprototypes,
@@ -13,7 +14,7 @@
 self.args = args
 def getargs(self, spec):
 args = self.args
-args.setdefault('*', {})
+args.setdefault(b'*', {})
 names = spec.split()
 return [args[n] for n in names]
 
@@ -26,7 +27,7 @@
 return self.serverrepo.ui
 
 def url(self):
-return 'test'
+return b'test'
 
 def local(self):
 return None
@@ -41,9 +42,10 @@
 pass
 
 def capabilities(self):
-return ['batch']
+return [b'batch']
 
 def _call(self, cmd, **args):
+args = pycompat.byteskwargs(args)
 res = wireproto.dispatch(self.serverrepo, proto(args), cmd)
 if isinstance(res, wireprototypes.bytesresponse):
 return res.data
@@ -58,31 +60,31 @@
 @wireproto.batchable
 def greet(self, name):
 f = wireproto.future()
-yield {'name': mangle(name)}, f
+yield {b'name': mangle(name)}, f
 yield unmangle(f.value)
 
 class serverrepo(object):
 def greet(self, name):
-return "Hello, " + name
+return b"Hello, " + name
 
 def filtered(self, name):
 return self
 
 def mangle(s):
-return ''.join(chr(ord(c) + 1) for c in s)
+return b''.join(pycompat.bytechr(ord(c) + 1) for c in pycompat.bytestr(s))
 def unmangle(s):
-return ''.join(chr(ord(c) - 1) for c in s)
+return b''.join(pycompat.bytechr(ord(c) - 1) for c in pycompat.bytestr(s))
 
 def greet(repo, proto, name):
 return mangle(repo.greet(unmangle(name)))
 
-wireproto.commands['greet'] = (greet, 'name',)
+wireproto.commands[b'greet'] = (greet, b'name',)
 
 srv = serverrepo()
 clt = clientpeer(srv)
 
-print(clt.greet("Foobar"))
+print(clt.greet(b"Foobar"))
 b = clt.iterbatch()
-map(b.greet, ('Fo, =;:

D2533: py3: use pycompat.bytestr() to convert None to bytes

2018-03-01 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2533

AFFECTED FILES
  mercurial/localrepo.py

CHANGE DETAILS

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -191,7 +191,9 @@
 
 def debugwireargs(self, one, two, three=None, four=None, five=None):
 """Used to test argument passing over the wire"""
-return "%s %s %s %s %s" % (one, two, three, four, five)
+return "%s %s %s %s %s" % (one, two, pycompat.bytestr(three),
+   pycompat.bytestr(four),
+   pycompat.bytestr(five))
 
 def getbundle(self, source, heads=None, common=None, bundlecaps=None,
   **kwargs):
@@ -2231,7 +2233,9 @@
 
 def debugwireargs(self, one, two, three=None, four=None, five=None):
 '''used to test argument passing over the wire'''
-return "%s %s %s %s %s" % (one, two, three, four, five)
+return "%s %s %s %s %s" % (one, two, pycompat.bytestr(three),
+   pycompat.bytestr(four),
+   pycompat.bytestr(five))
 
 def savecommitmessage(self, text):
 fp = self.vfs('last-message.txt', 'wb')



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


D2534: py3: port tests/test-wireproto.py to Python 3

2018-03-01 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2534

AFFECTED FILES
  tests/test-wireproto.py

CHANGE DETAILS

diff --git a/tests/test-wireproto.py b/tests/test-wireproto.py
--- a/tests/test-wireproto.py
+++ b/tests/test-wireproto.py
@@ -2,6 +2,7 @@
 
 from mercurial import (
 error,
+pycompat,
 util,
 wireproto,
 wireprototypes,
@@ -13,7 +14,7 @@
 self.args = args
 def getargs(self, spec):
 args = self.args
-args.setdefault('*', {})
+args.setdefault(b'*', {})
 names = spec.split()
 return [args[n] for n in names]
 
@@ -26,7 +27,7 @@
 return self.serverrepo.ui
 
 def url(self):
-return 'test'
+return b'test'
 
 def local(self):
 return None
@@ -41,9 +42,10 @@
 pass
 
 def capabilities(self):
-return ['batch']
+return [b'batch']
 
 def _call(self, cmd, **args):
+args = pycompat.byteskwargs(args)
 res = wireproto.dispatch(self.serverrepo, proto(args), cmd)
 if isinstance(res, wireprototypes.bytesresponse):
 return res.data
@@ -58,31 +60,31 @@
 @wireproto.batchable
 def greet(self, name):
 f = wireproto.future()
-yield {'name': mangle(name)}, f
+yield {b'name': mangle(name)}, f
 yield unmangle(f.value)
 
 class serverrepo(object):
 def greet(self, name):
-return "Hello, " + name
+return b"Hello, " + name
 
 def filtered(self, name):
 return self
 
 def mangle(s):
-return ''.join(chr(ord(c) + 1) for c in s)
+return b''.join(pycompat.bytechr(ord(c) + 1) for c in pycompat.bytestr(s))
 def unmangle(s):
-return ''.join(chr(ord(c) - 1) for c in s)
+return b''.join(pycompat.bytechr(ord(c) - 1) for c in pycompat.bytestr(s))
 
 def greet(repo, proto, name):
 return mangle(repo.greet(unmangle(name)))
 
-wireproto.commands['greet'] = (greet, 'name',)
+wireproto.commands[b'greet'] = (greet, b'name',)
 
 srv = serverrepo()
 clt = clientpeer(srv)
 
-print(clt.greet("Foobar"))
+print(clt.greet(b"Foobar"))
 b = clt.iterbatch()
-map(b.greet, ('Fo, =;:

D2531: templatefilters: stop using str as a variable name

2018-03-01 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGde41b8a1e012: templatefilters: stop using str as a variable 
name (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2531?vs=6307=6310

REVISION DETAIL
  https://phab.mercurial-scm.org/D2531

AFFECTED FILES
  mercurial/templatefilters.py

CHANGE DETAILS

diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py
--- a/mercurial/templatefilters.py
+++ b/mercurial/templatefilters.py
@@ -264,9 +264,9 @@
 return encoding.lower(text)
 
 @templatefilter('nonempty')
-def nonempty(str):
+def nonempty(text):
 """Any text. Returns '(none)' if the string is empty."""
-return str or "(none)"
+return text or "(none)"
 
 @templatefilter('obfuscate')
 def obfuscate(text):



To: pulkit, #hg-reviewers, yuja
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2532: webcommands: use explicit integer division for Python 3 compat

2018-03-01 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd40cfe72b79d: webcommands: use explicit integer division 
for Python 3 compat (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2532?vs=6308=6311

REVISION DETAIL
  https://phab.mercurial-scm.org/D2532

AFFECTED FILES
  mercurial/hgweb/webcommands.py

CHANGE DETAILS

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -300,7 +300,7 @@
 pass
 
 lessvars = copy.copy(tmpl.defaults['sessionvars'])
-lessvars['revcount'] = max(revcount / 2, 1)
+lessvars['revcount'] = max(revcount // 2, 1)
 lessvars['rev'] = query
 morevars = copy.copy(tmpl.defaults['sessionvars'])
 morevars['revcount'] = revcount * 2
@@ -395,7 +395,7 @@
 pass
 
 lessvars = copy.copy(tmpl.defaults['sessionvars'])
-lessvars['revcount'] = max(revcount / 2, 1)
+lessvars['revcount'] = max(revcount // 2, 1)
 morevars = copy.copy(tmpl.defaults['sessionvars'])
 morevars['revcount'] = revcount * 2
 
@@ -990,7 +990,7 @@
 lrange = webutil.linerange(req)
 
 lessvars = copy.copy(tmpl.defaults['sessionvars'])
-lessvars['revcount'] = max(revcount / 2, 1)
+lessvars['revcount'] = max(revcount // 2, 1)
 morevars = copy.copy(tmpl.defaults['sessionvars'])
 morevars['revcount'] = revcount * 2
 
@@ -1208,7 +1208,7 @@
 pass
 
 lessvars = copy.copy(tmpl.defaults['sessionvars'])
-lessvars['revcount'] = max(revcount / 2, 1)
+lessvars['revcount'] = max(revcount // 2, 1)
 morevars = copy.copy(tmpl.defaults['sessionvars'])
 morevars['revcount'] = revcount * 2
 



To: durin42, #hg-reviewers, yuja
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH STABLE] annotate: do not poorly split lines at CR (issue5798)

2018-03-01 Thread Augie Fackler


> On Feb 21, 2018, at 07:49, Yuya Nishihara  wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1519215245 -32400
> #  Wed Feb 21 21:14:05 2018 +0900
> # Branch stable
> # Node ID 24b17a714a92c8fe860db5f6d0d49c23293deec6
> # Parent  c19e66dacaa184feba31136c18a369ba995ddfe4
> annotate: do not poorly split lines at CR (issue5798)

queued, thanks
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 01 of 10] py3: silence return value of file.write() in test-command-template.t

2018-03-01 Thread Pulkit Goyal
Looks good to me. Queued the series. Many thanks.

On Fri, Mar 2, 2018 at 6:04 AM, Pulkit Goyal <7895pul...@gmail.com> wrote:
> On Fri, Mar 2, 2018 at 5:56 AM, Yuya Nishihara  wrote:
>> # HG changeset patch
>> # User Yuya Nishihara 
>> # Date 1519937847 18000
>> #  Thu Mar 01 15:57:27 2018 -0500
>> # Node ID 8d4520c4501899f53310e536e6bfd174cc58493a
>> # Parent  761065ed3a186569a1b06b33eadbdfdb7e689df1
>> py3: silence return value of file.write() in test-command-template.t
>>
>> diff --git a/tests/test-command-template.t b/tests/test-command-template.t
>> --- a/tests/test-command-template.t
>> +++ b/tests/test-command-template.t
>> @@ -2219,7 +2219,7 @@ Age filter:
>>>>> import datetime
>>>>> fp = open('a', 'wb')
>>>>> n = datetime.datetime.now() + datetime.timedelta(366 * 7)
>> -  >>> fp.write(b'%d-%d-%d 00:00' % (n.year, n.month, n.day))
>> +  >>> fp.write(b'%d-%d-%d 00:00' % (n.year, n.month, n.day)) and None
>
> This sounds like a good way. We need this it at a lot of places.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 01 of 10] py3: silence return value of file.write() in test-command-template.t

2018-03-01 Thread Pulkit Goyal
On Fri, Mar 2, 2018 at 5:56 AM, Yuya Nishihara  wrote:
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1519937847 18000
> #  Thu Mar 01 15:57:27 2018 -0500
> # Node ID 8d4520c4501899f53310e536e6bfd174cc58493a
> # Parent  761065ed3a186569a1b06b33eadbdfdb7e689df1
> py3: silence return value of file.write() in test-command-template.t
>
> diff --git a/tests/test-command-template.t b/tests/test-command-template.t
> --- a/tests/test-command-template.t
> +++ b/tests/test-command-template.t
> @@ -2219,7 +2219,7 @@ Age filter:
>>>> import datetime
>>>> fp = open('a', 'wb')
>>>> n = datetime.datetime.now() + datetime.timedelta(366 * 7)
> -  >>> fp.write(b'%d-%d-%d 00:00' % (n.year, n.month, n.day))
> +  >>> fp.write(b'%d-%d-%d 00:00' % (n.year, n.month, n.day)) and None

This sounds like a good way. We need this it at a lot of places.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2528: error: fix isinstnace check to use bytes instead of str

2018-03-01 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGe28a7a07bb73: error: fix isinstnace check to use bytes 
instead of str (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2528?vs=6304=6309

REVISION DETAIL
  https://phab.mercurial-scm.org/D2528

AFFECTED FILES
  mercurial/error.py

CHANGE DETAILS

diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -47,7 +47,7 @@
 # this can't be called 'message' because at least some installs of
 # Python 2.6+ complain about the 'message' property being deprecated
 self.lookupmessage = message
-if isinstance(name, str) and len(name) == 20:
+if isinstance(name, bytes) and len(name) == 20:
 from .node import short
 name = short(name)
 RevlogError.__init__(self, '%s@%s: %s' % (index, name, message))



To: durin42, #hg-reviewers, pulkit
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 06 of 10] py3: byte-stringify ValueError of unescapestr() to reraise as ParseError

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519941820 18000
#  Thu Mar 01 17:03:40 2018 -0500
# Node ID 1d65b2d4de6f87f079ae9d29843ee5e8fb675a23
# Parent  3a9920b08348866d5d9f2f85b9d332544686b843
py3: byte-stringify ValueError of unescapestr() to reraise as ParseError

diff --git a/mercurial/parser.py b/mercurial/parser.py
--- a/mercurial/parser.py
+++ b/mercurial/parser.py
@@ -22,6 +22,7 @@ from .i18n import _
 from . import (
 encoding,
 error,
+pycompat,
 util,
 )
 
@@ -192,7 +193,7 @@ def unescapestr(s):
 return util.unescapestr(s)
 except ValueError as e:
 # mangle Python's exception into our format
-raise error.ParseError(str(e).lower())
+raise error.ParseError(pycompat.bytestr(e).lower())
 
 def _brepr(obj):
 if isinstance(obj, bytes):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 08 of 10] py3: don't crash when re-raising encoding error

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519944992 18000
#  Thu Mar 01 17:56:32 2018 -0500
# Node ID 42239a898f18efa768297ab43b016793726834cd
# Parent  ebad609de255394be78d234e76a61426776e54ae
py3: don't crash when re-raising encoding error

diff --git a/mercurial/encoding.py b/mercurial/encoding.py
--- a/mercurial/encoding.py
+++ b/mercurial/encoding.py
@@ -181,7 +181,8 @@ def fromlocal(s):
 return u.encode("utf-8")
 except UnicodeDecodeError as inst:
 sub = s[max(0, inst.start - 10):inst.start + 10]
-raise error.Abort("decoding near '%s': %s!" % (sub, inst))
+raise error.Abort("decoding near '%s': %s!"
+  % (sub, pycompat.bytestr(inst)))
 except LookupError as k:
 raise error.Abort(k, hint="please check your locale settings")
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 09 of 10] py3: replace type 'str' by 'bytes' in templater.py

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519945585 18000
#  Thu Mar 01 18:06:25 2018 -0500
# Node ID a7eb4c25e04e5be83918ed160dfff78e782165c1
# Parent  42239a898f18efa768297ab43b016793726834cd
py3: replace type 'str' by 'bytes' in templater.py

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -968,7 +968,7 @@ def localdate(context, mapping, args):
 if len(args) >= 2:
 tzoffset = None
 tz = evalfuncarg(context, mapping, args[1])
-if isinstance(tz, str):
+if isinstance(tz, bytes):
 tzoffset, remainder = util.parsetimezone(tz)
 if remainder:
 tzoffset = None
@@ -1602,10 +1602,10 @@ def stylemap(styles, paths=None):
 
 if paths is None:
 paths = templatepaths()
-elif isinstance(paths, str):
+elif isinstance(paths, bytes):
 paths = [paths]
 
-if isinstance(styles, str):
+if isinstance(styles, bytes):
 styles = [styles]
 
 for style in styles:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 07 of 10] py3: mark all string literals in test-command-template.t as bytes

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519944205 18000
#  Thu Mar 01 17:43:25 2018 -0500
# Node ID ebad609de255394be78d234e76a61426776e54ae
# Parent  1d65b2d4de6f87f079ae9d29843ee5e8fb675a23
py3: mark all string literals in test-command-template.t as bytes

# skip-blame because just b'' prefixes

diff --git a/tests/revnamesext.py b/tests/revnamesext.py
--- a/tests/revnamesext.py
+++ b/tests/revnamesext.py
@@ -7,12 +7,12 @@ from mercurial import (
 )
 
 def reposetup(ui, repo):
-names = {'r%d' % rev: repo[rev].node() for rev in repo}
+names = {b'r%d' % rev: repo[rev].node() for rev in repo}
 namemap = lambda r, name: names.get(name)
-nodemap = lambda r, node: ['r%d' % repo[node].rev()]
+nodemap = lambda r, node: [b'r%d' % repo[node].rev()]
 
-ns = namespaces.namespace('revnames', templatename='revname',
-  logname='revname',
+ns = namespaces.namespace(b'revnames', templatename=b'revname',
+  logname=b'revname',
   listnames=lambda r: names.keys(),
   namemap=namemap, nodemap=nodemap)
 repo.names.addnamespace(ns)
diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -4622,9 +4622,9 @@ Test that template function in extension
   > 
   > templatefunc = registrar.templatefunc()
   > 
-  > @templatefunc('custom()')
+  > @templatefunc(b'custom()')
   > def custom(context, mapping, args):
-  > return 'custom'
+  > return b'custom'
   > EOF
   $ cat < .hg/hgrc
   > [extensions]
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 10 of 10] py3: fix string slicing in util.parsetimezone()

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519946158 18000
#  Thu Mar 01 18:15:58 2018 -0500
# Node ID 92dac7bbce17a875c89b9589d1adc14e48e7440e
# Parent  a7eb4c25e04e5be83918ed160dfff78e782165c1
py3: fix string slicing in util.parsetimezone()

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2353,6 +2353,7 @@ def shortdate(date=None):
 def parsetimezone(s):
 """find a trailing timezone, if any, in string, and return a
(offset, remainder) pair"""
+s = pycompat.bytestr(s)
 
 if s.endswith("GMT") or s.endswith("UTC"):
 return 0, s[:-3].rstrip()
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 04 of 10] py3: drop b'' from error message generated by templater.runmember()

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519941137 18000
#  Thu Mar 01 16:52:17 2018 -0500
# Node ID 47a09e779081aed563018208407c771ede557ffd
# Parent  7f0a461c110f7d953dda945dfe9c0912865f8e91
py3: drop b'' from error message generated by templater.runmember()

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -548,7 +548,7 @@ def runmember(context, mapping, data):
 if sym:
 raise error.ParseError(_("keyword '%s' has no member") % sym)
 else:
-raise error.ParseError(_("%r has no member") % d)
+raise error.ParseError(_("%r has no member") % pycompat.bytestr(d))
 
 def buildnegate(exp, context):
 arg = compileexp(exp[1], context, exprmethods)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 01 of 10] py3: silence return value of file.write() in test-command-template.t

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519937847 18000
#  Thu Mar 01 15:57:27 2018 -0500
# Node ID 8d4520c4501899f53310e536e6bfd174cc58493a
# Parent  761065ed3a186569a1b06b33eadbdfdb7e689df1
py3: silence return value of file.write() in test-command-template.t

diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -2219,7 +2219,7 @@ Age filter:
   >>> import datetime
   >>> fp = open('a', 'wb')
   >>> n = datetime.datetime.now() + datetime.timedelta(366 * 7)
-  >>> fp.write(b'%d-%d-%d 00:00' % (n.year, n.month, n.day))
+  >>> fp.write(b'%d-%d-%d 00:00' % (n.year, n.month, n.day)) and None
   >>> fp.close()
   $ hg add a
   $ hg commit -m future -d "`cat a`"
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 05 of 10] py3: fix type of string literals in templater.tokenize()

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519941398 18000
#  Thu Mar 01 16:56:38 2018 -0500
# Node ID 3a9920b08348866d5d9f2f85b9d332544686b843
# Parent  47a09e779081aed563018208407c771ede557ffd
py3: fix type of string literals in templater.tokenize()

# skip-blame because just b'' prefixes

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -98,8 +98,8 @@ def tokenize(program, start, end, term=N
 pos += 1
 yield ('integer', program[s:pos], s)
 pos -= 1
-elif (c == '\\' and program[pos:pos + 2] in (r"\'", r'\"')
-  or c == 'r' and program[pos:pos + 3] in (r"r\'", r'r\"')):
+elif (c == '\\' and program[pos:pos + 2] in (br"\'", br'\"')
+  or c == 'r' and program[pos:pos + 3] in (br"r\'", br'r\"')):
 # handle escaped quoted strings for compatibility with 2.9.2-3.4,
 # where some of nested templates were preprocessed as strings and
 # then compiled. therefore, \"...\" was allowed. (issue4733)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 03 of 10] py3: fix join(), min(), and max() template functions over string

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519940544 18000
#  Thu Mar 01 16:42:24 2018 -0500
# Node ID 7f0a461c110f7d953dda945dfe9c0912865f8e91
# Parent  d44f1bec9f60ebec416be5a7cd44aa386e04da64
py3: fix join(), min(), and max() template functions over string

It's silly to split a string into characters and concatenate them, but that
should work and test-command-template.t has one. min() and max() had the
same issue on Python 3, so fixed too.

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -908,7 +908,7 @@ def join(context, mapping, args):
 joiner = evalstring(context, mapping, args[1])
 
 first = True
-for x in joinset:
+for x in pycompat.maybebytestr(joinset):
 if first:
 first = False
 else:
@@ -991,7 +991,7 @@ def max_(context, mapping, args, **kwarg
 
 iterable = evalfuncarg(context, mapping, args[0])
 try:
-x = max(iterable)
+x = max(pycompat.maybebytestr(iterable))
 except (TypeError, ValueError):
 # i18n: "max" is a keyword
 raise error.ParseError(_("max first argument should be an iterable"))
@@ -1006,7 +1006,7 @@ def min_(context, mapping, args, **kwarg
 
 iterable = evalfuncarg(context, mapping, args[0])
 try:
-x = min(iterable)
+x = min(pycompat.maybebytestr(iterable))
 except (TypeError, ValueError):
 # i18n: "min" is a keyword
 raise error.ParseError(_("min first argument should be an iterable"))
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 02 of 10] py3: use startswith() to check existence of trailing '\n' in .hgtags file

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1519939965 18000
#  Thu Mar 01 16:32:45 2018 -0500
# Node ID d44f1bec9f60ebec416be5a7cd44aa386e04da64
# Parent  8d4520c4501899f53310e536e6bfd174cc58493a
py3: use startswith() to check existence of trailing '\n' in .hgtags file

diff --git a/mercurial/tags.py b/mercurial/tags.py
--- a/mercurial/tags.py
+++ b/mercurial/tags.py
@@ -559,7 +559,7 @@ def _tag(repo, names, node, message, loc
 
 def writetags(fp, names, munge, prevtags):
 fp.seek(0, 2)
-if prevtags and prevtags[-1] != '\n':
+if prevtags and not prevtags.endswith('\n'):
 fp.write('\n')
 for name in names:
 if munge:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


mercurial@36509: 4 new changesets

2018-03-01 Thread Mercurial Commits
4 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/74c033b9d579
changeset:   36506:74c033b9d579
user:Yuya Nishihara 
date:Tue Feb 27 22:37:57 2018 +0900
summary: test-acl: mock up util.getuser() to trust $LOGNAME on Windows

https://www.mercurial-scm.org/repo/hg/rev/165cf86365ff
changeset:   36507:165cf86365ff
user:Yuya Nishihara 
date:Sun Feb 18 10:54:24 2018 +0900
summary: cmdutil: strip "%m" pattern (first line of commit message) from 
both ends

https://www.mercurial-scm.org/repo/hg/rev/d7a23d6184a2
changeset:   36508:d7a23d6184a2
user:Yuya Nishihara 
date:Sun Feb 18 10:58:15 2018 +0900
summary: cmdutil: reorder optional arguments passed to makefileobj()

https://www.mercurial-scm.org/repo/hg/rev/638c012a87ef
changeset:   36509:638c012a87ef
bookmark:@
tag: tip
user:Yuya Nishihara 
date:Sun Feb 18 11:53:26 2018 +0900
summary: templater: add option to parse template string just like raw 
string literal

-- 
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


D2532: webcommands: use explicit integer division for Python 3 compat

2018-03-01 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2532

AFFECTED FILES
  mercurial/hgweb/webcommands.py

CHANGE DETAILS

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -300,7 +300,7 @@
 pass
 
 lessvars = copy.copy(tmpl.defaults['sessionvars'])
-lessvars['revcount'] = max(revcount / 2, 1)
+lessvars['revcount'] = max(revcount // 2, 1)
 lessvars['rev'] = query
 morevars = copy.copy(tmpl.defaults['sessionvars'])
 morevars['revcount'] = revcount * 2
@@ -395,7 +395,7 @@
 pass
 
 lessvars = copy.copy(tmpl.defaults['sessionvars'])
-lessvars['revcount'] = max(revcount / 2, 1)
+lessvars['revcount'] = max(revcount // 2, 1)
 morevars = copy.copy(tmpl.defaults['sessionvars'])
 morevars['revcount'] = revcount * 2
 
@@ -990,7 +990,7 @@
 lrange = webutil.linerange(req)
 
 lessvars = copy.copy(tmpl.defaults['sessionvars'])
-lessvars['revcount'] = max(revcount / 2, 1)
+lessvars['revcount'] = max(revcount // 2, 1)
 morevars = copy.copy(tmpl.defaults['sessionvars'])
 morevars['revcount'] = revcount * 2
 
@@ -1208,7 +1208,7 @@
 pass
 
 lessvars = copy.copy(tmpl.defaults['sessionvars'])
-lessvars['revcount'] = max(revcount / 2, 1)
+lessvars['revcount'] = max(revcount // 2, 1)
 morevars = copy.copy(tmpl.defaults['sessionvars'])
 morevars['revcount'] = revcount * 2
 



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2531: templatefilters: stop using str as a variable name

2018-03-01 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  str() is an inbuilt function.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2531

AFFECTED FILES
  mercurial/templatefilters.py

CHANGE DETAILS

diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py
--- a/mercurial/templatefilters.py
+++ b/mercurial/templatefilters.py
@@ -264,9 +264,9 @@
 return encoding.lower(text)
 
 @templatefilter('nonempty')
-def nonempty(str):
+def nonempty(text):
 """Any text. Returns '(none)' if the string is empty."""
-return str or "(none)"
+return text or "(none)"
 
 @templatefilter('obfuscate')
 def obfuscate(text):



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


D2530: py3: whitelist three more passing tests

2018-03-01 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: pulkit.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2530

AFFECTED FILES
  contrib/python3-whitelist

CHANGE DETAILS

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -45,6 +45,8 @@
 test-convert-authormap.t
 test-convert-clonebranches.t
 test-convert-datesort.t
+test-convert-filemap.t
+test-convert-hg-sink.t
 test-convert-hg-startrev.t
 test-copy-move-merge.t
 test-copytrace-heuristics.t
@@ -194,6 +196,7 @@
 test-narrow-copies.t
 test-narrow-debugrebuilddirstate.t
 test-narrow-exchange-merges.t
+test-narrow-exchange.t
 test-narrow-merge.t
 test-narrow-patch.t
 test-narrow-patterns.t



To: durin42, pulkit, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2529: convert: fix two %r output formats with pycompat.bytestr() wrapping

2018-03-01 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2529

AFFECTED FILES
  hgext/convert/filemap.py

CHANGE DETAILS

diff --git a/hgext/convert/filemap.py b/hgext/convert/filemap.py
--- a/hgext/convert/filemap.py
+++ b/hgext/convert/filemap.py
@@ -11,6 +11,7 @@
 from mercurial.i18n import _
 from mercurial import (
 error,
+pycompat,
 )
 from . import common
 SKIPREV = common.SKIPREV
@@ -67,7 +68,8 @@
 name.endswith('/') or
 '//' in name):
 self.ui.warn(_('%s:%d: superfluous / in %s %r\n') %
- (lex.infile, lex.lineno, listname, name))
+ (lex.infile, lex.lineno, listname,
+  pycompat.bytestr(name)))
 return 1
 return 0
 lex = common.shlexer(
@@ -92,7 +94,7 @@
 errs += self.parse(normalize(lex.get_token()))
 else:
 self.ui.warn(_('%s:%d: unknown directive %r\n') %
- (lex.infile, lex.lineno, cmd))
+ (lex.infile, lex.lineno, pycompat.bytestr(cmd)))
 errs += 1
 cmd = lex.get_token()
 return errs



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2527: convert: use our shlex wrapper in filemap to avoid Python 3 tracebacks

2018-03-01 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2527

AFFECTED FILES
  hgext/convert/filemap.py

CHANGE DETAILS

diff --git a/hgext/convert/filemap.py b/hgext/convert/filemap.py
--- a/hgext/convert/filemap.py
+++ b/hgext/convert/filemap.py
@@ -7,7 +7,6 @@
 from __future__ import absolute_import, print_function
 
 import posixpath
-import shlex
 
 from mercurial.i18n import _
 from mercurial import (
@@ -71,8 +70,8 @@
  (lex.infile, lex.lineno, listname, name))
 return 1
 return 0
-lex = shlex.shlex(open(path, 'rb'), path, True)
-lex.wordchars += '!@#$%^&*()-=+[]{}|;:,./<>?'
+lex = common.shlexer(
+filepath=path, wordchars='!@#$%^&*()-=+[]{}|;:,./<>?')
 cmd = lex.get_token()
 while cmd:
 if cmd == 'include':



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2524: pycompat: add support for encoding argument to our wrapper

2018-03-01 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This only works on Python 3, but I'm about to need it for a
  regrettable hack in the convert code.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2524

AFFECTED FILES
  mercurial/pycompat.py

CHANGE DETAILS

diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -224,8 +224,8 @@
 xrange = builtins.range
 unicode = str
 
-def open(name, mode='r', buffering=-1):
-return builtins.open(name, sysstr(mode), buffering)
+def open(name, mode='r', buffering=-1, encoding=None):
+return builtins.open(name, sysstr(mode), buffering, encoding)
 
 def _getoptbwrapper(orig, args, shortlist, namelist):
 """



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2525: convert: add some utility code for working with shlex on Python 3

2018-03-01 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This could have gone in pycompat, but it's only needed in convert, so
  I figured it made more sense here. It's got py3 in the name and checks
  pycompat.ispy3, so we'll find it whenever we decide to drop Python 2
  support in 20x6.
  
  1. no-check-commit because of required foo_bar naming on the proxy class

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2525

AFFECTED FILES
  hgext/convert/common.py

CHANGE DETAILS

diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -11,6 +11,7 @@
 import errno
 import os
 import re
+import shlex
 import subprocess
 
 from mercurial.i18n import _
@@ -25,6 +26,58 @@
 pickle = util.pickle
 propertycache = util.propertycache
 
+def _encodeornone(d):
+if d is None:
+return
+return d.encode('latin1')
+
+class _shlexpy3proxy(object):
+
+def __init__(self, l):
+self._l = l
+
+def __iter__(self):
+return (_encodeornone(v) for v in self._l)
+
+def get_token(self):
+return _encodeornone(self._l.get_token())
+
+@property
+def infile(self):
+return self._l.infile or ''
+
+@property
+def lineno(self):
+return self._l.lineno
+
+def shlexer(data=None, filepath=None, wordchars=None, whitespace=None):
+if data is None:
+if pycompat.ispy3:
+data = open(filepath, 'r', encoding=r'latin1')
+else:
+data = open(filepath, 'r')
+else:
+if filepath is not None:
+raise error.ProgrammingError(
+'shlexer only accepts data or filepath, not both')
+if pycompat.ispy3:
+data = data.decode('latin1')
+l = shlex.shlex(data, infile=filepath, posix=True)
+if whitespace is not None:
+l.whitespace_split = True
+if pycompat.ispy3:
+l.whitespace += whitespace.decode('latin1')
+else:
+l.whitespace += whitespace
+if wordchars is not None:
+if pycompat.ispy3:
+l.wordchars += wordchars.decode('latin1')
+else:
+l.wordchars += wordchars
+if pycompat.ispy3:
+return _shlexpy3proxy(l)
+return l
+
 def encodeargs(args):
 def encodearg(s):
 lines = base64.encodestring(s)



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2528: error: fix isinstnace check to use bytes instead of str

2018-03-01 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2528

AFFECTED FILES
  mercurial/error.py

CHANGE DETAILS

diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -47,7 +47,7 @@
 # this can't be called 'message' because at least some installs of
 # Python 2.6+ complain about the 'message' property being deprecated
 self.lookupmessage = message
-if isinstance(name, str) and len(name) == 20:
+if isinstance(name, bytes) and len(name) == 20:
 from .node import short
 name = short(name)
 RevlogError.__init__(self, '%s@%s: %s' % (index, name, message))



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2526: convcmd: use our shlex wrapper to avoid Python 3 tracebacks

2018-03-01 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2526

AFFECTED FILES
  hgext/convert/convcmd.py

CHANGE DETAILS

diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py
--- a/hgext/convert/convcmd.py
+++ b/hgext/convert/convcmd.py
@@ -8,7 +8,6 @@
 
 import collections
 import os
-import shlex
 import shutil
 
 from mercurial.i18n import _
@@ -211,9 +210,7 @@
 # Ignore blank lines
 continue
 # split line
-lex = shlex.shlex(line, posix=True)
-lex.whitespace_split = True
-lex.whitespace += ','
+lex = common.shlexer(data=line, whitespace=',')
 line = list(lex)
 # check number of parents
 if not (2 <= len(line) <= 3):



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


mercurial@36505: 16 new changesets

2018-03-01 Thread Mercurial Commits
16 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/1c4247b0040a
changeset:   36490:1c4247b0040a
user:Pulkit Goyal <7895pul...@gmail.com>
date:Thu Mar 01 23:51:32 2018 +0530
summary: py3: use '%d' instead of '%s' for ints

https://www.mercurial-scm.org/repo/hg/rev/149c5af35de5
changeset:   36491:149c5af35de5
user:Pulkit Goyal <7895pul...@gmail.com>
date:Thu Mar 01 23:52:30 2018 +0530
summary: py3: listify the return value of filter()

https://www.mercurial-scm.org/repo/hg/rev/6e90c59b6da1
changeset:   36492:6e90c59b6da1
user:Pulkit Goyal <7895pul...@gmail.com>
date:Thu Mar 01 23:54:52 2018 +0530
summary: py3: use pycompat.bytestr() to convert error instances to bytes

https://www.mercurial-scm.org/repo/hg/rev/5b5cc44b2cdc
changeset:   36493:5b5cc44b2cdc
user:Pulkit Goyal <7895pul...@gmail.com>
date:Thu Mar 01 23:57:16 2018 +0530
summary: py3: add a b'' prefix in tests/test-fncache.t

https://www.mercurial-scm.org/repo/hg/rev/f1e05fe1a78f
changeset:   36494:f1e05fe1a78f
user:Pulkit Goyal <7895pul...@gmail.com>
date:Thu Mar 01 23:58:21 2018 +0530
summary: py3: add b'' prefixes in tests/test-obsolete.t

https://www.mercurial-scm.org/repo/hg/rev/eafd380fe1b8
changeset:   36495:eafd380fe1b8
user:Pulkit Goyal <7895pul...@gmail.com>
date:Thu Mar 01 23:59:20 2018 +0530
summary: py3: make sure we write bytes in a file open in bytes mode

https://www.mercurial-scm.org/repo/hg/rev/7af7443877da
changeset:   36496:7af7443877da
user:Pulkit Goyal <7895pul...@gmail.com>
date:Fri Mar 02 00:00:41 2018 +0530
summary: py3: replace str() with it's bytes equivalent in hgext/shelve.py

https://www.mercurial-scm.org/repo/hg/rev/b2e54b257832
changeset:   36497:b2e54b257832
user:Yuya Nishihara 
date:Thu Mar 01 06:38:37 2018 -0500
summary: templatefilters: use encoding.unifromlocal/unitolocal() for py3 
compatibility

https://www.mercurial-scm.org/repo/hg/rev/b546181ae451
changeset:   36498:b546181ae451
user:Yuya Nishihara 
date:Thu Mar 01 06:40:09 2018 -0500
summary: py3: make regexp literal bytes in templatefilters.py

https://www.mercurial-scm.org/repo/hg/rev/77f681f11003
changeset:   36499:77f681f11003
user:Yuya Nishihara 
date:Thu Mar 01 06:43:13 2018 -0500
summary: py3: use '%d' to format diffstat sum

https://www.mercurial-scm.org/repo/hg/rev/43e108027b0d
changeset:   36500:43e108027b0d
user:Yuya Nishihara 
date:Thu Mar 01 06:47:06 2018 -0500
summary: py3: move between bytes and unicode when re-raising IOError

https://www.mercurial-scm.org/repo/hg/rev/169ac2bb3c9c
changeset:   36501:169ac2bb3c9c
user:Yuya Nishihara 
date:Thu Mar 01 08:19:47 2018 -0500
summary: py3: fix type of attribute names forwarded by templatekw._hybrid

https://www.mercurial-scm.org/repo/hg/rev/faaabe0dc4d1
changeset:   36502:faaabe0dc4d1
user:Yuya Nishihara 
date:Thu Mar 01 08:38:39 2018 -0500
summary: py3: use bytes.endswith('\n') to strip off '\n' from debug color 
output

https://www.mercurial-scm.org/repo/hg/rev/8b662717c53f
changeset:   36503:8b662717c53f
user:Yuya Nishihara 
date:Thu Mar 01 08:45:34 2018 -0500
summary: py3: use bytestr() to coerce position carried by ParseError to 
string

https://www.mercurial-scm.org/repo/hg/rev/b075f45456a5
changeset:   36504:b075f45456a5
user:Yuya Nishihara 
date:Thu Mar 01 08:55:39 2018 -0500
summary: py3: fix test-command-template.t to write files in binary mode

https://www.mercurial-scm.org/repo/hg/rev/db33c5bc781f
changeset:   36505:db33c5bc781f
bookmark:@
tag: tip
user:Yuya Nishihara 
date:Thu Mar 01 04:50:22 2018 -0500
summary: fileset: drop bad "elif:" trying to check invalid size expression

-- 
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


D2438: util: use pycompat.bytestr() on repr() in date parse abort

2018-03-01 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG8346c0e2af92: util: use pycompat.bytestr() on repr() in 
date parse abort (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2438?vs=6296=6298

REVISION DETAIL
  https://phab.mercurial-scm.org/D2438

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2479,7 +2479,8 @@
 else:
 break
 else:
-raise error.ParseError(_('invalid date: %r') % date)
+raise error.ParseError(
+_('invalid date: %s') % pycompat.bytestr(repr(date)))
 # validate explicit (probably user-specified) date and
 # time zone offset. values must fit in signed 32 bits for
 # current 32-bit linux runtimes. timezones go from UTC-12



To: durin42, #hg-reviewers, pulkit
Cc: pulkit, yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2439: py3: whitelist another nine passing tests

2018-03-01 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG761065ed3a18: py3: whitelist another nine passing tests 
(authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2439?vs=6297=6299

REVISION DETAIL
  https://phab.mercurial-scm.org/D2439

AFFECTED FILES
  contrib/python3-whitelist

CHANGE DETAILS

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -6,6 +6,7 @@
 test-ancestor.py
 test-annotate.py
 test-automv.t
+test-backout.t
 test-backwards-remove.t
 test-bheads.t
 test-bisect2.t
@@ -33,7 +34,9 @@
 test-clone-pull-corruption.t
 test-clone-r.t
 test-clone-update-order.t
+test-commit-amend.t
 test-commit-unresolved.t
+test-commit.t
 test-completion.t
 test-conflict.t
 test-confused-revert.t
@@ -108,6 +111,7 @@
 test-git-export.t
 test-glog-topological.t
 test-gpg.t
+test-graft.t
 test-hghave.t
 test-hgk.t
 test-histedit-arguments.t
@@ -253,6 +257,7 @@
 test-rebase-brute-force.t
 test-rebase-cache.t
 test-rebase-check-restore.t
+test-rebase-collapse.t
 test-rebase-dest.t
 test-rebase-detach.t
 test-rebase-emptycommit.t
@@ -262,10 +267,12 @@
 test-rebase-legacy.t
 test-rebase-named-branches.t
 test-rebase-newancestor.t
+test-rebase-obsolete.t
 test-rebase-parameters.t
 test-rebase-partial.t
 test-rebase-pull.t
 test-rebase-rename.t
+test-rebase-scenario-global.t
 test-rebase-templates.t
 test-rebase-transaction.t
 test-record.t



To: durin42, pulkit, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2438: util: use pycompat.bytestr() on repr() in date parse abort

2018-03-01 Thread pulkit (Pulkit Goyal)
pulkit accepted this revision.
pulkit added a comment.


  Looks good to me and Yuya's feedback is also addressed. Queued thanks.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2438

To: durin42, #hg-reviewers, pulkit
Cc: pulkit, yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2439: py3: whitelist another nine passing tests

2018-03-01 Thread durin42 (Augie Fackler)
durin42 updated this revision to Diff 6297.
durin42 edited the summary of this revision.
durin42 retitled this revision from "py3: whitelist another seven passing 
tests" to "py3: whitelist another nine passing tests".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2439?vs=6268=6297

REVISION DETAIL
  https://phab.mercurial-scm.org/D2439

AFFECTED FILES
  contrib/python3-whitelist

CHANGE DETAILS

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -6,6 +6,7 @@
 test-ancestor.py
 test-annotate.py
 test-automv.t
+test-backout.t
 test-backwards-remove.t
 test-bheads.t
 test-bisect2.t
@@ -33,7 +34,9 @@
 test-clone-pull-corruption.t
 test-clone-r.t
 test-clone-update-order.t
+test-commit-amend.t
 test-commit-unresolved.t
+test-commit.t
 test-completion.t
 test-conflict.t
 test-confused-revert.t
@@ -108,6 +111,7 @@
 test-git-export.t
 test-glog-topological.t
 test-gpg.t
+test-graft.t
 test-hghave.t
 test-hgk.t
 test-histedit-arguments.t
@@ -253,6 +257,7 @@
 test-rebase-brute-force.t
 test-rebase-cache.t
 test-rebase-check-restore.t
+test-rebase-collapse.t
 test-rebase-dest.t
 test-rebase-detach.t
 test-rebase-emptycommit.t
@@ -262,10 +267,12 @@
 test-rebase-legacy.t
 test-rebase-named-branches.t
 test-rebase-newancestor.t
+test-rebase-obsolete.t
 test-rebase-parameters.t
 test-rebase-partial.t
 test-rebase-pull.t
 test-rebase-rename.t
+test-rebase-scenario-global.t
 test-rebase-templates.t
 test-rebase-transaction.t
 test-record.t



To: durin42, pulkit, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2438: util: use pycompat.bytestr() on repr() in date parse abort

2018-03-01 Thread durin42 (Augie Fackler)
durin42 updated this revision to Diff 6296.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2438?vs=6267=6296

REVISION DETAIL
  https://phab.mercurial-scm.org/D2438

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2479,7 +2479,8 @@
 else:
 break
 else:
-raise error.ParseError(_('invalid date: %r') % date)
+raise error.ParseError(
+_('invalid date: %s') % pycompat.bytestr(repr(date)))
 # validate explicit (probably user-specified) date and
 # time zone offset. values must fit in signed 32 bits for
 # current 32-bit linux runtimes. timezones go from UTC-12



To: durin42, #hg-reviewers
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2523: py3: whitelist 14 new tests passing

2018-03-01 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG81d4a11549ec: py3: whitelist 14 new tests passing (authored 
by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2523?vs=6293=6295

REVISION DETAIL
  https://phab.mercurial-scm.org/D2523

AFFECTED FILES
  contrib/python3-whitelist

CHANGE DETAILS

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -35,6 +35,7 @@
 test-clone-update-order.t
 test-commit-unresolved.t
 test-completion.t
+test-conflict.t
 test-confused-revert.t
 test-contrib-check-code.t
 test-contrib-check-commit.t
@@ -108,6 +109,7 @@
 test-glog-topological.t
 test-gpg.t
 test-hghave.t
+test-hgk.t
 test-histedit-arguments.t
 test-histedit-base.t
 test-histedit-bookmark-motion.t
@@ -117,9 +119,11 @@
 test-histedit-fold-non-commute.t
 test-histedit-fold.t
 test-histedit-no-change.t
+test-histedit-non-commute-abort.t
 test-histedit-non-commute.t
 test-histedit-obsolete.t
 test-histedit-outgoing.t
+test-histedit-templates.t
 test-http-branchmap.t
 test-http-clone-r.t
 test-identify.t
@@ -163,14 +167,16 @@
 test-merge-revert2.t
 test-merge-subrepos.t
 test-merge-symlinks.t
+test-merge-types.t
 test-merge1.t
 test-merge10.t
 test-merge2.t
 test-merge4.t
 test-merge5.t
 test-merge6.t
 test-merge7.t
 test-merge8.t
+test-merge9.t
 test-mq-git.t
 test-mq-pull-from-bundle.t
 test-mq-qdiff.t
@@ -200,6 +206,8 @@
 test-obsolete-checkheads.t
 test-obsolete-distributed.t
 test-parents.t
+test-pathconflicts-merge.t
+test-pathconflicts-update.t
 test-pending.t
 test-permissions.t
 test-phases.t
@@ -239,21 +247,26 @@
 test-push-http.t
 test-push-warn.t
 test-pushvars.t
+test-rebase-abort.t
 test-rebase-base-flag.t
 test-rebase-bookmarks.t
 test-rebase-brute-force.t
+test-rebase-cache.t
 test-rebase-check-restore.t
 test-rebase-dest.t
+test-rebase-detach.t
 test-rebase-emptycommit.t
 test-rebase-inmemory.t
 test-rebase-interruptions.t
 test-rebase-issue-noparam-single-rev.t
 test-rebase-legacy.t
 test-rebase-named-branches.t
 test-rebase-newancestor.t
+test-rebase-parameters.t
 test-rebase-partial.t
 test-rebase-pull.t
 test-rebase-rename.t
+test-rebase-templates.t
 test-rebase-transaction.t
 test-record.t
 test-relink.t
@@ -264,6 +277,7 @@
 test-rename.t
 test-repair-strip.t
 test-repo-compengines.t
+test-resolve.t
 test-revert-flags.t
 test-revert-unknown.t
 test-revlog-ancestry.py



To: pulkit, #hg-reviewers, durin42
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2522: py3: slice over bytes to prevent getting ascii values

2018-03-01 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG1d99260c3a81: py3: slice over bytes to prevent getting 
ascii values (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2522?vs=6292=6294

REVISION DETAIL
  https://phab.mercurial-scm.org/D2522

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -287,14 +287,14 @@
 off = 0
 end = len(data)
 while off < end:
-rtype = data[off]
+rtype = data[off:off + 1]
 off += 1
 length = _unpack('>I', data[off:(off + 4)])[0]
 off += 4
 record = data[off:(off + length)]
 off += length
 if rtype == 't':
-rtype, record = record[0], record[1:]
+rtype, record = record[0:1], record[1:]
 records.append((rtype, record))
 f.close()
 except IOError as err:



To: pulkit, #hg-reviewers, durin42
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


mercurial@36489: 47 new changesets

2018-03-01 Thread Mercurial Commits
47 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/8dbd97aef915
changeset:   36443:8dbd97aef915
user:Yuya Nishihara 
date:Sun Feb 25 12:47:53 2018 +0900
summary: templater: move specialized exception types to top

https://www.mercurial-scm.org/repo/hg/rev/717a279c0c21
changeset:   36444:717a279c0c21
user:Yuya Nishihara 
date:Sun Feb 25 12:50:30 2018 +0900
summary: templater: specialize ResourceUnavailable error so that it can be 
caught

https://www.mercurial-scm.org/repo/hg/rev/e8d37838f5df
changeset:   36445:e8d37838f5df
user:Yuya Nishihara 
date:Sun Feb 25 13:24:35 2018 +0900
summary: templatekw: add 'requires' flag to switch to exception-safe 
interface

https://www.mercurial-scm.org/repo/hg/rev/3d58037c6ec0
changeset:   36446:3d58037c6ec0
user:Pulkit Goyal <7895pul...@gmail.com>
date:Mon Feb 26 16:23:12 2018 +0530
summary: py3: use '%d' for integers instead of '%s'

https://www.mercurial-scm.org/repo/hg/rev/588048a6a8d3
changeset:   36447:588048a6a8d3
user:Pulkit Goyal <7895pul...@gmail.com>
date:Mon Feb 26 17:25:46 2018 +0530
summary: py3: slice over bytes or use .startswith() to prevent getting 
ascii values

https://www.mercurial-scm.org/repo/hg/rev/39c9f339b692
changeset:   36448:39c9f339b692
user:Pulkit Goyal <7895pul...@gmail.com>
date:Mon Feb 26 16:19:53 2018 +0530
summary: py3: use email.utils module instead of email.Utils

https://www.mercurial-scm.org/repo/hg/rev/a918c996a881
changeset:   36449:a918c996a881
user:Pulkit Goyal <7895pul...@gmail.com>
date:Mon Feb 26 23:50:30 2018 +0530
summary: py3: use encoding.strtolocal() to convert str to bytes

https://www.mercurial-scm.org/repo/hg/rev/d478c8cd89d1
changeset:   36450:d478c8cd89d1
user:Pulkit Goyal <7895pul...@gmail.com>
date:Mon Feb 26 23:54:40 2018 +0530
summary: py3: convert bytes to str using encoding.strfromlocal

https://www.mercurial-scm.org/repo/hg/rev/1fa35ca345a5
changeset:   36451:1fa35ca345a5
user:Gregory Szorc 
date:Sat Feb 17 11:19:52 2018 -0700
summary: internals: document bundle2 format

https://www.mercurial-scm.org/repo/hg/rev/ab81e5a8fba5
changeset:   36452:ab81e5a8fba5
user:Gregory Szorc 
date:Mon Feb 26 13:32:03 2018 -0800
summary: phases: write phaseroots deterministically

https://www.mercurial-scm.org/repo/hg/rev/bfb4494f846d
changeset:   36453:bfb4494f846d
user:Gregory Szorc 
date:Mon Feb 26 13:34:35 2018 -0800
summary: bookmarks: write bookmarks file deterministically

https://www.mercurial-scm.org/repo/hg/rev/698fe0f6eb5c
changeset:   36454:698fe0f6eb5c
user:Pulkit Goyal <7895pul...@gmail.com>
date:Tue Feb 27 00:43:37 2018 +0530
summary: py3: use pycompat.strurl to convert url to str

https://www.mercurial-scm.org/repo/hg/rev/9e3cb58c7ab3
changeset:   36455:9e3cb58c7ab3
user:Pulkit Goyal <7895pul...@gmail.com>
date:Tue Feb 27 14:28:17 2018 +0530
summary: py3: make sure regexes are bytes

https://www.mercurial-scm.org/repo/hg/rev/9ff5cbfbc26a
changeset:   36456:9ff5cbfbc26a
user:Pulkit Goyal <7895pul...@gmail.com>
date:Tue Feb 27 14:41:24 2018 +0530
summary: py3: fix more keyword arguments handling

https://www.mercurial-scm.org/repo/hg/rev/0e8b76644e20
changeset:   36457:0e8b76644e20
user:Pulkit Goyal <7895pul...@gmail.com>
date:Tue Feb 27 14:42:30 2018 +0530
summary: py3: convert os.devnull to bytes using pycompat.bytestr

https://www.mercurial-scm.org/repo/hg/rev/2218f5bfafca
changeset:   36458:2218f5bfafca
user:Pulkit Goyal <7895pul...@gmail.com>
date:Tue Feb 27 14:44:37 2018 +0530
summary: py3: add b'' prefixes in tests/test-extension.t

https://www.mercurial-scm.org/repo/hg/rev/580f75f70f39
changeset:   36459:580f75f70f39
user:Pulkit Goyal <7895pul...@gmail.com>
date:Tue Feb 27 14:46:35 2018 +0530
summary: py3: use '%d' to convert integers to bytes

https://www.mercurial-scm.org/repo/hg/rev/432b85a46717
changeset:   36460:432b85a46717
user:Pulkit Goyal <7895pul...@gmail.com>
date:Tue Feb 27 14:49:05 2018 +0530
summary: py3: use print as a function in tests/test-hgrc.t

https://www.mercurial-scm.org/repo/hg/rev/51a9f0246931
changeset:   36461:51a9f0246931
user:Matt Harbison 
date:Mon Feb 26 23:34:29 2018 -0500
summary: run-tests: resume raising an exception when a server fails to start

https://www.mercurial-scm.org/repo/hg/rev/5c1cea8a3e60
changeset:   36462:5c1cea8a3e60
user:Matt Harbison 
date:Sun Feb 25 17:22:25 2018 -0500
summary: run-tests: cache hghave results

https://www.mercurial-scm.org/repo/hg/rev/1bd132a021dd

D2523: py3: whitelist 14 new tests passing

2018-03-01 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  12 new tests passed because of parent changeset and 2 were passing before that
  too.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2523

AFFECTED FILES
  contrib/python3-whitelist

CHANGE DETAILS

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -35,6 +35,7 @@
 test-clone-update-order.t
 test-commit-unresolved.t
 test-completion.t
+test-conflict.t
 test-confused-revert.t
 test-contrib-check-code.t
 test-contrib-check-commit.t
@@ -108,6 +109,7 @@
 test-glog-topological.t
 test-gpg.t
 test-hghave.t
+test-hgk.t
 test-histedit-arguments.t
 test-histedit-base.t
 test-histedit-bookmark-motion.t
@@ -117,9 +119,11 @@
 test-histedit-fold-non-commute.t
 test-histedit-fold.t
 test-histedit-no-change.t
+test-histedit-non-commute-abort.t
 test-histedit-non-commute.t
 test-histedit-obsolete.t
 test-histedit-outgoing.t
+test-histedit-templates.t
 test-http-branchmap.t
 test-http-clone-r.t
 test-identify.t
@@ -163,14 +167,16 @@
 test-merge-revert2.t
 test-merge-subrepos.t
 test-merge-symlinks.t
+test-merge-types.t
 test-merge1.t
 test-merge10.t
 test-merge2.t
 test-merge4.t
 test-merge5.t
 test-merge6.t
 test-merge7.t
 test-merge8.t
+test-merge9.t
 test-mq-git.t
 test-mq-pull-from-bundle.t
 test-mq-qdiff.t
@@ -200,6 +206,8 @@
 test-obsolete-checkheads.t
 test-obsolete-distributed.t
 test-parents.t
+test-pathconflicts-merge.t
+test-pathconflicts-update.t
 test-pending.t
 test-permissions.t
 test-phases.t
@@ -239,21 +247,26 @@
 test-push-http.t
 test-push-warn.t
 test-pushvars.t
+test-rebase-abort.t
 test-rebase-base-flag.t
 test-rebase-bookmarks.t
 test-rebase-brute-force.t
+test-rebase-cache.t
 test-rebase-check-restore.t
 test-rebase-dest.t
+test-rebase-detach.t
 test-rebase-emptycommit.t
 test-rebase-inmemory.t
 test-rebase-interruptions.t
 test-rebase-issue-noparam-single-rev.t
 test-rebase-legacy.t
 test-rebase-named-branches.t
 test-rebase-newancestor.t
+test-rebase-parameters.t
 test-rebase-partial.t
 test-rebase-pull.t
 test-rebase-rename.t
+test-rebase-templates.t
 test-rebase-transaction.t
 test-record.t
 test-relink.t
@@ -264,6 +277,7 @@
 test-rename.t
 test-repair-strip.t
 test-repo-compengines.t
+test-resolve.t
 test-revert-flags.t
 test-revert-unknown.t
 test-revlog-ancestry.py



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


D2522: py3: slice over bytes to prevent getting ascii values

2018-03-01 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This fixed reading of mergestate files and fixes 14 tests on Python 3.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2522

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -287,14 +287,14 @@
 off = 0
 end = len(data)
 while off < end:
-rtype = data[off]
+rtype = data[off:off + 1]
 off += 1
 length = _unpack('>I', data[off:(off + 4)])[0]
 off += 4
 record = data[off:(off + length)]
 off += length
 if rtype == 't':
-rtype, record = record[0], record[1:]
+rtype, record = record[0:1], record[1:]
 records.append((rtype, record))
 f.close()
 except IOError as err:



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


D2471: debugcommands: support for triggering push protocol

2018-03-01 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG638216a91996: debugcommands: support for triggering push 
protocol (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2471?vs=6259=6289

REVISION DETAIL
  https://phab.mercurial-scm.org/D2471

AFFECTED FILES
  mercurial/debugcommands.py
  tests/test-completion.t
  tests/test-ssh-proto-unbundle.t

CHANGE DETAILS

diff --git a/tests/test-ssh-proto-unbundle.t b/tests/test-ssh-proto-unbundle.t
new file mode 100644
--- /dev/null
+++ b/tests/test-ssh-proto-unbundle.t
@@ -0,0 +1,1676 @@
+  $ cat > hgrc-sshv2 << EOF
+  > %include $HGRCPATH
+  > [experimental]
+  > sshpeer.advertise-v2 = true
+  > sshserver.support-v2 = true
+  > EOF
+
+  $ debugwireproto() {
+  >   commands=`cat -`
+  >   echo 'testing ssh1'
+  >   tip=`hg log -r tip -T '{node}'`
+  >   echo "${commands}" | hg --verbose debugwireproto --localssh 
--noreadstderr
+  >   if [ -n "$1" ]; then
+  >   hg --config extensions.strip= strip --no-backup -r "all() - ::${tip}"
+  >   fi
+  >   echo ""
+  >   echo 'testing ssh2'
+  >   echo "${commands}" | HGRCPATH=$TESTTMP/hgrc-sshv2 hg --verbose 
debugwireproto --localssh --noreadstderr
+  >   if [ -n "$1" ]; then
+  >   hg --config extensions.strip= strip --no-backup -r "all() - ::${tip}"
+  >   fi
+  > }
+
+Generate some bundle files
+
+  $ hg init repo
+  $ cd repo
+  $ echo 0 > foo
+  $ hg -q commit -A -m initial
+  $ hg bundle --all -t none-v1 ../initial.v1.hg
+  1 changesets found
+  $ cd ..
+
+Test pushing bundle1 payload to a server with bundle1 disabled
+
+  $ hg init no-bundle1
+  $ cd no-bundle1
+  $ cat > .hg/hgrc << EOF
+  > [server]
+  > bundle1 = false
+  > EOF
+
+  $ debugwireproto << EOF
+  > command unbundle
+  > # This is "force" in hex.
+  > heads 666f726365
+  > PUSHFILE ../initial.v1.hg
+  > EOF
+  testing ssh1
+  creating ssh peer from handshake results
+  i> write(104) -> None:
+  i> hello\n
+  i> between\n
+  i> pairs 81\n
+  i> 
-
+  i> flush() -> None
+  o> readline() -> 4:
+  o> 384\n
+  o> readline() -> 384:
+  o> capabilities: lookup changegroupsubset branchmap pushkey known 
getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
+  o> readline() -> 2:
+  o> 1\n
+  o> readline() -> 1:
+  o> \n
+  sending unbundle command
+  i> write(9) -> None:
+  i> unbundle\n
+  i> write(9) -> None:
+  i> heads 10\n
+  i> write(10) -> None: 666f726365
+  i> flush() -> None
+  o> readline() -> 2:
+  o> 0\n
+  i> write(4) -> None:
+  i> 426\n
+  i> write(426) -> None:
+  i> 
HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
+  i> test\n
+  i> 0 0\n
+  i> foo\n
+  i> \n
+  i> 
initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
+  i> 
\x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
+  i> \x00\x00\x00\x00\x00\x00\x00\x00
+  i> write(2) -> None:
+  i> 0\n
+  i> flush() -> None
+  o> readline() -> 2:
+  o> 0\n
+  e> read(-1) -> 115:
+  e> abort: incompatible Mercurial client; bundle2 required\n
+  e> (see https://www.mercurial-scm.org/wiki/IncompatibleClient)\n
+  remote: abort: incompatible Mercurial client; bundle2 required
+  remote: (see https://www.mercurial-scm.org/wiki/IncompatibleClient)
+  o> read(0) -> 0: 
+  o> readline() -> 2:
+  o> 1\n
+  o> read(1) -> 1: 0
+  result: 0
+  remote output: 
+  
+  testing ssh2
+  creating ssh peer from handshake results
+  i> write(171) -> None:
+  i> upgrade * proto=exp-ssh-v2-0001\n (glob)
+  i> hello\n
+  i> between\n
+  i> pairs 81\n
+  i> 
-
+  i> flush() -> None
+  o> readline() -> 62:
+  o> upgraded * exp-ssh-v2-0001\n (glob)
+  o> readline() 

D2481: wireproto: use named arguments for commandentry

2018-03-01 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG91247ab87fb5: wireproto: use named arguments for 
commandentry (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2481?vs=6180=6290

REVISION DETAIL
  https://phab.mercurial-scm.org/D2481

AFFECTED FILES
  mercurial/wireproto.py

CHANGE DETAILS

diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -604,7 +604,7 @@
 data not captured by the 2-tuple and a new instance containing
 the union of the two objects is returned.
 """
-return commandentry(func, args)
+return commandentry(func, args=args)
 
 # Old code treats instances as 2-tuples. So expose that interface.
 def __iter__(self):
@@ -640,7 +640,7 @@
 if k in self:
 v = self[k]._merge(v[0], v[1])
 else:
-v = commandentry(v[0], v[1])
+v = commandentry(v[0], args=v[1])
 else:
 raise ValueError('command entries must be commandentry instances '
  'or 2-tuples')
@@ -664,7 +664,7 @@
 accepts. ``*`` is a special value that says to accept all arguments.
 """
 def register(func):
-commands[name] = commandentry(func, args)
+commands[name] = commandentry(func, args=args)
 return func
 return register
 



To: indygreg, #hg-reviewers, durin42
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2408: debugcommands: support for sending "batch" requests

2018-03-01 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG8c3e67747c4e: debugcommands: support for sending 
batch requests (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2408?vs=6253=6286

REVISION DETAIL
  https://phab.mercurial-scm.org/D2408

AFFECTED FILES
  mercurial/debugcommands.py
  tests/test-ssh-proto.t

CHANGE DETAILS

diff --git a/tests/test-ssh-proto.t b/tests/test-ssh-proto.t
--- a/tests/test-ssh-proto.t
+++ b/tests/test-ssh-proto.t
@@ -1830,3 +1830,105 @@
   o> 15\n
   o> bufferedread(15) -> 15: publishingTrue
   response: publishing True
+
+  $ cd ..
+
+Test batching of requests
+
+  $ hg init batching
+  $ cd batching
+  $ echo 0 > foo
+  $ hg add foo
+  $ hg -q commit -m initial
+  $ hg phase --public
+  $ echo 1 > foo
+  $ hg commit -m 'commit 1'
+  $ hg -q up 0
+  $ echo 2 > foo
+  $ hg commit -m 'commit 2'
+  created new head
+  $ hg book -r 1 bookA
+  $ hg book -r 2 bookB
+
+  $ debugwireproto << EOF
+  > batchbegin
+  > command heads
+  > command listkeys
+  > namespace bookmarks
+  > command listkeys
+  > namespace phases
+  > batchsubmit
+  > EOF
+  testing ssh1
+  creating ssh peer from handshake results
+  i> write(104) -> None:
+  i> hello\n
+  i> between\n
+  i> pairs 81\n
+  i> 
-
+  i> flush() -> None
+  o> readline() -> 4:
+  o> 384\n
+  o> readline() -> 384:
+  o> capabilities: lookup changegroupsubset branchmap pushkey known 
getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
+  o> readline() -> 2:
+  o> 1\n
+  o> readline() -> 1:
+  o> \n
+  sending batch with 3 sub-commands
+  i> write(6) -> None:
+  i> batch\n
+  i> write(4) -> None:
+  i> * 0\n
+  i> write(8) -> None:
+  i> cmds 61\n
+  i> write(61) -> None: heads ;listkeys namespace=bookmarks;listkeys 
namespace=phases
+  i> flush() -> None
+  o> bufferedreadline() -> 4:
+  o> 278\n
+  o> bufferedread(278) -> 278:
+  o> bfebe6bd38eebc6f8202e419c1171268987ea6a6 
4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n
+  o> ;bookA4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n
+  o> bookB 
bfebe6bd38eebc6f8202e419c1171268987ea6a6;4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab
   1\n
+  o> bfebe6bd38eebc6f8202e419c1171268987ea6a6  1\n
+  o> publishingTrue
+  response #0: bfebe6bd38eebc6f8202e419c1171268987ea6a6 
4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n
+  response #1: bookA   4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\nbookB 
bfebe6bd38eebc6f8202e419c1171268987ea6a6
+  response #2: 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab
1\nbfebe6bd38eebc6f8202e419c1171268987ea6a6 1\npublishing   True
+  
+  testing ssh2
+  creating ssh peer from handshake results
+  i> write(171) -> None:
+  i> upgrade * proto=exp-ssh-v2-0001\n (glob)
+  i> hello\n
+  i> between\n
+  i> pairs 81\n
+  i> 
-
+  i> flush() -> None
+  o> readline() -> 62:
+  o> upgraded * exp-ssh-v2-0001\n (glob)
+  o> readline() -> 4:
+  o> 383\n
+  o> read(383) -> 383: capabilities: lookup changegroupsubset branchmap 
pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
+  o> read(1) -> 1:
+  o> \n
+  sending batch with 3 sub-commands
+  i> write(6) -> None:
+  i> batch\n
+  i> write(4) -> None:
+  i> * 0\n
+  i> write(8) -> None:
+  i> cmds 61\n
+  i> write(61) -> None: heads ;listkeys namespace=bookmarks;listkeys 
namespace=phases
+  i> flush() -> None
+  o> bufferedreadline() -> 4:
+  o> 278\n
+  o> bufferedread(278) -> 278:
+  o> bfebe6bd38eebc6f8202e419c1171268987ea6a6 
4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n
+  o> ;bookA4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n
+  o> bookB 
bfebe6bd38eebc6f8202e419c1171268987ea6a6;4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab
   1\n
+  o> bfebe6bd38eebc6f8202e419c1171268987ea6a6  1\n
+  o> publishingTrue
+  response #0: bfebe6bd38eebc6f8202e419c1171268987ea6a6 
4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n
+  response #1: bookA   4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\nbookB 
bfebe6bd38eebc6f8202e419c1171268987ea6a6
+  response #2: 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab
1\nbfebe6bd38eebc6f8202e419c1171268987ea6a6 1\npublishing   True
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2629,6 +2629,21 @@
 Values are interpreted as Python b'' literals. This allows encoding
 special byte sequences via backslash escaping.
 
+batchbegin
+--
+
+Instruct the peer to begin a batched send.
+
+All ``command`` 

D2467: sshpeer: support not reading and forwarding stderr

2018-03-01 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG9dfedb47d000: sshpeer: support not reading and forwarding 
stderr (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2467?vs=6255=6288

REVISION DETAIL
  https://phab.mercurial-scm.org/D2467

AFFECTED FILES
  mercurial/sshpeer.py

CHANGE DETAILS

diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -337,13 +337,16 @@
 return protoname, caps
 
 class sshv1peer(wireproto.wirepeer):
-def __init__(self, ui, url, proc, stdin, stdout, stderr, caps):
+def __init__(self, ui, url, proc, stdin, stdout, stderr, caps,
+ autoreadstderr=True):
 """Create a peer from an existing SSH connection.
 
 ``proc`` is a handle on the underlying SSH process.
 ``stdin``, ``stdout``, and ``stderr`` are handles on the stdio
 pipes for that process.
 ``caps`` is a set of capabilities supported by the remote.
+``autoreadstderr`` denotes whether to automatically read from
+stderr and to forward its output.
 """
 self._url = url
 self._ui = ui
@@ -353,8 +356,9 @@
 
 # And we hook up our "doublepipe" wrapper to allow querying
 # stderr any time we perform I/O.
-stdout = doublepipe(ui, util.bufferedinputpipe(stdout), stderr)
-stdin = doublepipe(ui, stdin, stderr)
+if autoreadstderr:
+stdout = doublepipe(ui, util.bufferedinputpipe(stdout), stderr)
+stdin = doublepipe(ui, stdin, stderr)
 
 self._pipeo = stdin
 self._pipei = stdout
@@ -531,7 +535,7 @@
 # And handshake is performed before the peer is instantiated. So
 # we need no custom code.
 
-def makepeer(ui, path, proc, stdin, stdout, stderr):
+def makepeer(ui, path, proc, stdin, stdout, stderr, autoreadstderr=True):
 """Make a peer instance from existing pipes.
 
 ``path`` and ``proc`` are stored on the eventual peer instance and may
@@ -552,9 +556,11 @@
 raise
 
 if protoname == wireprotoserver.SSHV1:
-return sshv1peer(ui, path, proc, stdin, stdout, stderr, caps)
+return sshv1peer(ui, path, proc, stdin, stdout, stderr, caps,
+ autoreadstderr=autoreadstderr)
 elif protoname == wireprotoserver.SSHV2:
-return sshv2peer(ui, path, proc, stdin, stdout, stderr, caps)
+return sshv2peer(ui, path, proc, stdin, stdout, stderr, caps,
+ autoreadstderr=autoreadstderr)
 else:
 _cleanuppipes(ui, stdout, stdin, stderr)
 raise error.RepoError(_('unknown version of SSH protocol: %s') %



To: indygreg, #hg-reviewers, durin42
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2406: debugcommands: allow sending of simple commands with debugwireproto

2018-03-01 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG2aeacc6b479d: debugcommands: allow sending of simple 
commands with debugwireproto (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2406?vs=6252=6285

REVISION DETAIL
  https://phab.mercurial-scm.org/D2406

AFFECTED FILES
  mercurial/debugcommands.py
  tests/test-ssh-proto.t

CHANGE DETAILS

diff --git a/tests/test-ssh-proto.t b/tests/test-ssh-proto.t
--- a/tests/test-ssh-proto.t
+++ b/tests/test-ssh-proto.t
@@ -1,3 +1,23 @@
+  $ cat > hgrc-sshv2 << EOF
+  > %include $HGRCPATH
+  > [experimental]
+  > sshpeer.advertise-v2 = true
+  > sshserver.support-v2 = true
+  > EOF
+
+Helper function to run protocol tests against multiple protocol versions.
+This is easier than using #testcases because managing differences between
+protocols with inline conditional output is hard to read.
+
+  $ debugwireproto() {
+  >   commands=`cat -`
+  >   echo 'testing ssh1'
+  >   echo "${commands}" | hg --verbose debugwireproto --localssh
+  >   echo ""
+  >   echo 'testing ssh2'
+  >   echo "${commands}" | HGRCPATH=$TESTTMP/hgrc-sshv2 hg --verbose 
debugwireproto --localssh
+  > }
+
   $ cat >> $HGRCPATH << EOF
   > [ui]
   > ssh = $PYTHON "$TESTDIR/dummyssh"
@@ -1252,3 +1272,561 @@
   e> read(-1) -> 49:
   e> malformed handshake protocol: missing pairs 81\n
   e> -\n
+
+  $ cd ..
+
+Test listkeys for listing namespaces
+
+  $ hg init empty
+  $ cd empty
+  $ debugwireproto << EOF
+  > command listkeys
+  > namespace namespaces
+  > EOF
+  testing ssh1
+  creating ssh peer from handshake results
+  i> write(104) -> None:
+  i> hello\n
+  i> between\n
+  i> pairs 81\n
+  i> 
-
+  i> flush() -> None
+  o> readline() -> 4:
+  o> 384\n
+  o> readline() -> 384:
+  o> capabilities: lookup changegroupsubset branchmap pushkey known 
getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
+  o> readline() -> 2:
+  o> 1\n
+  o> readline() -> 1:
+  o> \n
+  sending listkeys command
+  i> write(9) -> None:
+  i> listkeys\n
+  i> write(13) -> None:
+  i> namespace 10\n
+  i> write(10) -> None: namespaces
+  i> flush() -> None
+  o> bufferedreadline() -> 3:
+  o> 30\n
+  o> bufferedread(30) -> 30:
+  o> bookmarks \n
+  o> namespaces\n
+  o> phases
+  response: bookmarks  \nnamespaces\nphases
+  
+  testing ssh2
+  creating ssh peer from handshake results
+  i> write(171) -> None:
+  i> upgrade * proto=exp-ssh-v2-0001\n (glob)
+  i> hello\n
+  i> between\n
+  i> pairs 81\n
+  i> 
-
+  i> flush() -> None
+  o> readline() -> 62:
+  o> upgraded * exp-ssh-v2-0001\n (glob)
+  o> readline() -> 4:
+  o> 383\n
+  o> read(383) -> 383: capabilities: lookup changegroupsubset branchmap 
pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
+  o> read(1) -> 1:
+  o> \n
+  sending listkeys command
+  i> write(9) -> None:
+  i> listkeys\n
+  i> write(13) -> None:
+  i> namespace 10\n
+  i> write(10) -> None: namespaces
+  i> flush() -> None
+  o> bufferedreadline() -> 3:
+  o> 30\n
+  o> bufferedread(30) -> 30:
+  o> bookmarks \n
+  o> namespaces\n
+  o> phases
+  response: bookmarks  \nnamespaces\nphases
+
+  $ cd ..
+
+Test listkeys for bookmarks
+
+  $ hg init bookmarkrepo
+  $ cd bookmarkrepo
+  $ echo 0 > foo
+  $ hg add foo
+  $ hg -q commit -m initial
+  $ echo 1 > foo
+  $ hg commit -m second
+
+With no bookmarks set
+
+  $ debugwireproto << EOF
+  > command listkeys
+  > namespace bookmarks
+  > EOF
+  testing ssh1
+  creating ssh peer from handshake results
+  i> write(104) -> None:
+  i> hello\n
+  i> between\n
+  i> pairs 81\n
+  i> 
-
+  i> flush() -> None
+  o> readline() -> 4:
+  o> 384\n
+  o> readline() -> 384:
+  o> capabilities: lookup changegroupsubset branchmap pushkey known 
getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
+  o> readline() -> 2:
+  o> 1\n
+  o> readline() -> 1:
+  o> \n
+  sending listkeys command
+  i> write(9) -> None:
+  i> listkeys\n
+  i> write(12) -> None:
+  i> namespace 9\n
+  i> write(9) -> None: bookmarks
+  i> flush() -> None
+  o> bufferedreadline() -> 2:
+  o> 0\n
+  response: 
+  
+  testing ssh2
+  creating ssh peer from handshake results
+  i> write(171) -> None:
+  i> upgrade * proto=exp-ssh-v2-0001\n (glob)
+  i> hello\n
+  i> between\n
+  

D2482: wireprotoserver: move SSHV1 and SSHV2 constants to wireprototypes

2018-03-01 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG049c038f56f8: wireprotoserver: move SSHV1 and SSHV2 
constants to wireprototypes (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2482?vs=6181=6291

REVISION DETAIL
  https://phab.mercurial-scm.org/D2482

AFFECTED FILES
  mercurial/sshpeer.py
  mercurial/wireprotoserver.py
  mercurial/wireprototypes.py

CHANGE DETAILS

diff --git a/mercurial/wireprototypes.py b/mercurial/wireprototypes.py
--- a/mercurial/wireprototypes.py
+++ b/mercurial/wireprototypes.py
@@ -7,6 +7,12 @@
 
 import abc
 
+# Names of the SSH protocol implementations.
+SSHV1 = 'ssh-v1'
+# This is advertised over the wire. Incremental the counter at the end
+# to reflect BC breakages.
+SSHV2 = 'exp-ssh-v2-0001'
+
 class bytesresponse(object):
 """A wire protocol response consisting of raw bytes."""
 def __init__(self, data):
diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -33,11 +33,8 @@
 HGTYPE2 = 'application/mercurial-0.2'
 HGERRTYPE = 'application/hg-error'
 
-# Names of the SSH protocol implementations.
-SSHV1 = 'ssh-v1'
-# This is advertised over the wire. Incremental the counter at the end
-# to reflect BC breakages.
-SSHV2 = 'exp-ssh-v2-0001'
+SSHV1 = wireprototypes.SSHV1
+SSHV2 = wireprototypes.SSHV2
 
 def decodevaluefromheaders(req, headerprefix):
 """Decode a long value from multiple HTTP request headers.
@@ -324,7 +321,7 @@
 
 @property
 def name(self):
-return SSHV1
+return wireprototypes.SSHV1
 
 def getargs(self, args):
 data = {}
@@ -492,7 +489,7 @@
 # We should never transition into this state if we've switched
 # protocols.
 assert not protoswitched
-assert proto.name == SSHV1
+assert proto.name == wireprototypes.SSHV1
 
 # Expected: upgrade  
 # If we get something else, the request is malformed. It could be
diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -17,6 +17,7 @@
 util,
 wireproto,
 wireprotoserver,
+wireprototypes,
 )
 
 def _serverquote(s):
@@ -257,7 +258,7 @@
 badresponse()
 
 # Assume version 1 of wire protocol by default.
-protoname = wireprotoserver.SSHV1
+protoname = wireprototypes.SSHV1
 reupgraded = re.compile(b'^upgraded %s (.*)$' % re.escape(token))
 
 lines = ['', 'dummy']
@@ -296,7 +297,7 @@
 
 # For version 1, we should see a ``capabilities`` line in response to the
 # ``hello`` command.
-if protoname == wireprotoserver.SSHV1:
+if protoname == wireprototypes.SSHV1:
 for l in reversed(lines):
 # Look for response to ``hello`` command. Scan from the back so
 # we don't misinterpret banner output as the command reply.
@@ -555,10 +556,10 @@
 _cleanuppipes(ui, stdout, stdin, stderr)
 raise
 
-if protoname == wireprotoserver.SSHV1:
+if protoname == wireprototypes.SSHV1:
 return sshv1peer(ui, path, proc, stdin, stdout, stderr, caps,
  autoreadstderr=autoreadstderr)
-elif protoname == wireprotoserver.SSHV2:
+elif protoname == wireprototypes.SSHV2:
 return sshv2peer(ui, path, proc, stdin, stdout, stderr, caps,
  autoreadstderr=autoreadstderr)
 else:



To: indygreg, #hg-reviewers, durin42
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2392: debugcommands: add debugwireproto command

2018-03-01 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG36f21b975efb: debugcommands: add debugwireproto command 
(authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2392?vs=6250=6283

REVISION DETAIL
  https://phab.mercurial-scm.org/D2392

AFFECTED FILES
  mercurial/debugcommands.py
  tests/test-completion.t
  tests/test-help.t
  tests/test-ssh-proto.t

CHANGE DETAILS

diff --git a/tests/test-ssh-proto.t b/tests/test-ssh-proto.t
--- a/tests/test-ssh-proto.t
+++ b/tests/test-ssh-proto.t
@@ -12,10 +12,29 @@
   $ echo 0 > foo
   $ hg -q add foo
   $ hg commit -m initial
-  $ cd ..
+
+A no-op connection performs a handshake
+
+  $ hg debugwireproto --localssh << EOF
+  > EOF
+  creating ssh peer from handshake results
+
+Raw peers don't perform any activity
+
+  $ hg debugwireproto --localssh --peer raw << EOF
+  > EOF
+  using raw connection to peer
+  $ hg debugwireproto --localssh --peer ssh1 << EOF
+  > EOF
+  creating ssh peer for wire protocol version 1
+  $ hg debugwireproto --localssh --peer ssh2 << EOF
+  > EOF
+  creating ssh peer for wire protocol version 2
 
 Test a normal behaving server, for sanity
 
+  $ cd ..
+
   $ hg --debug debugpeer ssh://user@dummy/server
   running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' 
(glob) (no-windows !)
   running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" 
(glob) (windows !)
@@ -33,11 +52,19 @@
 
 Server should answer the "hello" command in isolation
 
-  $ hg -R server serve --stdio << EOF
-  > hello
+  $ hg -R server debugwireproto --localssh --peer raw << EOF
+  > raw
+  > hello\n
+  > readline
+  > readline
   > EOF
-  384
-  capabilities: lookup changegroupsubset branchmap pushkey known getbundle 
unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN
+  using raw connection to peer
+  i> write(6) -> None:
+  i> hello\n
+  o> readline() -> 4:
+  o> 384\n
+  o> readline() -> 384:
+  o> capabilities: lookup changegroupsubset branchmap pushkey known 
getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
 
 `hg debugserve --sshstdio` works
 
@@ -80,16 +107,33 @@
 Server should reply with capabilities and should send "1\n\n" as a successful
 reply with empty response to the "between".
 
-  $ hg -R server serve --stdio << EOF
-  > hello
-  > between
-  > pairs 81
-  > 
-
+  $ hg -R server debugwireproto --localssh --peer raw << EOF
+  > raw
+  > hello\n
+  > readline
+  > readline
+  > raw
+  > between\n
+  > pairs 81\n
+  > 
-
+  > readline
+  > readline
   > EOF
-  384
-  capabilities: lookup changegroupsubset branchmap pushkey known getbundle 
unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN
-  1
-  
+  using raw connection to peer
+  i> write(6) -> None:
+  i> hello\n
+  o> readline() -> 4:
+  o> 384\n
+  o> readline() -> 384:
+  o> capabilities: lookup changegroupsubset branchmap pushkey known 
getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
+  i> write(98) -> None:
+  i> between\n
+  i> pairs 81\n
+  i> 
-
+  o> readline() -> 2:
+  o> 1\n
+  o> readline() -> 1:
+  o> \n
 
 SSH banner is not printed by default, ignored by clients
 
@@ -127,26 +171,63 @@
 
 And test the banner with the raw protocol
 
-  $ SSHSERVERMODE=banner hg -R server serve --stdio << EOF
-  > hello
-  > between
-  > pairs 81
-  > 
-
+  $ SSHSERVERMODE=banner hg -R server debugwireproto --localssh --peer raw << 
EOF
+  > raw
+  > hello\n
+  > readline
+  > readline
+  > readline
+  > readline
+  > readline
+  > readline
+  > readline
+  > readline
+  > readline
+  > readline
+  > readline
+  > readline
+  > raw
+  > between\n
+  > pairs 81\n
+  > 
-
+  > readline
+  > readline
   > EOF
-  banner: line 0
-  banner: line 1
-  banner: line 2
-  banner: line 3
-  banner: line 4
-  banner: line 5
-  banner: line 6
-  banner: line 7
-  banner: line 8
-  banner: line 9
-  384
-  capabilities: lookup changegroupsubset branchmap pushkey known getbundle 
unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN
-  1
-  
+  using raw connection to peer
+  i> write(6) -> None:
+  i> hello\n
+  o> readline() -> 15:
+  o> banner: line 0\n
+  o> readline() -> 15:

D2466: tests: add wire protocol tests for pushkey

2018-03-01 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG67915cd305a2: tests: add wire protocol tests for pushkey 
(authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2466?vs=6254=6287

REVISION DETAIL
  https://phab.mercurial-scm.org/D2466

AFFECTED FILES
  tests/test-ssh-proto.t

CHANGE DETAILS

diff --git a/tests/test-ssh-proto.t b/tests/test-ssh-proto.t
--- a/tests/test-ssh-proto.t
+++ b/tests/test-ssh-proto.t
@@ -1547,6 +1547,94 @@
   o> bookB 1880f3755e2e52e3199e0ee5638128b08642f34d
   response: bookA  68986213bd4485ea51533535e3fc9e78007a711f\nbookB 
1880f3755e2e52e3199e0ee5638128b08642f34d
 
+Test pushkey for bookmarks
+
+  $ debugwireproto << EOF
+  > command pushkey
+  > namespace bookmarks
+  > key remote
+  > old
+  > new 68986213bd4485ea51533535e3fc9e78007a711f
+  > EOF
+  testing ssh1
+  creating ssh peer from handshake results
+  i> write(104) -> None:
+  i> hello\n
+  i> between\n
+  i> pairs 81\n
+  i> 
-
+  i> flush() -> None
+  o> readline() -> 4:
+  o> 384\n
+  o> readline() -> 384:
+  o> capabilities: lookup changegroupsubset branchmap pushkey known 
getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
+  o> readline() -> 2:
+  o> 1\n
+  o> readline() -> 1:
+  o> \n
+  sending pushkey command
+  i> write(8) -> None:
+  i> pushkey\n
+  i> write(6) -> None:
+  i> key 6\n
+  i> write(6) -> None: remote
+  i> write(12) -> None:
+  i> namespace 9\n
+  i> write(9) -> None: bookmarks
+  i> write(7) -> None:
+  i> new 40\n
+  i> write(40) -> None: 68986213bd4485ea51533535e3fc9e78007a711f
+  i> write(6) -> None:
+  i> old 0\n
+  i> flush() -> None
+  o> bufferedreadline() -> 2:
+  o> 2\n
+  o> bufferedread(2) -> 2:
+  o> 1\n
+  response: 1\n
+  
+  testing ssh2
+  creating ssh peer from handshake results
+  i> write(171) -> None:
+  i> upgrade * proto=exp-ssh-v2-0001\n (glob)
+  i> hello\n
+  i> between\n
+  i> pairs 81\n
+  i> 
-
+  i> flush() -> None
+  o> readline() -> 62:
+  o> upgraded * exp-ssh-v2-0001\n (glob)
+  o> readline() -> 4:
+  o> 383\n
+  o> read(383) -> 383: capabilities: lookup changegroupsubset branchmap 
pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
+  o> read(1) -> 1:
+  o> \n
+  sending pushkey command
+  i> write(8) -> None:
+  i> pushkey\n
+  i> write(6) -> None:
+  i> key 6\n
+  i> write(6) -> None: remote
+  i> write(12) -> None:
+  i> namespace 9\n
+  i> write(9) -> None: bookmarks
+  i> write(7) -> None:
+  i> new 40\n
+  i> write(40) -> None: 68986213bd4485ea51533535e3fc9e78007a711f
+  i> write(6) -> None:
+  i> old 0\n
+  i> flush() -> None
+  o> bufferedreadline() -> 2:
+  o> 2\n
+  o> bufferedread(2) -> 2:
+  o> 1\n
+  response: 1\n
+
+  $ hg bookmarks
+ bookA 0:68986213bd44
+ bookB 1:1880f3755e2e
+ remote0:68986213bd44
+
   $ cd ..
 
 Test listkeys for phases
@@ -1831,6 +1919,96 @@
   o> bufferedread(15) -> 15: publishingTrue
   response: publishing True
 
+Setting public phase via pushkey
+
+  $ hg phase --draft --force -r .
+
+  $ debugwireproto << EOF
+  > command pushkey
+  > namespace phases
+  > key 7127240a084fd9dc86fe8d1f98e26229161ec82b
+  > old 1
+  > new 0
+  > EOF
+  testing ssh1
+  creating ssh peer from handshake results
+  i> write(104) -> None:
+  i> hello\n
+  i> between\n
+  i> pairs 81\n
+  i> 
-
+  i> flush() -> None
+  o> readline() -> 4:
+  o> 384\n
+  o> readline() -> 384:
+  o> capabilities: lookup changegroupsubset branchmap pushkey known 
getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
+  o> readline() -> 2:
+  o> 1\n
+  o> readline() -> 1:
+  o> \n
+  sending pushkey command
+  i> write(8) -> None:
+  i> pushkey\n
+  i> write(7) -> None:
+  i> key 40\n
+  i> write(40) -> None: 7127240a084fd9dc86fe8d1f98e26229161ec82b
+  i> write(12) -> None:
+  i> namespace 6\n
+  i> write(6) -> None: phases
+  i> write(6) -> None:
+  i> new 1\n
+  i> write(1) -> None: 0
+  i> write(6) -> None:
+  i> old 1\n
+  i> write(1) -> None: 1
+  i> flush() -> None
+  o> bufferedreadline() -> 2:
+  o> 2\n
+  o> bufferedread(2) -> 2:
+  o> 1\n
+  response: 1\n
+  
+  testing ssh2
+  creating ssh peer from handshake results
+  i> write(171) -> None:
+  i> upgrade * proto=exp-ssh-v2-0001\n 

D2405: wireproto: sort response to listkeys

2018-03-01 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGf195db4d0b34: wireproto: sort response to listkeys 
(authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2405?vs=6251=6284

REVISION DETAIL
  https://phab.mercurial-scm.org/D2405

AFFECTED FILES
  mercurial/wireproto.py

CHANGE DETAILS

diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -916,7 +916,7 @@
 
 @wireprotocommand('listkeys', 'namespace')
 def listkeys(repo, proto, namespace):
-d = repo.listkeys(encoding.tolocal(namespace)).items()
+d = sorted(repo.listkeys(encoding.tolocal(namespace)).items())
 return bytesresponse(pushkeymod.encodekeys(d))
 
 @wireprotocommand('lookup', 'key')



To: indygreg, #hg-reviewers, durin42
Cc: durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2483: wireproto: allow wire protocol commands to declare transport support

2018-03-01 Thread durin42 (Augie Fackler)
durin42 added inline comments.

INLINE COMMENTS

> wireproto.py:669-673
> +POLICY_ALL = 'all'
> +POLICY_SSH_ONLY = 'ssh-only'
> +POLICY_HTTP_ONLY = 'http-only'
> +POLICY_V1_ONLY = 'v1-only'
> +POLICY_V2_ONLY = 'v2-only'

These feel vaguely orthogonal? Some are proto versions (that only apply to ssh?)

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2483

To: indygreg, #hg-reviewers
Cc: durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2405: wireproto: sort response to listkeys

2018-03-01 Thread durin42 (Augie Fackler)
durin42 added a comment.


  I'm a little bummed about this because namespaces could be *enormous*, like 
bookmarks. We might want to find another way to handle this...

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2405

To: indygreg, #hg-reviewers
Cc: durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2404: util: enable observing of util.bufferedinputpipe

2018-03-01 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGcafa60632281: util: enable observing of 
util.bufferedinputpipe (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2404?vs=6247=6280

REVISION DETAIL
  https://phab.mercurial-scm.org/D2404

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -373,6 +373,13 @@
 This class lives in the 'util' module because it makes use of the 'os'
 module from the python stdlib.
 """
+def __new__(cls, fh):
+# If we receive a fileobjectproxy, we need to use a variation of this
+# class that notifies observers about activity.
+if isinstance(fh, fileobjectproxy):
+cls = observedbufferedinputpipe
+
+return super(bufferedinputpipe, cls).__new__(cls)
 
 def __init__(self, input):
 self._input = input
@@ -453,6 +460,8 @@
 self._lenbuf += len(data)
 self._buffer.append(data)
 
+return data
+
 def mmapread(fp):
 try:
 fd = getattr(fp, 'fileno', lambda: fp)()
@@ -505,6 +514,8 @@
 
 def __getattribute__(self, name):
 ours = {
+r'_observer',
+
 # IOBase
 r'close',
 # closed if a property
@@ -639,6 +650,46 @@
 return object.__getattribute__(self, r'_observedcall')(
 r'read1', *args, **kwargs)
 
+class observedbufferedinputpipe(bufferedinputpipe):
+"""A variation of bufferedinputpipe that is aware of fileobjectproxy.
+
+``bufferedinputpipe`` makes low-level calls to ``os.read()`` that
+bypass ``fileobjectproxy``. Because of this, we need to make
+``bufferedinputpipe`` aware of these operations.
+
+This variation of ``bufferedinputpipe`` can notify observers about
+``os.read()`` events. It also re-publishes other events, such as
+``read()`` and ``readline()``.
+"""
+def _fillbuffer(self):
+res = super(observedbufferedinputpipe, self)._fillbuffer()
+
+fn = getattr(self._input._observer, r'osread', None)
+if fn:
+fn(res, _chunksize)
+
+return res
+
+# We use different observer methods because the operation isn't
+# performed on the actual file object but on us.
+def read(self, size):
+res = super(observedbufferedinputpipe, self).read(size)
+
+fn = getattr(self._input._observer, r'bufferedread', None)
+if fn:
+fn(res, size)
+
+return res
+
+def readline(self, *args, **kwargs):
+res = super(observedbufferedinputpipe, self).readline(*args, **kwargs)
+
+fn = getattr(self._input._observer, r'bufferedreadline', None)
+if fn:
+fn(res)
+
+return res
+
 DATA_ESCAPE_MAP = {pycompat.bytechr(i): br'\x%02x' % i for i in range(256)}
 DATA_ESCAPE_MAP.update({
 b'\\': b'',
@@ -702,6 +753,16 @@
 
 self.fh.write('%s> flush() -> %r\n' % (self.name, res))
 
+# For observedbufferedinputpipe.
+def bufferedread(self, res, size):
+self.fh.write('%s> bufferedread(%d) -> %d' % (
+self.name, size, len(res)))
+self._writedata(res)
+
+def bufferedreadline(self, res):
+self.fh.write('%s> bufferedreadline() -> %d' % (self.name, len(res)))
+self._writedata(res)
+
 def makeloggingfileobject(logh, fh, name, reads=True, writes=True,
   logdata=False):
 """Turn a file object into a logging file object."""



To: indygreg, #hg-reviewers, durin42
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2463: wireprotoserver: support logging SSH server I/O to a file descriptor

2018-03-01 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG64efadb62026: wireprotoserver: support logging SSH server 
I/O to a file descriptor (authored by indygreg, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D2463?vs=6248=6281#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2463?vs=6248=6281

REVISION DETAIL
  https://phab.mercurial-scm.org/D2463

AFFECTED FILES
  mercurial/wireprotoserver.py

CHANGE DETAILS

diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -588,12 +588,19 @@
  state)
 
 class sshserver(object):
-def __init__(self, ui, repo):
+def __init__(self, ui, repo, logfh=None):
 self._ui = ui
 self._repo = repo
 self._fin = ui.fin
 self._fout = ui.fout
 
+# Log write I/O to stdout and stderr if configured.
+if logfh:
+self._fout = util.makeloggingfileobject(
+logfh, self._fout, 'o', logdata=True)
+ui.ferr = util.makeloggingfileobject(
+logfh, ui.ferr, 'e', logdata=True)
+
 hook.redirect(True)
 ui.fout = repo.ui.fout = ui.ferr
 



To: indygreg, #hg-reviewers, durin42
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2464: debugcommands: add debugserve command

2018-03-01 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG33403069f376: debugcommands: add debugserve command 
(authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2464?vs=6249=6282

REVISION DETAIL
  https://phab.mercurial-scm.org/D2464

AFFECTED FILES
  mercurial/debugcommands.py
  tests/test-completion.t
  tests/test-help.t
  tests/test-ssh-proto.t

CHANGE DETAILS

diff --git a/tests/test-ssh-proto.t b/tests/test-ssh-proto.t
--- a/tests/test-ssh-proto.t
+++ b/tests/test-ssh-proto.t
@@ -39,6 +39,43 @@
   384
   capabilities: lookup changegroupsubset branchmap pushkey known getbundle 
unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN
 
+`hg debugserve --sshstdio` works
+
+  $ cd server
+  $ hg debugserve --sshstdio << EOF
+  > hello
+  > EOF
+  384
+  capabilities: lookup changegroupsubset branchmap pushkey known getbundle 
unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN
+
+I/O logging works
+
+  $ hg debugserve --sshstdio --logiofd 1 << EOF
+  > hello
+  > EOF
+  o> write(4) -> None:
+  o> 384\n
+  o> write(384) -> None:
+  o> capabilities: lookup changegroupsubset branchmap pushkey known 
getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
+  384
+  capabilities: lookup changegroupsubset branchmap pushkey known getbundle 
unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN
+  o> flush() -> None
+
+  $ hg debugserve --sshstdio --logiofile $TESTTMP/io << EOF
+  > hello
+  > EOF
+  384
+  capabilities: lookup changegroupsubset branchmap pushkey known getbundle 
unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN
+
+  $ cat $TESTTMP/io
+  o> write(4) -> None:
+  o> 384\n
+  o> write(384) -> None:
+  o> capabilities: lookup changegroupsubset branchmap pushkey known 
getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
+  o> flush() -> None
+
+  $ cd ..
+
 >=0.9.1 clients send a "hello" + "between" for the null range as part of 
 >handshake.
 Server should reply with capabilities and should send "1\n\n" as a successful
 reply with empty response to the "between".
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -967,6 +967,7 @@
debugrename   dump rename information
debugrevlog   show data and statistics about a revlog
debugrevspec  parse and apply a revision specification
+   debugserverun a server with advanced settings
debugsetparents
  manually set the parents of the current working directory
debugssl  test a secure connection to a server
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -111,6 +111,7 @@
   debugrename
   debugrevlog
   debugrevspec
+  debugserve
   debugsetparents
   debugssl
   debugsub
@@ -291,6 +292,7 @@
   debugrename: rev
   debugrevlog: changelog, manifest, dir, dump
   debugrevspec: optimize, show-revs, show-set, show-stage, no-optimized, 
verify-optimized
+  debugserve: sshstdio, logiofd, logiofile
   debugsetparents: 
   debugssl: 
   debugsub: rev
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -73,6 +73,7 @@
 url as urlmod,
 util,
 vfs as vfsmod,
+wireprotoserver,
 )
 
 release = lockmod.release
@@ -2230,6 +2231,37 @@
 for c in revs:
 ui.write("%d\n" % c)
 
+@command('debugserve', [
+('', 'sshstdio', False, _('run an SSH server bound to process handles')),
+('', 'logiofd', '', _('file descriptor to log server I/O to')),
+('', 'logiofile', '', _('file to log server I/O to')),
+], '')
+def debugserve(ui, repo, **opts):
+"""run a server with advanced settings
+
+This command is similar to :hg:`serve`. It exists partially as a
+workaround to the fact that ``hg serve --stdio`` must have specific
+arguments for security reasons.
+"""
+opts = pycompat.byteskwargs(opts)
+
+if not opts['sshstdio']:
+raise error.Abort(_('only --sshstdio is currently supported'))
+
+logfh = None
+
+if opts['logiofd'] and opts['logiofile']:
+raise error.Abort(_('cannot use both --logiofd and --logiofile'))
+
+if opts['logiofd']:
+# Line buffered because output is line based.
+logfh = os.fdopen(int(opts['logiofd']), 'ab', 1)
+elif opts['logiofile']:
+logfh = open(opts['logiofile'], 'ab', 1)
+
+s = wireprotoserver.sshserver(ui, repo, logfh=logfh)
+s.serve_forever()
+
 @command('debugsetparents', [], _('REV1 [REV2]'))
 

D2462: util: add a file object proxy that can notify observers

2018-03-01 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG72c27b55928c: util: add a file object proxy that can notify 
observers (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2462?vs=6135=6279

REVISION DETAIL
  https://phab.mercurial-scm.org/D2462

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -488,6 +488,228 @@
  env=env)
 return p.stdin, p.stdout, p.stderr, p
 
+class fileobjectproxy(object):
+"""A proxy around file objects that tells a watcher when events occur.
+
+This type is intended to only be used for testing purposes. Think hard
+before using it in important code.
+"""
+__slots__ = (
+'_orig',
+'_observer',
+)
+
+def __init__(self, fh, observer):
+object.__setattr__(self, '_orig', fh)
+object.__setattr__(self, '_observer', observer)
+
+def __getattribute__(self, name):
+ours = {
+# IOBase
+r'close',
+# closed if a property
+r'fileno',
+r'flush',
+r'isatty',
+r'readable',
+r'readline',
+r'readlines',
+r'seek',
+r'seekable',
+r'tell',
+r'truncate',
+r'writable',
+r'writelines',
+# RawIOBase
+r'read',
+r'readall',
+r'readinto',
+r'write',
+# BufferedIOBase
+# raw is a property
+r'detach',
+# read defined above
+r'read1',
+# readinto defined above
+# write defined above
+}
+
+# We only observe some methods.
+if name in ours:
+return object.__getattribute__(self, name)
+
+return getattr(object.__getattribute__(self, r'_orig'), name)
+
+def __delattr__(self, name):
+return delattr(object.__getattribute__(self, r'_orig'), name)
+
+def __setattr__(self, name, value):
+return setattr(object.__getattribute__(self, r'_orig'), name, value)
+
+def __iter__(self):
+return object.__getattribute__(self, r'_orig').__iter__()
+
+def _observedcall(self, name, *args, **kwargs):
+# Call the original object.
+orig = object.__getattribute__(self, r'_orig')
+res = getattr(orig, name)(*args, **kwargs)
+
+# Call a method on the observer of the same name with arguments
+# so it can react, log, etc.
+observer = object.__getattribute__(self, r'_observer')
+fn = getattr(observer, name, None)
+if fn:
+fn(res, *args, **kwargs)
+
+return res
+
+def close(self, *args, **kwargs):
+return object.__getattribute__(self, r'_observedcall')(
+r'close', *args, **kwargs)
+
+def fileno(self, *args, **kwargs):
+return object.__getattribute__(self, r'_observedcall')(
+r'fileno', *args, **kwargs)
+
+def flush(self, *args, **kwargs):
+return object.__getattribute__(self, r'_observedcall')(
+r'flush', *args, **kwargs)
+
+def isatty(self, *args, **kwargs):
+return object.__getattribute__(self, r'_observedcall')(
+r'isatty', *args, **kwargs)
+
+def readable(self, *args, **kwargs):
+return object.__getattribute__(self, r'_observedcall')(
+r'readable', *args, **kwargs)
+
+def readline(self, *args, **kwargs):
+return object.__getattribute__(self, r'_observedcall')(
+r'readline', *args, **kwargs)
+
+def readlines(self, *args, **kwargs):
+return object.__getattribute__(self, r'_observedcall')(
+r'readlines', *args, **kwargs)
+
+def seek(self, *args, **kwargs):
+return object.__getattribute__(self, r'_observedcall')(
+r'seek', *args, **kwargs)
+
+def seekable(self, *args, **kwargs):
+return object.__getattribute__(self, r'_observedcall')(
+r'seekable', *args, **kwargs)
+
+def tell(self, *args, **kwargs):
+return object.__getattribute__(self, r'_observedcall')(
+r'tell', *args, **kwargs)
+
+def truncate(self, *args, **kwargs):
+return object.__getattribute__(self, r'_observedcall')(
+r'truncate', *args, **kwargs)
+
+def writable(self, *args, **kwargs):
+return object.__getattribute__(self, r'_observedcall')(
+r'writable', *args, **kwargs)
+
+def writelines(self, *args, **kwargs):
+return object.__getattribute__(self, r'_observedcall')(
+r'writelines', *args, **kwargs)
+
+def read(self, *args, **kwargs):
+return object.__getattribute__(self, r'_observedcall')(
+r'read', *args, **kwargs)
+
+def readall(self, *args, 

D2461: wireprotoserver: ability to run an SSH server until an event is set

2018-03-01 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGe7411fb7ba7f: wireprotoserver: ability to run an SSH server 
until an event is set (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2461?vs=6134=6278

REVISION DETAIL
  https://phab.mercurial-scm.org/D2461

AFFECTED FILES
  mercurial/wireprotoserver.py

CHANGE DETAILS

diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -9,6 +9,7 @@
 import contextlib
 import struct
 import sys
+import threading
 
 from .i18n import _
 from . import (
@@ -373,7 +374,7 @@
 class sshv2protocolhandler(sshv1protocolhandler):
 """Protocol handler for version 2 of the SSH protocol."""
 
-def _runsshserver(ui, repo, fin, fout):
+def _runsshserver(ui, repo, fin, fout, ev):
 # This function operates like a state machine of sorts. The following
 # states are defined:
 #
@@ -430,7 +431,7 @@
 proto = sshv1protocolhandler(ui, fin, fout)
 protoswitched = False
 
-while True:
+while not ev.is_set():
 if state == 'protov1-serving':
 # Commands are issued on new lines.
 request = fin.readline()[:-1]
@@ -601,5 +602,9 @@
 util.setbinary(self._fout)
 
 def serve_forever(self):
-_runsshserver(self._ui, self._repo, self._fin, self._fout)
+self.serveuntil(threading.Event())
 sys.exit(0)
+
+def serveuntil(self, ev):
+"""Serve until a threading.Event is set."""
+_runsshserver(self._ui, self._repo, self._fin, self._fout, ev)



To: indygreg, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[Bug 5809] New: Performance regression on pulling + incoming in 5cfdf6137af8 (from 10s to 40s)

2018-03-01 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=5809

Bug ID: 5809
   Summary: Performance regression on pulling + incoming in
5cfdf6137af8 (from 10s to 40s)
   Product: Mercurial
   Version: default branch
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Keywords: perfregression
  Severity: bug
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: lothiral...@gmail.com
CC: mercurial-devel@mercurial-scm.org

ASV detected a regression on incoming when specifying a revision on
https://www.mercurial-scm.org/repo/hg/rev/5cfdf613.

The regression detected were detected on pypy
(http://perf.octobus.net/#regressions?sort=3=desc).

The scenario is the following:
- Starting on the same repository, strip X (10, 100, 1000) changesets.
- Rebuild caches with debugupdatecache.
- Identify the hash of the default branch on the original repository.
- Do a `hg incoming -r HASH`.

The pypy snapshot we are using on the bench machine has 91957 changesets and
169 heads. The repo we are running incoming in has X (10, 100, 1000) changesets
less than the target and around 30% of them are on the default branch.


I reproduced the issue on a private repository on both incoming and pull. 
The repository has around 1 million changesets and 2500 heads.


With a difference of 10 changesets between the two repositories and only 2
pulled changeset, `hg pull --rev xxx ../source` went from ~10s on 4.5 to ~40s
with 5cfdf613. (+30 seconds, 4 time slower)

ASV seems to indicate that the performance regression is not dependent on the
number of changesets missing between the two repositories.

-- 
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


D2521: tests: fix run-tests environment cleanup on Python 3

2018-03-01 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGc3df20906689: tests: fix run-tests environment cleanup on 
Python 3 (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2521?vs=6276=6277

REVISION DETAIL
  https://phab.mercurial-scm.org/D2521

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1087,7 +1087,7 @@
 del env[k]
 
 # unset env related to hooks
-for k in env.keys():
+for k in list(env):
 if k.startswith('HG_'):
 del env[k]
 



To: durin42, #hg-reviewers, pulkit
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 2 of 2 V2] revset: skip old style lookup if external whitespace are detected

2018-03-01 Thread Feld Boris

On 26/02/2018 08:11, Yuya Nishihara wrote:

On Mon, 26 Feb 2018 11:45:03 +0100, Feld Boris wrote:

On 13/02/2018 12:47, Yuya Nishihara wrote:

On Mon, 12 Feb 2018 18:00:52 +0100, Boris Feld wrote:

# HG changeset patch
# User Boris Feld 
# Date 1518448909 -3600
#  Mon Feb 12 16:21:49 2018 +0100
# Node ID b0f45e1376e2d0f32023e197c51802bc21c60490
# Parent  f02fd7ca256d044c4a51c3f3fc0ecaf95d23e03d
# EXP-Topic noname
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
b0f45e1376e2
revset: skip old style lookup if external whitespace are detected

Since label cannot contains leading or trailing whitespace we can skip looking
for them. This is useful in repository with slow labels (eg: special type of
tags). Short command running on a specific revision can benefit from such
shortcut.

eg on a repository where loading tags take 0.4s:

1: hg log --template '{node}\n' --rev 'rev(0)'
 0.560 seconds

2: hg log --template '{node}\n' --rev ' rev(0)'
 0.109 seconds

Seems okay, but isn't it too obscure that prefixing with ' ' is the fast
way of querying?

Yes, it is a bit obscure but it's the best solution we came up with
existing code. I sent a new patch that implements the fast path at the
individual name-space level in a way that seems cleaner and more useful.

Another solution is we could force revset evaluation using a `set:` (or
`revset:`) prefix. This way we could have both a clean and explicit way
of implementing the fast path.

That isn't possible because "set:whatever" can be a range between "set"
and whatever. ;)


The proposal here is to define a prefix for which we break backward 
compatibility. If we do so, people with a "" label will have to use:


  "":whatever

to get a similar effect.

Instead, maybe we can make lookup() to not search slow labels assuming these
labeling schemes didn't exist in pre-revset era.

We are afraid it is a bit more complex than that. Because `rev(0)` is a
valid tag and a valid bookmark, we don't think we can ever skip this
lookup call (yes, in our case, both tags and bookmarks are expensive to
load).

If loading plain tags and bookmarks is expensive, yeah, there would be no
fast path of lookup().


Alternatively, we could add
a config knob to switch off the old-style range support.

Having a config knob for this seems weird. We don't expect users to find
it and really understand what the config is about. It would be useful
for large corporate users with centralized config, but they would need
to set the flag on every one of their scripts/servers involving Mercurial.

IMHO, config knob is easier to learn than using the ' ' prefix. I would say
WTF if I taught to use the ' ' to make hg fast. And I think this config can
be switched on by tweakdefaults because lookup() exists only for backward
compatibility. (We might still want to allow dashes in symbols, though.)
Dropping the older lookup methods seems impractical. Right now, `rev(0)` 
is a valid tag. So dropping legacy lookup means all these things will 
have to be heavily quoted: (eg: hg log -r '"version-4(candidate2)"').


(In practice, even `"rev(0)"` is also a valid tag, starting and escaping 
fest).


A longer terms solution would be to support configuring constraints on 
labels. If tags can be configured to only match a specific pattern we 
could skip lookup for data that does not match it very quickly. To be 
fully enforced it probably need to a part of the .hg/requires so it is a 
heavier change. It also needs to be more than just a hook so that the 
lookup logic is aware of it and can fast path it. Such approach work in 
our use-case but is also more specific and requires more 
configuration(work?).
We could use the same approach as the V2 series proposed here: 
https://www.mercurial-scm.org/pipermail/mercurial-devel/2018-February/112087.html


However, we think it still makes sense to have an easy and standard way 
to force something to be evaluated as a revset as it's not possible as 
of today.


Here is a summary of the idea we've discussed so far:

1) Using some kind of prefix, breaking BC for people using the prefix as 
a label:


  `revs:rev(42)` → directly evaluated as `rev(42)`
  `"revs":rev(42)` → force "revs" as a label

2) Adding a special revset for revset evaluation.

  `revset("rev(42)")` → directly evaluated `rev(42)`

3) adding strange special case: (leading space, parents).

  ` rev(42)` → directly evaluated as `rev(42)`
  `(rev(42))` → directly evaluated as `rev(42)`

4) Config flag to disable legacy parsing (force quote for strange labels).

5) Full-featured label patterns enforcement as described earlier in this 
email.




We agree fast-pathing on (3) is a bit too obscure.
We find (4) to be impractical (and likely to break unexpected stuff).

(5) is a good solution but significantly heavier to write and much more 
specific.


So we would be happy if we could agree on a way to go 

D2521: tests: fix run-tests environment cleanup on Python 3

2018-03-01 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2521

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1087,7 +1087,7 @@
 del env[k]
 
 # unset env related to hooks
-for k in env.keys():
+for k in list(env):
 if k.startswith('HG_'):
 del env[k]
 



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 7 V2] revbranchcache: add a public function to update the data

2018-03-01 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1516281665 -3600
#  Thu Jan 18 14:21:05 2018 +0100
# Node ID 9072a7903a7890cc61a6b7d0c7fa95e6d6db5b27
# Parent  4b9e9e3f450c7c8a8717e0a2ed9573a067903ce6
# EXP-Topic wire-rbc
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
9072a7903a78
revbranchcache: add a public function to update the data

We want to exchange more cached data over the wire. To do so, we need a clean
way to update the cache on the receiving ends.

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -454,6 +454,26 @@ class revbranchcache(object):
 self._setcachedata(rev, reponode, branchidx)
 return b, close
 
+def setdata(self, branch, rev, node, close):
+"""add new data information to the cache"""
+if branch in self._namesreverse:
+branchidx = self._namesreverse[branch]
+else:
+branchidx = len(self._names)
+self._names.append(branch)
+self._namesreverse[branch] = branchidx
+if close:
+branchidx |= _rbccloseflag
+self._setcachedata(rev, node, branchidx)
+# If no cache data were readable (non exists, bad permission, etc)
+# the cache was bypassing itself by setting:
+#
+#   self.branchinfo = self._branchinfo
+#
+# Since we now have data in the cache, we need to drop this bypassing.
+if 'branchinfo' in vars(self):
+del self.branchinfo
+
 def _setcachedata(self, rev, node, branchidx):
 """Writes the node's branch data to the in-memory cache data."""
 if rev == nullrev:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 7 of 7 V2] revbranchcache: advertise and use 'rbc' exchange capability

2018-03-01 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1516284622 -3600
#  Thu Jan 18 15:10:22 2018 +0100
# Node ID ae2bd3eea086fab9d55c1a85bab49de2272f4f90
# Parent  2811d9ca31137ca7a9cc7c8a37862cdbff87bbec
# EXP-Topic wire-rbc
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
ae2bd3eea086
revbranchcache: advertise and use 'rbc' exchange capability

The feature is now advertised and use.

Updating the branchmap cache can be very expensive (up to minutes on large
repository) and fetching revision branch data is about 80% of that. Exchanging
the rev branch cache over the wire really help to recover from branch map
invalidation.

(There is a good chance other in flight chance would conflict on
test-http-bad-server.t and other. So here is a small note to help update that
test again: capabilities=19bytes, part-107bytes)

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1492,6 +1492,7 @@ capabilities = {'HG20': (),
 'digests': tuple(sorted(util.DIGESTS.keys())),
 'remote-changegroup': ('http', 'https'),
 'hgtagsfnodes': (),
+'rev-branch-cache': (),
 'phases': ('heads',),
 'stream': ('v2',),
}
diff --git a/tests/common-pattern.py b/tests/common-pattern.py
--- a/tests/common-pattern.py
+++ b/tests/common-pattern.py
@@ -22,6 +22,7 @@ substitutions = [
  br'phases%253Dheads%250A'
  br'pushkey%250A'
  br'remote-changegroup%253Dhttp%252Chttps%250A'
+ br'rev-branch-cache%250A'
  br'stream%253Dv2',
  # (the replacement patterns)
  br'$USUAL_BUNDLE_CAPS$'
@@ -50,6 +51,7 @@ substitutions = [
  br'phases%3Dheads%0A'
  br'pushkey%0A'
  br'remote-changegroup%3Dhttp%2Chttps%0A'
+ br'rev-branch-cache%0A'
  br'stream%3Dv2',
  # (replacement patterns)
  br'$USUAL_BUNDLE2_CAPS$'
@@ -64,7 +66,8 @@ substitutions = [
  br'listkeys%0A'
  br'phases%3Dheads%0A'
  br'pushkey%0A'
- br'remote-changegroup%3Dhttp%2Chttps',
+ br'remote-changegroup%3Dhttp%2Chttps%0A'
+ br'rev-branch-cache',
  # (replacement patterns)
  br'$USUAL_BUNDLE2_CAPS_SERVER$'
  ),
diff --git a/tests/test-acl.t b/tests/test-acl.t
--- a/tests/test-acl.t
+++ b/tests/test-acl.t
@@ -93,14 +93,14 @@ Extension disabled for lack of a hook
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 188 bytes payload
+  bundle2-output-part: "replycaps" 205 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 188
+  bundle2-input-part: total payload size 205
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -156,14 +156,14 @@ Extension disabled for lack of acl.sourc
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 188 bytes payload
+  bundle2-output-part: "replycaps" 205 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 188
+  bundle2-input-part: total payload size 205
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -222,14 +222,14 @@ No [acl.allow]/[acl.deny]
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 188 bytes payload
+  bundle2-output-part: "replycaps" 205 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 188
+  bundle2-input-part: total payload size 205
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: 

[PATCH 6 of 7 V2] revbranchcache: disable the new part for narrow hg bundle

2018-03-01 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1519237601 -3600
#  Wed Feb 21 19:26:41 2018 +0100
# Node ID 2811d9ca31137ca7a9cc7c8a37862cdbff87bbec
# Parent  56f869a852230bdbcff6ae3c366cb0d83f6cf757
# EXP-Topic wire-rbc
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
2811d9ca3113
revbranchcache: disable the new part for narrow hg bundle

The lack of some revisions confuses the new cache part. To simplify things, we
disable it for now.

diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -479,6 +479,19 @@ def setup():
 origcgfn(*args, **kwargs)
 exchange.getbundle2partsmapping['changegroup'] = wrappedcgfn
 
+# disable rev branch cache exchange when serving a narrow bundle
+# (currently incompatible with that part)
+origrbcfn = exchange.getbundle2partsmapping['cache:rev-branch-cache']
+def wrappedcgfn(*args, **kwargs):
+repo = args[1]
+if repo.ui.has_section(_NARROWACL_SECTION):
+return
+elif kwargs.get('narrow', False):
+return
+else:
+origrbcfn(*args, **kwargs)
+exchange.getbundle2partsmapping['cache:rev-branch-cache'] = wrappedcgfn
+
 # Extend changegroup receiver so client can fixup after widen requests.
 origcghandler = bundle2.parthandlermapping['changegroup']
 def wrappedcghandler(op, inpart):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 4 of 7 V2] bundle: include advisory rev branch cache part in bundle2 bundle

2018-03-01 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1519230780 -3600
#  Wed Feb 21 17:33:00 2018 +0100
# Node ID d0012d0077b4cb19cbd32b3f1b1741b3d53edc6f
# Parent  73e85c62e2927df8a905430436ec95686c28afd6
# EXP-Topic wire-rbc
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
d0012d0077b4
bundle: include advisory rev branch cache part in bundle2 bundle

`hg bundle` command producing bundle2 will now include an optional part
containing the revision-branch cache data.

The data sent are mostly nodes so it is quite compact.  The goal of the
rev-branch-cache is to speed up branch map computation, especially when the
branchmap gets invalidated so we send data for all exchanged changesets. In
addition, computing the relevant heads to send in case of partial pulling would
be challenging.

As a reminder, the rev branch cache data significantly speed up branch
computation. Having it around provides a small speedup to pull/clone and much
higher tolerance to branch map cache invalidation that might happens from later
commands.

On the Mercurial repository, computing the visible branchmap from scratch move
from 2.00 seconds to 0.34s (a -83% speedup).

Using this new part, Unbundling the full Mercurial repository moves from 25.736
seconds to 24.030 seconds (around -7% speedup). The bundle size increase is
around 3% (from 22.43 MB to 23.13MB)


On an half a million revision repository with twenty thousand
branches, computing the branchmap moves from 75 seconds to 45 second (-40%) if
the caches is used.

A bundle containing 50 000 changesets in such repository get a 0.5% size
increase from such part for a -3% unbundling time speedup.

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1591,6 +1591,7 @@ def _addpartsfromopts(ui, repo, bundler,
 part.addparam('targetphase', '%d' % phases.secret, mandatory=False)
 
 addparttagsfnodescache(repo, bundler, outgoing)
+addpartrevbranchcache(repo, bundler, outgoing)
 
 if opts.get('obsolescence', False):
 obsmarkers = repo.obsstore.relevantmarkers(outgoing.missing)
diff --git a/tests/test-bundle-phases.t b/tests/test-bundle-phases.t
--- a/tests/test-bundle-phases.t
+++ b/tests/test-bundle-phases.t
@@ -42,6 +42,7 @@ Phases are restored when unbundling
   26805aba1e600a82e93661149f2313866a221a7b
   f585351a92f85104bff7c284233c338b10eb1df7
   9bc730a19041f9ec7cb33c626e811aa233efb18c
+  cache:rev-branch-cache -- {}
   phase-heads -- {}
   26805aba1e600a82e93661149f2313866a221a7b draft
   $ hg strip --no-backup C
@@ -233,6 +234,7 @@ Restore bundle of entire repo
   dc0947a82db884575bb76ea10ac97b08536bfa03
   4e4f9194f9f181c57f62e823e8bdfa46ab9e4ff4
   03ca77807e919db8807c3749086dc36fb478cac0
+  cache:rev-branch-cache -- {}
   phase-heads -- {}
   dc0947a82db884575bb76ea10ac97b08536bfa03 public
   03ca77807e919db8807c3749086dc36fb478cac0 draft
@@ -258,6 +260,7 @@ Restore bundle of entire repo
   changegroup -- {nbchanges: 2, targetphase: 2, version: 02}
   112478962961147124edd43549aedd1a335e44bf
   4e4f9194f9f181c57f62e823e8bdfa46ab9e4ff4
+  cache:rev-branch-cache -- {}
   phase-heads -- {}
   $ rm bundle
 
@@ -269,6 +272,7 @@ Restore bundle of entire repo
   112478962961147124edd43549aedd1a335e44bf
   dc0947a82db884575bb76ea10ac97b08536bfa03
   4e4f9194f9f181c57f62e823e8bdfa46ab9e4ff4
+  cache:rev-branch-cache -- {}
   phase-heads -- {}
   dc0947a82db884575bb76ea10ac97b08536bfa03 public
   $ rm bundle
@@ -280,6 +284,7 @@ Restore bundle of entire repo
   changegroup -- {nbchanges: 2, targetphase: 2, version: 02}
   4e4f9194f9f181c57f62e823e8bdfa46ab9e4ff4
   03ca77807e919db8807c3749086dc36fb478cac0
+  cache:rev-branch-cache -- {}
   phase-heads -- {}
   03ca77807e919db8807c3749086dc36fb478cac0 draft
   $ rm bundle
diff --git a/tests/test-bundle-type.t b/tests/test-bundle-type.t
--- a/tests/test-bundle-type.t
+++ b/tests/test-bundle-type.t
@@ -76,6 +76,7 @@ test bundle types
   Stream params: {}
   changegroup -- {nbchanges: 1, version: 02}
   c35a0f9217e65d1fdb90c936ffa7dbe679f83ddf
+  cache:rev-branch-cache -- {}
   none-v2
   
   % test bundle type bzip2
@@ -85,6 +86,7 @@ test bundle types
   Stream params: {Compression: BZ}
   changegroup -- {nbchanges: 1, version: 02}
   c35a0f9217e65d1fdb90c936ffa7dbe679f83ddf
+  cache:rev-branch-cache -- {}
   bzip2-v2
   
   % test bundle type gzip
@@ -94,6 +96,7 @@ test bundle types
   Stream params: {Compression: GZ}
   changegroup -- {nbchanges: 1, version: 02}
   c35a0f9217e65d1fdb90c936ffa7dbe679f83ddf
+  cache:rev-branch-cache -- {}
   gzip-v2
   
   % test bundle type none-v2
@@ -103,6 +106,7 @@ test bundle types
   Stream params: {}
   changegroup -- {nbchanges: 1, version: 02}
   c35a0f9217e65d1fdb90c936ffa7dbe679f83ddf
+  cache:rev-branch-cache -- {}
 

[PATCH 5 of 7 V2] revbranchcache: add the necessary bit to send 'rbc' data over bundle2

2018-03-01 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1516283882 -3600
#  Thu Jan 18 14:58:02 2018 +0100
# Node ID 56f869a852230bdbcff6ae3c366cb0d83f6cf757
# Parent  d0012d0077b4cb19cbd32b3f1b1741b3d53edc6f
# EXP-Topic wire-rbc
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
56f869a85223
revbranchcache: add the necessary bit to send 'rbc' data over bundle2

Getbundle is now capable of sending rev-branch-cache information for the
changesets it bundle. The data sent are mostly nodes so it is quite compact.
The goal of the rev-branch-cache is to speed up branch map computation,
especially when the branchmap gets invalidated so we send data for all
exchanged changesets. In addition, computing the relevant heads to send in
case of partial pulling would be challenging.

The feature is still inactive since the capability is not advertised yet.

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1931,6 +1931,28 @@ def _getbundletagsfnodes(bundler, repo, 
 outgoing = _computeoutgoing(repo, heads, common)
 bundle2.addparttagsfnodescache(repo, bundler, outgoing)
 
+@getbundle2partsgenerator('cache:rev-branch-cache')
+def _getbundlerevbranchcache(bundler, repo, source, bundlecaps=None,
+ b2caps=None, heads=None, common=None,
+ **kwargs):
+"""Transfer the rev-branch-cache mapping
+
+The payload is a series of data related to each branch
+
+1) branch name length
+2) number of open heads
+3) number of closed heads
+4) open heads nodes
+5) closed heads nodes
+"""
+# Don't send unless:
+# - changeset are being exchanged,
+# - the client supports it.
+if not (kwargs.get(r'cg', True)) or 'rev-branch-cache' not in b2caps:
+return
+outgoing = _computeoutgoing(repo, heads, common)
+bundle2.addpartrevbranchcache(repo, bundler, outgoing)
+
 def check_heads(repo, their_heads, context):
 """check if the heads of a repo have been modified
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2403: stack: remove destutil.stackbase

2018-03-01 Thread lothiraldan (Boris Feld)
lothiraldan added a comment.


  In https://phab.mercurial-scm.org/D2403#39460, @indygreg wrote:
  
  > Oh, I guess the series never did formerly define a revset for stack :/
  >
  > I think there is room for one. We have the ability to mark revsets as 
experimental or internal, right? Could/should we do that so we don't need `hg 
debugstack`?
  >
  > Anyway, I could probably queue this with some minor rework. But I'm going 
to hold off a bit and see if others have opinions.
  
  
  I have updated the series without using debugstack, thank you for the 
suggestion. I thought revset would were much harder to implement but turn out 
not so much harder.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2403

To: lothiraldan, #hg-reviewers
Cc: indygreg, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] fileset: drop bad "elif:" trying to check invalid size expression

2018-03-01 Thread Pulkit Goyal
On Thu, Mar 1, 2018 at 6:23 PM, Pulkit Goyal <7895pul...@gmail.com> wrote:
> Looks good to me.

And queued too. Thanks.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 1 of 8] templatefilters: use encoding.unifromlocal/unitolocal() for py3 compatibility

2018-03-01 Thread Pulkit Goyal
Using my new super powers, I queued the series. Thanks

On Thu, Mar 1, 2018 at 7:47 PM, Yuya Nishihara  wrote:
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1519904317 18000
> #  Thu Mar 01 06:38:37 2018 -0500
> # Node ID 905fd8fbfd54838f8e079719e5ada074d975b824
> # Parent  4b9e9e3f450c7c8a8717e0a2ed9573a067903ce6
> templatefilters: use encoding.unifromlocal/unitolocal() for py3 compatibility
>
> diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py
> --- a/mercurial/templatefilters.py
> +++ b/mercurial/templatefilters.py
> @@ -152,12 +152,12 @@ def fill(text, width, initindent='', han
>  while True:
>  m = para_re.search(text, start)
>  if not m:
> -uctext = unicode(text[start:], encoding.encoding)
> +uctext = encoding.unifromlocal(text[start:])
>  w = len(uctext)
>  while 0 < w and uctext[w - 1].isspace():
>  w -= 1
> -yield (uctext[:w].encode(encoding.encoding),
> -   uctext[w:].encode(encoding.encoding))
> +yield (encoding.unitolocal(uctext[:w]),
> +   encoding.unitolocal(uctext[w:]))
>  break
>  yield text[start:m.start(0)], m.group(1)
>  start = m.end(1)
> ___
> 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] Fix for Bug #5807

2018-03-01 Thread Augie Fackler
On Thu, Mar 01, 2018 at 11:06:59AM +0100, Sascha Nemecek wrote:
> # HG changeset patch
> # User Sascha Nemecek 
> # Date 1519831479 -3600
> #  Wed Feb 28 16:24:39 2018 +0100
> # Node ID 42ddf4ee4f91d76f19ca0c3efc4c8e4c1c6fa96c
> # Parent  1bd132a021dd00f96604e33a8fb5306d37e56007
> Don't close 'fp' (= 'ui.fout') stream to prevent 'ValueError: I/O operation

Queued, thanks. Congrats on your first hg patch!

(In the future please read up on
https://www.mercurial-scm.org/wiki/ContributingChanges - this patch
appears to have gotten damaged in transit, requring some manual fixing
on my end)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 4 of 4 V2] cmdutil: expand filename format string by templater (BC)

2018-03-01 Thread Augie Fackler
On Sun, Feb 18, 2018 at 02:18:02PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1515293587 -32400
> #  Sun Jan 07 11:53:07 2018 +0900
> # Node ID 34976879e67e40c36b69090360fcd72af3274160
> # Parent  045d2ccca9c6979a31f88e4ac0c69728f4b56837
> cmdutil: expand filename format string by templater (BC)

queued, thanks
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] test-acl: mock up util.getuser() to trust $LOGNAME on Windows

2018-03-01 Thread Augie Fackler
On Tue, Feb 27, 2018 at 11:57:25PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1519738677 -32400
> #  Tue Feb 27 22:37:57 2018 +0900
> # Node ID 27a69d7c94488b6a21ce4ddbcdb183ce335714e1
> # Parent  1a1f7b96d833af5a29d6d75580d083511ff388f6
> test-acl: mock up util.getuser() to trust $LOGNAME on Windows

queued, thanks
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2516: py3: use pycompat.bytestr() to convert error instances to bytes

2018-03-01 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG6e90c59b6da1: py3: use pycompat.bytestr() to convert error 
instances to bytes (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2516?vs=6262=6271

REVISION DETAIL
  https://phab.mercurial-scm.org/D2516

AFFECTED FILES
  mercurial/commands.py
  mercurial/debugcommands.py

CHANGE DETAILS

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1591,7 +1591,8 @@
  metadata=metadata, ui=ui)
 tr.close()
 except ValueError as exc:
-raise error.Abort(_('bad obsmarker input: %s') % exc)
+raise error.Abort(_('bad obsmarker input: %s') %
+  pycompat.bytestr(exc))
 finally:
 tr.release()
 finally:
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2370,7 +2370,7 @@
 try:
 regexp = util.re.compile(pattern, reflags)
 except re.error as inst:
-ui.warn(_("grep: invalid match pattern: %s\n") % inst)
+ui.warn(_("grep: invalid match pattern: %s\n") % 
pycompat.bytestr(inst))
 return 1
 sep, eol = ':', '\n'
 if opts.get('print0'):



To: pulkit, #hg-reviewers, durin42
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2518: py3: add b'' prefixes in tests/test-obsolete.t

2018-03-01 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGf1e05fe1a78f: py3: add b prefixes in 
tests/test-obsolete.t (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2518?vs=6264=6273

REVISION DETAIL
  https://phab.mercurial-scm.org/D2518

AFFECTED FILES
  tests/test-obsolete.t

CHANGE DETAILS

diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -18,7 +18,7 @@
   > def reposetup(ui, repo):
   > class debugkeysrepo(repo.__class__):
   > def listkeys(self, namespace):
-  > ui.write('listkeys %s\n' % (namespace,))
+  > ui.write(b'listkeys %s\n' % (namespace,))
   > return super(debugkeysrepo, self).listkeys(namespace)
   > 
   > if repo.local():
@@ -1279,12 +1279,12 @@
   > 
   > cmdtable = {}
   > command = registrar.command(cmdtable)
-  > @command(b"amendtransient",[], _('hg amendtransient [rev]'))
+  > @command(b"amendtransient",[], _(b'hg amendtransient [rev]'))
   > def amend(ui, repo, *pats, **opts):
   >   opts['message'] = 'Test'
   >   opts['logfile'] = None
   >   cmdutil.amend(ui, repo, repo['.'], {}, pats, opts)
-  >   ui.write('%s\n' % repo.changelog.headrevs())
+  >   ui.write(b'%s\n' % repo.changelog.headrevs())
   > EOF
   $ cat >> $HGRCPATH << EOF
   > [extensions]
@@ -1319,7 +1319,7 @@
   >  def trhook(tr):
   >   repo = reporef()
   >   hidden1 = repoview.computehidden(repo)
-  >   hidden = repoview.filterrevs(repo, 'visible')
+  >   hidden = repoview.filterrevs(repo, b'visible')
   >   if sorted(hidden1) != sorted(hidden):
   > print("cache inconsistency")
   >  bkmstoreinst._repo.currenttransaction().addpostclose('test_extension', 
trhook)



To: pulkit, #hg-reviewers, durin42
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2519: py3: make sure we write bytes in a file open in bytes mode

2018-03-01 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGeafd380fe1b8: py3: make sure we write bytes in a file open 
in bytes mode (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2519?vs=6265=6274

REVISION DETAIL
  https://phab.mercurial-scm.org/D2519

AFFECTED FILES
  tests/test-grep.t

CHANGE DETAILS

diff --git a/tests/test-grep.t b/tests/test-grep.t
--- a/tests/test-grep.t
+++ b/tests/test-grep.t
@@ -271,7 +271,7 @@
 
 match in last "line" without newline
 
-  $ $PYTHON -c 'fp = open("noeol", "wb"); fp.write("no infinite loop"); 
fp.close();'
+  $ $PYTHON -c 'fp = open("noeol", "wb"); fp.write(b"no infinite loop"); 
fp.close();'
   $ hg ci -Amnoeol
   adding noeol
   $ hg grep loop



To: pulkit, #hg-reviewers, durin42
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2517: py3: add a b'' prefix in tests/test-fncache.t

2018-03-01 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG5b5cc44b2cdc: py3: add a b prefix in 
tests/test-fncache.t (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2517?vs=6263=6272

REVISION DETAIL
  https://phab.mercurial-scm.org/D2517

AFFECTED FILES
  tests/test-fncache.t

CHANGE DETAILS

diff --git a/tests/test-fncache.t b/tests/test-fncache.t
--- a/tests/test-fncache.t
+++ b/tests/test-fncache.t
@@ -236,7 +236,7 @@
   > wlock.release()
   > 
   > def extsetup(ui):
-  > extensions.wrapcommand(commands.table, "commit", commitwrap)
+  > extensions.wrapcommand(commands.table, b"commit", commitwrap)
   > EOF
   $ extpath=`pwd`/exceptionext.py
   $ hg init fncachetxn



To: pulkit, #hg-reviewers, durin42
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


  1   2   >