D6709: config: add --all flag to show all known configs

2019-08-02 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 16117.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6709?vs=16114=16117

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6709/new/

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/ui.py
  tests/test-completion.t
  tests/test-config.t

CHANGE DETAILS

diff --git a/tests/test-config.t b/tests/test-config.t
--- a/tests/test-config.t
+++ b/tests/test-config.t
@@ -222,3 +222,452 @@
   > done
   $ HGRCPATH=configs hg config section.key
   99
+
+test --all flag
+
+  $ hg showconfig --all
+  annotate.git=False
+  annotate.ignoreblanklines=False
+  annotate.ignorews=False
+  annotate.ignorewsamount=False
+  annotate.ignorewseol=False
+  annotate.nobinary=False
+  annotate.nodates=False
+  annotate.noprefix=False
+  annotate.showfunc=False
+  annotate.unified=None
+  annotate.word-diff=False
+  auth.cookiefile=None
+  bookmarks.pushing=[]
+  bundle.mainreporoot=$TESTTMP
+  censor.policy=abort
+  chgserver.idletimeout=3600
+  chgserver.skiphash=False
+  cmdserver.log=None
+  cmdserver.max-log-files=7
+  cmdserver.max-log-size=1 MB
+  cmdserver.max-repo-cache=0
+  cmdserver.message-encodings=[]
+  cmdserver.track-log=['chgserver', 'cmdserver', 'repocache']
+  color..*=None
+  color.mode=auto
+  commands.commit.interactive.git=False
+  commands.commit.interactive.ignoreblanklines=False
+  commands.commit.interactive.ignorews=False
+  commands.commit.interactive.ignorewsamount=False
+  commands.commit.interactive.ignorewseol=False
+  commands.commit.interactive.nobinary=False
+  commands.commit.interactive.nodates=False
+  commands.commit.interactive.noprefix=False
+  commands.commit.interactive.showfunc=False
+  commands.commit.interactive.unified=None
+  commands.commit.interactive.word-diff=False
+  commands.commit.post-status=False
+  commands.grep.all-files=False
+  commands.rebase.requiredest=False
+  commands.resolve.confirm=False
+  commands.resolve.explicit-re-merge=False
+  commands.resolve.mark-check=none
+  commands.revert.interactive.git=False
+  commands.revert.interactive.ignoreblanklines=False
+  commands.revert.interactive.ignorews=False
+  commands.revert.interactive.ignorewsamount=False
+  commands.revert.interactive.ignorewseol=False
+  commands.revert.interactive.nobinary=False
+  commands.revert.interactive.nodates=False
+  commands.revert.interactive.noprefix=False
+  commands.revert.interactive.showfunc=False
+  commands.revert.interactive.unified=None
+  commands.revert.interactive.word-diff=False
+  commands.show.aliasprefix=[]
+  commands.status.relative=False
+  commands.status.skipstates=[]
+  commands.status.terse=
+  commands.status.verbose=False
+  commands.update.check=None
+  commands.update.requiredest=False
+  committemplate..*=None
+  convert.bzr.saverev=True
+  convert.cvsps.cache=True
+  convert.cvsps.fuzz=60
+  convert.cvsps.logencoding=None
+  convert.cvsps.mergefrom=None
+  convert.cvsps.mergeto=None
+  convert.git.committeractions=['messagedifferent']
+  convert.git.extrakeys=[]
+  convert.git.findcopiesharder=False
+  convert.git.remoteprefix=remote
+  convert.git.renamelimit=400
+  convert.git.saverev=True
+  convert.git.similarity=50
+  convert.git.skipsubmodules=False
+  convert.hg.clonebranches=False
+  convert.hg.ignoreerrors=False
+  convert.hg.preserve-hash=False
+  convert.hg.revs=None
+  convert.hg.saverev=False
+  convert.hg.sourcename=None
+  convert.hg.startrev=None
+  convert.hg.tagsbranch=default
+  convert.hg.usebranchnames=True
+  convert.ignoreancestorcheck=False
+  convert.localtimezone=False
+  convert.p4.startrev=0
+  convert.skiptags=False
+  convert.svn.branches=None
+  convert.svn.debugsvnlog=True
+  convert.svn.startrev=0
+  convert.svn.tags=None
+  convert.svn.trunk=None
+  debug.dirstate.delaywrite=0
+  defaults..*=None
+  devel.all-warnings=true
+  devel.bundle.delta=
+  devel.bundle2.debug=False
+  devel.cache-vfs=None
+  devel.check-locks=False
+  devel.check-relroot=False
+  devel.debug.copies=False
+  devel.debug.extensions=False
+  devel.debug.peer-request=False
+  devel.default-date=0 0
+  devel.deprec-warn=False
+  devel.disableloaddefaultcerts=False
+  devel.legacy.exchange=[]
+  devel.servercafile=
+  devel.serverexactprotocol=
+  devel.serverrequirecert=False
+  devel.strip-obsmarkers=True
+  devel.user.obsmarker=None
+  devel.warn-config=None
+  devel.warn-config-default=None
+  devel.warn-config-unknown=None
+  devel.warn-empty-changegroup=False
+  diff.git=False
+  diff.ignoreblanklines=False
+  diff.ignorews=False
+  diff.ignorewsamount=False
+  diff.ignorewseol=False
+  diff.nobinary=False
+  diff.nodates=False
+  diff.noprefix=False
+  diff.showfunc=False
+  diff.unified=None
+  diff.word-diff=False
+  email.bcc=None
+  email.cc=None
+  email.charsets=[]
+  email.from=None
+  email.method=smtp
+  email.reply-to=None
+  email.to=None
+  experimental.auto-publish=publish
+  

D6710: branchmap: properly refresh/warm all branchmap caches

2019-08-02 Thread spectral (Kyle Lippincott)
spectral added a comment.
spectral planned changes to this revision.


  Needs some test updates.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6710/new/

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

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


D6710: branchmap: properly refresh/warm all branchmap caches

2019-08-02 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The comment about 'served' refreshing all the others only applies when served 
is
  the head of the branchmap cache subsets. This was already no longer the case
  (and is presumably why served.hidden was added) but the comment was not
  adjusted. Currently, the "heads" of the branchmap cache subsets are the three
  specified here: visible, visible-hidden, served.hidden.
  
  Additionally, 'full' claims it will warm all of the caches that are known 
about,
  but this is not the case - it does not actually warm the branchmap caches for
  subsets that we haven't requested or for subsets that are still considered
  "valid".

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/localrepo.py

CHANGE DETAILS

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2192,10 +2192,13 @@
 return
 
 if tr is None or tr.changes['origrepolen'] < len(self):
-# accessing the 'ser ved' branchmap should refresh all the others,
+# There are three "heads" to the cache hierarchy: visible,
+# visible-hidden, and served.hidden. Updating any of these three
+# should cause all of the others (currently: served, immutable,
+# base) that are stale to be updated.
 self.ui.debug('updating the branch cache\n')
-self.filtered('served').branchmap()
-self.filtered('served.hidden').branchmap()
+for filt in ['visible', 'visible-hidden', 'served.hidden']:
+self.filtered(filt).branchmap()
 
 if full:
 unfi = self.unfiltered()
@@ -2214,6 +2217,12 @@
 self.tags()
 self.filtered('served').tags()
 
+# Warm the branchmap caches even for caches we haven't needed yet,
+# including forcing a write to disk.
+for filt in repoview.filtertable.keys():
+filtered = self.filtered(filt)
+filtered.branchmap().write(filtered)
+
 def invalidatecaches(self):
 
 if r'_tagscache' in vars(self):



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


D6711: branchheads: store wdir-dependent caches in wcache (issue6181)

2019-08-02 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Previously, all branch2-* caches were stored in .hg/cache, which is shared
  across repos when using `hg share`. This can cause cache thrashing when the
  repos are accessed concurrently, since some of the caches depend on wdir state
  (which is NOT shared across the repos).
  
  There's already a cache directory for caches that depend on wdir state, 
wcache,
  so let's just put the caches there.
  
  This change does not clean up any existing caches in .hg/cache that are now
  moved to the new location, and it does not re-use the caches from that 
location
  when constructing them in the wcache directory. Upgrades to versions of
  Mercurial that have this commit will need to regenerate their branchheads 
once, and
  this may be an expensive operation.
  
  The format of these cache files is not changing - forwards/backwards
  compatibility remains; if a newer repo (with these in wcache) is accessed by 
an
  older hg, the older hg will either see the files that remain in .hg/cache, and
  update them there, or will not see the files at all and will fall back to a
  slower path (and then likely cache them in .hg/cache). If it's then accessed 
by
  a newer hg, the work done by the older hg is ignored, and the wcache copies 
are
  brought up to date.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/branchmap.py
  mercurial/utils/repoviewutil.py
  tests/test-branchmap-cache.t

CHANGE DETAILS

diff --git a/tests/test-branchmap-cache.t b/tests/test-branchmap-cache.t
new file mode 100644
--- /dev/null
+++ b/tests/test-branchmap-cache.t
@@ -0,0 +1,38 @@
+  $ cat >> $HGRCPATH << EOF
+  > [extensions]
+  > share=
+  > [experimental]
+  > evolution=createmarkers
+  > EOF
+  $ hg init -q orig
+  $ cd orig
+  $ echo hi > foo
+  $ hg ci -qAm initial_rev0
+  $ echo "hi again" >> foo
+  $ hg ci -qAm "hi again rev1"
+  $ hg commit -q --amend -m "obsoleted 1, this is rev2"
+  $ cd ..
+  $ hg share -q orig other
+  $ cd other
+  $ hg co -qr 1 --hidden
+  updated to hidden changeset a3571a6d8234
+  (hidden revision 'a3571a6d8234' was rewritten as: 0444ce380f11)
+  $ cd ..
+
+Forcefully update the caches in each repo once; we're not using --debug since 
we
+know that these are going to update some/all of the caches, we don't need to
+know which.
+  $ hg -R orig debugupdatecache
+  $ hg -R other debugupdatecache
+
+The branchheads caches should not change just because we're accessing from a
+different repo each time. If they were stale, we'd get another line in the
+output per filtername that's stale.
+  $ hg -R orig debugupdatecache --debug
+  updating the branch cache
+  $ hg -R other debugupdatecache --debug
+  updating the branch cache
+  $ hg -R orig debugupdatecache --debug
+  updating the branch cache
+  $ hg -R other debugupdatecache --debug
+  updating the branch cache
diff --git a/mercurial/utils/repoviewutil.py b/mercurial/utils/repoviewutil.py
--- a/mercurial/utils/repoviewutil.py
+++ b/mercurial/utils/repoviewutil.py
@@ -20,3 +20,8 @@
'served.hidden': 'served',
'served': 'immutable',
'immutable': 'base'}
+
+# List of views that are potentially dependent upon wdir state (such as the
+# current parents of the working directory) and need to be kept in wcache
+# instead of cache.
+wdirdependent = frozenset(['served', 'visible', 'visible-hidden'])
diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -221,7 +221,7 @@
 def fromfile(cls, repo):
 f = None
 try:
-f = repo.cachevfs(cls._filename(repo))
+f = cls._opencachefile(repo)
 lineiter = iter(f)
 cachekey = next(lineiter).rstrip('\n').split(" ", 2)
 last, lrev = cachekey[:2]
@@ -271,12 +271,15 @@
 self._closednodes.add(node)
 
 @staticmethod
-def _filename(repo):
+def _opencachefile(repo, *args, **kwargs):
 """name of a branchcache file for a given repo or repoview"""
 filename = "branch2"
+vfs = repo.cachevfs
 if repo.filtername:
 filename = '%s-%s' % (filename, repo.filtername)
-return filename
+if repo.filtername in repoviewutil.wdirdependent:
+vfs = repo.wcachevfs
+return vfs(filename, *args, **kwargs)
 
 def validfor(self, repo):
 """Is the cache content valid regarding a repo
@@ -335,7 +338,7 @@
 
 def write(self, repo):
 try:
-f = repo.cachevfs(self._filename(repo), "w", atomictemp=True)
+f = self._opencachefile(repo, "w", atomictemp=True)
 cachekey = [hex(self.tipnode), '%d' % self.tiprev]
 if self.filteredhash is not None:
 cachekey.append(hex(self.filteredhash))



To: 

Re: [PATCH 3 of 5] byteify-strings: add test for byteify-strings.py

2019-08-02 Thread Yuya Nishihara
On Fri, 02 Aug 2019 17:01:24 +0200, Raphaël Gomès wrote:
> # HG changeset patch
> # User Raphaël Gomès 
> # Date 1564757642 -7200
> #  Fri Aug 02 16:54:02 2019 +0200
> # Node ID 91a17ea759c5f0fceaae18fb558435ab379faac7
> # Parent  fea16ec00093e73bf0aa4db3f2a709c385fc6336
> # EXP-Topic byteify-strings
> byteify-strings: add test for byteify-strings.py
> 
> This tests the basic features expected from this script, some cases may not
> be covered yet.
> 
> A future patch will demonstrate an issue with multi-line `(`, `[` and `{`
> alignment and propose a fix.
> 
> diff -r fea16ec00093 -r 91a17ea759c5 tests/test-byteify-strings.t
> --- /dev/null Thu Jan 01 00:00:00 1970 +
> +++ b/tests/test-byteify-strings.tFri Aug 02 16:54:02 2019 +0200
> @@ -0,0 +1,195 @@

Needs #require py3

> +Test in-place
> +
> +  $ cat > testfile.py < +  > obj['test'] = b"1234"
> +  > mydict.iteritems()
> +  > EOF
> +  $ python $BINDIR/contrib/byteify-strings.py testfile.py -i

Probably better to use $PYTHON.
And it should be $TESTDIR/../contrib. You can add a shell function.

  $ byteify-strings () {
  >   $PYTHON "$TESTDIR/../contrib/byteify-strings.py" "$@"
  > }
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 5 of 5] byteify-strings: fix alignment issue

2019-08-02 Thread Yuya Nishihara
On Fri, 02 Aug 2019 17:01:26 +0200, Raphaël Gomès wrote:
> # HG changeset patch
> # User Raphaël Gomès 
> # Date 1564758059 -7200
> #  Fri Aug 02 17:00:59 2019 +0200
> # Node ID 91da691d3bbc18d32760179e4012047505c244b8
> # Parent  1ae95b109c557785f566d307c13ded3eedc73dd9
> # EXP-Topic byteify-strings
> byteify-strings: fix alignment issue
> 
> While removing this `if` statement fixes the alignment issue, I could not
> figure out what it was intended for despite its comment, and I am hoping its
> author Yuya can help me fix both issues at the same time.
> 
> diff -r 1ae95b109c55 -r 91da691d3bbc contrib/byteify-strings.py
> --- a/contrib/byteify-strings.py  Fri Aug 02 16:57:22 2019 +0200
> +++ b/contrib/byteify-strings.py  Fri Aug 02 17:00:59 2019 +0200
> @@ -134,9 +134,6 @@
>  if coloffset < 0:
>  if t.start[1] == parens[-1][1]:
>  coloffset = parens[-1][2]
> -elif t.start[1] + 1 == parens[-1][1]:
> -# fix misaligned indent of s/util.Abort/error.Abort/
> -coloffset = parens[-1][2] + (parens[-1][1] - t.start[1])

It handles the following example:

  $ cat > misaligned.py <<'EOF'
  > def foo():
  > error.Abort(_("foo"
  >  "bar"
  >  "%s")
  >% parameter)
  > EOF
  $ $PYTHON $BINDIR/contrib/byteify-strings.py misaligned.py
  def foo():
  error.Abort(_(b"foo"
b"bar"
b"%s")
  % parameter)

Perhaps, we'll need to check the token right after the opening paren. If
the token is whitespace-ish, the paired paren should be at the same column.

{
}

If not, it should be at the end column of the opening paren.

{foo,
 }

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


Re: [PATCH 1 of 5] byteify-strings: simplify default value for `--treat-as-kwargs`

2019-08-02 Thread Yuya Nishihara
On Fri, 02 Aug 2019 17:01:22 +0200, Raphaël Gomès wrote:
> # HG changeset patch
> # User Raphaël Gomès 
> # Date 1564755240 -7200
> #  Fri Aug 02 16:14:00 2019 +0200
> # Node ID 4a3e6c4ac759ed0d7678980328c0dec3824192ea
> # Parent  f95b59ffc307c4549d9640a81d750a99bd75f423
> # EXP-Topic byteify-strings
> byteify-strings: simplify default value for `--treat-as-kwargs`

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


[Bug 6181] New: branchmap cache stores non-store-specific caches in shared cache

2019-08-02 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=6181

Bug ID: 6181
   Summary: branchmap cache stores non-store-specific caches in
shared cache
   Product: Mercurial
   Version: unspecified
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: feature
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: h...@pewpew.net
CC: mercurial-devel@mercurial-scm.org

Created attachment 2054
  --> https://bz.mercurial-scm.org/attachment.cgi?id=2054=edit
.t test demonstrating issue

Reproduction setup:

hg init orig
cd orig
echo hi > foo
hg ci -qAm initial_rev0
echo "hi again" >> foo
hg ci -qAm "hi again rev1"
hg prune -r .   # automatically goes to rev0
cd ..
hg share orig other
cd other
hg co -r 1 --hidden
cd ..


We now have:

repo 'orig', with rev0 checked out, and rev1 is considered "hidden"
repo 'other', with rev1 checked out, so it's NOT considered "hidden"

Operations in 'other' will write to orig/.hg/cache/branch2-served saying that
rev1 is part of that set. Operations in 'orig' will write to that same file
saying that it is *not*.


Proof:
hg -R orig log -r 'public()' >/dev/null
cat orig/.hg/cache/branch2-served
hg -R other log -r 'public()' >/dev/null
cat orig/.hg/cache/branch2-served
hg -R orig log -r 'public()' >/dev/null
cat orig/.hg/cache/branch2-served

The branch2-served file will flip-flop between considering rev1 as the tip and
rev0, depending on the most recent repo to access it. 

The attached .t file will also demonstrate this issue.

The other caches, besides -served, are probably fine. The caches are: 
- unfiltered, a superset of visible
- visible-hidden, a superset of visible
- visible, a superset of served
- served.hidden, a superset of served
- served, a superset of immutable
- immutable, a superset of base

Here's what I believe is a description of each cache type:

- base: this appears to be "the set of public (immutable) changes, starting at
0, that have no mutable revision between the min and the max of the set". i.e.
if rev0, rev1, and rev3 are public, but rev2 is draft, this will only include
{0, 1}. This cache is based entirely on phaseroots, and is safe to put in
shared cache.
- immutable: all "public" revisions. Again, based on phaseroots, safe in shared
cache.
- served: any commit not considered "hidden" or in "secret" (or above:
internal/archived) phases. Since "hidden"ness is wdir-dependent, this is NOT
safe in shared cache.
- served.hidden: served + hidden, aka "secret" (or above). Only uses
phaseroots, safe in shared cache.
- visible and visible-hidden appear to be identical: "not hidden". These are
probably also NOT safe in shared cache, but `hg debugupdatecache` doesn't
update visible or visible-hidden, so it's a little harder to prove in testing
currently.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[Bug 6180] New: pruning while rebasing confuses rebase

2019-08-02 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=6180

Bug ID: 6180
   Summary: pruning while rebasing confuses rebase
   Product: Mercurial
   Version: 4.8
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: feature
  Priority: wish
 Component: rebase
  Assignee: bugzi...@mercurial-scm.org
  Reporter: martinv...@google.com
CC: mercurial-devel@mercurial-scm.org

The test case below starts a rebase of 2 commits and runs into conflicts on the
first one. We then decide we don't want the changes from that commit, so we
revert the changes and also prune the original commit. When we continue the
rebase, the second commit is also pruned. Perhaps the evolve extension should
disallow `hg prune` during rebase, but it still seems like rebase should behave
better in this case.


  $ cat >> $HGRCPATH < [experimental]
  > evolution.createmarkers=True
  > evolution.allowunstable=True
  >
  > [extensions]
  > rebase=
  >
  > [alias]
  > tglog = log -G --template "{rev}:{phase} '{desc}' {branches}\n"
  > EOF

  $ hg init repo
  $ cd repo
  $ echo 0 > a
  $ hg ci -Aqm 'add a'
  $ echo 1 > a
  $ hg ci -m 'edit a'
  $ hg co -q 0
  $ echo 2 > a
  $ hg ci -qm 'conflict in a'
  $ echo 3 > b
  $ hg ci -Aqm 'add b'
  $ hg tglog
  @  3:draft 'add b'
  |
  o  2:draft 'conflict in a'
  |
  | o  1:draft 'edit a'
  |/
  o  0:draft 'add a'

  $ hg rebase -d 1
  rebasing 2:06a50ac6b5ab "conflict in a"
  merging a
  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')  
  unresolved conflicts (see hg resolve, then hg rebase --continue)  
  [1]
  $ echo 1 > a
  $ hg debugobsolete $(hg id -ir 2 --debug)
  obsoleted 1 changesets
  1 new orphan changesets
  $ hg resolve -m
  (no more unresolved files)
  continue: hg rebase --continue
  $ hg rebase -c
  note: not rebasing 2:06a50ac6b5ab "conflict in a", it has no successor
  rebasing 3:aea370672fd7 "add b" (tip)
  note: not rebasing 3:aea370672fd7 "add b" (tip), its destination already has
all its changes
  $ hg tglog
  @  1:draft 'edit a'
  |
  o  0:draft 'add a'

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 5] byteify-strings: simplify default value for `--treat-as-kwargs`

2019-08-02 Thread Raphaël Gomès
# HG changeset patch
# User Raphaël Gomès 
# Date 1564755240 -7200
#  Fri Aug 02 16:14:00 2019 +0200
# Node ID 4a3e6c4ac759ed0d7678980328c0dec3824192ea
# Parent  f95b59ffc307c4549d9640a81d750a99bd75f423
# EXP-Topic byteify-strings
byteify-strings: simplify default value for `--treat-as-kwargs`

diff -r f95b59ffc307 -r 4a3e6c4ac759 contrib/byteify-strings.py
--- a/contrib/byteify-strings.pyFri Aug 02 10:18:22 2019 +0200
+++ b/contrib/byteify-strings.pyFri Aug 02 16:14:00 2019 +0200
@@ -276,15 +276,13 @@
 help='edit files in place')
 ap.add_argument('--dictiter', action='store_true', default=False,
 help='rewrite iteritems() and itervalues()'),
-ap.add_argument('--treat-as-kwargs', nargs="+",
+ap.add_argument('--treat-as-kwargs', nargs="+", default=[],
 help="ignore kwargs-like objects"),
 ap.add_argument('files', metavar='FILE', nargs='+', help='source file')
 args = ap.parse_args()
 opts = {
 'dictiter': args.dictiter,
-'treat-as-kwargs': set(
-args.treat_as_kwargs
-) if args.treat_as_kwargs else set()
+'treat-as-kwargs': set(args.treat_as_kwargs),
 }
 for fname in args.files:
 if args.inplace:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 5 of 5] byteify-strings: fix alignment issue

2019-08-02 Thread Raphaël Gomès
# HG changeset patch
# User Raphaël Gomès 
# Date 1564758059 -7200
#  Fri Aug 02 17:00:59 2019 +0200
# Node ID 91da691d3bbc18d32760179e4012047505c244b8
# Parent  1ae95b109c557785f566d307c13ded3eedc73dd9
# EXP-Topic byteify-strings
byteify-strings: fix alignment issue

While removing this `if` statement fixes the alignment issue, I could not
figure out what it was intended for despite its comment, and I am hoping its
author Yuya can help me fix both issues at the same time.

diff -r 1ae95b109c55 -r 91da691d3bbc contrib/byteify-strings.py
--- a/contrib/byteify-strings.pyFri Aug 02 16:57:22 2019 +0200
+++ b/contrib/byteify-strings.pyFri Aug 02 17:00:59 2019 +0200
@@ -134,9 +134,6 @@
 if coloffset < 0:
 if t.start[1] == parens[-1][1]:
 coloffset = parens[-1][2]
-elif t.start[1] + 1 == parens[-1][1]:
-# fix misaligned indent of s/util.Abort/error.Abort/
-coloffset = parens[-1][2] + (parens[-1][1] - t.start[1])
 else:
 coloffset = 0
 
diff -r 1ae95b109c55 -r 91da691d3bbc tests/test-byteify-strings.t
--- a/tests/test-byteify-strings.t  Fri Aug 02 16:57:22 2019 +0200
+++ b/tests/test-byteify-strings.t  Fri Aug 02 17:00:59 2019 +0200
@@ -216,6 +216,6 @@
   (b'a', b'b'),
   {
   b'aslkdjf',
-   }
-   ]
+  }
+  ]
   )
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 4 of 5] byteify-strings: demonstrate an issue with multi-line parenthesis alignment

2019-08-02 Thread Raphaël Gomès
# HG changeset patch
# User Raphaël Gomès 
# Date 1564757842 -7200
#  Fri Aug 02 16:57:22 2019 +0200
# Node ID 1ae95b109c557785f566d307c13ded3eedc73dd9
# Parent  91a17ea759c5f0fceaae18fb558435ab379faac7
# EXP-Topic byteify-strings
byteify-strings: demonstrate an issue with multi-line parenthesis alignment

diff -r 91a17ea759c5 -r 1ae95b109c55 tests/test-byteify-strings.t
--- a/tests/test-byteify-strings.t  Fri Aug 02 16:54:02 2019 +0200
+++ b/tests/test-byteify-strings.t  Fri Aug 02 16:57:22 2019 +0200
@@ -193,3 +193,29 @@
   $ python $BINDIR/contrib/byteify-strings.py testfile.py
   obj[b'test'] = b"1234"
   obj[r'test'] = u"1234"
+
+Test preserve alignment
+
+  $ cat > testfile.py < @test(
+  > 'test',
+  > [
+  > ('a', 'b'),
+  > ('a', 'b'),
+  > {
+  > 'aslkdjf',
+  > }
+  > ]
+  > )
+  > EOF
+  $ python $BINDIR/contrib/byteify-strings.py testfile.py
+  @test(
+  b'test',
+  [
+  (b'a', b'b'),
+  (b'a', b'b'),
+  {
+  b'aslkdjf',
+   }
+   ]
+  )
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 5] byteify-strings: add test for byteify-strings.py

2019-08-02 Thread Raphaël Gomès
# HG changeset patch
# User Raphaël Gomès 
# Date 1564757642 -7200
#  Fri Aug 02 16:54:02 2019 +0200
# Node ID 91a17ea759c5f0fceaae18fb558435ab379faac7
# Parent  fea16ec00093e73bf0aa4db3f2a709c385fc6336
# EXP-Topic byteify-strings
byteify-strings: add test for byteify-strings.py

This tests the basic features expected from this script, some cases may not
be covered yet.

A future patch will demonstrate an issue with multi-line `(`, `[` and `{`
alignment and propose a fix.

diff -r fea16ec00093 -r 91a17ea759c5 tests/test-byteify-strings.t
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/tests/test-byteify-strings.t  Fri Aug 02 16:54:02 2019 +0200
@@ -0,0 +1,195 @@
+Test in-place
+
+  $ cat > testfile.py < obj['test'] = b"1234"
+  > mydict.iteritems()
+  > EOF
+  $ python $BINDIR/contrib/byteify-strings.py testfile.py -i
+  $ cat testfile.py
+  obj[b'test'] = b"1234"
+  mydict.iteritems()
+
+Test with dictiter
+
+  $ cat > testfile.py < obj['test'] = b"1234"
+  > mydict.iteritems()
+  > EOF
+  $ python $BINDIR/contrib/byteify-strings.py testfile.py --dictiter
+  obj[b'test'] = b"1234"
+  mydict.items()
+
+Test kwargs-like objects
+
+  $ cat > testfile.py < kwargs['test'] = "123"
+  > kwargs[test['testing']]
+  > kwargs[test[[['testing'
+  > kwargs[kwargs['testing']]
+  > kwargs.get('test')
+  > kwargs.pop('test')
+  > kwargs.get('test', 'testing')
+  > kwargs.pop('test', 'testing')
+  > kwargs.setdefault('test', 'testing')
+  > 
+  > opts['test'] = "123"
+  > opts[test['testing']]
+  > opts[test[[['testing'
+  > opts[opts['testing']]
+  > opts.get('test')
+  > opts.pop('test')
+  > opts.get('test', 'testing')
+  > opts.pop('test', 'testing')
+  > opts.setdefault('test', 'testing')
+  > 
+  > commitopts['test'] = "123"
+  > commitopts[test['testing']]
+  > commitopts[test[[['testing'
+  > commitopts[commitopts['testing']]
+  > commitopts.get('test')
+  > commitopts.pop('test')
+  > commitopts.get('test', 'testing')
+  > commitopts.pop('test', 'testing')
+  > commitopts.setdefault('test', 'testing')
+  > EOF
+  $ python $BINDIR/contrib/byteify-strings.py testfile.py --treat-as-kwargs 
kwargs opts commitopts
+  kwargs['test'] = b"123"
+  kwargs[test[b'testing']]
+  kwargs[test[[[b'testing'
+  kwargs[kwargs['testing']]
+  kwargs.get('test')
+  kwargs.pop('test')
+  kwargs.get('test', b'testing')
+  kwargs.pop('test', b'testing')
+  kwargs.setdefault('test', b'testing')
+  
+  opts['test'] = b"123"
+  opts[test[b'testing']]
+  opts[test[[[b'testing'
+  opts[opts['testing']]
+  opts.get('test')
+  opts.pop('test')
+  opts.get('test', b'testing')
+  opts.pop('test', b'testing')
+  opts.setdefault('test', b'testing')
+  
+  commitopts['test'] = b"123"
+  commitopts[test[b'testing']]
+  commitopts[test[[[b'testing'
+  commitopts[commitopts['testing']]
+  commitopts.get('test')
+  commitopts.pop('test')
+  commitopts.get('test', b'testing')
+  commitopts.pop('test', b'testing')
+  commitopts.setdefault('test', b'testing')
+
+Test attr*() as methods
+
+  $ cat > testfile.py < setattr(o, 'a', 1)
+  > util.setattr(o, 'ae', 1)
+  > util.getattr(o, 'alksjdf', 'default')
+  > util.addattr(o, 'asdf')
+  > util.hasattr(o, 'lksjdf', 'default')
+  > util.safehasattr(o, 'lksjdf', 'default')
+  > @eh.wrapfunction(func, 'lksjdf')
+  > @eh.wrapclass(klass, 'lksjdf')
+  > EOF
+  $ python $BINDIR/contrib/byteify-strings.py testfile.py --allow-attr-methods
+  setattr(o, 'a', 1)
+  util.setattr(o, 'ae', 1)
+  util.getattr(o, 'alksjdf', b'default')
+  util.addattr(o, 'asdf')
+  util.hasattr(o, 'lksjdf', b'default')
+  util.safehasattr(o, 'lksjdf', b'default')
+  @eh.wrapfunction(func, 'lksjdf')
+  @eh.wrapclass(klass, 'lksjdf')
+
+Test without attr*() as methods
+
+  $ cat > testfile.py < setattr(o, 'a', 1)
+  > util.setattr(o, 'ae', 1)
+  > util.getattr(o, 'alksjdf', 'default')
+  > util.addattr(o, 'asdf')
+  > util.hasattr(o, 'lksjdf', 'default')
+  > util.safehasattr(o, 'lksjdf', 'default')
+  > @eh.wrapfunction(func, 'lksjdf')
+  > @eh.wrapclass(klass, 'lksjdf')
+  > EOF
+  $ python $BINDIR/contrib/byteify-strings.py testfile.py
+  setattr(o, 'a', 1)
+  util.setattr(o, b'ae', 1)
+  util.getattr(o, b'alksjdf', b'default')
+  util.addattr(o, b'asdf')
+  util.hasattr(o, b'lksjdf', b'default')
+  util.safehasattr(o, b'lksjdf', b'default')
+  @eh.wrapfunction(func, b'lksjdf')
+  @eh.wrapclass(klass, b'lksjdf')
+
+Test ignore comments
+
+  $ cat > testfile.py < #py3-transform: off
+  > "none"
+  > "of"
+  > 'these'
+  > s = """should"""
+  > d = '''be'''
+  > #py3-transform: on
+  > "this should"
+  > 'and this also'
+  > 
+  > #no-py3-transform
+  > l = "this should be ignored"
+  > l2 = "this shouldn't"
+  > 
+  > EOF
+  $ python $BINDIR/contrib/byteify-strings.py testfile.py
+  #py3-transform: off
+  "none"
+  "of"
+  'these'
+  s = """should"""
+  d = '''be'''
+  #py3-transform: on
+  b"this should"
+  b'and this also'
+  
+  #no-py3-transform
+  l = "this should be ignored"
+  l2 = b"this 

[PATCH 2 of 5] byteify-strings: add cli argument to handle `attr*()` when they are methods

2019-08-02 Thread Raphaël Gomès
# HG changeset patch
# User Raphaël Gomès 
# Date 1564755422 -7200
#  Fri Aug 02 16:17:02 2019 +0200
# Node ID fea16ec00093e73bf0aa4db3f2a709c385fc6336
# Parent  4a3e6c4ac759ed0d7678980328c0dec3824192ea
# EXP-Topic byteify-strings
byteify-strings: add cli argument to handle `attr*()` when they are methods

Certain code bases have useful utils that wrap the builtin functions, and are
called like `util.setattr`.

diff -r 4a3e6c4ac759 -r fea16ec00093 contrib/byteify-strings.py
--- a/contrib/byteify-strings.pyFri Aug 02 16:14:00 2019 +0200
+++ b/contrib/byteify-strings.pyFri Aug 02 16:17:02 2019 +0200
@@ -208,8 +208,10 @@
 fn = t.string
 
 # *attr() builtins don't accept byte strings to 2nd argument.
-if (fn in ('getattr', 'setattr', 'hasattr', 'safehasattr') and
-not _isop(i - 1, '.')):
+if fn in (
+'getattr', 'setattr', 'hasattr', 'safehasattr', 'wrapfunction',
+'wrapclass', 'addattr'
+) and (opts['allow-attr-methods'] or not _isop(i - 1, '.')):
 arg1idx = _findargnofcall(1)
 if arg1idx is not None:
 _ensuresysstr(arg1idx)
@@ -276,6 +278,9 @@
 help='edit files in place')
 ap.add_argument('--dictiter', action='store_true', default=False,
 help='rewrite iteritems() and itervalues()'),
+ap.add_argument('--allow-attr-methods', action='store_true',
+default=False,
+help='also handle attr*() when they are methods'),
 ap.add_argument('--treat-as-kwargs', nargs="+", default=[],
 help="ignore kwargs-like objects"),
 ap.add_argument('files', metavar='FILE', nargs='+', help='source file')
@@ -283,6 +288,7 @@
 opts = {
 'dictiter': args.dictiter,
 'treat-as-kwargs': set(args.treat_as_kwargs),
+'allow-attr-methods': args.allow_attr_methods,
 }
 for fname in args.files:
 if args.inplace:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6704: config: add defaultvalue template keyword

2019-08-02 Thread yuja (Yuya Nishihara)
yuja added a comment.


  > +def configdefault(self, section, name):
  > +"""returns the default value of the config item"""
  > +item = self._knownconfig.get(section, {}).get(name)
  > +itemdefault = None
  > +if item is not None:
  > +if callable(item.default):
  > +itemdefault = item.default()
  > +else:
  > +itemdefault = item.default
  > +return itemdefault
  
  Need to handle configitems.dynamicdefault.
  
  > diff --git a/mercurial/commands.py b/mercurial/commands.py
  >
  > - a/mercurial/commands.py
  >
  > +++ b/mercurial/commands.py
  > @@ -1872,6 +1872,7 @@
  >
  >   for section, name, value in ui.walkconfig(untrusted=untrusted):
  >   source = ui.configsource(section, name, untrusted)
  >   value = pycompat.bytestr(value)
  >
  > +defaultvalue = pycompat.bytestr(ui.configdefault(section, name))
  
  We'll probably want to keep None as itself. It's useless if an empty
  default were mapped to truthy value, "None".
  
  > @@ -1881,7 +1882,7 @@
  >
  >   fm.startitem()
  >   fm.condwrite(ui.debugflag, 'source', '%s: ', source)
  >   if uniquesel:
  >
  > - fm.data(name=entryname)
  >
  > +fm.data(name=entryname, defaultvalue=defaultvalue)
  >
  >   fm.write('value', '%s\n', value)
  >   else:
  >   fm.write('name value', '%s=%s\n', entryname, value)
  
  Missed fm.data() for the else case. fm.data(defaultvalue=...) can be moved
  out of the if block.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6704/new/

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

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


Re: D6704: config: add defaultvalue template keyword

2019-08-02 Thread Yuya Nishihara
> +def configdefault(self, section, name):
> +"""returns the default value of the config item"""
> +item = self._knownconfig.get(section, {}).get(name)
> +itemdefault = None
> +if item is not None:
> +if callable(item.default):
> +itemdefault = item.default()
> +else:
> +itemdefault = item.default
> +return itemdefault

Need to handle configitems.dynamicdefault.

> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -1872,6 +1872,7 @@
>  for section, name, value in ui.walkconfig(untrusted=untrusted):
>  source = ui.configsource(section, name, untrusted)
>  value = pycompat.bytestr(value)
> +defaultvalue = pycompat.bytestr(ui.configdefault(section, name))

We'll probably want to keep None as itself. It's useless if an empty
default were mapped to truthy value, "None".

> @@ -1881,7 +1882,7 @@
>  fm.startitem()
>  fm.condwrite(ui.debugflag, 'source', '%s: ', source)
>  if uniquesel:
> -fm.data(name=entryname)
> +fm.data(name=entryname, defaultvalue=defaultvalue)
>  fm.write('value', '%s\n', value)
>  else:
>  fm.write('name value', '%s=%s\n', entryname, value)

Missed fm.data() for the else case. fm.data(defaultvalue=...) can be moved
out of the if block.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 4 of 6] byteify-strings: broaden handling of attr* functions

2019-08-02 Thread Yuya Nishihara
On Fri, 02 Aug 2019 10:22:15 +0200, Raphaël Gomès wrote:
> # HG changeset patch
> # User Raphaël Gomès 
> # Date 1564733030 -7200
> #  Fri Aug 02 10:03:50 2019 +0200
> # Node ID edff9054a1a327d3d444d4acfde0879a92742549
> # Parent  2ba0327a754304b371c06d84a80ab1871e02fa66
> # EXP-Topic byteify-strings
> byteify-strings: broaden handling of attr* functions
> 
> The current safeguard that makes sure that `getattr`, etc. is not a method is
> too restrictive as it is easy to ignore wrappers use as `util.getattr`.
> 
> This change also adds other "good candidates": `wrapfunction`, `wrapclass`
> and `addattr`.
> 
> diff -r 2ba0327a7543 -r edff9054a1a3 contrib/byteify-strings.py
> --- a/contrib/byteify-strings.py  Fri Aug 02 09:55:32 2019 +0200
> +++ b/contrib/byteify-strings.py  Fri Aug 02 10:03:50 2019 +0200
> @@ -178,8 +178,10 @@
>  fn = t.string
>  
>  # *attr() builtins don't accept byte strings to 2nd argument.
> -if (fn in ('getattr', 'setattr', 'hasattr', 'safehasattr') and
> -not _isop(i - 1, '.')):
> +if fn in (
> +'getattr', 'setattr', 'hasattr', 'safehasattr', 
> 'wrapfunction',
> +'wrapclass', 'addattr'
> +):

IIRC, Mercurial APIs such as util.safehasattr() are supposed to take bytes.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 6 of 6] byteify-strings: add --treat-as-kwargs argument to handle kwargs-like objects

2019-08-02 Thread Yuya Nishihara
On Fri, 02 Aug 2019 10:22:17 +0200, Raphaël Gomès wrote:
> # HG changeset patch
> # User Raphaël Gomès 
> # Date 1564733902 -7200
> #  Fri Aug 02 10:18:22 2019 +0200
> # Node ID e6e13ca43b23038dd34e2c35b799f68868674f4b
> # Parent  d28c8bac8d4bc1eddc4a899eb081563e4823f6a6
> # EXP-Topic byteify-strings
> byteify-strings: add --treat-as-kwargs argument to handle kwargs-like objects

Queued 1-3, 5, 6, thanks.

> +ap.add_argument('--treat-as-kwargs', nargs="+",
> +help="ignore kwargs-like objects"),

Could be 'default=[]' instead of 'if ... else set()'.

>  ap.add_argument('files', metavar='FILE', nargs='+', help='source file')
>  args = ap.parse_args()
>  opts = {
>  'dictiter': args.dictiter,
> +'treat-as-kwargs': set(
> +args.treat_as_kwargs
> +) if args.treat_as_kwargs else set()
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6709: config: add --all flag to show all known configs

2019-08-02 Thread av6 (Anton Shestakov)
This revision now requires changes to proceed.
av6 added inline comments.
av6 requested changes to this revision.

INLINE COMMENTS

> commands.py:1774
>  @command('config|showconfig|debugconfig',
> -[('u', 'untrusted', None, _('show untrusted configuration options')),
> +[('a', 'all', None, _('show all known configuration options')),
> + ('u', 'untrusted', None, _('show untrusted configuration options')),

This needs a better description to differentiate this flag and the default mode 
(see line 1786).

> test-config.t:238
> +  progress.format=['topic', 'bar', 'number', 'estimate']
> +  devel-warn: config item requires an explicit default value: 
> 'progress.width' at: 
> /tmp/hgtests.Ps_zAY/install/lib/python/mercurial/commands.py:1876 (config)
> +  progress.width=None

Certainly a good way to find all config options without default values, but in 
the final implementation of `showconfig -a` it should not produce any warnings 
(especially not developer warnings).

It's probably possible to add default values to some of the items this test 
found, but I think some of them are missing defaults by design (an obvious 
example being `alias..*`). In that case it might be better to just skip them.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6709/new/

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

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


D6709: config: add --all flag to show all known configs

2019-08-02 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 16114.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6709?vs=16113=16114

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6709/new/

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/ui.py
  tests/test-completion.t
  tests/test-config.t

CHANGE DETAILS

diff --git a/tests/test-config.t b/tests/test-config.t
--- a/tests/test-config.t
+++ b/tests/test-config.t
@@ -222,3 +222,507 @@
   > done
   $ HGRCPATH=configs hg config section.key
   99
+
+test --all flag
+
+  $ hg showconfig --all
+  chgserver.idletimeout=3600
+  chgserver.skiphash=False
+  fsmonitor.warn_when_unused=True
+  fsmonitor.warn_update_file_count=5
+  progress.assume-tty=False
+  progress.clear-complete=True
+  progress.refresh=0.1
+  progress.debug=False
+  progress.format=['topic', 'bar', 'number', 'estimate']
+  devel-warn: config item requires an explicit default value: 'progress.width' 
at: /tmp/hgtests.Ps_zAY/install/lib/python/mercurial/commands.py:1876 (config)
+  progress.width=None
+  progress.changedelay=1
+  progress.estimateinterval=60.0
+  progress.delay=3
+  progress.disable=False
+  sparse.missingwarning=True
+  devel-warn: config item requires an explicit default value: 'alias..*' at: 
/tmp/hgtests.Ps_zAY/install/lib/python/mercurial/commands.py:1876 (config)
+  alias..*=None
+  merge.followcopies=True
+  merge.preferancestor=['*']
+  merge.on-failure=continue
+  merge.checkunknown=abort
+  merge.checkignored=abort
+  merge.strict-capability-check=False
+  email.cc=None
+  email.reply-to=None
+  email.bcc=None
+  email.charsets=[]
+  email.from=None
+  email.method=smtp
+  email.to=None
+  format.generaldelta=False
+  format.usefncache=True
+  format.obsstore-version=None
+  devel-warn: config item requires an explicit default value: 
'format.maxchainlen' at: 
/tmp/hgtests.Ps_zAY/install/lib/python/mercurial/commands.py:1876 (config)
+  format.maxchainlen=None
+  format.internal-phase=False
+  format.revlog-compression=$BUNDLE2_COMPRESSIONS$
+  format.manifestcachesize=None
+  format.bookmarks-in-store=False
+  format.usestore=True
+  format.chunkcachesize=None
+  format.usegeneraldelta=True
+  format.dotencode=True
+  format.sparse-revlog=True
+  profiling.nested=0
+  profiling.output=None
+  profiling.enabled=False
+  devel-warn: config item requires an explicit default value: 
'profiling.time-track' at: 
/tmp/hgtests.Ps_zAY/install/lib/python/mercurial/commands.py:1876 (config)
+  profiling.time-track=None
+  profiling.freq=1000
+  profiling.format=text
+  profiling.statformat=hotpath
+  profiling.type=stat
+  profiling.showmax=0.999
+  devel-warn: config item requires an explicit default value: 
'profiling.showmin' at: 
/tmp/hgtests.Ps_zAY/install/lib/python/mercurial/commands.py:1876 (config)
+  profiling.showmin=None
+  profiling.limit=30
+  profiling.showtime=True
+  profiling.sort=inlinetime
+  cmdserver.max-repo-cache=0
+  cmdserver.message-encodings=[]
+  cmdserver.max-log-files=7
+  cmdserver.track-log=['chgserver', 'cmdserver', 'repocache']
+  cmdserver.max-log-size=1 MB
+  cmdserver.log=None
+  push.pushvars.server=False
+  bookmarks.pushing=[]
+  devel-warn: config item requires an explicit default value: 
'pager.attend-.*' at: 
/tmp/hgtests.Ps_zAY/install/lib/python/mercurial/commands.py:1876 (config)
+  pager.attend-.*=None
+  devel-warn: config item requires an explicit default value: 'pager.pager' 
at: /tmp/hgtests.Ps_zAY/install/lib/python/mercurial/commands.py:1876 (config)
+  pager.pager=None
+  pager.ignore=[]
+  web.deny_push=[]
+  web.maxfiles=10
+  devel-warn: config item requires an explicit default value: 'web.name' at: 
/tmp/hgtests.Ps_zAY/install/lib/python/mercurial/commands.py:1876 (config)
+  web.name=None
+  web.contact=None
+  web.allow-pull=True
+  web.port=8000
+  web.errorlog=-
+  web.comparisoncontext=5
+  web.archivesubrepos=False
+  web.templates=None
+  web.logourl=https://mercurial-scm.org/
+  web.refreshinterval=20
+  web.cacerts=None
+  web.allowgz=False
+  web.allowbz2=False
+  web.collapse=False
+  web.server-header=testing stub value
+  web.labels=[]
+  web.csp=None
+  web.ipv6=False
+  web.accesslog=-
+  web.allow-archive=[]
+  web.guessmime=False
+  web.prefix=
+  web.cache=True
+  web.push_ssl=True
+  web.allow-push=[]
+  web.logoimg=hglogo.png
+  web.allowzip=False
+  web.description=
+  web.view=served
+  web.baseurl=None
+  web.allow_read=[]
+  web.hidden=False
+  web.deny_read=[]
+  web.certificate=None
+  web.encoding=ascii
+  web.staticurl=None
+  web.address=localhost
+  web.motd=
+  web.maxchanges=10
+  web.stripes=1
+  web.style=paper
+  web.descend=True
+  web.maxshortchanges=60
+  web.static=None
+  hgweb-paths..*=[]
+  devel-warn: accessing unregistered config item: 
'hostsecurity..*:verifycertsfile$' at: 
/tmp/hgtests.Ps_zAY/install/lib/python/mercurial/commands.py:1876 (config)
+  

D6709: config: add --all flag to show all known configs

2019-08-02 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh created this revision.
Herald added subscribers: mercurial-devel, mjpieters.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch fixes one of the issues in issue6014. This adds an `--all`
  flag to `hg showconfig` to show all known config options.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/ui.py
  tests/test-config.t

CHANGE DETAILS

diff --git a/tests/test-config.t b/tests/test-config.t
--- a/tests/test-config.t
+++ b/tests/test-config.t
@@ -222,3 +222,507 @@
   > done
   $ HGRCPATH=configs hg config section.key
   99
+
+test --all flag
+
+  $ hg showconfig --all
+  chgserver.idletimeout=3600
+  chgserver.skiphash=False
+  fsmonitor.warn_when_unused=True
+  fsmonitor.warn_update_file_count=5
+  progress.assume-tty=False
+  progress.clear-complete=True
+  progress.refresh=0.1
+  progress.debug=False
+  progress.format=['topic', 'bar', 'number', 'estimate']
+  devel-warn: config item requires an explicit default value: 'progress.width' 
at: /tmp/hgtests.Ps_zAY/install/lib/python/mercurial/commands.py:1876 (config)
+  progress.width=None
+  progress.changedelay=1
+  progress.estimateinterval=60.0
+  progress.delay=3
+  progress.disable=False
+  sparse.missingwarning=True
+  devel-warn: config item requires an explicit default value: 'alias..*' at: 
/tmp/hgtests.Ps_zAY/install/lib/python/mercurial/commands.py:1876 (config)
+  alias..*=None
+  merge.followcopies=True
+  merge.preferancestor=['*']
+  merge.on-failure=continue
+  merge.checkunknown=abort
+  merge.checkignored=abort
+  merge.strict-capability-check=False
+  email.cc=None
+  email.reply-to=None
+  email.bcc=None
+  email.charsets=[]
+  email.from=None
+  email.method=smtp
+  email.to=None
+  format.generaldelta=False
+  format.usefncache=True
+  format.obsstore-version=None
+  devel-warn: config item requires an explicit default value: 
'format.maxchainlen' at: 
/tmp/hgtests.Ps_zAY/install/lib/python/mercurial/commands.py:1876 (config)
+  format.maxchainlen=None
+  format.internal-phase=False
+  format.revlog-compression=$BUNDLE2_COMPRESSIONS$
+  format.manifestcachesize=None
+  format.bookmarks-in-store=False
+  format.usestore=True
+  format.chunkcachesize=None
+  format.usegeneraldelta=True
+  format.dotencode=True
+  format.sparse-revlog=True
+  profiling.nested=0
+  profiling.output=None
+  profiling.enabled=False
+  devel-warn: config item requires an explicit default value: 
'profiling.time-track' at: 
/tmp/hgtests.Ps_zAY/install/lib/python/mercurial/commands.py:1876 (config)
+  profiling.time-track=None
+  profiling.freq=1000
+  profiling.format=text
+  profiling.statformat=hotpath
+  profiling.type=stat
+  profiling.showmax=0.999
+  devel-warn: config item requires an explicit default value: 
'profiling.showmin' at: 
/tmp/hgtests.Ps_zAY/install/lib/python/mercurial/commands.py:1876 (config)
+  profiling.showmin=None
+  profiling.limit=30
+  profiling.showtime=True
+  profiling.sort=inlinetime
+  cmdserver.max-repo-cache=0
+  cmdserver.message-encodings=[]
+  cmdserver.max-log-files=7
+  cmdserver.track-log=['chgserver', 'cmdserver', 'repocache']
+  cmdserver.max-log-size=1 MB
+  cmdserver.log=None
+  push.pushvars.server=False
+  bookmarks.pushing=[]
+  devel-warn: config item requires an explicit default value: 
'pager.attend-.*' at: 
/tmp/hgtests.Ps_zAY/install/lib/python/mercurial/commands.py:1876 (config)
+  pager.attend-.*=None
+  devel-warn: config item requires an explicit default value: 'pager.pager' 
at: /tmp/hgtests.Ps_zAY/install/lib/python/mercurial/commands.py:1876 (config)
+  pager.pager=None
+  pager.ignore=[]
+  web.deny_push=[]
+  web.maxfiles=10
+  devel-warn: config item requires an explicit default value: 'web.name' at: 
/tmp/hgtests.Ps_zAY/install/lib/python/mercurial/commands.py:1876 (config)
+  web.name=None
+  web.contact=None
+  web.allow-pull=True
+  web.port=8000
+  web.errorlog=-
+  web.comparisoncontext=5
+  web.archivesubrepos=False
+  web.templates=None
+  web.logourl=https://mercurial-scm.org/
+  web.refreshinterval=20
+  web.cacerts=None
+  web.allowgz=False
+  web.allowbz2=False
+  web.collapse=False
+  web.server-header=testing stub value
+  web.labels=[]
+  web.csp=None
+  web.ipv6=False
+  web.accesslog=-
+  web.allow-archive=[]
+  web.guessmime=False
+  web.prefix=
+  web.cache=True
+  web.push_ssl=True
+  web.allow-push=[]
+  web.logoimg=hglogo.png
+  web.allowzip=False
+  web.description=
+  web.view=served
+  web.baseurl=None
+  web.allow_read=[]
+  web.hidden=False
+  web.deny_read=[]
+  web.certificate=None
+  web.encoding=ascii
+  web.staticurl=None
+  web.address=localhost
+  web.motd=
+  web.maxchanges=10
+  web.stripes=1
+  web.style=paper
+  web.descend=True
+  web.maxshortchanges=60
+  web.static=None
+  hgweb-paths..*=[]
+  devel-warn: accessing unregistered config item: 
'hostsecurity..*:verifycertsfile$' at: 

[PATCH 6 of 6] byteify-strings: add --treat-as-kwargs argument to handle kwargs-like objects

2019-08-02 Thread Raphaël Gomès
# HG changeset patch
# User Raphaël Gomès 
# Date 1564733902 -7200
#  Fri Aug 02 10:18:22 2019 +0200
# Node ID e6e13ca43b23038dd34e2c35b799f68868674f4b
# Parent  d28c8bac8d4bc1eddc4a899eb081563e4823f6a6
# EXP-Topic byteify-strings
byteify-strings: add --treat-as-kwargs argument to handle kwargs-like objects

This argument will help extensions move to Python 3 as keyword arguments
should not be byte-prefixed. Most of the time, code bases will call this
object `kwargs`, but other conventions exist like `opts`, so it should make
sense to allow for custom names.

This is a best effort solution that does minimal static checking; cases like

`options = [o for o in ('a', 'b', 'c') if kwargs.get(o)]`

and other just as complicated will not be detected.

diff -r d28c8bac8d4b -r e6e13ca43b23 contrib/byteify-strings.py
--- a/contrib/byteify-strings.pyFri Aug 02 10:10:23 2019 +0200
+++ b/contrib/byteify-strings.pyFri Aug 02 10:18:22 2019 +0200
@@ -230,6 +230,12 @@
 yield adjusttokenpos(t._replace(string=fn[4:]), coloffset)
 continue
 
+if t.type == token.NAME and t.string in opts['treat-as-kwargs']:
+if _isitemaccess(i):
+_ensuresysstr(i + 2)
+if _ismethodcall(i, 'get', 'pop', 'setdefault', 'popitem'):
+_ensuresysstr(i + 4)
+
 # Looks like "if __name__ == '__main__'".
 if (t.type == token.NAME and t.string == '__name__'
 and _isop(i + 1, '==')):
@@ -272,10 +278,15 @@
 help='edit files in place')
 ap.add_argument('--dictiter', action='store_true', default=False,
 help='rewrite iteritems() and itervalues()'),
+ap.add_argument('--treat-as-kwargs', nargs="+",
+help="ignore kwargs-like objects"),
 ap.add_argument('files', metavar='FILE', nargs='+', help='source file')
 args = ap.parse_args()
 opts = {
 'dictiter': args.dictiter,
+'treat-as-kwargs': set(
+args.treat_as_kwargs
+) if args.treat_as_kwargs else set()
 }
 for fname in args.files:
 if args.inplace:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 6] byteify-strings: handle triple quoted strings if they are not docstrings

2019-08-02 Thread Raphaël Gomès
# HG changeset patch
# User Raphaël Gomès 
# Date 1564732093 -7200
#  Fri Aug 02 09:48:13 2019 +0200
# Node ID 649e2ec4232c359d5b09833d8d6e1b9e309ba28a
# Parent  623f86cf8834b154cc2b7c88b6dd8378ff9481c6
# EXP-Topic byteify-strings
byteify-strings: handle triple quoted strings if they are not docstrings

As with anything in this script, this is a best effort approach. Most of the
time, when a triple quoted string is assigned to something, it's not a
docstring.

diff -r 623f86cf8834 -r 649e2ec4232c contrib/byteify-strings.py
--- a/contrib/byteify-strings.pyFri Aug 02 09:44:11 2019 +0200
+++ b/contrib/byteify-strings.pyFri Aug 02 09:48:13 2019 +0200
@@ -139,8 +139,10 @@
 # components touching docstrings need to handle unicode,
 # unfortunately.
 if s[0:3] in ("'''", '"""'):
-yield adjusttokenpos(t, coloffset)
-continue
+# If it's assigned to something, it's not a docstring
+if not _isop(i - 1, '='):
+yield adjusttokenpos(t, coloffset)
+continue
 
 # If the first character isn't a quote, it is likely a string
 # prefixing character (such as 'b', 'u', or 'r'. Ignore.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 5 of 6] byteify-strings: add helpers to check for item access or method call

2019-08-02 Thread Raphaël Gomès
# HG changeset patch
# User Raphaël Gomès 
# Date 1564733423 -7200
#  Fri Aug 02 10:10:23 2019 +0200
# Node ID d28c8bac8d4bc1eddc4a899eb081563e4823f6a6
# Parent  edff9054a1a327d3d444d4acfde0879a92742549
# EXP-Topic byteify-strings
byteify-strings: add helpers to check for item access or method call

These helpers will be used in a future patch, split for ease of review.

diff -r edff9054a1a3 -r d28c8bac8d4b contrib/byteify-strings.py
--- a/contrib/byteify-strings.pyFri Aug 02 10:03:50 2019 +0200
+++ b/contrib/byteify-strings.pyFri Aug 02 10:10:23 2019 +0200
@@ -92,6 +92,36 @@
 except IndexError:
 break
 
+def _isitemaccess(j):
+"""Assert the next tokens form an item access on `tokens[j]` and that
+`tokens[j]` is a name.
+"""
+try:
+return (
+tokens[j].type == token.NAME
+and _isop(j + 1, '[')
+and tokens[j + 2].type == token.STRING
+and _isop(j + 3, ']')
+)
+except IndexError:
+return False
+
+def _ismethodcall(j, *methodnames):
+"""Assert the next tokens form a call to `methodname` with a string
+as first argument on `tokens[j]` and that `tokens[j]` is a name.
+"""
+try:
+return (
+tokens[j].type == token.NAME
+and _isop(j + 1, '.')
+and tokens[j + 2].type == token.NAME
+and tokens[j + 2].string in methodnames
+and _isop(j + 3, '(')
+and tokens[j + 4].type == token.STRING
+)
+except IndexError:
+return False
+
 coldelta = 0  # column increment for new opening parens
 coloffset = -1  # column offset for the current line (-1: TBD)
 parens = [(0, 0, 0)]  # stack of (line, end-column, column-offset)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 4 of 6] byteify-strings: broaden handling of attr* functions

2019-08-02 Thread Raphaël Gomès
# HG changeset patch
# User Raphaël Gomès 
# Date 1564733030 -7200
#  Fri Aug 02 10:03:50 2019 +0200
# Node ID edff9054a1a327d3d444d4acfde0879a92742549
# Parent  2ba0327a754304b371c06d84a80ab1871e02fa66
# EXP-Topic byteify-strings
byteify-strings: broaden handling of attr* functions

The current safeguard that makes sure that `getattr`, etc. is not a method is
too restrictive as it is easy to ignore wrappers use as `util.getattr`.

This change also adds other "good candidates": `wrapfunction`, `wrapclass`
and `addattr`.

diff -r 2ba0327a7543 -r edff9054a1a3 contrib/byteify-strings.py
--- a/contrib/byteify-strings.pyFri Aug 02 09:55:32 2019 +0200
+++ b/contrib/byteify-strings.pyFri Aug 02 10:03:50 2019 +0200
@@ -178,8 +178,10 @@
 fn = t.string
 
 # *attr() builtins don't accept byte strings to 2nd argument.
-if (fn in ('getattr', 'setattr', 'hasattr', 'safehasattr') and
-not _isop(i - 1, '.')):
+if fn in (
+'getattr', 'setattr', 'hasattr', 'safehasattr', 'wrapfunction',
+'wrapclass', 'addattr'
+):
 arg1idx = _findargnofcall(1)
 if arg1idx is not None:
 _ensuresysstr(arg1idx)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 6] byteify-strings: add support for ignore comments

2019-08-02 Thread Raphaël Gomès
# HG changeset patch
# User Raphaël Gomès 
# Date 1564732532 -7200
#  Fri Aug 02 09:55:32 2019 +0200
# Node ID 2ba0327a754304b371c06d84a80ab1871e02fa66
# Parent  649e2ec4232c359d5b09833d8d6e1b9e309ba28a
# EXP-Topic byteify-strings
byteify-strings: add support for ignore comments

Our simple token analysis is sometimes not clever enough, we need to be able
to turn off our script for parts of the code.

This change introduces three special comments:

- `#no-py3-transform` to tell `byteify-strings` ignore the next line
- `#py3-transform: off` to ignore everything until the end of the file
- `#py3-transform: on` to stop ignoring

The last two can be particularly useful within Python 2/3 compatibility files.

diff -r 649e2ec4232c -r 2ba0327a7543 contrib/byteify-strings.py
--- a/contrib/byteify-strings.pyFri Aug 02 09:48:13 2019 +0200
+++ b/contrib/byteify-strings.pyFri Aug 02 09:55:32 2019 +0200
@@ -95,6 +95,8 @@
 coldelta = 0  # column increment for new opening parens
 coloffset = -1  # column offset for the current line (-1: TBD)
 parens = [(0, 0, 0)]  # stack of (line, end-column, column-offset)
+ignorenextline = False  # don't transform the next line
+insideignoreblock = False # don't transform until turned off
 for i, t in enumerate(tokens):
 # Compute the column offset for the current line, such that
 # the current line will be aligned to the last opening paren
@@ -113,6 +115,21 @@
 yield adjusttokenpos(t, coloffset)
 coldelta = 0
 coloffset = -1
+if not insideignoreblock:
+ignorenextline = (
+tokens[i-1].type == token.COMMENT
+and tokens[i-1].string == "#no-py3-transform"
+)
+continue
+
+if t.type == token.COMMENT:
+if t.string == "#py3-transform: off":
+insideignoreblock = True
+if t.string == "#py3-transform: on":
+insideignoreblock = False
+
+if ignorenextline or insideignoreblock:
+yield adjusttokenpos(t, coloffset)
 continue
 
 # Remember the last paren position.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 6] byteify-strings: handle multi-line strings in _ensuresysstr

2019-08-02 Thread Raphaël Gomès
# HG changeset patch
# User Raphaël Gomès 
# Date 1564731851 -7200
#  Fri Aug 02 09:44:11 2019 +0200
# Node ID 623f86cf8834b154cc2b7c88b6dd8378ff9481c6
# Parent  4b04244f2d5fdc6221c29d6ae8074a81fe352c5e
# EXP-Topic byteify-strings
byteify-strings: handle multi-line strings in _ensuresysstr

The current implementation did not handle calls like

`repo.ui.log("first line"
 "other line")`

correctly.

diff -r 4b04244f2d5f -r 623f86cf8834 contrib/byteify-strings.py
--- a/contrib/byteify-strings.pyFri Jul 26 10:47:06 2019 -0700
+++ b/contrib/byteify-strings.pyFri Aug 02 09:44:11 2019 +0200
@@ -78,9 +78,19 @@
 already been done.
 
 """
-st = tokens[j]
-if st.type == token.STRING and st.string.startswith(("'", '"')):
-sysstrtokens.add(st)
+k = j
+currtoken = tokens[k]
+while currtoken.type in (token.STRING, token.NEWLINE, tokenize.NL):
+k += 1
+if (
+currtoken.type == token.STRING
+and currtoken.string.startswith(("'", '"'))
+):
+sysstrtokens.add(currtoken)
+try:
+currtoken = tokens[k]
+except IndexError:
+break
 
 coldelta = 0  # column increment for new opening parens
 coloffset = -1  # column offset for the current line (-1: TBD)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6708: unshelve: clear shelvedstate and _finishunshelve() on partial unshelve

2019-08-02 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  On a partial unshelve, `shelvedstate` was not cleared and `_finishunshelve()`
  was not called. Ideally, these should be called on this case. This patch makes
  `shelvedstate` to delete after a successful partial unshelve and calls
  `_finishunshelve()` in the same case.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/shelve.py
  tests/test-shelve.t

CHANGE DETAILS

diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -1239,6 +1239,7 @@
   > y
   > EOF
   unshelving change 'default'
+  temporarily committing pending changes (restore with 'hg unshelve --abort')
   rebasing shelved changes
   diff --git a/d b/d
   new file mode 100644
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -1002,11 +1002,10 @@
 with ui.configoverride(overrides, 'unshelve'):
 mergefiles(ui, repo, pctx, shelvectx)
 restorebranch(ui, repo, branchtorestore)
+shelvedstate.clear(repo)
+_finishunshelve(repo, oldtiprev, tr, activebookmark)
 if not ispartialunshelve:
 _forgetunknownfiles(repo, shelvectx, addedbefore)
-
-shelvedstate.clear(repo)
-_finishunshelve(repo, oldtiprev, tr, activebookmark)
 unshelvecleanup(ui, repo, basename, opts)
 finally:
 if tr:



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


D6699: tests: add test for unshelve --interactive --keep

2019-08-02 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 16111.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6699?vs=16086=16111

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6699/new/

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

AFFECTED FILES
  tests/test-shelve.t

CHANGE DETAILS

diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -1453,3 +1453,25 @@
   record this change to 'bar2'?
   (enter ? for help) [Ynesfdaq?] y
   
+-- test for unshelve --interactive --keep
+  $ hg unshelve -i --keep < y
+  > y
+  > EOF
+  unshelving change 'default'
+  temporarily committing pending changes (restore with 'hg unshelve --abort')
+  rebasing shelved changes
+  diff --git a/foo b/foo
+  1 hunks, 1 lines changed
+  examine changes to 'foo'?
+  (enter ? for help) [Ynesfdaq?] y
+  
+  @@ -1,2 +1,3 @@
+   A
+   B
+  +C
+  record this change to 'foo'?
+  (enter ? for help) [Ynesfdaq?] y
+  
+  $ hg shelve --list
+  default (1s ago)changes to: add B to foo



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


D6697: cmdutil: add allowunfinished to prevent checkunfinished() on docommit()

2019-08-02 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 16110.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6697?vs=16073=16110

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6697/new/

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/shelve.py

CHANGE DETAILS

diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -824,7 +824,6 @@
 bool to know whether the shelve is partly done or completely done.
 """
 opts['message'] = shelvectx.description()
-opts['interactive-unshelve'] = True
 pats = []
 if not interactive:
 newnode = repo.commit(text=shelvectx.description(),
@@ -836,7 +835,7 @@
 commitfunc = getcommitfunc(shelvectx.extra(), interactive=True,
editor=True)
 newnode = cmdutil.dorecord(ui, repo, commitfunc, None, False,
-   cmdutil.recordfilter, *pats,
+   cmdutil.recordfilter, True, *pats,
**pycompat.strkwargs(opts))
 snode = repo.commit(text=shelvectx.description(),
 extra=shelvectx.extra(),
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -239,7 +239,7 @@
 return newchunks, newopts
 
 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall,
-filterfn, *pats, **opts):
+filterfn, allowunfinished=False, *pats, **opts):
 opts = pycompat.byteskwargs(opts)
 if not ui.interactive():
 if cmdsuggest:
@@ -265,8 +265,13 @@
 
 In the end we'll record interesting changes, and everything else
 will be left in place, so the user can continue working.
+
+We will prevent committing changesets on unfinished states if and only
+if `allowunfinished` is not set `True`. For example, `unshelve` on
+interactive mode does a commit during an unfinished state and we don't
+want to prevent that.
 """
-if not opts.get('interactive-unshelve'):
+if not allowunfinished:
 checkunfinished(repo, commit=True)
 wctx = repo[None]
 merge = len(wctx.parents()) > 1



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


D6694: unshelve: delete shelvedstate after a successful unshelve --continue

2019-08-02 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 16109.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6694?vs=16085=16109

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6694/new/

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

AFFECTED FILES
  mercurial/shelve.py
  tests/test-shelve.t

CHANGE DETAILS

diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -1425,3 +1425,31 @@
  summary: add A to bars
   
 #endif
+
+-- now, --continue should abort as the last unshelve was successful even
+-- though it was partially done. it can be completed without --continue.
+  $ hg unshelve --continue
+  abort: no unshelve in progress
+  [255]
+
+  $ hg shelve --list
+  default-01  (1s ago)changes to: add A to bars
+  default (1s ago)changes to: add B to foo
+  $ hg unshelve -n default-01 -i < y
+  > y
+  > EOF
+  temporarily committing pending changes (restore with 'hg unshelve --abort')
+  rebasing shelved changes
+  diff --git a/bar2 b/bar2
+  1 hunks, 1 lines changed
+  examine changes to 'bar2'?
+  (enter ? for help) [Ynesfdaq?] y
+  
+  @@ -1,2 +1,3 @@
+   A
+  +B
+   C
+  record this change to 'bar2'?
+  (enter ? for help) [Ynesfdaq?] y
+  
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -750,8 +750,8 @@
 if not phases.supportinternal(repo):
 repair.strip(ui, repo, state.nodestoremove, backup=False,
  topic='shelve')
+shelvedstate.clear(repo)
 if not ispartialunshelve:
-shelvedstate.clear(repo)
 unshelvecleanup(ui, repo, state.name, opts)
 _restoreactivebookmark(repo, state.activebookmark)
 ui.status(_("unshelve of '%s' complete\n") % state.name)



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


D6686: unshelve: handle stripping changesets on interactive mode

2019-08-02 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 16108.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6686?vs=16065=16108

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6686/new/

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

AFFECTED FILES
  mercurial/shelve.py
  tests/test-shelve.t

CHANGE DETAILS

diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -1357,11 +1357,33 @@
   A
   B
   C
+
+#if stripbased
+  $ hg log -r 3:: -G
+  @  changeset:   5:506510493902
+  |  tag: tip
+  |  parent:  3:adfeba9a1ac4
+  |  user:shelve@localhost
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: changes to: add A to bars
+  |
+  | @  changeset:   4:8b023952e29c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: add C to bars
+  |
+  o  changeset:   3:adfeba9a1ac4
+  |  user:test
+  ~  date:Thu Jan 01 00:00:00 1970 +
+ summary: add A to bars
+  
+#endif
+
   $ hg unshelve --continue < y
   > y
   > y
-  > y
+  > n
   > EOF
   diff --git a/bar1 b/bar1
   1 hunks, 1 lines changed
@@ -1385,6 +1407,21 @@
   +B
C
   record change 2/2 to 'bar2'?
-  (enter ? for help) [Ynesfdaq?] y
+  (enter ? for help) [Ynesfdaq?] n
   
   unshelve of 'default-01' complete
+
+#if stripbased
+  $ hg log -r 3:: -G
+  @  changeset:   4:8b023952e29c
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: add C to bars
+  |
+  o  changeset:   3:adfeba9a1ac4
+  |  user:test
+  ~  date:Thu Jan 01 00:00:00 1970 +
+ summary: add A to bars
+  
+#endif
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -747,10 +747,10 @@
 mergefiles(ui, repo, state.wctx, shelvectx)
 restorebranch(ui, repo, state.branchtorestore)
 
+if not phases.supportinternal(repo):
+repair.strip(ui, repo, state.nodestoremove, backup=False,
+ topic='shelve')
 if not ispartialunshelve:
-if not phases.supportinternal(repo):
-repair.strip(ui, repo, state.nodestoremove, backup=False,
-topic='shelve')
 shelvedstate.clear(repo)
 unshelvecleanup(ui, repo, state.name, opts)
 _restoreactivebookmark(repo, state.activebookmark)



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


D6704: config: add defaultvalue template keyword

2019-08-02 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh added inline comments.
navaneeth.suresh marked an inline comment as done.

INLINE COMMENTS

> durin42 wrote in commands.py:1875
> you almost certainly want `pycompat.bytestr()` here and not `str()` for py3 
> compat reasons

thanks for the fix and queuing @durin42.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6704/new/

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

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


D6707: revset: drop argument when it's None

2019-08-02 Thread av6 (Anton Shestakov)
av6 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  getstack's definition is `getstack(repo, rev=None)`, so providing None
  explicitly is unnecessary. Moreover, when x is not None, it's definitely not a
  revision but a part of a parsed tree of revset arguments.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revset.py

CHANGE DETAILS

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1695,7 +1695,7 @@
 parent. (EXPERIMENTAL)
 """
 if x is None:
-stacks = stackmod.getstack(repo, x)
+stacks = stackmod.getstack(repo)
 else:
 stacks = smartset.baseset([])
 for revision in getset(repo, fullreposet(repo), x):



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


D6706: stack: remove unnecessary reverse() predicate

2019-08-02 Thread av6 (Anton Shestakov)
av6 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Stack already sorts revisions, so no need to do it twice.
  
  This change was a part of D2400 , which 
didn't land for other reasons. See also
  D2399 , where this change was suggested.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/stack.py

CHANGE DETAILS

diff --git a/mercurial/stack.py b/mercurial/stack.py
--- a/mercurial/stack.py
+++ b/mercurial/stack.py
@@ -22,7 +22,7 @@
 if rev is None:
 rev = '.'
 
-revspec = 'reverse(only(%s) and not public() and not ::merge())'
+revspec = 'only(%s) and not public() and not ::merge()'
 revset = revsetlang.formatspec(revspec, rev)
 revisions = scmutil.revrange(repo, [revset])
 revisions.sort()



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


[Bug 6179] New: `hg fix -r .` should update to rewritten commit

2019-08-02 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=6179

Bug ID: 6179
   Summary: `hg fix -r .` should update to rewritten commit
   Product: Mercurial
   Version: stable branch
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: bug
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: z...@zash.se
CC: mercurial-devel@mercurial-scm.org

If `hg fix` is used to rewrite the working directory parent then you end up
with the same old parent afterwards. With evolve enabled you probably want `hg
evolve` to check out the fixed changeset, but without you get a warning about
"unknown working parent".

``` .hgrc
[fix]
trailing-whitespace:command=sed
trailing-whitespace:linerange=-e '{first},{last}s/\s\+$//'
trailing-whitespace:pattern=set:not binary()
```

$ hg init
$ echo "foo " > bar
$ hg add bar
$ hg ci -m init
$ hg fix -r .
$ hg stat
warning: ignoring unknown working parent b99a6b4226ff!

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 3 of 3 STABLE] bookmarks: actual fix for race condition deleting bookmark

2019-08-02 Thread Pierre-Yves David

I don't see them in any repositories. Did you push them somewhere ?

On 8/1/19 8:54 PM, Augie Fackler wrote:

queued for stable, thanks


On Aug 1, 2019, at 13:55, Pierre-Yves David  
wrote:

# HG changeset patch
# User Pierre-Yves David 
# Date 1561081840 -7200
#  Fri Jun 21 03:50:40 2019 +0200
# Branch stable
# Node ID 56f34aeebffda197bacd77cc2345386d9dd1f073
# Parent  df77a77a8b1744d93de9823fb8ac2d5c5d8c07d8
# EXP-Topic debug-book
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
56f34aeebffd
bookmarks: actual fix for race condition deleting bookmark

This is a simple but efficient fix to prevent the issue tested in
`test-bookmarks-corner-case.t`. It might be worth pursuing a more generic
approach where filecache learn to depend on each other, but that would not be
suitable for stable.

The issue is complicated enough that I documented the race and its current
solution as inline comment. See this comment for details on the fix.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1227,6 +1227,55 @@ class localrepository(object):
 @mixedrepostorecache(('bookmarks', 'plain'), ('bookmarks.current', 
'plain'),
  ('bookmarks', ''), ('00changelog.i', ''))
 def _bookmarks(self):
+# Since the multiple files involved in the transaction cannot be
+# written atomically (with current repository format), there is a race
+# condition here.
+#
+# 1) changelog content A is read
+# 2) outside transaction update changelog to content B
+# 3) outside transaction update bookmark file referring to content B
+# 4) bookmarks file content is read and filtered against changelog-A
+#
+# When this happens, bookmarks against nodes missing from A are 
dropped.
+#
+# Having this happening during read is not great, but it become worse
+# when this happen during write because the bookmarks to the "unknown"
+# nodes will be dropped for good. However, writes happen within locks.
+# This locking makes it possible to have a race free consistent read.
+# For this purpose data read from disc before locking  are
+# "invalidated" right after the locks are taken. This invalidations are
+# "light", the `filecache` mechanism keep the data in memory and will
+# reuse them if the underlying files did not changed. Not parsing the
+# same data multiple times helps performances.
+#
+# Unfortunately in the case describe above, the files tracked by the
+# bookmarks file cache might not have changed, but the in-memory
+# content is still "wrong" because we used an older changelog content
+# to process the on-disk data. So after locking, the changelog would be
+# refreshed but `_bookmarks` would be preserved.
+# Adding `00changelog.i` to the list of tracked file is not
+# enough, because at the time we build the content for `_bookmarks` in
+# (4), the changelog file has already diverged from the content used
+# for loading `changelog` in (1)
+#
+# To prevent the issue, we force the changelog to be explicitly
+# reloaded while computing `_bookmarks`. The data race can still happen
+# without the lock (with a narrower window), but it would no longer go
+# undetected during the lock time refresh.
+#
+# The new schedule is as follow
+#
+# 1) filecache logic detect that `_bookmarks` needs to be computed
+# 2) cachestat for `bookmarks` and `changelog` are captured (for book)
+# 3) We force `changelog` filecache to be tested
+# 4) cachestat for `changelog` are captured (for changelog)
+# 5) `_bookmarks` is computed and cached
+#
+# The step in (3) ensure we have a changelog at least as recent as the
+# cache stat computed in (1). As a result at locking time:
+#  * if the changelog did not changed since (1) -> we can reuse the 
data
+#  * otherwise -> the bookmarks get refreshed.
+self._refreshchangelog()
 return bookmarks.bmstore(self)

 def _refreshchangelog(self):
diff --git a/tests/test-bookmarks-corner-case.t 
b/tests/test-bookmarks-corner-case.t
--- a/tests/test-bookmarks-corner-case.t
+++ b/tests/test-bookmarks-corner-case.t
@@ -200,6 +200,7 @@ Check raced push output.
   $ cat push-output.txt
   pushing to ssh://user@dummy/bookrace-server
   searching for changes
+  remote has heads on branch 'default' that are not known locally: f26c3b5167d1
   remote: setting raced push up
   remote: adding changesets
   remote: adding manifests
@@ -219,7 +220,7 @@ Check result of the push.
   |  summary: A1
   |
   | o  changeset:   3:f26c3b5167d1
-  | |  bookmark:book-B