[PATCH] tests: disable remotefilelog on Windows

2018-11-24 Thread Matt Harbison
# HG changeset patch
# User Matt Harbison 
# Date 1543086662 18000
#  Sat Nov 24 14:11:02 2018 -0500
# Node ID 99e50fb3ffc6fa3d5e81427c69e5280c84254ab0
# Parent  1f9de5636e5f7f4bfe2d3fb8c5dde543a1870161
tests: disable remotefilelog on Windows

I've spent a non trivial amount of time trying to eliminate the test errors, but
it's looking like this is pretty dependent on Unix support.  For example, there
are attempts to delete open files, and uses of threads that report I/O attempts
on closed files.  (Maybe this is a race condition?  Don't we usually use
processes as workers on Windows?)

In any event, I don't want real new errors elsewhere to be masked by these known
problems.

For some reason $CACHEDIR is reported as missing in test-remotefilelog-repack.t,
but it actually exists in the hgcloneshallow call inside
shallowutil.mkstickygroupdir().  By the time the process exits, it's gone.  I
don't see it being removed by code that calls 'rmdir' or 'remove' in the
extension itself.

diff --git a/tests/test-remotefilelog-bad-configs.t 
b/tests/test-remotefilelog-bad-configs.t
--- a/tests/test-remotefilelog-bad-configs.t
+++ b/tests/test-remotefilelog-bad-configs.t
@@ -1,3 +1,5 @@
+#require no-windows
+
   $ . "$TESTDIR/remotefilelog-library.sh"
 
   $ hg init master
diff --git a/tests/test-remotefilelog-bgprefetch.t 
b/tests/test-remotefilelog-bgprefetch.t
--- a/tests/test-remotefilelog-bgprefetch.t
+++ b/tests/test-remotefilelog-bgprefetch.t
@@ -1,3 +1,5 @@
+#require no-windows
+
   $ . "$TESTDIR/remotefilelog-library.sh"
 
   $ hg init master
diff --git a/tests/test-remotefilelog-blame.t b/tests/test-remotefilelog-blame.t
--- a/tests/test-remotefilelog-blame.t
+++ b/tests/test-remotefilelog-blame.t
@@ -1,3 +1,5 @@
+#require no-windows
+
   $ . "$TESTDIR/remotefilelog-library.sh"
 
   $ hg init master
diff --git a/tests/test-remotefilelog-bundle2-legacy.t 
b/tests/test-remotefilelog-bundle2-legacy.t
--- a/tests/test-remotefilelog-bundle2-legacy.t
+++ b/tests/test-remotefilelog-bundle2-legacy.t
@@ -1,3 +1,5 @@
+#require no-windows
+
   $ . "$TESTDIR/remotefilelog-library.sh"
 
 generaldelta to generaldelta interactions with bundle2 but legacy clients
diff --git a/tests/test-remotefilelog-bundle2.t 
b/tests/test-remotefilelog-bundle2.t
--- a/tests/test-remotefilelog-bundle2.t
+++ b/tests/test-remotefilelog-bundle2.t
@@ -1,3 +1,5 @@
+#require no-windows
+
   $ . "$TESTDIR/remotefilelog-library.sh"
 
   $ hg init master
diff --git a/tests/test-remotefilelog-bundles.t 
b/tests/test-remotefilelog-bundles.t
--- a/tests/test-remotefilelog-bundles.t
+++ b/tests/test-remotefilelog-bundles.t
@@ -1,3 +1,5 @@
+#require no-windows
+
   $ . "$TESTDIR/remotefilelog-library.sh"
 
   $ hg init master
diff --git a/tests/test-remotefilelog-cacheprocess.t 
b/tests/test-remotefilelog-cacheprocess.t
--- a/tests/test-remotefilelog-cacheprocess.t
+++ b/tests/test-remotefilelog-cacheprocess.t
@@ -1,3 +1,5 @@
+#require no-windows
+
   $ . "$TESTDIR/remotefilelog-library.sh"
 
   $ hg init repo
diff --git a/tests/test-remotefilelog-clone-tree.t 
b/tests/test-remotefilelog-clone-tree.t
--- a/tests/test-remotefilelog-clone-tree.t
+++ b/tests/test-remotefilelog-clone-tree.t
@@ -1,3 +1,5 @@
+#require no-windows
+
   $ . "$TESTDIR/remotefilelog-library.sh"
 
   $ hg init master
diff --git a/tests/test-remotefilelog-clone.t b/tests/test-remotefilelog-clone.t
--- a/tests/test-remotefilelog-clone.t
+++ b/tests/test-remotefilelog-clone.t
@@ -1,3 +1,5 @@
+#require no-windows
+
   $ . "$TESTDIR/remotefilelog-library.sh"
 
   $ hg init master
diff --git a/tests/test-remotefilelog-corrupt-cache.t 
b/tests/test-remotefilelog-corrupt-cache.t
--- a/tests/test-remotefilelog-corrupt-cache.t
+++ b/tests/test-remotefilelog-corrupt-cache.t
@@ -1,3 +1,5 @@
+#require no-windows
+
   $ . "$TESTDIR/remotefilelog-library.sh"
 
   $ hg init master
diff --git a/tests/test-remotefilelog-gc.t b/tests/test-remotefilelog-gc.t
--- a/tests/test-remotefilelog-gc.t
+++ b/tests/test-remotefilelog-gc.t
@@ -1,3 +1,5 @@
+#require no-windows
+
   $ . "$TESTDIR/remotefilelog-library.sh"
 
   $ hg init master
diff --git a/tests/test-remotefilelog-gcrepack.t 
b/tests/test-remotefilelog-gcrepack.t
--- a/tests/test-remotefilelog-gcrepack.t
+++ b/tests/test-remotefilelog-gcrepack.t
@@ -1,3 +1,5 @@
+#require no-windows
+
   $ . "$TESTDIR/remotefilelog-library.sh"
 
   $ hg init master
diff --git a/tests/test-remotefilelog-http.t b/tests/test-remotefilelog-http.t
--- a/tests/test-remotefilelog-http.t
+++ b/tests/test-remotefilelog-http.t
@@ -1,3 +1,5 @@
+#require no-windows
+
   $ . "$TESTDIR/remotefilelog-library.sh"
 
   $ hg init master
diff --git a/tests/test-remotefilelog-keepset.t 
b/tests/test-remotefilelog-keepset.t
--- a/tests/test-remotefilelog-keepset.t
+++ b/tests/test-remotefilelog-keepset.t
@@ -1,3 +1,5 @@
+#require no-windows
+
   $ . "$TESTDIR/remotefilelog-library.sh"
 
   $ hg init master
diff --git a/tests/test-remotefilelog-linknodes.t 

Re: D5295: branchmap: define a hasbranch() to find whether a branch exists or not

2018-11-24 Thread Yuya Nishihara
I don't think it's good idea to re-scan the cache file per hasbranch() call.
Instead, we'll probably need a lazy parser backed by a in-memory cache data.
The current cache file format is text-based, which wouldn't be easily bisected
without loading (or memmap) the whole content.

> +def hasbranch(repo, branchname):
> +"""check whether a branchname exists in the repo or not by reading the
> +branchmap cache"""
> +
> +if not repo.cachevfs.exists(_filename(repo)):
> +# branchmap file is not present, let's go repo.branchmap() route 
> which
> +# will create that file
> +return branchname in repo.branchmap()
> +
> +# TODO: implement binary-search here for faster search
> +with repo.cachevfs(_filename(repo)) as f:
> +f = repo.cachevfs(_filename(repo))
> +lineiter = iter(f)
> +next(lineiter).rstrip('\n').split(" ", 2)

Need to check if the cache file is valid.

> +for l in lineiter:
> +l = l.rstrip('\n')
> +if not l:
> +continue
> +label = l.split(" ", 2)[2]
> +label = encoding.tolocal(label.strip())
> +if label == branchname:

And maybe need to check if the node exists.

> +return True
> +return False
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5297: tests: add test for `--version` flag of perfchangegroupchangelog

2018-11-24 Thread yuja (Yuya Nishihara)
yuja added a comment.


  > +  $ hg perfchangegroupchangelog --version 01
  >  +  Mercurial Distributed SCM (version 4.8+262-efd0f79246e3+20181122)
  >  +  (see https://mercurial-scm.org for more information)
  >  +  
  >  +  Copyright (C) 2005-2018 Matt Mackall and others
  >  +  This is free software; see the source for copying conditions. There is 
NO
  >  +  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 
PURPOSE.
  
  lol
  
  Folded this with the next patch and queued, thanks. The output of "hg version"
  is unstable.

REPOSITORY
  rHG Mercurial

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

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


Re: D5297: tests: add test for `--version` flag of perfchangegroupchangelog

2018-11-24 Thread Yuya Nishihara
> +  $ hg perfchangegroupchangelog --version 01
> +  Mercurial Distributed SCM (version 4.8+262-efd0f79246e3+20181122)
> +  (see https://mercurial-scm.org for more information)
> +  
> +  Copyright (C) 2005-2018 Matt Mackall and others
> +  This is free software; see the source for copying conditions. There is NO
> +  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

lol

Folded this with the next patch and queued, thanks. The output of "hg version"
is unstable.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5297: tests: add test for `--version` flag of perfchangegroupchangelog

2018-11-24 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGcfaf3843491b: perf: rename version flag of 
perfchangegroupchangelog to cgversion (authored by pulkit, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D5297?vs=12588=12593#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5297?vs=12588=12593

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

AFFECTED FILES
  contrib/perf.py
  tests/test-contrib-perf.t

CHANGE DETAILS

diff --git a/tests/test-contrib-perf.t b/tests/test-contrib-perf.t
--- a/tests/test-contrib-perf.t
+++ b/tests/test-contrib-perf.t
@@ -145,6 +145,7 @@
   $ hg perfbranchmap
   $ hg perfcca
   $ hg perfchangegroupchangelog
+  $ hg perfchangegroupchangelog --cgversion 01
   $ hg perfchangeset 2
   $ hg perfctxfiles 2
   $ hg perfdiffwd
diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -712,9 +712,9 @@
 fm.end()
 
 @command(b'perfchangegroupchangelog', formatteropts +
- [(b'', b'version', b'02', b'changegroup version'),
+ [(b'', b'cgversion', b'02', b'changegroup version'),
   (b'r', b'rev', b'', b'revisions to add to changegroup')])
-def perfchangegroupchangelog(ui, repo, version=b'02', rev=None, **opts):
+def perfchangegroupchangelog(ui, repo, cgversion=b'02', rev=None, **opts):
 """Benchmark producing a changelog group for a changegroup.
 
 This measures the time spent processing the changelog during a
@@ -727,7 +727,7 @@
 opts = _byteskwargs(opts)
 cl = repo.changelog
 nodes = [cl.lookup(r) for r in repo.revs(rev or b'all()')]
-bundler = changegroup.getbundler(version, repo)
+bundler = changegroup.getbundler(cgversion, repo)
 
 def d():
 state, chunks = bundler._generatechangelog(cl, nodes)



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


Re: [PATCH] push: config option to control behavior when pushing to a publishing server

2018-11-24 Thread Yuya Nishihara
On Fri, 23 Nov 2018 13:23:43 +0800, Anton Shestakov wrote:
> # HG changeset patch
> # User Anton Shestakov 
> # Date 1541397139 -28800
> #  Mon Nov 05 13:52:19 2018 +0800
> # Node ID ea18d94ac7006faff7148cb2eca3b970655955b9
> # Parent  efd0f79246e3e6633dfd06226464a48584f69b19
> # EXP-Topic push-publish
> push: config option to control behavior when pushing to a publishing server

> `hg push --publish` can be used to make push succeed even when auto-publish is
> set to 'abort'.
> 
> diff --git a/mercurial/configitems.py b/mercurial/configitems.py
> --- a/mercurial/configitems.py
> +++ b/mercurial/configitems.py
> @@ -449,6 +449,9 @@ coreconfigitem('email', 'to',
>  coreconfigitem('experimental', 'archivemetatemplate',
>  default=dynamicdefault,
>  )
> +coreconfigitem('experimental', 'auto-publish',
> +default='ignore',

auto-publish=ignore sounds like the push operation will never promote the
changesets to public. Perhaps, it can be renamed to 'allow'?

> --- a/mercurial/exchange.py
> +++ b/mercurial/exchange.py
> @@ -334,6 +334,30 @@ def _computeoutgoing(repo, heads, common
>  heads = cl.heads()
>  return discovery.outgoing(repo, common, heads)
>  
> +def _checkpublish(pushop):
> +repo = pushop.repo
> +ui = repo.ui
> +behavior = ui.config('experimental', 'auto-publish')
> +if pushop.publish or behavior not in ('warn', 'abort'):
> +return
> +remotephases = listkeys(pushop.remote, 'phases')
> +if not remotephases.get('publishing', False):
> +return
> +
> +if pushop.revs is None:
> +published = repo.filtered('served').revs('not public()')
> +else:
> +published = repo.revs('::%ln - public()', pushop.revs)
> +if published:
> +if behavior == 'warn':
> +ui.warn(_('%i changesets about to be published\n')
> +% len(published))

I don't think 'warn' is useful unless there's a reliable way to interrupt
the push operation.

> +elif behavior == 'abort':
> +msg = _('push would publish %i changesets') % len(published)
> +hint = _("behavior controlled by 'experimental.auto-publish'"
> +" config")

Shouldn't we instead suggest "hg push --publish"?
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 1 of 4 V2] perf: add a `clear-revlogs` flag to `perftags`

2018-11-24 Thread Yuya Nishihara
On Fri, 23 Nov 2018 18:25:47 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1542710780 0
> #  Tue Nov 20 10:46:20 2018 +
> # Node ID 2e15140b7b18f40ebbcf71e82c99acf8edadb69b
> # Parent  4369c00a8ee168565fba97112283bbc00be8ce44
> # EXP-Topic perf-tags
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> 2e15140b7b18
> perf: add a `clear-revlogs` flag to `perftags`
> 
> This flag (on by default) makes it possible to disable the refresh of the
> changelog and revlog. This is useful to check for the time spent in the core
> tags logic without the associated side effects. Usually, these side effects
> are shared with other logics (eg: bookmarks).
> 
> Example output in my Mercurial repository
> 
> $ hg perftags
> ! wall 0.017919 comb 0.02 user 0.02 sys 0.00 (best of 141)
> $ hg perftags --no-clear-revlogs
> ! wall 0.012982 comb 0.01 user 0.01 sys 0.00 (best of 207)
> 
> diff --git a/contrib/perf.py b/contrib/perf.py
> --- a/contrib/perf.py
> +++ b/contrib/perf.py
> @@ -528,7 +528,10 @@ def perfheads(ui, repo, **opts):
>  timer(d)
>  fm.end()
>  
> -@command(b'perftags', formatteropts)
> +@command(b'perftags', formatteropts+
> +[
> +(b'', b'clear-revlogs', True, 'refresh changelog and manifest'),
> +])
>  def perftags(ui, repo, **opts):
>  import mercurial.changelog
>  import mercurial.manifest
> @@ -537,11 +540,13 @@ def perftags(ui, repo, **opts):
>  timer, fm = gettimer(ui, opts)
>  svfs = getsvfs(repo)
>  repocleartagscache = repocleartagscachefunc(repo)
> +clearrevlogs = opts['clear_revlogs']
>  def s():
> -repo.changelog = mercurial.changelog.changelog(svfs)
> -rootmanifest = mercurial.manifest.manifestrevlog(svfs)
> -repo.manifestlog = mercurial.manifest.manifestlog(svfs, repo,
> -  rootmanifest)
> +if clearrevlogs:
> +repo.changelog = mercurial.changelog.changelog(svfs)
> +rootmanifest = mercurial.manifest.manifestrevlog(svfs)
> +repo.manifestlog = mercurial.manifest.manifestlog(svfs, repo,
> +  rootmanifest)

Can you update these to discard cached properties? It isn't your fault, but
it doesn't seem correct to replace repo attributes by new revlogs.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 3 of 4 V2] perf: add a `clear-revlogs` flag to `perfbookmarks`

2018-11-24 Thread Yuya Nishihara
On Fri, 23 Nov 2018 18:25:49 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1542711320 0
> #  Tue Nov 20 10:55:20 2018 +
> # Node ID 438718ecc3058c55b0d5a4a9742b3325b83e78cc
> # Parent  832048aabff97aa43cd306cd70cea00227f5e19e
> # EXP-Topic perf-tags
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> 438718ecc305
> perf: add a `clear-revlogs` flag to `perfbookmarks`
> 
> This flag (off by default) makes it possible to enable the refresh of the
> changelog and revlog. This is useful to check for costly side effects of
> bookmark loading.
> 
> Usually, these side effects are shared with other logics (eg: tags).
> 
> example output in my mercurial repo (with 1 bookmark, so not a great example):
> $ hg perfbookmarks
> ! wall 0.44
> $ hg perfbookmarks --clear-revlogs
> ! wall 0.001380
> 
> diff --git a/contrib/perf.py b/contrib/perf.py
> --- a/contrib/perf.py
> +++ b/contrib/perf.py
> @@ -577,13 +577,20 @@ def perfancestorset(ui, repo, revset, **
>  timer(d)
>  fm.end()
>  
> -@command(b'perfbookmarks', formatteropts)
> +@command(b'perfbookmarks', formatteropts +
> +[
> +(b'', b'clear-revlogs', False, 'refresh changelog and manifest'),
> +])
>  def perfbookmarks(ui, repo, **opts):
>  """benchmark parsing bookmarks from disk to memory"""
>  opts = _byteskwargs(opts)
>  timer, fm = gettimer(ui, opts)
>  
> +svfs = getsvfs(repo)
> +clearrevlogs = opts['clear_revlogs']
>  def s():
> +if clearrevlogs:
> +repo.changelog = mercurial.changelog.changelog(svfs)

Same here. We might want a helper function that discards revlog cache.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 2 of 4 V2] tags: cache `repo.changelog` access when checking tags nodes

2018-11-24 Thread Yuya Nishihara
On Fri, 23 Nov 2018 18:25:48 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1542710295 0
> #  Tue Nov 20 10:38:15 2018 +
> # Node ID 832048aabff97aa43cd306cd70cea00227f5e19e
> # Parent  2e15140b7b18f40ebbcf71e82c99acf8edadb69b
> # EXP-Topic perf-tags
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> 832048aabff9
> tags: cache `repo.changelog` access when checking tags nodes
> 
> The tags reading process checks if the nodes referenced in tags exist. Caching
> the access to `repo.changelog` provides a large speedup for repositories with
> many tags.
> 
> running `hg perftags` in a large private repository
> before: ! wall 0.393464 comb 0.39 user 0.33 sys 0.06 (median of 
> 25)
> after:  ! wall 0.267711 comb 0.27 user 0.21 sys 0.06 (median of 
> 38)
> 
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -1416,13 +1416,11 @@ class localrepository(object):
>  tags, tt = self._findtags()
>  else:
>  tags = self._tagscache.tags
> +rev = self.changelog.nodemap.get
>  for k, v in tags.iteritems():
> -try:
> -# ignore tags to unknown nodes
> -self.changelog.rev(v)
> +# ignore tags to unknown nodes
> +if rev(v) is not None:

It doesn't work if a tagged node is hidden.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 1 of 2] remotefilelog: drop some compatibility cruft for finding the hg exeutable

2018-11-24 Thread Yuya Nishihara
On Sat, 24 Nov 2018 01:46:36 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison 
> # Date 1543029536 18000
> #  Fri Nov 23 22:18:56 2018 -0500
> # Node ID 2abf33243bea3e4679ac944315d82fce21918d8f
> # Parent  197f7eebf5f89fb2b9d0e117157b4a040dde0a89
> remotefilelog: drop some compatibility cruft for finding the hg exeutable

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


D5299: phabricator: fallback reading arcanist config files

2018-11-24 Thread mharbison72 (Matt Harbison)
mharbison72 added inline comments.

INLINE COMMENTS

> phabricator.py:179
> +"""
> +if os.name == 'nt':
> +paths = [

pycompat.iswindows

> phabricator.py:181
> +paths = [
> +os.path.join(os.environ['ProgramData'],
> + 'Phabricator',

I think there’s something for environment variables in encoding (or maybe 
procutil- I don’t have the code in front of me).

Also, is there a way to use vfs here?  I think we’re trying to avoid direct 
os.path usage.

https://www.mercurial-scm.org/wiki/WindowsUTF8Plan

REPOSITORY
  rHG Mercurial

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

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


[PATCH 4 of 4] annotate: remove dead code to not convert path to relative path

2018-11-24 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1543057555 -32400
#  Sat Nov 24 20:05:55 2018 +0900
# Node ID 1aac31914fee54803cd5c206f0dddcc18f6120e2
# Parent  3ba66c3809b43da8216aea05b0cef15bf3a53109
annotate: remove dead code to not convert path to relative path

It's annotate. There should be at least one file path specified.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -412,8 +412,7 @@ def annotate(ui, repo, *pats, **opts):
 rootfm.startitem()
 rootfm.data(path=abs)
 if not opts.get('text') and fctx.isbinary():
-rootfm.plain(_("%s: binary file\n")
- % ((pats and m.rel(abs)) or abs))
+rootfm.plain(_("%s: binary file\n") % m.rel(abs))
 continue
 
 fm = rootfm.nested('lines', tmpl='{rev}: {line}')
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 4] annotate: start pager soon after command options are validated

2018-11-24 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1543052504 -32400
#  Sat Nov 24 18:41:44 2018 +0900
# Node ID 3ba66c3809b43da8216aea05b0cef15bf3a53109
# Parent  b37d6fbea8df01bd7ea822435f4bfce2a97112e7
annotate: start pager soon after command options are validated

It helps extracting helper class.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -333,6 +333,7 @@ def annotate(ui, repo, *pats, **opts):
 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
 ctx = scmutil.revsingle(repo, rev)
 
+ui.pager('annotate')
 rootfm = ui.formatter('annotate', opts)
 if ui.debugflag:
 shorthex = pycompat.identity
@@ -381,8 +382,6 @@ def annotate(ui, repo, *pats, **opts):
 'lineno': 'line_number',
 }
 
-ui.pager('annotate')
-
 if rootfm.isplain():
 def makefunc(get, fmt):
 return lambda x: fmt(get(x))
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 4] annotate: check and update command options first

2018-11-24 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1543052324 -32400
#  Sat Nov 24 18:38:44 2018 +0900
# Node ID b37d6fbea8df01bd7ea822435f4bfce2a97112e7
# Parent  4c5309a4bd4028c260fcc6ceda1ba48167e8733e
annotate: check and update command options first

It helps extracting helper class.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -320,6 +320,14 @@ def annotate(ui, repo, *pats, **opts):
 # to mimic the behavior of Mercurial before version 1.5
 opts['file'] = True
 
+if (not opts.get('user') and not opts.get('changeset')
+and not opts.get('date') and not opts.get('file')):
+opts['number'] = True
+
+linenumber = opts.get('line_number') is not None
+if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
+raise error.Abort(_('at least one of -n/-c is required for -l'))
+
 rev = opts.get('rev')
 if rev:
 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
@@ -373,14 +381,6 @@ def annotate(ui, repo, *pats, **opts):
 'lineno': 'line_number',
 }
 
-if (not opts.get('user') and not opts.get('changeset')
-and not opts.get('date') and not opts.get('file')):
-opts['number'] = True
-
-linenumber = opts.get('line_number') is not None
-if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
-raise error.Abort(_('at least one of -n/-c is required for -l'))
-
 ui.pager('annotate')
 
 if rootfm.isplain():
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 4] annotate: format local tables in less-dense form

2018-11-24 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1543052204 -32400
#  Sat Nov 24 18:36:44 2018 +0900
# Node ID 4c5309a4bd4028c260fcc6ceda1ba48167e8733e
# Parent  50a64c321c1e74b98ec1fa959bdc92efdc6f4ee7
annotate: format local tables in less-dense form

I'll move these to a class, where one-extra indent will be needed.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -358,15 +358,20 @@ def annotate(ui, repo, *pats, **opts):
 formatrev = b'%d'.__mod__
 formathex = shorthex
 
-opmap = [('user', ' ', lambda x: x.fctx.user(), ui.shortuser),
- ('rev', ' ', lambda x: scmutil.intrev(x.fctx), formatrev),
- ('node', ' ', lambda x: hex(scmutil.binnode(x.fctx)), formathex),
- ('date', ' ', lambda x: x.fctx.date(), util.cachefunc(datefunc)),
- ('path', ' ', lambda x: x.fctx.path(), pycompat.bytestr),
- ('lineno', ':', lambda x: x.lineno, pycompat.bytestr),
-]
-opnamemap = {'rev': 'number', 'node': 'changeset', 'path': 'file',
- 'lineno': 'line_number'}
+opmap = [
+('user', ' ', lambda x: x.fctx.user(), ui.shortuser),
+('rev', ' ', lambda x: scmutil.intrev(x.fctx), formatrev),
+('node', ' ', lambda x: hex(scmutil.binnode(x.fctx)), formathex),
+('date', ' ', lambda x: x.fctx.date(), util.cachefunc(datefunc)),
+('path', ' ', lambda x: x.fctx.path(), pycompat.bytestr),
+('lineno', ':', lambda x: x.lineno, pycompat.bytestr),
+]
+opnamemap = {
+'rev': 'number',
+'node': 'changeset',
+'path': 'file',
+'lineno': 'line_number',
+}
 
 if (not opts.get('user') and not opts.get('changeset')
 and not opts.get('date') and not opts.get('file')):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel