Re: [PATCH 6 of 6 remotenames-ext] selectivepull: support list of default bookmarks

2017-02-21 Thread Gregory Szorc
On Mon, Feb 13, 2017 at 1:41 AM, Stanislau Hlebik  wrote:

> Excerpts from Gregory Szorc's message of 2017-02-11 10:54:43 -0800:
> >
> > > On Jan 30, 2017, at 07:56, Stanislau Hlebik  wrote:
> > >
> > > # HG changeset patch
> > > # User Stanislau Hlebik 
> > > # Date 1485791649 28800
> > > #  Mon Jan 30 07:54:09 2017 -0800
> > > # Node ID 227796849698292c76c70e874179de52b7b688d6
> > > # Parent  a96117003c763be640a975d8128068d2bd3527c0
> > > selectivepull: support list of default bookmarks
> > >
> > > The addition is that we now support list of default bookmarks, instead
> of a
> > > single default bookmark (the previous behavior).
> >
> > Cool series!
> >
> > [paths] entries have sub-options to control push behavior, including
> which rev is pushed by default (https://urldefense.
> proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_
> repo_hg_file_a95fc01aaffe_mercurial_help_config.txt-23l1348=DwIFAg=
> 5VD0RTtNlTh3ycd41b3MUw=1EQ58Dmb5uX1qHujcsT1Mg=m80cJkPdWL1VwONVzbgynAt-
> AQewDC6TBiaCt4FE9EE=HPqaL5aBO4IeOlcb_2VjalCA7VhXXAmjqYHNWbaFsBY= ).
> >
> > So if we wanted to implement selective pull in core, the mechanism to
> support defining the config is there...
>
> There is one problem with that. We want to update pullrev whenever we
> pull one more bookmark. For example by default `hg pull` will pull only `@`
> bookmark, but after user does `hg pull -B release-bookmark` next `hg pull`
> will pull `@` and `release-bookmark`. I think there isn't a way to update
> config from inside hg, is there?
>

No. But I saw smf making noise about this a few days ago.


>
> >
> > >
> > > diff --git a/remotenames.py b/remotenames.py
> > > --- a/remotenames.py
> > > +++ b/remotenames.py
> > > @@ -81,14 +81,19 @@
> > > return ui.configbool('remotenames', 'selectivepull', False)
> > >
> > > def _getselectivepulldefaultbookmarks(ui, remotebookmarks):
> > > -default_book = ui.config('remotenames', 'selectivepulldefault')
> > > -if not default_book:
> > > -raise error.Abort(_('no default bookmark specified for
> selectivepull'))
> > > -if default_book in remotebookmarks:
> > > -return {default_book: remotebookmarks[default_book]}
> > > -else:
> > > +default_books = ui.configlist('remotenames',
> 'selectivepulldefault')
> > > +if not default_books:
> > > +raise error.Abort(_('no default bookmarks specified for
> selectivepull'))
> > > +
> > > +result = {}
> > > +for default_book in default_books:
> > > +if default_book in remotebookmarks:
> > > +result[default_book] = remotebookmarks[default_book]
> > > +
> > > +if not default_books:
> > > raise error.Abort(
> > > -_('default bookmark %s is not found on remote') %
> default_book)
> > > +_('default bookmarks %s are not found on remote') %
> default_books)
> > > +return result
> > >
> > > def _trypullremotebookmark(mayberemotebookmark, repo, ui):
> > > ui.warn(_('`%s` not found: assuming it is a remote bookmark '
> > > diff --git a/tests/test-selective-pull.t b/tests/test-selective-pull.t
> > > --- a/tests/test-selective-pull.t
> > > +++ b/tests/test-selective-pull.t
> > > @@ -227,3 +227,14 @@
> > >   $ hg pull -q
> > >   $ hg book --remote
> > >  default/master2:0238718db2b1
> > > +
> > > +Set two bookmarks in selectivepulldefault, make sure both of them
> were pulled
> > > +  $ cat >> .hg/hgrc << EOF
> > > +  > [remotenames]
> > > +  > selectivepulldefault=master,thirdbook
> > > +  > EOF
> > > +  $ rm .hg/selectivepullenabled
> > > +  $ hg pull -q
> > > +  $ hg book --remote
> > > + default/master2:0238718db2b1
> > > + default/thirdbook 0:1449e7934ec1
> > > ___
> > > Mercurial-devel mailing list
> > > Mercurial-devel@mercurial-scm.org
> > > https://urldefense.proofpoint.com/v2/url?u=https-3A__www.
> mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel=DwIFAg=
> 5VD0RTtNlTh3ycd41b3MUw=1EQ58Dmb5uX1qHujcsT1Mg=m80cJkPdWL1VwONVzbgynAt-
> AQewDC6TBiaCt4FE9EE=SwBFnDsS8d4zYF2z3lzuaDpSruRPoom8wzTyogP_JVQ=
>
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: RFC: bitmap storage for precursors and phases

2017-02-21 Thread Jun Wu
Excerpts from Sean Farley's message of 2017-02-21 15:45:44 -0800:
> Augie Fackler  writes:
> 
> > On Fri, Feb 17, 2017 at 07:14:12PM -0800, Jun Wu wrote:
> >> Excerpts from Bryan O'Sullivan's message of 2017-02-17 13:29:58 -0800:
> >> > I think there are multiple topics being discussed:
> >> >
> >> >   1. How to solve the overhead loading hiddenrevs with minimal changes?
> >> >   2. Why is the bitmap format interesting (future use-cases)?
> >> >
> >> For 2,
> >>
> >>   len(filteredrevs) in my hg-committed is 2155. It's small. I tend to think
> >>   about solutions that scale longer and are not too complex to build. That
> >>   may or may not be a good habit.
> >>
> >
> > For what it's worth, my clone of hg has 12716 hidden revisions - about
> > a quarter of the entire repo history is hidden.
> 
> Actually, that's 40%. Mine is a bit over 25%.

I think you have incorrectly excluded hidden revs from repo history:

12716.0 / (len(repo) - len(repo.changelog.filteredrevs) + 12716) = 28.8% # 
correct
12716.0 / (len(repo) - len(repo.changelog.filteredrevs)) = 40.3% # incorrect

Yours should be around 20%:

8000.0 / (len(repo) - len(repo.changelog.filteredrevs) + 8000) = 20.3%
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 1 of 2] chg: refactor ui.system() to be partly overridden

2017-02-21 Thread Jun Wu
The series is a nice refator and looks good to me.

Excerpts from Yuya Nishihara's message of 2017-02-19 02:44:51 +0900:
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1487433610 -32400
> #  Sun Feb 19 01:00:10 2017 +0900
> # Node ID c6dd20729bb3fd2f7745139c27488ce7279f13e1
> # Parent  22722c297b33c2f68a8a34e0b0be0e6a9e0f4759
> chg: refactor ui.system() to be partly overridden
> 
> Since fd598149112b changed the signature of ui.system(), chgui.system()
> should have been updated. This patch factors out the util.system() call
> so that chg can override how a shell command is executed.
> 
> diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
> --- a/mercurial/chgserver.py
> +++ b/mercurial/chgserver.py
> @@ -179,17 +179,16 @@ def _newchgui(srcui, csystem, attachio):
>  else:
>  self._csystem = csystem
>  
> -def system(self, cmd, environ=None, cwd=None, onerr=None,
> -   errprefix=None):
> +def _runsystem(self, cmd, environ, cwd, onerr, errprefix, out):
>  # fallback to the original system method if the output needs to 
> be
>  # captured (to self._buffers), or the output stream is not stdout
>  # (e.g. stderr, cStringIO), because the chg client is not aware 
> of
>  # these situations and will behave differently (write to stdout).
> -if (any(s[1] for s in self._bufferstates)
> +if (out is not self.fout
>  or not util.safehasattr(self.fout, 'fileno')
>  or self.fout.fileno() != util.stdout.fileno()):
> -return super(chgui, self).system(cmd, environ, cwd, onerr,
> - errprefix)
> +return util.system(cmd, environ=environ, cwd=cwd, 
> onerr=onerr,
> +   errprefix=errprefix, out=out)
>  self.flush()
>  rc = self._csystem(cmd, util.shellenviron(environ), cwd)
>  if rc and onerr:
> diff --git a/mercurial/ui.py b/mercurial/ui.py
> --- a/mercurial/ui.py
> +++ b/mercurial/ui.py
> @@ -1253,8 +1253,14 @@ class ui(object):
>  if any(s[1] for s in self._bufferstates):
>  out = self
>  with self.timeblockedsection(blockedtag):
> -return util.system(cmd, environ=environ, cwd=cwd, onerr=onerr,
> -   errprefix=errprefix, out=out)
> +return self._runsystem(cmd, environ=environ, cwd=cwd, 
> onerr=onerr,
> +   errprefix=errprefix, out=out)
> +
> +def _runsystem(self, cmd, environ, cwd, onerr, errprefix, out):
> +"""actually execute the given shell command (can be overridden by
> +extensions like chg)"""
> +return util.system(cmd, environ=environ, cwd=cwd, onerr=onerr,
> +   errprefix=errprefix, out=out)
>  
>  def traceback(self, exc=None, force=False):
>  '''print exception traceback if traceback printing enabled or forced.
> diff --git a/tests/test-chg.t b/tests/test-chg.t
> --- a/tests/test-chg.t
> +++ b/tests/test-chg.t
> @@ -32,6 +32,46 @@ long socket path
>  
>$ cd ..
>  
> +editor
> +--
> +
> +  $ cat >> pushbuffer.py < +  > def reposetup(ui, repo):
> +  > repo.ui.pushbuffer(subproc=True)
> +  > EOF
> +
> +  $ chg init editor
> +  $ cd editor
> +
> +by default, system() should be redirected to the client:
> +
> +  $ touch foo
> +  $ CHGDEBUG= HGEDITOR=cat chg ci -Am channeled --edit 2>&1 \
> +  > | egrep "HG:|run 'cat"
> +  chg: debug: run 'cat "*"' at '$TESTTMP/editor' (glob)
> +  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
> +  HG: Leave message empty to abort commit.
> +  HG: --
> +  HG: user: test
> +  HG: branch 'default'
> +  HG: added foo
> +
> +but no redirection should be made if output is captured:
> +
> +  $ touch bar
> +  $ CHGDEBUG= HGEDITOR=cat chg ci -Am bufferred --edit \
> +  > --config extensions.pushbuffer="$TESTTMP/pushbuffer.py" 2>&1 \
> +  > | egrep "HG:|run 'cat"
> +  [1]
> +
> +check that commit commands succeeded:
> +
> +  $ hg log -T '{rev}:{desc}\n'
> +  1:bufferred
> +  0:channeled
> +
> +  $ cd ..
> +
>  pager
>  -
>  
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH] smartset: preserve istopo for baseset operations

2017-02-21 Thread Jun Wu
# HG changeset patch
# User Jun Wu 
# Date 1487723371 28800
#  Tue Feb 21 16:29:31 2017 -0800
# Node ID 70e221675023dc23b5da10ae0c1d6baffdd6dd93
# Parent  37ab9e20991c1d39014db8297065357fbded0213
# Available At https://bitbucket.org/quark-zju/hg-draft
#  hg pull https://bitbucket.org/quark-zju/hg-draft -r 70e221675023
smartset: preserve istopo for baseset operations

This is a follow-up of "smartset: use native set operations as fast paths".
It's more correct to just preserve the "istopo" information for "&" and "-"
operations, like what filteredset does.

diff --git a/mercurial/smartset.py b/mercurial/smartset.py
--- a/mercurial/smartset.py
+++ b/mercurial/smartset.py
@@ -204,4 +204,12 @@ class baseset(abstractsmartset):
 >>> [type(i).__name__ for i in [xs + ys, xs & ys, xs - ys]]
 ['addset', 'baseset', 'baseset']
+
+istopo is preserved across set operations
+>>> xs = baseset(set(x), istopo=True)
+>>> rs = xs & ys
+>>> type(rs).__name__
+'baseset'
+>>> rs._istopo
+True
 """
 def __init__(self, data=(), datarepr=None, istopo=False):
@@ -327,5 +335,6 @@ class baseset(abstractsmartset):
 if (type(other) is baseset and '_set' in other.__dict__ and '_set' in
 self.__dict__ and self._ascending is not None):
-s = baseset(data=getattr(self._set, op)(other._set))
+s = baseset(data=getattr(self._set, op)(other._set),
+istopo=self._istopo)
 s._ascending = self._ascending
 else:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: Better release notes

2017-02-21 Thread Sean Farley
timeless  writes:

> Sean Farley wrote:
>> I assume that these commit messages were from employees with commit
>> access? If that's true, then that's a bit different than patch-based
>> review where we can edit and review the commit message / notes.
>
> Well, we had two sources:
> 1. Mozilla upstream, where in theory messages were curated, but
> possibly too technical to be useful to our audience
> 2. In house, where people had commit access, and while we could have
> tried to review, practically the pace prevented anything useful -- and
> I was the primary native speaker, my colleagues weren't native
> speakers.
>
> But note: even for Mercurial, getting commit messages to be great is
> hard. At this point I tune in once every couple of weeks and batch
> read, typically long after code has landed.
>
> For Cordova, where I think >50% of committers were native speakers,
> and where we had PRs, and comments, the commit logs weren't good
> enough for Release notes either. So, expecting to rely on commit
> messages as a final truth isn't a great idea.
>
> As a side note: I'm currently running my spelling checker against
> dozens of open source projects, and one of the portions with the
> highest spelling error rate is changelogs/commit messages.

Some good points there. Though, I didn't think we were talking about the
commit message in general but rather with the special note tag:

summary: change foo to bar

Some technical details. More blah werd.

:: notes

  This would be a highly curated message. Almost as if it were a patch
  in its own right.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH v3] hg: allow usage of XDG_CONFIG_HOME and $HOME/.config/hg/hgrc

2017-02-21 Thread Sean Farley
Yuya Nishihara  writes:

> On Tue, 14 Feb 2017 15:53:24 +0100, David Demelier wrote:
>> Le 14/02/2017 à 14:34, Yuya Nishihara a écrit :
>> > On Mon, 13 Feb 2017 09:37:48 -0800, Jun Wu wrote:
>> >> Excerpts from David Demelier's message of 2017-02-13 15:43:45 +0100:
>> >>> Le 10/02/2017 à 10:08, Raffaele Salmaso a écrit :
>>  Hi,
>> 
>>  On Fri, Feb 10, 2017 at 9:19 AM, David Demelier
>>  > wrote:
>> 
>>  I've updated the code so that hg config --edit still create a
>>  ~/.hgrc file first if no file is found.
>> 
>>  Why?
>>  If you support this specs, I expect it does the right thing by default
>>  (or at least ask, if any)
>> 
>>  A lot of things can go wrong even for $HOME/.hgrc, so I don't think it
>>  is a bigger problem creating a directory first
>> 
>> >>>
>> >>> I have no problem with this but I would like to know if everybody agree
>> >>> with that.
>> >>>
>> >>
>> >> I'm +1 on creating the directory and editing XDG_CONFIG_HOME/hg/hgrc if
>> >> ~/.hgrc does not exist.
>> >
>> > -1 for compatibility with old versions. Since old hg won't read 
>> > .config/hg/hgrc,
>> > creating it by default could confuse users.
>> >
>> 
>> So if I understand correctly, that means:
>> 
>> 1. the user installs a recent version of Mercurial
>> 2. the user init a config using hg config --edit
>> 3. the user downgrades Mercurial
>
> Yes. Alternatively,
>
>  3. the user switch to another host sharing HOME

Or in my too frequent case:

3. the user activates a different virtualenv
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] transaction: enable hardlink backups for non-windows systems

2017-02-21 Thread Sean Farley
Augie Fackler  writes:

> On Tue, Feb 14, 2017 at 01:31:02AM -0800, Jeroen Vaelen wrote:
>> # HG changeset patch
>> # User Jeroen Vaelen 
>> # Date 1487064458 28800
>> #  Tue Feb 14 01:27:38 2017 -0800
>> # Node ID c7fb7ac39a12c8683518bb7db7e1a93346e017e0
>> # Parent  a0e3d808690d57d1c9dff840e0b8ee099526397b
>> transaction: enable hardlink backups for non-windows systems
>>
>> 07a92bbd02e5 disabled hardlink backups entirely because they can cause 
>> trouble
>> with CIFS on Windows (see issue 4546). This changeset limits that restriction
>> to Windows systems. Ideally we check for CIFS, because e.g. NTFS does support
>> hardlinks. But this at least gives us cheaper transactional backups for 
>> posix,
>> which is a step forward.
>
> I'm hesitant to take this because as of 10.12 macOS is pushing people
> towards CIFS instead of AFP

Actually, it's since 10.9:

http://appleinsider.com/articles/13/06/11/apple-shifts-from-afp-file-sharing-to-smb2-in-os-x-109-mavericks
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: RFC: bitmap storage for precursors and phases

2017-02-21 Thread Sean Farley
Augie Fackler  writes:

> On Fri, Feb 17, 2017 at 07:14:12PM -0800, Jun Wu wrote:
>> Excerpts from Bryan O'Sullivan's message of 2017-02-17 13:29:58 -0800:
>> > I think there are multiple topics being discussed:
>> >
>> >   1. How to solve the overhead loading hiddenrevs with minimal changes?
>> >   2. Why is the bitmap format interesting (future use-cases)?
>> >
>> For 2,
>>
>>   len(filteredrevs) in my hg-committed is 2155. It's small. I tend to think
>>   about solutions that scale longer and are not too complex to build. That
>>   may or may not be a good habit.
>>
>
> For what it's worth, my clone of hg has 12716 hidden revisions - about
> a quarter of the entire repo history is hidden.

Actually, that's 40%. Mine is a bit over 25%.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: RFC: bitmap storage for precursors and phases

2017-02-21 Thread Sean Farley
Jun Wu  writes:

> Excerpts from Bryan O'Sullivan's message of 2017-02-17 13:29:58 -0800:
>> On Fri, Feb 17, 2017 at 10:30 AM, Jun Wu  wrote:
>> 
>> > Excerpts from Stanislau Hlebik's message of 2017-02-17 11:24:34 +:
>> > > As I said before we will load all non-public revs in one set and all
>> >
>> > The problem is, loading a Python set from disk is O(size-of-the-set).
>> >
>> > Bitmap's loading cost should be basically 0 (with mmap). I think that's why
>> > we want bitmap at the first place. There are other choices like packfile
>> > index, hash tables, but bitmap is the simplest and most efficient.
>> >
>> 
>> Hey folks,
>> 
>> I haven't yet seen mention of some considerations that seem very important
>> in driving the decision-making, so I'd appreciate it if someone could fill
>> me in.
>> 
>> Firstly, what's our current understanding of the sizes and compositions of
>> these sets of numbers? In theory, we have a lot of data from practical
>> application at Facebook, but nobody's brought it up.
>> 
>> To clarify why this matters, if an obsstore contains say 100 entries, then
>> a very naive implementation should be fine. If it's related to something
>> else, such as the size of, amount of activity in, or local age of a repo,
>> then maybe we have a different set of decisions to make.
>
> First, I agree that if N is small, O(N) or O(log(N)), or O(1), do not matter
> much in practice. I tend to always reason about future-proof solutions,
> which may or may not be a good habit - I'll adjust in the future.
>
> I think there are multiple topics being discussed:
>
>   1. How to solve the overhead loading hiddenrevs with minimal changes?
>   2. Why is the bitmap format interesting (future use-cases)?
>
> For 1,
>
>   I once tried to make one bit of revlog flag as the source of truth of
>   "hidden", which looks a nice solution. But it got rejected because revlog
>   has to be append-only. Moving the flag bits out formed the bitmap idea
>   naturally.
>
>   Bitmap fits here but it does not mean we have to use it to solve this
>   particular problem. For example, stateful chg will get us some easy wins,
>   and see the problem analysis and proposed solution below.
>
>   Note that we actually have a simple caching format for the "hiddenrevs".
>   See repoview.py, computehidden.
>
>   But what's wrong with "computehidden" is the choice of the cache key - it
>   calls "hideablerevs", which takes 0.5 seconds in obsolete.getrevs(repo,
>   'obsolete'), which reads the giant obsstore (in hg-committed) and do some
>   complex computation. The result is then hashed and used as a cache key of
>   "computehidden".
>
>   So, if we do not want to know the "obsolete()" revisions, but just want to
>   know what's hidden. Changing the cache key would be a very straightforward
>   and effective solution which does not require a new file format.
>
>   That'll help commands like "hg st", "hg log -T foo", etc. But it won't
>   help complex "log"s which do require the "obsolete()" revisions. To speed
>   up the latter, we can probably just copy the caching infrastructure from
>   repoview.py.
>
> For 2,
>
>   len(filteredrevs) in my hg-committed is 2155. It's small. I tend to think

Another data point for my hg-committed:

len(filteredrevs) > 8k

len(obs markers) > 120k
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 6] color: move 'win32' declaration to the core module

2017-02-21 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1482372679 -3600
#  Thu Dec 22 03:11:19 2016 +0100
# Node ID 60a489f0531abbafc7f53a3dd4bad50f13b38015
# Parent  e5363cb96233861fc99f7e9b85d7884d3121558c
# EXP-Topic color
color: move 'win32' declaration to the core module

This is another part of moving color implementation into core. before we can
move the advance logic, we need to move the basic definition and building
bricks. This is one more step on that road.

diff -r e5363cb96233 -r 60a489f0531a hgext/color.py
--- a/hgext/color.pyThu Dec 22 02:38:53 2016 +0100
+++ b/hgext/color.pyThu Dec 22 03:11:19 2016 +0100
@@ -263,7 +263,7 @@ def _modesetup(ui, coloropt):
 # gibberish, we error on the side of selecting "win32". However, if
 # w32effects is not defined, we almost certainly don't support
 # "win32", so don't even try.
-if (term and 'xterm' in term) or not w32effects:
+if (term and 'xterm' in term) or not color.w32effects:
 realmode = 'ansi'
 else:
 realmode = 'win32'
@@ -278,10 +278,10 @@ def _modesetup(ui, coloropt):
 
 if realmode == 'win32':
 color._terminfo_params.clear()
-if not w32effects:
+if not color.w32effects:
 modewarn()
 return None
-color._effects.update(w32effects)
+color._effects.update(color.w32effects)
 elif realmode == 'ansi':
 color._terminfo_params.clear()
 elif realmode == 'terminfo':
@@ -311,7 +311,7 @@ class colorui(uimod.ui):
 self._buffers[-1].extend(args)
 elif self._colormode == 'win32':
 for a in args:
-win32print(a, super(colorui, self).write, **opts)
+color.win32print(a, super(colorui, self).write, **opts)
 else:
 return super(colorui, self).write(
 *[self.label(a, label) for a in args], **opts)
@@ -325,7 +325,7 @@ class colorui(uimod.ui):
 return self.write(*args, **opts)
 if self._colormode == 'win32':
 for a in args:
-win32print(a, super(colorui, self).write_err, **opts)
+color.win32print(a, super(colorui, self).write_err, **opts)
 else:
 return super(colorui, self).write_err(
 *[self.label(a, label) for a in args], **opts)
@@ -432,138 +432,3 @@ def _debugdisplaystyle(ui):
 ui.write(' ' * (max(0, width - len(label
 ui.write(', '.join(ui.label(e, e) for e in effects.split()))
 ui.write('\n')
-
-if pycompat.osname != 'nt':
-w32effects = None
-else:
-import ctypes
-import re
-
-_kernel32 = ctypes.windll.kernel32
-
-_WORD = ctypes.c_ushort
-
-_INVALID_HANDLE_VALUE = -1
-
-class _COORD(ctypes.Structure):
-_fields_ = [('X', ctypes.c_short),
-('Y', ctypes.c_short)]
-
-class _SMALL_RECT(ctypes.Structure):
-_fields_ = [('Left', ctypes.c_short),
-('Top', ctypes.c_short),
-('Right', ctypes.c_short),
-('Bottom', ctypes.c_short)]
-
-class _CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure):
-_fields_ = [('dwSize', _COORD),
-('dwCursorPosition', _COORD),
-('wAttributes', _WORD),
-('srWindow', _SMALL_RECT),
-('dwMaximumWindowSize', _COORD)]
-
-_STD_OUTPUT_HANDLE = 0xfff5 # (DWORD)-11
-_STD_ERROR_HANDLE = 0xfff4  # (DWORD)-12
-
-_FOREGROUND_BLUE = 0x0001
-_FOREGROUND_GREEN = 0x0002
-_FOREGROUND_RED = 0x0004
-_FOREGROUND_INTENSITY = 0x0008
-
-_BACKGROUND_BLUE = 0x0010
-_BACKGROUND_GREEN = 0x0020
-_BACKGROUND_RED = 0x0040
-_BACKGROUND_INTENSITY = 0x0080
-
-_COMMON_LVB_REVERSE_VIDEO = 0x4000
-_COMMON_LVB_UNDERSCORE = 0x8000
-
-# http://msdn.microsoft.com/en-us/library/ms682088%28VS.85%29.aspx
-w32effects = {
-'none': -1,
-'black': 0,
-'red': _FOREGROUND_RED,
-'green': _FOREGROUND_GREEN,
-'yellow': _FOREGROUND_RED | _FOREGROUND_GREEN,
-'blue': _FOREGROUND_BLUE,
-'magenta': _FOREGROUND_BLUE | _FOREGROUND_RED,
-'cyan': _FOREGROUND_BLUE | _FOREGROUND_GREEN,
-'white': _FOREGROUND_RED | _FOREGROUND_GREEN | _FOREGROUND_BLUE,
-'bold': _FOREGROUND_INTENSITY,
-'black_background': 0x100,  # unused value > 0x0f
-'red_background': _BACKGROUND_RED,
-'green_background': _BACKGROUND_GREEN,
-'yellow_background': _BACKGROUND_RED | _BACKGROUND_GREEN,
-'blue_background': _BACKGROUND_BLUE,
-'purple_background': _BACKGROUND_BLUE | _BACKGROUND_RED,
-'cyan_background': _BACKGROUND_BLUE | _BACKGROUND_GREEN,
-'white_background': (_BACKGROUND_RED | _BACKGROUND_GREEN |
- 

[PATCH 6 of 6] color: set initial default value for 'colormode' to None

2017-02-21 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1482383925 -3600
#  Thu Dec 22 06:18:45 2016 +0100
# Node ID 87e88ffa32cd60d1f380ebe5259562a162fa94a8
# Parent  2278337558dfe55dc11db33654bff351c9a8ee2e
# EXP-Topic color
color: set initial default value for 'colormode' to None

This should not introduce any behavior changes when using the color extension.
In practive, the colormode will be setup at early at run time to the proper
value (from config and environment).

We do this change as this gets us closer of a state were we can have all the
mechanisms associated to color in core with the feature disabled by default.

diff -r 2278337558df -r 87e88ffa32cd hgext/color.py
--- a/hgext/color.pyThu Dec 22 13:19:12 2016 +0100
+++ b/hgext/color.pyThu Dec 22 06:18:45 2016 +0100
@@ -297,7 +297,7 @@ def _modesetup(ui, coloropt):
 return None
 
 class colorui(uimod.ui):
-_colormode = 'ansi'
+_colormode = None
 def write(self, *args, **opts):
 if self._colormode is None:
 return super(colorui, self).write(*args, **opts)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 4 of 6] color: merge two identical 'for' loops

2017-02-21 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1487238747 -3600
#  Thu Feb 16 10:52:27 2017 +0100
# Node ID 1f69891d7e7abe1f3707c5f184498eadcd42dc6f
# Parent  7d0d86f63673633f2223f60a13d359a243cbb946
# EXP-Topic color
color: merge two identical 'for' loops

The previous changeset made it clear that we are iterating twice on the same
items. We gather the two loops into a single one.

diff -r 7d0d86f63673 -r 1f69891d7e7a hgext/color.py
--- a/hgext/color.pyThu Dec 22 13:06:53 2016 +0100
+++ b/hgext/color.pyThu Feb 16 10:52:27 2017 +0100
@@ -206,9 +206,7 @@ def _terminfosetup(ui, mode):
 if key.startswith('color.'):
 newval = (False, int(val), '')
 color._terminfo_params[key[6:]] = newval
-
-for key, val in ui.configitems('color'):
-if key.startswith('terminfo.'):
+elif key.startswith('terminfo.'):
 newval = (True, '', val.replace('\\E', '\x1b'))
 color._terminfo_params[key[9:]] = newval
 try:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 6] color: make a test for curse availability explicite

2017-02-21 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1482383860 -3600
#  Thu Dec 22 06:17:40 2016 +0100
# Node ID 75a71d27817d72d9516be85134306a8e4b1c5f96
# Parent  60a489f0531abbafc7f53a3dd4bad50f13b38015
# EXP-Topic color
color: make a test for curse availability explicite

We won't use terminfo when curse failed to load. Before this change, we were
doing an indirect test, relying on the fact some variable ('_terminfo_params')
would be empty if curses failed to load. We update the code to be more explicit
and directly checks if we managed to load the curse module.

diff -r 60a489f0531a -r 75a71d27817d hgext/color.py
--- a/hgext/color.pyThu Dec 22 03:11:19 2016 +0100
+++ b/hgext/color.pyThu Dec 22 06:17:40 2016 +0100
@@ -196,7 +196,7 @@ def _terminfosetup(ui, mode):
 '''Initialize terminfo data and the terminal if we're in terminfo mode.'''
 
 # If we failed to load curses, we go ahead and return.
-if not color._terminfo_params:
+if curses is None:
 return
 # Otherwise, see what the config file says.
 if mode not in ('auto', 'terminfo'):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 6] color: minor simplification of some terminfo setup code

2017-02-21 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1482408413 -3600
#  Thu Dec 22 13:06:53 2016 +0100
# Node ID 7d0d86f63673633f2223f60a13d359a243cbb946
# Parent  75a71d27817d72d9516be85134306a8e4b1c5f96
# EXP-Topic color
color: minor simplification of some terminfo setup code

No logic change is introduced. The previous code were using a 'dict.update' with
a complex generator. That was a bit confusing to read and not so compact.
Instead we now use an explicit loop and conditional for the sake of clarity.

This also allow for more simplification coming in the next changeset.

diff -r 75a71d27817d -r 7d0d86f63673 hgext/color.py
--- a/hgext/color.pyThu Dec 22 06:17:40 2016 +0100
+++ b/hgext/color.pyThu Dec 22 13:06:53 2016 +0100
@@ -202,14 +202,15 @@ def _terminfosetup(ui, mode):
 if mode not in ('auto', 'terminfo'):
 return
 
-color._terminfo_params.update((key[6:], (False, int(val), ''))
-for key, val in ui.configitems('color')
-if key.startswith('color.'))
-color._terminfo_params.update((key[9:],
-   (True, '', val.replace('\\E', '\x1b')))
-for key, val in ui.configitems('color')
-if key.startswith('terminfo.'))
+for key, val in ui.configitems('color'):
+if key.startswith('color.'):
+newval = (False, int(val), '')
+color._terminfo_params[key[6:]] = newval
 
+for key, val in ui.configitems('color'):
+if key.startswith('terminfo.'):
+newval = (True, '', val.replace('\\E', '\x1b'))
+color._terminfo_params[key[9:]] = newval
 try:
 curses.setupterm()
 except curses.error as e:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 5 of 6] color: minor reversal of two conditional clause for clarity

2017-02-21 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1482409152 -3600
#  Thu Dec 22 13:19:12 2016 +0100
# Node ID 2278337558dfe55dc11db33654bff351c9a8ee2e
# Parent  1f69891d7e7abe1f3707c5f184498eadcd42dc6f
# EXP-Topic color
color: minor reversal of two conditional clause for clarity

Another minor cleanup while reading the code. The two branches of the 
conditional
have similar complexity so we go for the order that give us the simplest
condition (we drop the negation).

diff -r 1f69891d7e7a -r 2278337558df mercurial/color.py
--- a/mercurial/color.pyThu Feb 16 10:52:27 2017 +0100
+++ b/mercurial/color.pyThu Dec 22 13:19:12 2016 +0100
@@ -165,14 +165,14 @@ def _render_effects(text, effects):
 'Wrap text in commands to turn on each effect.'
 if not text:
 return text
-if not _terminfo_params:
+if _terminfo_params:
+start = ''.join(_effect_str(effect)
+for effect in ['none'] + effects.split())
+stop = _effect_str('none')
+else:
 start = [str(_effects[e]) for e in ['none'] + effects.split()]
 start = '\033[' + ';'.join(start) + 'm'
 stop = '\033[' + str(_effects['none']) + 'm'
-else:
-start = ''.join(_effect_str(effect)
-for effect in ['none'] + effects.split())
-stop = _effect_str('none')
 return ''.join([start, text, stop])
 
 w32effects = None
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 1 of 4 V4] update: accept --merge to allow merging across topo branches (issue5125)

2017-02-21 Thread Jun Wu
I like the behavior change (didn't check the implementation details
carefully).

Could you also update the table in the docstring of merge.update? I think
that's very helpful to explain the behavior cleanly. Thanks!

Excerpts from Martin von Zweigbergk's message of 2017-02-16 08:59:12 -0800:
> # HG changeset patch
> # User Martin von Zweigbergk 
> # Date 1487019517 28800
> #  Mon Feb 13 12:58:37 2017 -0800
> # Node ID 19f471c814809099b5452b1174a2ecb0699cb76a
> # Parent  1ee685defe80117cf6aafea1ede6c33c478abceb
> update: accept --merge to allow merging across topo branches (issue5125)
> 
> diff -r 1ee685defe80 -r 19f471c81480 mercurial/commands.py
> --- a/mercurial/commands.pyWed Feb 15 16:29:58 2017 -0800
> +++ b/mercurial/commands.pyMon Feb 13 12:58:37 2017 -0800
> @@ -5286,12 +5286,13 @@
>  @command('^update|up|checkout|co',
>  [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
>  ('c', 'check', None, _('require clean working directory')),
> +('m', 'merge', None, _('merge local changes')),
>  ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
>  ('r', 'rev', '', _('revision'), _('REV'))
>   ] + mergetoolopts,
> -_('[-C|-c] [-d DATE] [[-r] REV]'))
> +_('[-C|-c|-m] [-d DATE] [[-r] REV]'))
>  def update(ui, repo, node=None, rev=None, clean=False, date=None, 
> check=False,
> -   tool=None):
> +   merge=None, tool=None):
>  """update working directory (or switch revisions)
>  
>  Update the repository's working directory to the specified
> @@ -5310,8 +5311,8 @@
>  
>  .. container:: verbose
>  
> -  The -C/--clean and -c/--check options control what happens if the
> -  working directory contains uncommitted changes.
> +  The -C/--clean, -c/--check, and -m/--merge options control what
> +  happens if the working directory contains uncommitted changes.
>At most of one of them can be specified.
>  
>1. If no option is specified, and if
> @@ -5323,10 +5324,14 @@
>   branch), the update is aborted and the uncommitted changes
>   are preserved.
>  
> -  2. With the -c/--check option, the update is aborted and the
> +  2. With the -m/--merge option, the update is allowed even if the
> + requested changeset is not an ancestor or descendant of
> + the working directory's parent.
> +
> +  3. With the -c/--check option, the update is aborted and the
>   uncommitted changes are preserved.
>  
> -  3. With the -C/--clean option, uncommitted changes are discarded and
> +  4. With the -C/--clean option, uncommitted changes are discarded and
>   the working directory is updated to the requested changeset.
>  
>  To cancel an uncommitted merge (and lose your changes), use
> @@ -5351,8 +5356,15 @@
>  if date and rev is not None:
>  raise error.Abort(_("you can't specify a revision and a date"))
>  
> -if check and clean:
> -raise error.Abort(_("cannot specify both -c/--check and -C/--clean"))
> +if len([x for x in (clean, check, merge) if x]) > 1:
> +raise error.Abort(_("can only specify one of -C/--clean, -c/--check, 
> "
> +"or -m/merge"))
> +
> +updatecheck = None
> +if check:
> +updatecheck = 'abort'
> +elif merge:
> +updatecheck = 'none'
>  
>  with repo.wlock():
>  cmdutil.clearunfinished(repo)
> @@ -5366,7 +5378,8 @@
>  
>  repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
>  
> -return hg.updatetotally(ui, repo, rev, brev, clean=clean, 
> check=check)
> +return hg.updatetotally(ui, repo, rev, brev, clean=clean,
> +updatecheck=updatecheck)
>  
>  @command('verify', [])
>  def verify(ui, repo):
> diff -r 1ee685defe80 -r 19f471c81480 mercurial/hg.py
> --- a/mercurial/hg.pyWed Feb 15 16:29:58 2017 -0800
> +++ b/mercurial/hg.pyMon Feb 13 12:58:37 2017 -0800
> @@ -681,18 +681,19 @@
>  repo.ui.status(_("%d files updated, %d files merged, "
>   "%d files removed, %d files unresolved\n") % stats)
>  
> -def updaterepo(repo, node, overwrite):
> +def updaterepo(repo, node, overwrite, updatecheck=None):
>  """Update the working directory to node.
>  
>  When overwrite is set, changes are clobbered, merged else
>  
>  returns stats (see pydoc mercurial.merge.applyupdates)"""
>  return mergemod.update(repo, node, False, overwrite,
> -   labels=['working copy', 'destination'])
> +   labels=['working copy', 'destination'],
> +   updatecheck=updatecheck)
>  
> -def update(repo, node, quietempty=False):
> -"""update the working directory to node, merging linear changes"""
> -stats = updaterepo(repo, node, False)
> +def update(repo, node, quietempty=False, updatecheck=None):
> +"""update the working directory to 

Re: [PATCH 3 of 4 V3] update: also suggest --merge when non-linear update is aborted

2017-02-21 Thread Jun Wu
Excerpts from Augie Fackler's message of 2017-02-21 11:08:05 -0500:
> > "hg update --abort"?
> 
> I'd be a big fan of having an update --abort that just takes you back to
> where you were before the conflicts. To date, nobody has been motivated
> enough to do the work (I'd love to do it, but it's unlikely to be near the
> top of my stack for months/years).

I think that could be hard if the user do touch some files being updated -
it seems to me like a "recursive" update/merge situation, that requires
comprehensive transaction support which works for non-append-only files (and
maybe directories).

My intuition is that it's impossible to implement such fancy transaction
cleanly with the POSIX APIs, unless we control the filesystem (like fuse
etc). So I'd prefer simple and straightfoward solutions. "update --clean" to
go back looks good enough to me.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] histedit: improve documentation and behaviour of dates (issue4820)

2017-02-21 Thread Ben Schmidt

On 22/02/2017 8:25 am, Augie Fackler wrote:

Having thought about this more over the balance of my weekend, it
makes sense that this is consistent with 'hg amend' from evolve, and
it feels right enough. Since it wasn't previously documented we'll go
ahead and do this, and if anyone complains we can revert it between
now and 4.2 being final.


I agree entirely!


I'll push both patches with the commit message adjustments you pointed
out upthread. Many thanks!


Thank you greatly, also.

Ben



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


Re: [PATCH] histedit: improve documentation and behaviour of dates (issue4820)

2017-02-21 Thread Augie Fackler
On Mon, Feb 20, 2017 at 12:17 AM, Ben Schmidt
 wrote:
> I recognise there are probably use cases for the current 'roll'
> behaviour as well. What I'm primarily interested in is solving the
> problems raised in the bug, so if we can do that another way, such as
> adding a new action, that will satisfy me just fine.

Having thought about this more over the balance of my weekend, it
makes sense that this is consistent with 'hg amend' from evolve, and
it feels right enough. Since it wasn't previously documented we'll go
ahead and do this, and if anyone complains we can revert it between
now and 4.2 being final.

I'll push both patches with the commit message adjustments you pointed
out upthread. Many thanks!
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 2 pager-endgame] pager: add a config knob to just globally turn off the pager

2017-02-21 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1486505605 18000
#  Tue Feb 07 17:13:25 2017 -0500
# Node ID 390e26db66994cc2f627933815db02353958289f
# Parent  589dcabe2b7a2b9f2d49646d710335e5a70ad492
pager: add a config knob to just globally turn off the pager

diff --git a/mercurial/help/pager.txt b/mercurial/help/pager.txt
--- a/mercurial/help/pager.txt
+++ b/mercurial/help/pager.txt
@@ -26,3 +26,10 @@ you can use --pager=::
   - require the pager: `yes` or `on`.
   - suppress the pager: `no` or `off` (any unrecognized value
   will also work).
+
+To globally turn off all attempts to use a pager, set::
+
+  [pager]
+  enable = false
+
+which will prevent the pager from running.
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -857,6 +857,7 @@ class ui(object):
 if (self._disablepager
 or self.pageractive
 or command in self.configlist('pager', 'ignore')
+or not self.configbool('pager', 'enable', True)
 or not self.configbool('pager', 'attend-' + command, True)
 # TODO: if we want to allow HGPLAINEXCEPT=pager,
 # formatted() will need some adjustment.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 2 pager-endgame] pager: move most help to a new help topic and deprecate extension

2017-02-21 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1486444073 18000
#  Tue Feb 07 00:07:53 2017 -0500
# Node ID 589dcabe2b7a2b9f2d49646d710335e5a70ad492
# Parent  59e69ed81776f0186cb6e6c69f8d7659afab26b7
pager: move most help to a new help topic and deprecate extension

diff --git a/hgext/pager.py b/hgext/pager.py
--- a/hgext/pager.py
+++ b/hgext/pager.py
@@ -12,51 +12,14 @@
 #
 # Run 'hg help pager' to get info on configuration.
 
-'''browse command output with an external pager
-
-To set the pager that should be used, set the application variable::
-
-  [pager]
-  pager = less -FRX
-
-If no pager is set, the pager extensions uses the environment variable
-$PAGER. If neither pager.pager, nor $PAGER is set, no pager is used.
-
-You can disable the pager for certain commands by adding them to the
-pager.ignore list::
+'''browse command output with an external pager (DEPRECATED)
 
-  [pager]
-  ignore = version, help, update
-
-You can also enable the pager only for certain commands using
-pager.attend. Below is the default list of commands to be paged::
-
-  [pager]
-  attend = annotate, cat, diff, export, glog, log, qdiff
-
-Setting pager.attend to an empty value will cause all commands to be
-paged.
-
-If pager.attend is present, pager.ignore will be ignored.
-
-Lastly, you can enable and disable paging for individual commands with
-the attend- option. This setting takes precedence over
-existing attend and ignore options and defaults::
+Forcibly enable paging for individual commands that don't typically
+request pagination with the attend- option. This setting
+takes precedence over ignore options and defaults::
 
   [pager]
   attend-cat = false
-
-To ignore global commands like :hg:`version` or :hg:`help`, you have
-to specify them in your user configuration file.
-
-To control whether the pager is used at all for an individual command,
-you can use --pager=::
-
-  - use as needed: `auto`.
-  - require the pager: `yes` or `on`.
-  - suppress the pager: `no` or `off` (any unrecognized value
-  will also work).
-
 '''
 from __future__ import absolute_import
 
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -230,6 +230,7 @@ helptable = sorted([
  loaddoc('scripting')),
 (['internals'], _("Technical implementation topics"),
  internalshelp),
+(['pager'], _("Pager Support"), loaddoc('pager')),
 ])
 
 # Maps topics with sub-topics to a list of their sub-topics.
diff --git a/mercurial/help/pager.txt b/mercurial/help/pager.txt
new file mode 100644
--- /dev/null
+++ b/mercurial/help/pager.txt
@@ -0,0 +1,28 @@
+Some Mercurial commands produce a lot of output, and Mercurial will
+attempt to use a pager to make those commands more pleasant.
+
+To set the pager that should be used, set the application variable::
+
+  [pager]
+  pager = less -FRX
+
+If no pager is set, the pager extensions uses the environment variable
+$PAGER. If neither pager.pager, nor $PAGER is set, a default pager
+will be used, typically `more`.
+
+You can disable the pager for certain commands by adding them to the
+pager.ignore list::
+
+  [pager]
+  ignore = version, help, update
+
+To ignore global commands like :hg:`version` or :hg:`help`, you have
+to specify them in your user configuration file.
+
+To control whether the pager is used at all for an individual command,
+you can use --pager=::
+
+  - use as needed: `auto`.
+  - require the pager: `yes` or `on`.
+  - suppress the pager: `no` or `off` (any unrecognized value
+  will also work).
diff --git a/tests/test-globalopts.t b/tests/test-globalopts.t
--- a/tests/test-globalopts.t
+++ b/tests/test-globalopts.t
@@ -351,6 +351,7 @@ Testing -h/--help:
hgweb Configuring hgweb
internals Technical implementation topics
merge-tools   Merge Tools
+   pager Pager Support
patterns  File Name Patterns
phasesWorking with Phases
revisions Specifying Revisions
@@ -432,6 +433,7 @@ Testing -h/--help:
hgweb Configuring hgweb
internals Technical implementation topics
merge-tools   Merge Tools
+   pager Pager Support
patterns  File Name Patterns
phasesWorking with Phases
revisions Specifying Revisions
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -113,6 +113,7 @@ Short help:
hgweb Configuring hgweb
internals Technical implementation topics
merge-tools   Merge Tools
+   pager Pager Support
patterns  File Name Patterns
phasesWorking with Phases
revisions Specifying Revisions
@@ -188,6 +189,7 @@ Short help:
hgweb Configuring hgweb
internals Technical implementation topics
merge-tools   Merge Tools
+   pager Pager Support
patterns  File Name Patterns
phasesWorking with Phases
revisions Specifying Revisions
@@ -262,7 +264,6 @@ 

[PATCH 2 of 2 pager-dispatch-tweaks] dispatch: rearrange 'unknown command' code to better employ pager

2017-02-21 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1487704805 18000
#  Tue Feb 21 14:20:05 2017 -0500
# Node ID 52083816be40edfac2e3e052ebe4d828c6c4a1c6
# Parent  f489d1ec2070f25a09f571177b97d8284b3b1932
dispatch: rearrange 'unknown command' code to better employ pager

dispatch calls help like a ninja if you give it a truly unknown
command, and that might want to be paged. If it gets paged, then the
'hg: unknown command' text gets eaten by a grue, unless we call the
pager first. This change rearranges the codepaths so we can safely
only invoke the pager in the case where we'll have long output from
the help command code, rather than just a short message like "did you
mean stat instead of start" or "fetch is provided by the fetch
extension".

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -33,6 +33,7 @@ from . import (
 extensions,
 fancyopts,
 fileset,
+help,
 hg,
 hook,
 profiling,
@@ -242,19 +243,24 @@ def callcatch(ui, func):
 _formatparse(ui.warn, inst)
 return -1
 except error.UnknownCommand as inst:
-ui.warn(_("hg: unknown command '%s'\n") % inst.args[0])
+nocmdmsg = _("hg: unknown command '%s'\n") % inst.args[0]
 try:
 # check if the command is in a disabled extension
 # (but don't check for extensions themselves)
-commands.help_(ui, inst.args[0], unknowncmd=True)
+formatted = help.formattedhelp(ui, inst.args[0], unknowncmd=True)
+ui.warn(nocmdmsg)
+ui.write(formatted)
 except (error.UnknownCommand, error.Abort):
 suggested = False
 if len(inst.args) == 2:
 sim = _getsimilar(inst.args[1], inst.args[0])
 if sim:
+ui.warn(nocmdmsg)
 _reportsimilar(ui.warn, sim)
 suggested = True
 if not suggested:
+ui.pager('help')
+ui.warn(nocmdmsg)
 commands.help_(ui, 'shortlist')
 except IOError:
 raise
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 2 pager-dispatch-tweaks] help: move rst formatting of help documents into help.py

2017-02-21 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1487704651 18000
#  Tue Feb 21 14:17:31 2017 -0500
# Node ID f489d1ec2070f25a09f571177b97d8284b3b1932
# Parent  59e69ed81776f0186cb6e6c69f8d7659afab26b7
help: move rst formatting of help documents into help.py

This slight refactor will help me improve the 'unknown command'
experience in our new glorious pager future.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -39,7 +39,6 @@ from . import (
 hg,
 lock as lockmod,
 merge as mergemod,
-minirst,
 obsolete,
 patch,
 phases,
@@ -2721,10 +2720,6 @@ def help_(ui, name=None, **opts):
 
 Returns 0 if successful.
 """
-textwidth = ui.configint('ui', 'textwidth', 78)
-termwidth = ui.termwidth() - 2
-if textwidth <= 0 or termwidth < textwidth:
-textwidth = termwidth
 
 keep = opts.get('system') or []
 if len(keep) == 0:
@@ -2740,37 +2735,7 @@ def help_(ui, name=None, **opts):
 if ui.verbose:
 keep.append('verbose')
 
-fullname = name
-section = None
-subtopic = None
-if name and '.' in name:
-name, remaining = name.split('.', 1)
-remaining = encoding.lower(remaining)
-if '.' in remaining:
-subtopic, section = remaining.split('.', 1)
-else:
-if name in help.subtopics:
-subtopic = remaining
-else:
-section = remaining
-
-text = help.help_(ui, name, subtopic=subtopic, **opts)
-
-formatted, pruned = minirst.format(text, textwidth, keep=keep,
-   section=section)
-
-# We could have been given a weird ".foo" section without a name
-# to look for, or we could have simply failed to found "foo.bar"
-# because bar isn't a section of foo
-if section and not (formatted and name):
-raise error.Abort(_("help section not found: %s") % fullname)
-
-if 'verbose' in pruned:
-keep.append('omitted')
-else:
-keep.append('notomitted')
-formatted, pruned = minirst.format(text, textwidth, keep=keep,
-   section=section)
+formatted = help.formattedhelp(ui, name, keep=keep, **opts)
 ui.pager('help')
 ui.write(formatted)
 
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -605,3 +605,47 @@ def help_(ui, name, unknowncmd=False, fu
 rst.extend(helplist(None, **opts))
 
 return ''.join(rst)
+
+def formattedhelp(ui, name, keep=None, unknowncmd=False, full=True, **opts):
+"""get help for a given topic (as a dotted name) as rendered rst
+
+Either returns the rendered help text or raises an exception.
+"""
+if keep is None:
+keep = []
+fullname = name
+section = None
+subtopic = None
+if name and '.' in name:
+name, remaining = name.split('.', 1)
+remaining = encoding.lower(remaining)
+if '.' in remaining:
+subtopic, section = remaining.split('.', 1)
+else:
+if name in subtopics:
+subtopic = remaining
+else:
+section = remaining
+textwidth = ui.configint('ui', 'textwidth', 78)
+termwidth = ui.termwidth() - 2
+if textwidth <= 0 or termwidth < textwidth:
+textwidth = termwidth
+text = help_(ui, name,
+ subtopic=subtopic, unknowncmd=unknowncmd, full=full, **opts)
+
+formatted, pruned = minirst.format(text, textwidth, keep=keep,
+   section=section)
+
+# We could have been given a weird ".foo" section without a name
+# to look for, or we could have simply failed to found "foo.bar"
+# because bar isn't a section of foo
+if section and not (formatted and name):
+raise error.Abort(_("help section not found: %s") % fullname)
+
+if 'verbose' in pruned:
+keep.append('omitted')
+else:
+keep.append('notomitted')
+formatted, pruned = minirst.format(text, textwidth, keep=keep,
+   section=section)
+return formatted
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] patchbomb: allow specifying default --flag options via config(issue5354)

2017-02-21 Thread Pulkit Goyal
>
> I wanted to make it support templating so we can set 'flag = {topic}', etc.
>
> https://www.mercurial-scm.org/pipermail/mercurial-devel/
> 2015-April/068094.html
>
> (Well, this wasn't an April Fool patch.)
>
> Matt found this can be more generic, which seemed really nice, but no
> progress
> since then, sigh. Maybe I should send V2 of this as I cannot design a nice
> generic function right now.
>

​I will be happy to make progress on that. The random emoji thing makes it
look like a April Fool patch, though it will be cool one to have ;).​

>
> > [email]
> > to = mercurial-de...@mecurial-scm.org
> > flag = evolve-ext
>
> Perhaps "flag" should belong to the patchbomb section.
>
> > @@ -202,9 +202,13 @@
> >  else:
> >  msg = mail.mimetextpatch(body, display=opts.get('test'))
> >
> > +fl = "flag" # to avoid test-check-config.t from failing
> > +defaultflag = repo.ui.config('email', fl)
>
> You need to document it to silence the checker.
>
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 2 pager-tweaks] incoming: delay pager activation until right before printing changes

2017-02-21 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1487692393 18000
#  Tue Feb 21 10:53:13 2017 -0500
# Node ID 54759a9a01b70dc90fe8db95023f18244b50a7c4
# Parent  59e69ed81776f0186cb6e6c69f8d7659afab26b7
incoming: delay pager activation until right before printing changes

This prevents authentication and other brief status messages from
being paged.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3210,7 +3210,6 @@ def incoming(ui, repo, source="default",
 cmdutil.displaygraph(ui, repo, revdag, displayer,
  graphmod.asciiedges)
 
-ui.pager('incoming')
 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
 return 0
 
@@ -3230,7 +3229,6 @@ def incoming(ui, repo, source="default",
 
 repo._subtoppath = ui.expandpath(source)
 try:
-ui.pager('incoming')
 return hg.incoming(ui, repo, source, opts)
 finally:
 del repo._subtoppath
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -804,7 +804,7 @@ def _incoming(displaychlist, subreporecu
 if not chlist:
 ui.status(_("no changes found\n"))
 return subreporecurse()
-
+ui.pager('incoming')
 displayer = cmdutil.show_changeset(ui, other, opts, buffered)
 displaychlist(other, chlist, displayer)
 displayer.close()
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 04 of 10 ipv6 V2] tinyproxy: use IPv6 if HGIPV6 is set to 1

2017-02-21 Thread Jun Wu
Excerpts from David Soria Parra's message of 2017-02-21 09:29:50 -0800:
> [...]
> 
> I think my point is that the correct thing to do, is to bind on v6/v4 if
> available at all times (that includes hg serve, i look into this) instead
> of make it a switch, as that would defeat the address resolution rfc.

Got it. If "hg serve" is changed to bind on both, run-tests could be updated
accordingly. However "hg serve" is outside of my plate for now.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 04 of 10 ipv6 V2] tinyproxy: use IPv6 if HGIPV6 is set to 1

2017-02-21 Thread David Soria Parra
On Mon, Feb 20, 2017 at 07:03:36PM -0800, Jun Wu wrote:
> 
> Thanks for pointing out the RFC.
> 
> The V1 series was ipv6 by default. But buildbot was not happy with all
> changes. In order to make all changesets green, I have to temporarily
> disable V6 handling, therefore V2 and IPv4 by default.
> 
> Since the changes were committed, we could change it to V6 by default now.
> Maybe add a flag like --netaddr-family=auto|ipv6|ipv4
 
That would be an okay idea

> > In order to obtain the available localhost addresses we should use
> > socket.getaddrinfo() to obtain a list of available v4/v6 addresses and
> > bind on both. This should be doable without using HGIPV6 in tinyproxy
 
> As long as "hg serve" sticks to one address family, I don't think it's
> useful to make tinyproxy bind on both.

> "HGIPV6" is a way to provide hgrc's "web.ipv6" for non-hgrc-aware programs.
> So if you'd like to remove "HGIPV6", maybe try remove "web.ipv6" first.
> 
> > and dumbhttp. We can use this list to glob() 127.0.0.1 correctly, even in 
> > the
> > case of FreeBSD jails and don't rely on hardcoded ::1/127.0.0.1 addresses. 
> > This
> 
> This looks like a separate issue. Note that "getaddrinfo()" just reads
> "/etc/hosts", instead of the real interfaces. The list returned by
> "getaddrinfo()" cannot be trusted, if we want real interface info.

You are right. In this case it should be determining LOCALIP:
1. try to use getaddrinfo() of localhost
2. if unavailable, use ::1/127.0.0.1 loopback
3. otherwise abort

> > should allow us to use IPv6 on a test host correctly when avaialble and 
> > fallback
> > to IPv4 graciously. I see why we want to introduce switches in tests for 
> > v4/v6
> > only, but I feel that the current implementation does not correctly test 
> > default
> > addr selection (which might be part of causing the flakeyness).
> 
> Previously, there is no IPv6 support at all. The system has to have a
> working IPv4 configuration to run tests. And the port check logic only
> checked "localhost", which is simply wrong since "hg serve" binds on all
> interfaces.
> 
> So in weird situations, the tests will just fail, like:
> 
>   - All network interfaces (incl. "lo") do not have IPv4 addresses.
>   - The "localhost" hostname does not resolve to an IPv4 address.
>   - The port being used by "hg serve" is free on "lo", but not all
> interfaces.
>
> My patches should have made tests just work instead of failing, in the above
> situations.

I think my point is that the correct thing to do, is to bind on v6/v4 if
available at all times (that includes hg serve, i look into this) instead
of make it a switch, as that would defeat the address resolution rfc.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 5 of 5] localrepo: check HG_PENDING strictly

2017-02-21 Thread Augie Fackler
On Tue, Feb 21, 2017 at 01:28:04AM +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori 
> # Date 1487607660 -32400
> #  Tue Feb 21 01:21:00 2017 +0900
> # Node ID 0eebac024d47de9c94968f49bc9a0dcb2c8d3d2b
> # Parent  f307ed0b262616d31c43eb1e3655a21b1d90865c
> localrepo: check HG_PENDING strictly

Queued these, very nice centralization of the pending logic into a single place.

Do you think we should consolidate other transaction-related bits into
txnutil? Might let us have a bit more tidy organization of things.

>
> Before this patch, checking HG_PENDING for changelog in localrepo.py
> might cause unintentional reading unrelated '00changelog.i.a' in,
> because HG_PENDING is checked by str.startswith().
>
> An external hook spawned by inner repository in nested ones satisfies
> this condition.
>
> This patch uses txnutil.mayhavepending() to check HG_PENDING strictly.
>
> BTW, this patch may cause failure of bisect in the repository of
> Mercurial itself, if examination at bisecting assumes that an external
> hook can see all pending changes while nested transactions across
> repositories.
>
> This invisibility issue will be fixed by subsequent patch, which
> allows HG_PENDING to refer multiple repositories.
>
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -55,6 +55,7 @@ from . import (
>  subrepo,
>  tags as tagsmod,
>  transaction,
> +txnutil,
>  util,
>  )
>
> @@ -512,10 +513,8 @@ class localrepository(object):
>  @storecache('00changelog.i')
>  def changelog(self):
>  c = changelog.changelog(self.svfs)
> -if 'HG_PENDING' in encoding.environ:
> -p = encoding.environ['HG_PENDING']
> -if p.startswith(self.root):
> -c.readpending('00changelog.i.a')
> +if txnutil.mayhavepending(self.root):
> +c.readpending('00changelog.i.a')
>  return c
>
>  def _constructmanifest(self):
> diff --git a/tests/test-hook.t b/tests/test-hook.t
> --- a/tests/test-hook.t
> +++ b/tests/test-hook.t
> @@ -832,6 +832,50 @@ pretxnclose hook failure should abort th
>[1]
>$ cd ..
>
> +check whether HG_PENDING makes pending changes only in related
> +repositories visible to an external hook.
> +
> +(emulate a transaction running concurrently by copied
> +.hg/store/00changelog.i.a in subsequent test)
> +
> +  $ cat > $TESTTMP/savepending.sh < +  > cp .hg/store/00changelog.i.a  .hg/store/00changelog.i.a.saved
> +  > exit 1 # to avoid adding new revision for subsequent tests
> +  > EOF
> +  $ cd a
> +  $ hg tip -q
> +  4:539e4b31b6dc
> +  $ hg --config hooks.pretxnclose="sh $TESTTMP/savepending.sh" commit -m 
> "invisible"
> +  transaction abort!
> +  rollback completed
> +  abort: pretxnclose hook exited with status 1
> +  [255]
> +  $ cp .hg/store/00changelog.i.a.saved .hg/store/00changelog.i.a
> +
> +(check (in)visibility of new changeset while transaction running in
> +repo)
> +
> +  $ cat > $TESTTMP/checkpending.sh < +  > echo '@a'
> +  > hg -R $TESTTMP/a tip -q
> +  > echo '@a/nested'
> +  > hg -R $TESTTMP/a/nested tip -q
> +  > exit 1 # to avoid adding new revision for subsequent tests
> +  > EOF
> +  $ hg init nested
> +  $ cd nested
> +  $ echo a > a
> +  $ hg add a
> +  $ hg --config hooks.pretxnclose="sh $TESTTMP/checkpending.sh" commit -m 
> '#0'
> +  @a
> +  4:539e4b31b6dc
> +  @a/nested
> +  0:bf5e395ced2c
> +  transaction abort!
> +  rollback completed
> +  abort: pretxnclose hook exited with status 1
> +  [255]
> +
>  Hook from untrusted hgrc are reported as failure
>  
>
> ___
> 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] repoview: separate cache hash computation from cache reading

2017-02-21 Thread Augie Fackler
On Mon, Feb 20, 2017 at 01:56:19AM -0800, Stanislau Hlebik wrote:
> # HG changeset patch
> # User Stanislau Hlebik 
> # Date 1487584447 28800
> #  Mon Feb 20 01:54:07 2017 -0800
> # Node ID cb1151ce14f7ec9e2ca991bc8bd590020ec4b061
> # Parent  693a5bb478543a986808264e586073a3ceedc38f
> repoview: separate cache hash computation from cache reading

Seems harmless enough, queued. Thanks.

>
> This change will make it easier for extensions to use another cache hash.
>
> diff --git a/mercurial/repoview.py b/mercurial/repoview.py
> --- a/mercurial/repoview.py
> +++ b/mercurial/repoview.py
> @@ -139,15 +139,13 @@
>  if wlock:
>  wlock.release()
>
> -def tryreadcache(repo, hideable):
> -"""read a cache if the cache exists and is valid, otherwise returns 
> None."""
> +def _readhiddencache(repo, cachefilename, newhash):
>  hidden = fh = None
>  try:
>  if repo.vfs.exists(cachefile):
>  fh = repo.vfs.open(cachefile, 'rb')
>  version, = struct.unpack(">H", fh.read(2))
>  oldhash = fh.read(20)
> -newhash = cachehash(repo, hideable)
>  if (cacheversion, oldhash) == (version, newhash):
>  # cache is valid, so we can start reading the hidden revs
>  data = fh.read()
> @@ -165,6 +163,11 @@
>  if fh:
>  fh.close()
>
> +def tryreadcache(repo, hideable):
> +"""read a cache if the cache exists and is valid, otherwise returns 
> None."""
> +newhash = cachehash(repo, hideable)
> +return _readhiddencache(repo, cachefile, newhash)
> +
>  def computehidden(repo):
>  """compute the set of hidden revision to filter
>
> ___
> 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 3 of 4 V3] update: also suggest --merge when non-linear update is aborted

2017-02-21 Thread Augie Fackler

> On Feb 20, 2017, at 05:38, Gábor STEFANIK  wrote:
> 
>> On Wed, Feb 15, 2017 at 12:56:41PM -0800, Martin von Zweigbergk via
>> Mercurial-devel wrote:
>>> # HG changeset patch
>>> # User Martin von Zweigbergk  # Date
>> 1487140898
>>> 28800
>>> #  Tue Feb 14 22:41:38 2017 -0800
>>> # Node ID c6cd58d272aee6633fbad5eacdad742e2f9909cd
>>> # Parent  542a99ede6c3ac7cb4afccd3703fcc30e3d4c90d
>>> update: also suggest --merge when non-linear update is aborted
>> 
>> This makes me a touch nervous, since the merge can leave the user in an
>> state that's hard to recover from.
> 
> Basically "hg resolve -au; hg resolve -at:local; hg update --merge -r$(head 
> -c40 .hg/merge/state) -t:local"; but we need to expose a less hacky way of 
> doing so. 

Not quite, because this isn't sure (I don't think) to get you back to exactly 
the pre-update-command state, as some files might have been merged behind your 
back?

> 
> "hg update --abort"?

I'd be a big fan of having an update --abort that just takes you back to where 
you were before the conflicts. To date, nobody has been motivated enough to do 
the work (I'd love to do it, but it's unlikely to be near the top of my stack 
for months/years).
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 09 of 19 pager] help: enable pager

2017-02-21 Thread Augie Fackler

> On Feb 21, 2017, at 07:58, Yuya Nishihara  wrote:
> 
> On Sun, 19 Feb 2017 18:13:00 -0500, Augie Fackler wrote:
>> # HG changeset patch
>> # User Augie Fackler 
>> # Date 1486440561 18000
>> #  Mon Feb 06 23:09:21 2017 -0500
>> # Node ID f6f080904a6ecac993f137b92d50bf4991f8d07c
>> # Parent  6dd615d163eb069405ba71fe968980d3340d4702
>> help: enable pager
> 
> Good news: now --help can be paged!
> 
> Bad news: command error is hidden behind pager. Maybe we'll need to start
> a pager before calling ui.warn() + commands.help_() ?

Ooh, gross. I think I'd actually rather we change the 'unknown command' output 
to not include that full list of commands and instead have a hint to run 'hg 
help -c' for a list of commands - thoughts?

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


[PATCH 1 of 2 remotenames-ext] remotenames: get rid of useless lookup

2017-02-21 Thread Stanislau Hlebik
# HG changeset patch
# User Stanislau Hlebik 
# Date 1487690067 28800
#  Tue Feb 21 07:14:27 2017 -0800
# Node ID cf04161615a48d42a2bb6181060ae9be8ceaa467
# Parent  4f17d4ae821e7654b3c134002537155b28f7e146
remotenames: get rid of useless lookup

Lookup is useless since `bookmarks` dict already contains nodes for remote
bookmarks

diff --git a/remotenames.py b/remotenames.py
--- a/remotenames.py
+++ b/remotenames.py
@@ -158,8 +158,8 @@
 if args[0]:
 heads = args[0]
 args = args[1:]
-for bookmark in bookmarks:
-heads.append(remote.lookup(remotebookmarks[bookmark]))
+for node in bookmarks.values():
+heads.append(bin(node))
 kwargs['bookmarks'] = bookmarks
 kwargs['heads'] = heads
 else:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 2 remotenames-ext] remotenames: selectivepull, add _listremotebookmarks

2017-02-21 Thread Stanislau Hlebik
# HG changeset patch
# User Stanislau Hlebik 
# Date 1487690190 28800
#  Tue Feb 21 07:16:30 2017 -0800
# Node ID f49560facf4802449ab15aaf9b12287754619990
# Parent  cf04161615a48d42a2bb6181060ae9be8ceaa467
remotenames: selectivepull, add _listremotebookmarks

Adding a separate function to fetch only selected bookmarks from the server
allows extensions to wrap it. For example, infinitepush extensions
(https://bitbucket.org/facebook/hg-experimental/src/
98384e8d1db6534f7e5df08080f8ebf57688d380/infinitepush/?at=default) can wrap
this function and return bookmarks that are not present on hg server but
stored in a separate storage.

diff --git a/remotenames.py b/remotenames.py
--- a/remotenames.py
+++ b/remotenames.py
@@ -85,19 +85,18 @@
 def _isselectivepull(ui):
 return ui.configbool('remotenames', 'selectivepull', False)
 
-def _getselectivepulldefaultbookmarks(ui, remotebookmarks):
+def _getselectivepulldefaultbookmarks(ui):
 default_books = ui.configlist('remotenames', 'selectivepulldefault')
 if not default_books:
 raise error.Abort(_('no default bookmarks specified for 
selectivepull'))
+return default_books
 
+def _listremotebookmarks(remote, bookmarks):
+remotebookmarks = remote.listkeys('bookmarks')
 result = {}
-for default_book in default_books:
-if default_book in remotebookmarks:
-result[default_book] = remotebookmarks[default_book]
-
-if not default_books:
-raise error.Abort(
-_('default bookmarks %s are not found on remote') % default_books)
+for book in bookmarks:
+if book in remotebookmarks:
+result[book] = remotebookmarks[book]
 return result
 
 def _trypullremotebookmark(mayberemotebookmark, repo, ui):
@@ -122,7 +121,6 @@
 ui.warn(_('`%s` found remotely\n') % mayberemotebookmark)
 
 def expull(orig, repo, remote, *args, **kwargs):
-remotebookmarks = remote.listkeys('bookmarks')
 if _isselectivepull(repo.ui):
 # if selectivepull is enabled then we don't save all of the remote
 # bookmarks in remotenames file. Instead we save only bookmarks that
@@ -135,23 +133,21 @@
 # Selectivepull is helpful when server has too many remote bookmarks
 # because it may slow down clients.
 path = activepath(repo.ui, remote)
-bookmarks = {}
+remotebookmarkslist = []
 if repo.vfs.exists(_selectivepullenabledfile):
 # 'selectivepullenabled' file is used for transition between
 # non-selectivepull repo to selectivepull repo. It is used as
 # indicator to whether "non-interesting" bookmarks were removed
 # from remotenames file.
-for bookmark in readbookmarknames(repo, path):
-if bookmark in remotebookmarks:
-bookmarks[bookmark] = remotebookmarks[bookmark]
-if not bookmarks:
-bookmarks = _getselectivepulldefaultbookmarks(repo.ui,
-  remotebookmarks)
+remotebookmarkslist = list(readbookmarknames(repo, path))
+if not remotebookmarkslist:
+remotebookmarkslist = _getselectivepulldefaultbookmarks(repo.ui)
 
 if kwargs.get('bookmarks'):
-for bookmark in kwargs['bookmarks']:
-bookmarks[bookmark] = remotebookmarks[bookmark]
+remotebookmarkslist.extend(kwargs['bookmarks'])
+bookmarks = _listremotebookmarks(remote, remotebookmarkslist)
 else:
+bookmarks = _listremotebookmarks(remote, remotebookmarkslist)
 heads = kwargs.get('heads') or []
 # heads may be passed as positional args
 if len(args) > 0:
@@ -163,7 +159,7 @@
 kwargs['bookmarks'] = bookmarks
 kwargs['heads'] = heads
 else:
-bookmarks = remotebookmarks
+bookmarks = remote.listkeys('bookmarks')
 
 res = orig(repo, remote, *args, **kwargs)
 pullremotenames(repo, remote, bookmarks)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] Make test suite more immune to environment variables

2017-02-21 Thread Yuya Nishihara
On Mon, 20 Feb 2017 09:43:09 -0800, Bryan O'Sullivan wrote:
> On Mon, Feb 20, 2017 at 9:27 AM, Dr Rainer Woitok 
> wrote:
> 
> > tests: make test suite more immune to environment variables
> >
> 
> Good catch!

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


Re: [PATCH] patchbomb: allow specifying default --flag options via config(issue5354)

2017-02-21 Thread Yuya Nishihara
On Tue, 21 Feb 2017 08:55:07 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pul...@gmail.com>
> # Date 1487593583 -19800
> #  Mon Feb 20 17:56:23 2017 +0530
> # Node ID 3c7e816697791c48de126c06c069af23c9e2bc3a
> # Parent  2c9e619ba9ee8e72370cc0f27f59da39947773b6
> patchbomb: allow specifying default --flag options via config(issue5354)
> 
> This patch adds support for specifying default flag to be added while sending
> patches using patchbomb per repsoitory. After this patch one can add flag to
> email section in hgrc like

I wanted to make it support templating so we can set 'flag = {topic}', etc.

https://www.mercurial-scm.org/pipermail/mercurial-devel/2015-April/068094.html

(Well, this wasn't an April Fool patch.)

Matt found this can be more generic, which seemed really nice, but no progress
since then, sigh. Maybe I should send V2 of this as I cannot design a nice
generic function right now.

> [email]
> to = mercurial-de...@mecurial-scm.org
> flag = evolve-ext

Perhaps "flag" should belong to the patchbomb section.

> @@ -202,9 +202,13 @@
>  else:
>  msg = mail.mimetextpatch(body, display=opts.get('test'))
>  
> +fl = "flag" # to avoid test-check-config.t from failing
> +defaultflag = repo.ui.config('email', fl)

You need to document it to silence the checker.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 1 of 4 V2] serve: add support for Mercurial subrepositories

2017-02-21 Thread Yuya Nishihara
On Mon, 20 Feb 2017 22:00:20 -0500, Matt Harbison wrote:
> On Mon, 20 Feb 2017 09:27:44 -0500, Yuya Nishihara  wrote:
> > On Thu, 16 Feb 2017 16:41:08 -0500, Matt Harbison wrote:
> >> # HG changeset patch
> >> # User Matt Harbison 
> >> # Date 1486875517 18000
> >> #  Sat Feb 11 23:58:37 2017 -0500
> >> # Node ID 4f2862487d789edc1f36b5687d828a2914e1dc32
> >> # Parent  afaf3c2b129c8940387fd9928ae4fdc28259d13c
> >> serve: add support for Mercurial subrepositories
> >>
> >> I've been using `hg serve --web-conf ...` with a simple '/=projects/**'  
> >> [paths]
> >> configuration for awhile without issue.  Let's ditch the need for the  
> >> manual
> >> configuration in this case, and limit the repos served to the actual  
> >> subrepos.
> >>
> >> This doesn't attempt to handle the case where a new subrepo appears  
> >> while the
> >> server is running.  That could probably be handled with a hook if  
> >> somebody wants
> >> it.  But it's such a rare case, it probably doesn't matter for the  
> >> temporary
> >> serves.
> >>
> >> Unfortunately, the root of the webserver when serving multiple repos is  
> >> the html
> >> index file.  This makes the URL different for `hg serve` vs `hg serve  
> >> -S`,
> >> because the top level repo then needs to be part of the path.  That can  
> >> be
> >> fixed later.
> >
> > I'm puzzled by this new version which extensively relies on somewhat  
> > magical
> > HTTP redirection. Instead, can't we fix hgwebdir to be able to host  
> > hgweb at
> > '/' URL, and add explicit URL to show the index page hidden by it?
> 
> This patch is the same as the first in V1, except that I dropped forcing  
> the web.staticurl config, and I globbed away a bunch of the http  
> parameters in the tests, since only the URI and status is of interest.
> 
> The first version did host the parent at '/', and the subrepos relative to  
> it.

Yes, that seems intuitive way to serve a repo and its subrepos behind. I
thought there wasn't redirection magic as the parent repo was served at '/',
was there?

> - At http://localhost:8000, the links on the left side were corrupt (graph  
> is simply 'graph/tip', tags is 'http://tags', etc.)  The pattern seemed to  
> be that things ending in 'tip' are relative URLs, and the rest get an  
> http: prefix.  It looks from the sources like it is just a matter of '/'  
> not translating for the {repo} template.

[snip]

I saw some of these problems in V1. However, the standalone hgweb can host
a repository at '/', so I don't think it's quite difficult to host the subrepo
parent at '/'.

> To me, the benefits of this series over the original is:
> 
> 1) The repos aren't moved, and therefore don't incur these subtle bugs
> 2) These changes are totally isolated to subrepo serving, so there should  
> be no risk to mainstream hgweb usage
> 3) This is completely compatible with existing serves with a simple  
> '/=$projects_dir/**' config file, because the real repos are not anchored  
> to '/'.

I think (2) and (3) are up to how we build a repository map. If a map has no
'/' entry, hgweb would serve nothing at '/' and is compatible with the current
behavior.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 3 of 4 V2] serve: make the URL the same for `hg serve` and `hg serve -S`

2017-02-21 Thread Yuya Nishihara
On Mon, 20 Feb 2017 22:25:21 -0500, Matt Harbison wrote:
> On Mon, 20 Feb 2017 09:38:13 -0500, Yuya Nishihara  wrote:
> > On Thu, 16 Feb 2017 16:41:10 -0500, Matt Harbison wrote:
> >> # HG changeset patch
> >> # User Matt Harbison 
> >> # Date 1486877030 18000
> >> #  Sun Feb 12 00:23:50 2017 -0500
> >> # Node ID 38babd487181374325f3d27c5bc081dadf31b9b9
> >> # Parent  27a4bc77e8b8e50abc76c387f117082e5853c47e
> >> serve: make the URL the same for `hg serve` and `hg serve -S`
> >
> >>  elif not virtual:
> >> +if self._rootrepo:
> >> +# Redirect '/' to the main repo when -S is given.
> >> +path = '/' + self._rootrepo
> >> +if self.prefix:
> >> +path = '/' + self.prefix + path
> >> +req.headers.append(('Location', path))
> >> +html = 'Moved here.'
> >> +req.respond(HTTP_MOVED_PERMANENTLY, "text/html",  
> >> body=html)
> >> +return []
> >
> > Suppose "hg serve" is used for temporarily serving random repositories,  
> > 301
> > seems too strong.
> 
> The temporary serve is the case that I'm interested in.  It may not be  
> clear from this snippet, but the redirect is only reachable when using `hg  
> serve -S`, not random repos listed in a --web-conf file.
> 
> I guess I didn't think it was too strong, because the repo never is at  
> '/'.  Once the `hg serve` process is killed, everything is gone.   
> Everything goes away eventually.  But until then, it's a permanent  
> redirect.
> 
> The temporary/permanent distinction is important, because there needs to  
> be a trigger to update paths.default in hgrc without doing so for  
> temporary redirects.  The updated hgrc path is important, because the  
> subrepo is cloned relative to the parent repo's paths.default value.   
> (Keeping both the sub=sub and sub=../sub style paths working in the two  
> new tests were one of the many headaches with this.)
> 
> Since nothing other than hg clients should see the redirect, do you have a  
> specific concern?  (I haven't paid much attention to chg to know if it  
> would somehow cache the URL and get directed wrong when `hg serve` is  
> killed and something else is served.  But the aggressive caching done by  
> web browsers is why I limited the redirect as narrowly as possible.)

Hmm, if no web browser is involved, it would be okay as hg client wouldn't have
a permanent URL cache. I don't like the idea of using redirection to compensate
the problem of hgweb, though.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 09 of 19 pager] help: enable pager

2017-02-21 Thread Yuya Nishihara
On Sun, 19 Feb 2017 18:13:00 -0500, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler 
> # Date 1486440561 18000
> #  Mon Feb 06 23:09:21 2017 -0500
> # Node ID f6f080904a6ecac993f137b92d50bf4991f8d07c
> # Parent  6dd615d163eb069405ba71fe968980d3340d4702
> help: enable pager

Good news: now --help can be paged!

Bad news: command error is hidden behind pager. Maybe we'll need to start
a pager before calling ui.warn() + commands.help_() ?
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 10 of 19 pager] incoming: enable pager

2017-02-21 Thread Yuya Nishihara
On Sun, 19 Feb 2017 18:13:01 -0500, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler 
> # Date 1486440228 18000
> #  Mon Feb 06 23:03:48 2017 -0500
> # Node ID b6f05836ba20bb8b25469a30aeed1b3506392bbf
> # Parent  f6f080904a6ecac993f137b92d50bf4991f8d07c
> incoming: enable pager
> 
> The design of incoming means we have to activate the pager in several
> places, depending on which codepath gets chosen.
> 
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -3210,6 +3210,7 @@ def incoming(ui, repo, source="default",
>  cmdutil.displaygraph(ui, repo, revdag, displayer,
>   graphmod.asciiedges)
>  
> +ui.pager('incoming')
>  hg._incoming(display, lambda: 1, ui, repo, source, opts, 
> buffered=True)
>  return 0
>  
> @@ -3223,11 +3224,13 @@ def incoming(ui, repo, source="default",
>  if 'bookmarks' not in other.listkeys('namespaces'):
>  ui.warn(_("remote doesn't support bookmarks\n"))
>  return 0
> +ui.pager('incoming')
>  ui.status(_('comparing with %s\n') % util.hidepassword(source))
>  return bookmarks.incoming(ui, repo, other)
>  
>  repo._subtoppath = ui.expandpath(source)
>  try:
> +ui.pager('incoming')
>  return hg.incoming(ui, repo, source, opts)

As a follow-up, we'll probably want to delay ui.pager() until authentication
of the peer repo.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH pager annotate-fix] annotate: start pager after we're sure we wont abort

2017-02-21 Thread Yuya Nishihara
On Sun, 19 Feb 2017 18:12:08 -0500, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler 
> # Date 1487534981 18000
> #  Sun Feb 19 15:09:41 2017 -0500
> # Node ID 7353b9603c574678314f9525b3e56f31a4497bb9
> # Parent  2c9e619ba9ee8e72370cc0f27f59da39947773b6
> annotate: start pager after we're sure we wont abort

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


Re: [PATCH 01 of 19 pager] cat: migrate to modern pager API

2017-02-21 Thread Yuya Nishihara
On Sun, 19 Feb 2017 18:12:52 -0500, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler 
> # Date 1486439872 18000
> #  Mon Feb 06 22:57:52 2017 -0500
> # Node ID 2832edeb9d5358b483ad0babbbf3f1dfb43aaf4c
> # Parent  7353b9603c574678314f9525b3e56f31a4497bb9
> cat: migrate to modern pager API

The series generally looks good. Queued, thanks!
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel