D12625: amend: stop specifying matcher, get all copies in wctx

2022-05-11 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  When we're recreating the commit that we'll be committing, we don't want to
  filter our copy information based on just the *new* [versions of the] files
  we're amending. The test has an example of this case, but for clarity, the
  situation is:
  
$ hg cp src dst && hg commit

$ hg amend some_unrelated_file.txt
$ hg status --copies
A dst
A some_unrelated_file.txt
  
  What *should* happen is that `dst` should remain marked as a copy of `src`, 
but
  this did not previously happen. `matcher` here only includes the files that 
were
  specified on the commandline, so it only gets the copy information (if any, in
  this example there's not) for `some_unrelated_file.txt`. When it goes to apply
  the memctx to actually create the commit, the file copy information is
  incomplete and loses the information for the files that shouldn't have been
  affected at all by the amend.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-amend.t

CHANGE DETAILS

diff --git a/tests/test-amend.t b/tests/test-amend.t
--- a/tests/test-amend.t
+++ b/tests/test-amend.t
@@ -625,4 +625,4 @@
   $ hg status --change . --copies
   A new_file_amend_me
   A r0_copied
-r0 (missing-correct-output !)
+r0
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2914,9 +2914,9 @@
 # filectxs from the old commit.
 if changes or changeset_copies:
 # Recompute copies (avoid recording a -> b -> a)
-copied = copies.pathcopies(base, wctx, matcher)
-if old.p2:
-copied.update(copies.pathcopies(old.p2(), wctx, matcher))
+copied = copies.pathcopies(base, wctx)
+if old.p2():
+copied.update(copies.pathcopies(old.p2(), wctx))
 
 # Prune files which were reverted by the updates: if old
 # introduced file X and the file was renamed in the working



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


D12624: amend: add test showing poor behavior when copies are involved

2022-05-11 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-amend.t

CHANGE DETAILS

diff --git a/tests/test-amend.t b/tests/test-amend.t
--- a/tests/test-amend.t
+++ b/tests/test-amend.t
@@ -609,3 +609,20 @@
   >   hg status
   > fi
   OK.
+
+Amending a commit that has copies but not specifying those copies shouldn't
+cause them to be lost
+
+  $ cd $TESTTMP
+  $ hg init dont-lose-copies; cd dont-lose-copies
+  $ echo r0 > r0; hg commit -qAm "r0"
+  $ hg cp r0 r0_copied; hg commit -qm "copy r0"
+  $ echo hi > new_file_amend_me
+  $ hg status --change . --copies
+  A r0_copied
+r0
+  $ hg amend -qA new_file_amend_me
+  $ hg status --change . --copies
+  A new_file_amend_me
+  A r0_copied
+r0 (missing-correct-output !)



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


D12577: amend: small refactor of logic for clarity

2022-04-27 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2928,7 +2928,7 @@
 files = [
 f
 for f in files
-if (f not in filestoamend or not samefile(f, wctx, base))
+if not (f in filestoamend and samefile(f, wctx, base))
 ]
 
 def filectxfn(repo, ctx_, path):



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


D12576: amend: move "return None for removed files" into block handling filestoamend

2022-04-27 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is just a small logic cleanup from D12573 
, no change in behavior.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2933,16 +2933,15 @@
 
 def filectxfn(repo, ctx_, path):
 try:
-# Return None for removed files.
-if path in wctx.removed() and path in filestoamend:
-return None
-
 # If the file being considered is not amongst the files
 # to be amended, we should use the file context from the
 # old changeset. This avoids issues when only some files in
 # the working copy are being amended but there are also
 # changes to other files from the old changeset.
 if path in filestoamend:
+# Return None for removed files.
+if path in wctx.removed():
+return None
 fctx = wctx[path]
 else:
 fctx = old.filectx(path)



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


D12552: rebase: while rewriting desc hashes, ignore ambiguous prefix "hashes"

2022-04-13 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  If a repo is sufficiently large, a six digit number "hash prefix" can somewhat
  easily reference an ambiguous hash prefix.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/rewriteutil.py
  tests/test-rebase-inmemory.t

CHANGE DETAILS

diff --git a/tests/test-rebase-inmemory.t b/tests/test-rebase-inmemory.t
--- a/tests/test-rebase-inmemory.t
+++ b/tests/test-rebase-inmemory.t
@@ -1027,8 +1027,7 @@
   $ hg ci -qAm 'The previous two (parentless) commits had a hash prefix of 
b04363. Check that rewrite_hash_refs will not fail because of that.'
   $ hg rebase -r . -d 5
   rebasing 8:5c4cdabf5769 tip "The previous two (parentless) commits had a 
hash prefix of b04363. Check that rewrite_hash_refs will not fail because of 
that."
-  abort: 00changelog@b04363: ambiguous identifier
-  [50]
+  saved backup bundle to 
$TESTTMP/keep_merge/.hg/strip-backup/5c4cdabf5769-335e1828-rebase.hg
 
   $ cd ..
 
diff --git a/mercurial/rewriteutil.py b/mercurial/rewriteutil.py
--- a/mercurial/rewriteutil.py
+++ b/mercurial/rewriteutil.py
@@ -215,9 +215,9 @@
 for h in hashes:
 try:
 fullnode = scmutil.resolvehexnodeidprefix(unfi, h)
-except error.WdirUnsupported:
-# Someone has an f... in a commit message we're
-# rewriting. Don't try rewriting that.
+except (error.WdirUnsupported, error.AmbiguousPrefixLookupError):
+# Someone has an f... or some other prefix that's ambiguous in 
a
+# commit message we're rewriting. Don't try rewriting that.
 continue
 if fullnode is None:
 continue



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


D12551: tests: add test demonstrating issue with ambiguous has prefixes during rebase

2022-04-13 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  tests/test-rebase-inmemory.t

CHANGE DETAILS

diff --git a/tests/test-rebase-inmemory.t b/tests/test-rebase-inmemory.t
--- a/tests/test-rebase-inmemory.t
+++ b/tests/test-rebase-inmemory.t
@@ -1003,6 +1003,33 @@
   o  0: d20a80d4def3 'base'
   
 
+Add an explicit test for rewrite_hash_refs when the detected prefix is
+ambiguous. Here's the super low-tech way I found this collision, if the hashing
+scheme ever changes:
+# hg init
+# echo test0 > test
+# hg ci -qAm 'test0' -u 'test' -d '0 0'
+# i=1
+# while [[ $(chg log -r . -T'{shortest(node, 6)}' | wc -c) -eq 6 ]]; do
+#   chg co -r 00
+#   echo "test$i" > test
+#   chg ci -qAm "test$i" -u test -d '0 0'
+#   (( ++i ))
+# done
+  $ hg co -q 00
+  $ echo test5281 > test
+  $ hg ci -qAm 'test5281'
+  $ hg co -q 0
+  $ echo test9912 > test
+  $ hg ci -qAm 'test9912'
+  $ hg co -q 4
+  $ echo contents > some_file
+  $ hg ci -qAm 'The previous two (parentless) commits had a hash prefix of 
b04363. Check that rewrite_hash_refs will not fail because of that.'
+  $ hg rebase -r . -d 5
+  rebasing 8:5c4cdabf5769 tip "The previous two (parentless) commits had a 
hash prefix of b04363. Check that rewrite_hash_refs will not fail because of 
that."
+  abort: 00changelog@b04363: ambiguous identifier
+  [50]
+
   $ cd ..
 
 Test (virtual) working directory without changes, created by merge conflict



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


D12441: crecord: avoid duplicating lines when reverting noeol->eol change

2022-04-05 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  When reversing a patch that looks like this while using crecord:
  
@@ -301,4 +302,4 @@ zza
 zzb
 zzc
 zzd
-zze
\ No newline at end of file
+zze
  
  we would previously reverse the `-zze` line to be an add, encounter the "no
  newline" line and stop inspecting lines. This caused us to duplicate the line,
  producing `zzezze` (still without a newline).
  
  `break` is the correct action if we know there will be no lines afterwards, as
  would be the case in an eol -> noeol transition. It is incorrect if there are
  lines afterward, such as if both sides are missing the newline or if only the
  lhs is missing the newline.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/crecord.py
  tests/test-revert-interactive-curses.t

CHANGE DETAILS

diff --git a/tests/test-revert-interactive-curses.t 
b/tests/test-revert-interactive-curses.t
--- a/tests/test-revert-interactive-curses.t
+++ b/tests/test-revert-interactive-curses.t
@@ -68,6 +68,5 @@
   $ do_revert
   reverting a
   $ cat a
-  0 (wdir known-bad-output !)
   0 (no-eol)
 
diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -505,7 +505,7 @@
 text = line.linetext
 if line.linetext == diffhelper.MISSING_NEWLINE_MARKER:
 noeol = True
-break
+continue
 if line.applied:
 if text.startswith(b'+'):
 dels.append(text[1:])



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


D12440: crecord: add test demonstrating issue when reverting noeol->eol change

2022-04-05 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-revert-interactive-curses.t

CHANGE DETAILS

diff --git a/tests/test-revert-interactive-curses.t 
b/tests/test-revert-interactive-curses.t
--- a/tests/test-revert-interactive-curses.t
+++ b/tests/test-revert-interactive-curses.t
@@ -1,4 +1,5 @@
 #require curses
+#testcases committed wdir
 
 Revert interactive tests with the Curses interface
 
@@ -12,6 +13,22 @@
 
 TODO: Make a curses version of the other tests from test-revert-interactive.t.
 
+#if committed
+  $ maybe_commit() {
+  >   hg ci "$@"
+  > }
+  $ do_revert() {
+  >   hg revert -ir'.^'
+  > }
+#else
+  $ maybe_commit() {
+  >   true
+  > }
+  $ do_revert() {
+  >   hg revert -i
+  > }
+#endif
+
 When a line without EOL is selected during "revert -i"
 
   $ hg init $TESTTMP/revert-i-curses-eol
@@ -19,7 +36,7 @@
   $ echo 0 > a
   $ hg ci -qAm 0
   $ printf 1 >> a
-  $ hg ci -qAm 1
+  $ maybe_commit -qAm 1
   $ cat a
   0
   1 (no-eol)
@@ -28,7 +45,7 @@
   > c
   > EOF
 
-  $ hg revert -ir'.^'
+  $ do_revert
   reverting a
   $ cat a
   0
@@ -40,7 +57,7 @@
   $ printf 0 > a
   $ hg ci -qAm 0
   $ echo 0 > a
-  $ hg ci -qAm 1
+  $ maybe_commit -qAm 1
   $ cat a
   0
 
@@ -48,8 +65,9 @@
   > c
   > EOF
 
-  $ hg revert -ir'.^'
+  $ do_revert
   reverting a
   $ cat a
+  0 (wdir known-bad-output !)
   0 (no-eol)
 



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


D12375: tests: fix formatting issue in run-tests.py after c194e93d1ebc

2022-03-14 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -241,8 +241,11 @@
 except (socket.error, OSError) as exc:
 if exc.errno == errno.EADDRINUSE:
 return True
-elif exc.errno in (errno.EADDRNOTAVAIL, errno.EPROTONOSUPPORT,
-   errno.EAFNOSUPPORT):
+elif exc.errno in (
+errno.EADDRNOTAVAIL,
+errno.EPROTONOSUPPORT,
+errno.EAFNOSUPPORT,
+):
 return False
 else:
 raise



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


D12371: tests: support another error case when detecting ipv4/ipv6 support

2022-03-09 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I encountered this on Linux in a VM environment with a rather strange 
networking
  setup (both on the host and in the VM).

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -238,10 +238,11 @@
 s.bind(('localhost', port))
 s.close()
 return True
-except socket.error as exc:
+except (socket.error, OSError) as exc:
 if exc.errno == errno.EADDRINUSE:
 return True
-elif exc.errno in (errno.EADDRNOTAVAIL, errno.EPROTONOSUPPORT):
+elif exc.errno in (errno.EADDRNOTAVAIL, errno.EPROTONOSUPPORT,
+   errno.EAFNOSUPPORT):
 return False
 else:
 raise



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


D11883: directaccess: fix uses of commands.status() that don't go through flag parsing

2021-12-07 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  When `commands.commit.post-status` is enabled, after commit/amend,
  commands.status() is called without any revs argument, which means that status
  gets None instead of an empty list like it would receive if the user had 
invoked
  this on the commandline. With the `experimental.directaccess` config enabled,
  this gets passed to `unhidehashlikerevs`, which didn't previously handle None,
  but now should.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -2197,6 +2197,9 @@
 
 returns a repo object with the required changesets unhidden
 """
+if not specs:
+return repo
+
 if not repo.filtername or not repo.ui.configbool(
 b'experimental', b'directaccess'
 ):



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


D11884: status: when extracting arguments from `opts`, use the same default values

2021-12-07 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Sometimes other code, such as commit when using `commands.commit.post-status`,
  calls `commands.status()` without going through the normal dispatch mechanism
  that would typically fill in the args to be something besides None. As a
  "defense in depth" mechanism for a bug where Mercurial would crash if both
  `commands.commit.post-status` and `experimental.directaccess` were enabled,
  let's sanitize these values to be identical to the values they would have when
  the user invoked this method from the commandline.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6897,9 +6897,9 @@
 
 cmdutil.check_at_most_one_arg(opts, 'rev', 'change')
 opts = pycompat.byteskwargs(opts)
-revs = opts.get(b'rev')
-change = opts.get(b'change')
-terse = opts.get(b'terse')
+revs = opts.get(b'rev', [])
+change = opts.get(b'change', b'')
+terse = opts.get(b'terse', _NOTTERSE)
 if terse is _NOTTERSE:
 if revs:
 terse = b''



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


D11734: pyoxidizer: use in-memory resources on non-Windows platforms

2021-11-03 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  In-memory resources were disabled for macOS in 7bc1beed 
, 
and for all platforms
  in c900d962 
. 
Unfortunately this made it so that we were no longer producing
  standalone binaries on these platforms, and would have to ship the .py and 
.pyc
  files alongside the pyoxidized binary.
  
  These changes are no longer necessary after f6b04591 
, 
which disabled pep517 and
  solved the issue we were encountering.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hgcli/pyoxidizer.bzl

CHANGE DETAILS

diff --git a/rust/hgcli/pyoxidizer.bzl b/rust/hgcli/pyoxidizer.bzl
--- a/rust/hgcli/pyoxidizer.bzl
+++ b/rust/hgcli/pyoxidizer.bzl
@@ -34,7 +34,10 @@
 
 IS_WINDOWS = "windows" in BUILD_TARGET_TRIPLE
 
-USE_IN_MEMORY_RESOURCES = False
+# Use in-memory resources for all resources. If false, most of the Python
+# stdlib will be in memory, but other things such as Mercurial itself will not
+# be. See the comment in resource_callback, below.
+USE_IN_MEMORY_RESOURCES = not IS_WINDOWS
 
 # Code to run in Python interpreter.
 RUN_CODE = """



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


D11714: tests: fix test-convert-git to work w/ "git pull" requiring strategy

2021-10-20 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  A recent change to git (031e2f7ae195) made it an error to not specify a 
strategy
  (`--rebase`, `--no-rebase`, `--ff-only`), instead of just the warning it was
  previously. As far as I can tell, `--no-rebase` is the behavior we were 
getting
  before, and the only one that makes the test work.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-convert-git.t

CHANGE DETAILS

diff --git a/tests/test-convert-git.t b/tests/test-convert-git.t
--- a/tests/test-convert-git.t
+++ b/tests/test-convert-git.t
@@ -50,7 +50,7 @@
   $ echo a >> a
   $ commit -a -m t4.2
   $ git checkout master >/dev/null 2>/dev/null
-  $ git pull --no-commit . other > /dev/null 2>/dev/null
+  $ git pull --no-commit . other --no-rebase > /dev/null 2>/dev/null
   $ commit -m 'Merge branch other'
   $ cd ..
   $ hg convert --config extensions.progress= --config progress.assume-tty=1 \
@@ -137,7 +137,7 @@
   $ git add baz
   $ commit -a -m 'add baz'
   $ git checkout master >/dev/null 2>/dev/null
-  $ git pull --no-commit . Bar Baz > /dev/null 2>/dev/null
+  $ git pull --no-commit . Bar Baz --no-rebase > /dev/null 2>/dev/null
   $ commit -m 'Octopus merge'
   $ echo bar >> bar
   $ commit -a -m 'change bar'
@@ -145,7 +145,7 @@
   $ echo >> foo
   $ commit -a -m 'change foo'
   $ git checkout master >/dev/null 2>/dev/null
-  $ git pull --no-commit -s ours . Foo > /dev/null 2>/dev/null
+  $ git pull --no-commit -s ours . Foo --no-rebase > /dev/null 2>/dev/null
   $ commit -m 'Discard change to foo'
   $ cd ..
   $ glog()



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


D11706: merge-halt: fix issue with merge.on-failure=halt breaking unshelve

2021-10-19 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/merge.py
  tests/test-merge-halt.t

CHANGE DETAILS

diff --git a/tests/test-merge-halt.t b/tests/test-merge-halt.t
--- a/tests/test-merge-halt.t
+++ b/tests/test-merge-halt.t
@@ -44,7 +44,7 @@
   merging a
   merging b
   merging a failed!
-  merge halted after failed merge (see hg resolve)
+  unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
   [240]
 
   $ hg resolve --list
@@ -72,7 +72,7 @@
   continue merge operation (yn)? y
   merging b failed!
   continue merge operation (yn)? n
-  merge halted after failed merge (see hg resolve)
+  unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
   [240]
 
   $ hg resolve --list
@@ -101,7 +101,7 @@
   was merge successful (yn)? n
   merging b failed!
   continue merge operation (yn)? n
-  merge halted after failed merge (see hg resolve)
+  unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
   [240]
 
   $ hg resolve --list
@@ -124,7 +124,7 @@
   merging a
   merging b
   merging a failed!
-  merge halted after failed merge (see hg resolve)
+  unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
   [240]
 
   $ hg resolve --list
@@ -145,7 +145,7 @@
   was merge of 'a' successful (yn)? y
   was merge of 'b' successful (yn)? n
   merging b failed!
-  merge halted after failed merge (see hg resolve)
+  unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
   [240]
 
   $ hg resolve --list
@@ -167,6 +167,9 @@
   $ cat <> $HGRCPATH
   > [extensions]
   > shelve =
+  > [merge-tools]
+  > false.check=conflicts
+  > false.premerge=false
   > EOS
   $ echo foo > shelve_file1
   $ echo foo > shelve_file2
@@ -186,15 +189,14 @@
   merging shelve_file1
   merging shelve_file2
   merging shelve_file1 failed!
-  merge halted after failed merge (see hg resolve)
+  unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
   [240]
-FIXME: This should claim it's in an 'unshelve' state
   $ hg status --config commands.status.verbose=True
   M shelve_file1
   M shelve_file2
   ? shelve_file1.orig
   ? shelve_file2.orig
-  # The repository is in an unfinished *update* state.
+  # The repository is in an unfinished *unshelve* state.
   
   # Unresolved merge conflicts:
   # 
@@ -203,16 +205,16 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # To continue:hg update .
+  # To continue:hg unshelve --continue
+  # To abort:   hg unshelve --abort
   
-FIXME: This should not be referencing a stripped commit.
   $ hg resolve --tool false --all --re-merge
-  abort: unknown revision '4a1d727ea5bb6aed9adfacb2a8f776bae44301d6'
-  [255]
-Ensure the shelve is still around, since we haven't finished the operation yet.
+  merging shelve_file1
+  merging shelve_file2
+  merging shelve_file1 failed!
+  merge halted after failed merge (see hg resolve)
+  [240]
   $ hg shelve --list
   default (* ago)changes to: foo (glob)
-FIXME: `hg unshelve --abort` should work.
   $ hg unshelve --abort
-  abort: no unshelve in progress
-  [20]
+  unshelve of 'default' aborted
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1713,6 +1713,10 @@
 progress.increment(item=f, total=numupdates)
 ms.resolve(f, wctx)
 
+except error.InterventionRequired:
+# If the user has merge.on-failure=halt, catch the error and close the
+# merge state "properly".
+pass
 finally:
 ms.commit()
 



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


D11705: merge-halt: demonstrate unshelve issue with merge.on-failure=halt

2021-10-19 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-merge-halt.t

CHANGE DETAILS

diff --git a/tests/test-merge-halt.t b/tests/test-merge-halt.t
--- a/tests/test-merge-halt.t
+++ b/tests/test-merge-halt.t
@@ -162,3 +162,57 @@
   merging b
   $TESTTMP/repo/a *a~base* *a~other* (glob)
   $TESTTMP/repo/b *b~base* *b~other* (glob)
+
+Check that unshelve isn't broken by halting the merge
+  $ cat <> $HGRCPATH
+  > [extensions]
+  > shelve =
+  > EOS
+  $ echo foo > shelve_file1
+  $ echo foo > shelve_file2
+  $ hg ci -qAm foo
+  $ echo bar >> shelve_file1
+  $ echo bar >> shelve_file2
+  $ hg shelve --list
+  $ hg shelve
+  shelved as default
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo baz >> shelve_file1
+  $ echo baz >> shelve_file2
+  $ hg ci -m baz
+  $ hg unshelve --tool false --config merge-tools.false.premerge=keep
+  unshelving change 'default'
+  rebasing shelved changes
+  merging shelve_file1
+  merging shelve_file2
+  merging shelve_file1 failed!
+  merge halted after failed merge (see hg resolve)
+  [240]
+FIXME: This should claim it's in an 'unshelve' state
+  $ hg status --config commands.status.verbose=True
+  M shelve_file1
+  M shelve_file2
+  ? shelve_file1.orig
+  ? shelve_file2.orig
+  # The repository is in an unfinished *update* state.
+  
+  # Unresolved merge conflicts:
+  # 
+  # shelve_file1
+  # shelve_file2
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
+  # To continue:hg update .
+  
+FIXME: This should not be referencing a stripped commit.
+  $ hg resolve --tool false --all --re-merge
+  abort: unknown revision '4a1d727ea5bb6aed9adfacb2a8f776bae44301d6'
+  [255]
+Ensure the shelve is still around, since we haven't finished the operation yet.
+  $ hg shelve --list
+  default (* ago)changes to: foo (glob)
+FIXME: `hg unshelve --abort` should work.
+  $ hg unshelve --abort
+  abort: no unshelve in progress
+  [20]



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


D11698: pyoxidizer: update README.md with several small fixes

2021-10-19 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Currently, pyoxidizer.bzl does not mention the git commit that should be 
checked
  out, so these instructions are a bit difficult to follow right now 
(impossible,
  technically), so I removed the instruction to `git checkout ` and
  the admonition to use a specific version of PyOxidizer. I don't even know if 
the
  project currently builds with the "0.7.0-pre" version that was previously
  recommended.
  
  As fallout from that change to not "pin" to a specific PyOxidizer, I had to
  update the Python version to use when running the tests.
  
  While here, I added a recommendation to use `--release`, as the primary reason
  for this project is performance, and it may have been leaving some on the 
table
  to not have that there.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hgcli/README.md

CHANGE DETAILS

diff --git a/rust/hgcli/README.md b/rust/hgcli/README.md
--- a/rust/hgcli/README.md
+++ b/rust/hgcli/README.md
@@ -12,23 +12,21 @@
 
 # Building
 
-This project currently requires an unreleased version of PyOxidizer
-(0.7.0-pre). For best results, build the exact PyOxidizer commit
-as defined in the `pyoxidizer.bzl` file:
+First, acquire and build a copy of PyOxidizer; you probably want to do this in
+some directory outside of your clone of Mercurial:
 
 $ git clone https://github.com/indygreg/PyOxidizer.git
 $ cd PyOxidizer
-$ git checkout 
 $ cargo build --release
 
-Then build this Rust project using the built `pyoxidizer` executable::
+Then build this Rust project using the built `pyoxidizer` executable:
 
-$ /path/to/pyoxidizer/target/release/pyoxidizer build
+$ /path/to/pyoxidizer/target/release/pyoxidizer build --release
 
 If all goes according to plan, there should be an assembled application
-under `build//debug/app/` with an `hg` executable:
+under `build//release/app/` with an `hg` executable:
 
-$ build/x86_64-unknown-linux-gnu/debug/app/hg version
+$ build/x86_64-unknown-linux-gnu/release/app/hg version
 Mercurial Distributed SCM (version 5.3.1+433-f99cd77d53dc+20200331)
 (see https://mercurial-scm.org for more information)
 
@@ -46,5 +44,5 @@
 to the Mercurial source directory. e.g.:
 
 $ cd /path/to/hg/src/tests
-$ PYTHONPATH=`pwd`/.. python3.7 run-tests.py \
---with-hg 
`pwd`/../rust/hgcli/build/x86_64-unknown-linux-gnu/debug/app/hg
+$ PYTHONPATH=`pwd`/.. python3.9 run-tests.py \
+--with-hg 
`pwd`/../rust/hgcli/build/x86_64-unknown-linux-gnu/release/app/hg



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


D11697: pyoxidizer: disable using in-memory resources

2021-10-19 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  It's possible that the errors are due to using an incompatible version of
  PyOxidizer; unfortunately the README.md file in this directory says to fetch a
  copy of PyOxidizer matching the commit in this pyoxidizer.bzl file, and yet 
the
  pyoxidizer.bzl file does not actually have a commit mentioned in it.
  
  By disabling in-memory modules, this appears to work on all platforms using 
the
  current head version of PyOxidizer, so let's disable them for now.
  
  Sample error (during `pyoxidizer build`):
  
error[PYOXIDIZER_PYTHON_EXECUTABLE]: adding 
PythonExtensionModule

Caused by:
extension module hgext.fsmonitor.pywatchman.bser cannot be loaded from 
memory but memory loading required
   --> ./pyoxidizer.bzl:140:5
|
140 | exe.add_python_resources(exe.pip_install(["--verbose", ROOT]))
| ^^ 
add_python_resources()


error: adding PythonExtensionModule

Caused by:
extension module hgext.fsmonitor.pywatchman.bser cannot be loaded from 
memory but memory loading required

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hgcli/pyoxidizer.bzl

CHANGE DETAILS

diff --git a/rust/hgcli/pyoxidizer.bzl b/rust/hgcli/pyoxidizer.bzl
--- a/rust/hgcli/pyoxidizer.bzl
+++ b/rust/hgcli/pyoxidizer.bzl
@@ -33,7 +33,8 @@
 TIME_STAMP_SERVER_URL = VARS.get("TIME_STAMP_SERVER_URL", 
"http://timestamp.digicert.com;)
 
 IS_WINDOWS = "windows" in BUILD_TARGET_TRIPLE
-IS_MACOS = "darwin" in BUILD_TARGET_TRIPLE
+
+USE_IN_MEMORY_RESOURCES = False
 
 # Code to run in Python interpreter.
 RUN_CODE = """
@@ -84,7 +85,7 @@
 return default_python_distribution(python_version = "3.9")
 
 def resource_callback(policy, resource):
-if not (IS_WINDOWS or IS_MACOS):
+if USE_IN_MEMORY_RESOURCES:
 resource.add_location = "in-memory"
 return
 
@@ -115,7 +116,7 @@
 # extensions.
 packaging_policy.extension_module_filter = "all"
 packaging_policy.resources_location = "in-memory"
-if IS_WINDOWS or IS_MACOS:
+if not USE_IN_MEMORY_RESOURCES:
 packaging_policy.resources_location_fallback = 
"filesystem-relative:lib"
 packaging_policy.register_resource_callback(resource_callback)
 



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


D11391: filemerge: be more strict when detecting conflict markers, add `|` markers

2021-09-08 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I received a user complaint about detecting a line that contained 78 `=`
  followed by `*/` as a conflict marker. We'll never generate that, we generate 
7
  identical characters and either the end of the line, or a space. Let's be
  explicit about detecting exactly what we produce to reduce the chances of a
  false positive.
  
  While we're here, add `|||` as a detected conflict marker (generated with
  the `keep-merge3` style conflicts).

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/filemerge.py

CHANGE DETAILS

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -1212,9 +1212,13 @@
 
 
 def hasconflictmarkers(data):
+# Detect lines starting with a string of 7 identical characters from the
+# subset Mercurial uses for conflict markers, followed by either the end of
+# line or a space and some text. Note that using [<>=+|-]{7} would detect
+# `<><><><><` as a conflict marker, which we don't want.
 return bool(
 re.search(
-br"^(<<<.*|===.*|--- .*|\+\+\+\+\+\+\+ .*|>>>.*)$",
+br"^([<>=+|-])\1{6}( .*)$",
 data,
 re.MULTILINE,
 )



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


D11217: help: correct config.profiling.freq name (frequency->freq)

2021-07-27 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/helptext/config.txt

CHANGE DETAILS

diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt
--- a/mercurial/helptext/config.txt
+++ b/mercurial/helptext/config.txt
@@ -1832,7 +1832,7 @@
 ``json``
   Render profiling data as JSON.
 
-``frequency``
+``freq``
 Sampling frequency.  Specific to the ``stat`` sampling profiler.
 (default: 1000)
 



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


D10539: black: make codebase compatible with black v21.4b2 and v20.8b1

2021-04-30 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I don't know what exact version of black made it care about these whitespace
  differences, but this is the version I got when I just installed it with
  `pip3 install black`.
  
  I'm intentionally not increasing the version of black required, as I don't 
want
  to force everyone to upgrade their version of black, and these fixes are
  backwards compatible with black v20.8b1. If there are more issues in the 
future
  and this becomes a maintenance burden I may do so in a future change.
  
  Tested with both versions of black (I got the older version via
  `pip3 install black==20.8b1`)

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  doc/hgmanpage.py
  hgext/convert/git.py
  hgext/convert/hg.py
  hgext/convert/subversion.py
  hgext/convert/transport.py
  hgext/fsmonitor/pywatchman/__init__.py
  hgext/gpg.py
  hgext/histedit.py
  hgext/remotenames.py
  mercurial/branchmap.py
  mercurial/bundle2.py
  mercurial/cmdutil.py
  mercurial/commandserver.py
  mercurial/crecord.py
  mercurial/debugcommands.py
  mercurial/mail.py
  mercurial/mergestate.py
  mercurial/revlogutils/nodemap.py
  mercurial/scmutil.py
  mercurial/state.py
  mercurial/store.py
  mercurial/upgrade_utils/actions.py
  mercurial/upgrade_utils/engine.py
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -144,7 +144,7 @@
 
 def setumask(val):
 # type: (int) -> None
-''' updates the umask. used by chg server '''
+'''updates the umask. used by chg server'''
 if pycompat.iswindows:
 return
 os.umask(val)
diff --git a/mercurial/upgrade_utils/engine.py 
b/mercurial/upgrade_utils/engine.py
--- a/mercurial/upgrade_utils/engine.py
+++ b/mercurial/upgrade_utils/engine.py
@@ -134,7 +134,7 @@
 sidedatacompanion,
 oncopiedrevision,
 ):
-""" returns the new revlog object created"""
+"""returns the new revlog object created"""
 newrl = None
 if matchrevlog(upgrade_op.revlogs_to_process, rl_type):
 ui.note(
diff --git a/mercurial/upgrade_utils/actions.py 
b/mercurial/upgrade_utils/actions.py
--- a/mercurial/upgrade_utils/actions.py
+++ b/mercurial/upgrade_utils/actions.py
@@ -842,11 +842,11 @@
 self.ui.status(_(b'%s\n   %s\n\n') % (i.name, i.description))
 
 def has_upgrade_action(self, name):
-""" Check whether the upgrade operation will perform this action """
+"""Check whether the upgrade operation will perform this action"""
 return name in self._upgrade_actions_names
 
 def print_post_op_messages(self):
-""" print post upgrade operation warning messages """
+"""print post upgrade operation warning messages"""
 for a in self.upgrade_actions:
 if a.postupgrademessage is not None:
 self.ui.warn(b'%s\n' % a.postupgrademessage)
diff --git a/mercurial/store.py b/mercurial/store.py
--- a/mercurial/store.py
+++ b/mercurial/store.py
@@ -629,7 +629,7 @@
 fp.close()
 
 def _checkentries(self, fp, warn):
-""" make sure there is no empty string in entries """
+"""make sure there is no empty string in entries"""
 if b'' in self.entries:
 fp.seek(0)
 for n, line in enumerate(util.iterfile(fp)):
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -188,7 +188,7 @@
 return self._cmdmsg
 
 def continuemsg(self):
-""" returns appropriate continue message corresponding to command"""
+"""returns appropriate continue message corresponding to command"""
 return _(b'hg %s --continue') % (self._opname)
 
 def isunfinished(self, repo):
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1561,7 +1561,7 @@
 
 
 def istreemanifest(repo):
-""" returns whether the repository is using treemanifest or not """
+"""returns whether the repository is using treemanifest or not"""
 return requirementsmod.TREEMANIFEST_REQUIREMENT in repo.requirements
 
 
diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -133,7 +133,7 @@
 
 
 def delete_nodemap(tr, repo, revlog):
-""" Delete nodemap data on disk for a given revlog"""
+"""Delete nodemap data on disk for a given revlog"""
 if revlog.nodemap_file is None:
 msg = "calling persist nodemap on a revlog without the feature enabled"
 raise error.ProgrammingError(msg)
diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -306,11 +306,11 @@

D10537: tests: fix chg tests missed in D10470

2021-04-30 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/chg/chg.c
  tests/test-blackbox.t
  tests/test-merge-subrepos.t
  tests/test-setdiscovery.t

CHANGE DETAILS

diff --git a/tests/test-setdiscovery.t b/tests/test-setdiscovery.t
--- a/tests/test-setdiscovery.t
+++ b/tests/test-setdiscovery.t
@@ -1536,7 +1536,7 @@
   searching for changes
   101 102 103 104 105 106 107 108 109 110  (no-eol)
   $ hg -R r1 --config extensions.blackbox= blackbox --config blackbox.track=
-  * @5d0b986a083e0d91f116de4691e2aaa54d5bbec0 (*)> serve --cmdserver chgunix * 
(glob) (chg !)
+  * @5d0b986a083e0d91f116de4691e2aaa54d5bbec0 (*)> serve --no-profile 
--cmdserver chgunix * (glob) (chg !)
   * @5d0b986a083e0d91f116de4691e2aaa54d5bbec0 (*)> -R r1 outgoing r2 *-T{rev} 
* --config *extensions.blackbox=* (glob)
   * @5d0b986a083e0d91f116de4691e2aaa54d5bbec0 (*)> found 101 common and 1 
unknown server heads, 1 roundtrips in *.s (glob)
   * @5d0b986a083e0d91f116de4691e2aaa54d5bbec0 (*)> -R r1 outgoing r2 *-T{rev} 
* --config *extensions.blackbox=* exited 0 after *.?? seconds (glob)
diff --git a/tests/test-merge-subrepos.t b/tests/test-merge-subrepos.t
--- a/tests/test-merge-subrepos.t
+++ b/tests/test-merge-subrepos.t
@@ -61,7 +61,7 @@
   > --config blackbox.track='command commandfinish'
   9bfe45a197d7+ tip
   $ cat .hg/blackbox.log
-  * @9bfe45a197d7b0ab09bf287729dd57e9619c9da5+ (*)> serve --cmdserver chgunix 
* (glob) (chg !)
+  * @9bfe45a197d7b0ab09bf287729dd57e9619c9da5+ (*)> serve --no-profile 
--cmdserver chgunix * (glob) (chg !)
   * @9bfe45a197d7b0ab09bf287729dd57e9619c9da5+ (*)> id --config 
*extensions.blackbox=* --config *blackbox.dirty=True* (glob)
   * @9bfe45a197d7b0ab09bf287729dd57e9619c9da5+ (*)> id --config 
*extensions.blackbox=* --config *blackbox.dirty=True* exited 0 * (glob)
 
diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t
--- a/tests/test-blackbox.t
+++ b/tests/test-blackbox.t
@@ -221,7 +221,7 @@
   1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> 
pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob)
   1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> 
exthook-update: echo hooked finished in * seconds (glob)
   1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> 
update exited 0 after * seconds (glob)
-  1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> 
serve --cmdserver chgunix --address $TESTTMP.chgsock/server.* --daemon-postexec 
'chdir:/' (glob) (chg !)
+  1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> 
serve --no-profile --cmdserver chgunix --address $TESTTMP.chgsock/server.* 
--daemon-postexec 'chdir:/' (glob) (chg !)
   1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> 
blackbox -l 5
 
 log rotation
diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c
--- a/contrib/chg/chg.c
+++ b/contrib/chg/chg.c
@@ -240,14 +240,8 @@
const char *hgcmd = gethgcmd();
 
const char *baseargv[] = {
-   hgcmd,
-   "serve",
-   "--no-profile",
-   "--cmdserver",
-   "chgunix",
-   "--address",
-   opts->initsockname,
-   "--daemon-postexec",
+   hgcmd, "serve", "--no-profile", "--cmdserver",
+   "chgunix", "--address", opts->initsockname, "--daemon-postexec",
"chdir:/",
};
size_t baseargvsize = sizeof(baseargv) / sizeof(baseargv[0]);



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


D10538: tests: allow trunk versions of clang-format to be used

2021-04-30 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/hghave.py

CHANGE DETAILS

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -613,7 +613,13 @@
 def has_clang_format():
 m = matchoutput('clang-format --version', br'clang-format version (\d+)')
 # style changed somewhere between 10.x and 11.x
-return m and int(m.group(1)) >= 11
+if m:
+return int(m.group(1)) >= 11
+# Allow users to have a trunk version installed; this assumes that they 
keep
+# it up to date, unfortunately checking for that is difficult/impossible?
+return matchoutput(
+'clang-format --version', br'clang-format .*trunk \([0-9a-f]+\)'
+)
 
 
 @check("jshint", "JSHint static code analysis tool")



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


D10504: dirstateguard: use mktemp-like functionality to generate the backup filenames

2021-04-20 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Previously these were generated with names like:
  `dirstate.backup.commit.`
  
  This could cause problems if two hg commands ran at the same time that used 
the
  same memory address, (which is apparently not uncommon if chg is involved), as
  memory addresses are not unique across processes.
  
  This issue was reported in the post-review comments on
  http://phab.mercurial-scm.org/D9952.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstateguard.py

CHANGE DETAILS

diff --git a/mercurial/dirstateguard.py b/mercurial/dirstateguard.py
--- a/mercurial/dirstateguard.py
+++ b/mercurial/dirstateguard.py
@@ -7,6 +7,7 @@
 
 from __future__ import absolute_import
 
+import os
 from .i18n import _
 
 from . import (
@@ -34,11 +35,12 @@
 self._repo = repo
 self._active = False
 self._closed = False
-self._backupname = b'dirstate.backup.%s.%d' % (name, id(self))
-self._narrowspecbackupname = b'narrowspec.backup.%s.%d' % (
-name,
-id(self),
-)
+def getname(prefix):
+fd, fname = repo.vfs.mkstemp(prefix=prefix)
+os.close(fd)
+return fname
+self._backupname = getname(b'dirstate.backup.%s.' % name)
+self._narrowspecbackupname = getname(b'narrowspec.backup.%s.' % name)
 repo.dirstate.savebackup(repo.currenttransaction(), self._backupname)
 narrowspec.savewcbackup(repo, self._narrowspecbackupname)
 self._active = True



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


D10469: profiling: add --no-profile to disable profiling enabled via config

2021-04-19 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dispatch.py
  tests/test-chg.t

CHANGE DETAILS

diff --git a/tests/test-chg.t b/tests/test-chg.t
--- a/tests/test-chg.t
+++ b/tests/test-chg.t
@@ -468,3 +468,72 @@
   LC_ALL=
   LC_CTYPE=
   LANG=
+
+Profiling isn't permanently enabled or carried over between chg invocations 
that
+share the same server
+  $ cp $HGRCPATH.orig $HGRCPATH
+  $ hg init $TESTTMP/profiling
+  $ cd $TESTTMP/profiling
+  $ filteredchg() {
+  >   CHGDEBUG=1 chg "$@" 2>&1 | egrep 'Sample count|start cmdserver' || true
+  > }
+  $ newchg() {
+  >   chg --kill-chg-daemon
+  >   filteredchg "$@" | egrep -v 'start cmdserver' || true
+  > }
+(--profile isn't permanently on just because it was specified when chg was
+started)
+  $ newchg log -r . --profile
+  Sample count: * (glob)
+  $ filteredchg log -r .
+(enabling profiling via config works, even on the first chg command that starts
+a cmdserver)
+  $ cat >> $HGRCPATH < [profiling]
+  > type=stat
+  > enabled=1
+  > EOF
+  $ newchg log -r .
+  Sample count: * (glob)
+  $ filteredchg log -r .
+  Sample count: * (glob)
+(test that we aren't accumulating more and more samples each run)
+  $ cat > $TESTTMP/debugsleep.py < import time
+  > from mercurial import registrar
+  > cmdtable = {}
+  > command = registrar.command(cmdtable)
+  > @command(b'debugsleep', [], b'', norepo=True)
+  > def debugsleep(ui):
+  >   start = time.time()
+  >   x = 0
+  >   while time.time() < start + 0.5:
+  > time.sleep(.1)
+  > x += 1
+  >   ui.status(b'%d debugsleep iterations in %.03fs\n' % (x, time.time() - 
start))
+  > EOF
+  $ cat >> $HGRCPATH < [extensions]
+  > debugsleep = $TESTTMP/debugsleep.py
+  > EOF
+  $ newchg debugsleep > run_1
+  $ filteredchg debugsleep > run_2
+  $ filteredchg debugsleep > run_3
+  $ filteredchg debugsleep > run_4
+FIXME: Run 4 should not be >3x Run 1's number of samples.
+  $ "$PYTHON" < r1 = int(open("run_1", "r").read().split()[-1])
+  > r4 = int(open("run_4", "r").read().split()[-1])
+  > print("Run 1: %d samples\nRun 4: %d samples\nRun 4 > 3 * Run 1: %s" %
+  >   (r1, r4, r4 > (r1 * 3)))
+  > EOF
+  Run 1: * samples (glob)
+  Run 4: * samples (glob)
+  Run 4 > 3 * Run 1: True
+(Disabling with --no-profile on the commandline still works, but isn't 
permanent)
+  $ newchg log -r . --no-profile
+  $ filteredchg log -r .
+  Sample count: * (glob)
+  $ filteredchg log -r . --no-profile
+  $ filteredchg log -r .
+  Sample count: * (glob)
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -1063,6 +1063,16 @@
 if req.earlyoptions[b'profile']:
 for ui_ in uis:
 ui_.setconfig(b'profiling', b'enabled', b'true', b'--profile')
+elif req.earlyoptions[b'profile'] is False:
+# Check for it being set already, so that we don't pollute the config
+# with this when using chg in the very common case that it's not
+# enabled.
+if lui.configbool(b'profiling', b'enabled'):
+# Only do this on lui so that `chg foo` with a user config setting
+# profiling.enabled=1 still shows profiling information (chg will
+# specify `--no-profile` when `hg serve` is starting up, we don't
+# want that to propagate to every later invocation).
+lui.setconfig(b'profiling', b'enabled', b'false', b'--no-profile')
 
 profile = lui.configbool(b'profiling', b'enabled')
 with profiling.profile(lui, enabled=profile) as profiler:



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


D10470: chg: pass --no-profile to disable profiling when starting hg serve

2021-04-19 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  If profiling is enabled via global/user config (as far as I can tell, this
  doesn't affect use of the --profile flag, but it probably does affect --config
  profiling.enabled=1), then the profiling data can be *cumulative* for the
  lifetime of the chg process.
  
  This leads to some "interesting" results where hg claims the walltime is
  something like 200s on a command that took only a second or two to run. Worse,
  however, is that with at least some profilers (such as the default "stat"
  profiler), this can cause a large slowdown while generating the profiler 
output.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/chg/chg.c
  tests/test-chg.t

CHANGE DETAILS

diff --git a/tests/test-chg.t b/tests/test-chg.t
--- a/tests/test-chg.t
+++ b/tests/test-chg.t
@@ -529,7 +529,7 @@
   > EOF
   Run 1: * samples (glob)
   Run 4: * samples (glob)
-  Run 4 > 3 * Run 1: True
+  Run 4 > 3 * Run 1: False
 (Disabling with --no-profile on the commandline still works, but isn't 
permanent)
   $ newchg log -r . --no-profile
   $ filteredchg log -r .
diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c
--- a/contrib/chg/chg.c
+++ b/contrib/chg/chg.c
@@ -242,6 +242,7 @@
const char *baseargv[] = {
hgcmd,
"serve",
+   "--no-profile",
"--cmdserver",
"chgunix",
"--address",



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


D10468: tests: fix test-chg to ignore a warning about being unable to set locale

2021-04-19 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I think this is only enabled on some newer Python versions, which is why this
  wasn't caught before.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-chg.t

CHANGE DETAILS

diff --git a/tests/test-chg.t b/tests/test-chg.t
--- a/tests/test-chg.t
+++ b/tests/test-chg.t
@@ -458,6 +458,7 @@
   LC_CTYPE=
   $ (unset LC_ALL; unset LANG; LC_CTYPE=unsupported_value chg \
   >--config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
+  *cannot change locale* (glob) (?)
   LC_CTYPE=unsupported_value
   $ (unset LC_ALL; unset LANG; LC_CTYPE= chg \
   >--config extensions.debugenv=$TESTTMP/debugenv.py debugenv)



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


D6719: branchmap: refresh all "heads" of the branchmap subsets

2021-04-19 Thread spectral (Kyle Lippincott)
Herald added a subscriber: mercurial-patches.
spectral added a comment.
spectral abandoned this revision.


  I'm apparently not going to resolve the comments, sorry for leaving this open 
so long.

REPOSITORY
  rHG Mercurial

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

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

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


D10388: split: fix issue with empty splits adjusting phases

2021-04-13 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/split.py
  tests/test-split.t

CHANGE DETAILS

diff --git a/tests/test-split.t b/tests/test-split.t
--- a/tests/test-split.t
+++ b/tests/test-split.t
@@ -1063,7 +1063,6 @@
   |
   o  public 0:222799e2f90b r0
   
-FIXME: This should not show "So far it has been split into"
   $ printf 'd\na\n' | HGEDITOR=cat hg split || true
   diff --git a/foo b/foo
   new file mode 100644
@@ -1076,9 +1075,7 @@
   examine changes to 'foo'?
   (enter ? for help) [Ynesfdaq?] a
   
-  HG: Splitting ae694b2901bb. So far it has been split into:
-  HG: - 0:222799e2f90b "r0"
-  HG: Write commit message for the next split changeset.
+  HG: Splitting ae694b2901bb. Write commit message for the first split 
changeset.
   foo
   
   
@@ -1094,13 +1091,12 @@
   rollback completed (obsstore-on !)
   abort: changeset ae694b2901bb cannot obsolete itself (obsstore-on !)
 FIXME: this should not have stripped the commit we just no-op split
-(obsstore-off only), or made r0 draft.
+(obsstore-off only)
   $ hg log -G -T'{phase} {rev}:{node|short} {desc}'
   warning: ignoring unknown working parent ae694b2901bb! (obsstore-off !)
   @  draft 1:ae694b2901bb foo (obsstore-on !)
   | (obsstore-on !)
-  o  public 0:222799e2f90b r0 (obsstore-on !)
-  o  draft 0:222799e2f90b r0 (obsstore-off !)
+  o  public 0:222799e2f90b r0
   
 
 Now try the same thing but modifying the message so we don't trigger the
@@ -1121,7 +1117,6 @@
   $ cat > $TESTTMP/messages < message1
   > EOF
-FIXME: This should not show "So far it has been split into"
   $ printf 'd\na\n' | HGEDITOR="\"$PYTHON\" $TESTTMP/editor.py" hg split
   diff --git a/foo b/foo
   new file mode 100644
@@ -1134,9 +1129,7 @@
   examine changes to 'foo'?
   (enter ? for help) [Ynesfdaq?] a
   
-  EDITOR: HG: Splitting ae694b2901bb. So far it has been split into:
-  EDITOR: HG: - 0:222799e2f90b "r0"
-  EDITOR: HG: Write commit message for the next split changeset.
+  EDITOR: HG: Splitting ae694b2901bb. Write commit message for the first split 
changeset.
   EDITOR: foo
   EDITOR: 
   EDITOR: 
@@ -1148,15 +1141,13 @@
   EDITOR: HG: added foo
   created new head
   saved backup bundle to 
$TESTTMP/noop2/.hg/strip-backup/ae694b2901bb-28e0b457-split.hg (obsstore-off !)
-FIXME: this should not have made r0 draft
   $ hg log -G -T'{phase} {rev}:{node|short} {desc}'
   @  draft 1:de675559d3f9 message1 (obsstore-off !)
   @  draft 2:de675559d3f9 message1 (obsstore-on !)
   |
-  o  draft 0:222799e2f90b r0
+  o  public 0:222799e2f90b r0
   
 #if obsstore-on
-FIXME: this should not have marked 222799e (r0) as a precursor of anything.
   $ hg debugobsolete
-  ae694b2901bb8b0f8c4b5e075ddec0d63468d57a 
222799e2f90be09ccbe49f519c4615d8375a9242 
de675559d3f93ffc822c6eb7490e5c73033f17c7 0 * (glob)
+  ae694b2901bb8b0f8c4b5e075ddec0d63468d57a 
de675559d3f93ffc822c6eb7490e5c73033f17c7 0 * (glob)
 #endif
diff --git a/hgext/split.py b/hgext/split.py
--- a/hgext/split.py
+++ b/hgext/split.py
@@ -171,9 +171,13 @@
 b'message': header + ctx.description(),
 }
 )
+origctx = repo[b'.']
 commands.commit(ui, repo, **pycompat.strkwargs(opts))
 newctx = repo[b'.']
-committed.append(newctx)
+# Ensure user didn't do a "no-op" split (such as deselecting
+# everything).
+if origctx.node() != newctx.node():
+committed.append(newctx)
 
 if not committed:
 raise error.InputError(_(b'cannot split an empty revision'))



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


D10389: split: avoid strip if split is a no-op (identical to original)

2021-04-13 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/split.py
  tests/test-split.t

CHANGE DETAILS

diff --git a/tests/test-split.t b/tests/test-split.t
--- a/tests/test-split.t
+++ b/tests/test-split.t
@@ -1086,16 +1086,9 @@
   HG: branch 'default'
   HG: added foo
   warning: commit already existed in the repository!
-  saved backup bundle to 
$TESTTMP/noop/.hg/strip-backup/ae694b2901bb-28e0b457-split.hg (obsstore-off !)
-  transaction abort! (obsstore-on !)
-  rollback completed (obsstore-on !)
-  abort: changeset ae694b2901bb cannot obsolete itself (obsstore-on !)
-FIXME: this should not have stripped the commit we just no-op split
-(obsstore-off only)
   $ hg log -G -T'{phase} {rev}:{node|short} {desc}'
-  warning: ignoring unknown working parent ae694b2901bb! (obsstore-off !)
-  @  draft 1:ae694b2901bb foo (obsstore-on !)
-  | (obsstore-on !)
+  @  draft 1:ae694b2901bb foo
+  |
   o  public 0:222799e2f90b r0
   
 
diff --git a/hgext/split.py b/hgext/split.py
--- a/hgext/split.py
+++ b/hgext/split.py
@@ -182,12 +182,15 @@
 if not committed:
 raise error.InputError(_(b'cannot split an empty revision'))
 
-scmutil.cleanupnodes(
-repo,
-{ctx.node(): [c.node() for c in committed]},
-operation=b'split',
-fixphase=True,
-)
+if len(committed) != 1 or committed[0].node() != ctx.node():
+# Ensure we don't strip a node if we produce the same commit as already
+# exists
+scmutil.cleanupnodes(
+repo,
+{ctx.node(): [c.node() for c in committed]},
+operation=b'split',
+fixphase=True,
+)
 
 return committed[-1]
 



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


D10387: split: add test demonstrating issue with empty splits adjusting phases

2021-04-13 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-split.t

CHANGE DETAILS

diff --git a/tests/test-split.t b/tests/test-split.t
--- a/tests/test-split.t
+++ b/tests/test-split.t
@@ -1046,3 +1046,117 @@
   [ ui.warning|rollback completed]
   [ ui.error|abort: empty commit message]
   [10]
+
+Test that creating an empty split or "no-op"
+(identical to original) commit doesn't cause chaos
+--
+
+  $ hg init $TESTTMP/noop
+  $ cd $TESTTMP/noop
+  $ echo r0 > r0
+  $ hg ci -qAm r0
+  $ hg phase -p
+  $ echo foo > foo
+  $ hg ci -qAm foo
+  $ hg log -G -T'{phase} {rev}:{node|short} {desc}'
+  @  draft 1:ae694b2901bb foo
+  |
+  o  public 0:222799e2f90b r0
+  
+FIXME: This should not show "So far it has been split into"
+  $ printf 'd\na\n' | HGEDITOR=cat hg split || true
+  diff --git a/foo b/foo
+  new file mode 100644
+  examine changes to 'foo'?
+  (enter ? for help) [Ynesfdaq?] d
+  
+  no changes to record
+  diff --git a/foo b/foo
+  new file mode 100644
+  examine changes to 'foo'?
+  (enter ? for help) [Ynesfdaq?] a
+  
+  HG: Splitting ae694b2901bb. So far it has been split into:
+  HG: - 0:222799e2f90b "r0"
+  HG: Write commit message for the next split changeset.
+  foo
+  
+  
+  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  HG: Leave message empty to abort commit.
+  HG: --
+  HG: user: test
+  HG: branch 'default'
+  HG: added foo
+  warning: commit already existed in the repository!
+  saved backup bundle to 
$TESTTMP/noop/.hg/strip-backup/ae694b2901bb-28e0b457-split.hg (obsstore-off !)
+  transaction abort! (obsstore-on !)
+  rollback completed (obsstore-on !)
+  abort: changeset ae694b2901bb cannot obsolete itself (obsstore-on !)
+FIXME: this should not have stripped the commit we just no-op split
+(obsstore-off only), or made r0 draft.
+  $ hg log -G -T'{phase} {rev}:{node|short} {desc}'
+  warning: ignoring unknown working parent ae694b2901bb! (obsstore-off !)
+  @  draft 1:ae694b2901bb foo (obsstore-on !)
+  | (obsstore-on !)
+  o  public 0:222799e2f90b r0 (obsstore-on !)
+  o  draft 0:222799e2f90b r0 (obsstore-off !)
+  
+
+Now try the same thing but modifying the message so we don't trigger the
+identical changeset failures
+
+  $ hg init $TESTTMP/noop2
+  $ cd $TESTTMP/noop2
+  $ echo r0 > r0
+  $ hg ci -qAm r0
+  $ hg phase -p
+  $ echo foo > foo
+  $ hg ci -qAm foo
+  $ hg log -G -T'{phase} {rev}:{node|short} {desc}'
+  @  draft 1:ae694b2901bb foo
+  |
+  o  public 0:222799e2f90b r0
+  
+  $ cat > $TESTTMP/messages < message1
+  > EOF
+FIXME: This should not show "So far it has been split into"
+  $ printf 'd\na\n' | HGEDITOR="\"$PYTHON\" $TESTTMP/editor.py" hg split
+  diff --git a/foo b/foo
+  new file mode 100644
+  examine changes to 'foo'?
+  (enter ? for help) [Ynesfdaq?] d
+  
+  no changes to record
+  diff --git a/foo b/foo
+  new file mode 100644
+  examine changes to 'foo'?
+  (enter ? for help) [Ynesfdaq?] a
+  
+  EDITOR: HG: Splitting ae694b2901bb. So far it has been split into:
+  EDITOR: HG: - 0:222799e2f90b "r0"
+  EDITOR: HG: Write commit message for the next split changeset.
+  EDITOR: foo
+  EDITOR: 
+  EDITOR: 
+  EDITOR: HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  EDITOR: HG: Leave message empty to abort commit.
+  EDITOR: HG: --
+  EDITOR: HG: user: test
+  EDITOR: HG: branch 'default'
+  EDITOR: HG: added foo
+  created new head
+  saved backup bundle to 
$TESTTMP/noop2/.hg/strip-backup/ae694b2901bb-28e0b457-split.hg (obsstore-off !)
+FIXME: this should not have made r0 draft
+  $ hg log -G -T'{phase} {rev}:{node|short} {desc}'
+  @  draft 1:de675559d3f9 message1 (obsstore-off !)
+  @  draft 2:de675559d3f9 message1 (obsstore-on !)
+  |
+  o  draft 0:222799e2f90b r0
+  
+#if obsstore-on
+FIXME: this should not have marked 222799e (r0) as a precursor of anything.
+  $ hg debugobsolete
+  ae694b2901bb8b0f8c4b5e075ddec0d63468d57a 
222799e2f90be09ccbe49f519c4615d8375a9242 
de675559d3f93ffc822c6eb7490e5c73033f17c7 0 * (glob)
+#endif



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


D10386: tests: avoid use of "python", which may not even be installed

2021-04-13 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-convert-cvs.t
  tests/test-merge-tools.t

CHANGE DETAILS

diff --git a/tests/test-merge-tools.t b/tests/test-merge-tools.t
--- a/tests/test-merge-tools.t
+++ b/tests/test-merge-tools.t
@@ -1921,7 +1921,7 @@
 Binary files capability checking
 
   $ hg update -q -C 0
-  $ python < with open('b', 'wb') as fp:
   > fp.write(b'\x00\x01\x02\x03')
   > EOF
@@ -1929,7 +1929,7 @@
   $ hg commit -qm "add binary file (#1)"
 
   $ hg update -q -C 0
-  $ python < with open('b', 'wb') as fp:
   > fp.write(b'\x03\x02\x01\x00')
   > EOF
diff --git a/tests/test-convert-cvs.t b/tests/test-convert-cvs.t
--- a/tests/test-convert-cvs.t
+++ b/tests/test-convert-cvs.t
@@ -521,7 +521,7 @@
 |cp932 |\x82\xa0  |  x  x o|
 
   $ mkdir -p cvsrepo/transcoding
-  $ python < fp = open('cvsrepo/transcoding/file,v', 'wb')
   > fp.write((b'''
   > head   1.4;



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


D10320: remotefilelog: include file contents in bundles produced during strip

2021-04-06 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  `hg strip` and other things that use repair.strip (such as the narrow
  extension's `hg tracked --removeinclude`) will "save" some commits that have a
  higher revision number than the oldest commit we're stripping, but aren't
  actually descended from any of the commits that we're stripping. It saves them
  in a bundle, and then reapplies them to the repo.
  
  Remotefilelog doesn't generally participate in strip, it doesn't contribute
  files to either the backup bundle or the "saved" bundle, and doesn't adjust
  linknodes when commits are stripped. This can break things like push, which
  rely on the linknodes.
  
  This change makes it so that remotefilelog includes files in these bundles
  during strip operations. During reapplication, the files are reapplied from 
the
  bundle, and the linknode is properly updated.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/remotefilelog/__init__.py
  hgext/remotefilelog/shallowbundle.py
  tests/test-remotefilelog-bgprefetch.t
  tests/test-remotefilelog-bundles.t
  tests/test-remotefilelog-local.t
  tests/test-remotefilelog-prefetch.t
  tests/test-remotefilelog-sparse.t
  tests/test-remotefilelog-strip.t

CHANGE DETAILS

diff --git a/tests/test-remotefilelog-strip.t b/tests/test-remotefilelog-strip.t
--- a/tests/test-remotefilelog-strip.t
+++ b/tests/test-remotefilelog-strip.t
@@ -60,8 +60,9 @@
   |
   @  0 b292c1e3311f
   
-FIXME: This should point to a commit that actually exists in the repo. 
Otherwise
-remotefilelog has to search every commit in the repository looking for a valid
-linkrev every time it's queried, such as during push.
+Demonstrate that the linknode points to a commit that is actually in the repo
+after the strip operation. Otherwise remotefilelog has to search every commit 
in
+the repository looking for a valid linkrev every time it's queried, such as
+during push.
   $ hg debug-file-linknode -r 70494d a
-  df91f74b871e064c89afa1fe9e2f66afa2c125df
+  70494d7ec5ef6cd3cd6939a9fd2812f9956bf553
diff --git a/tests/test-remotefilelog-sparse.t 
b/tests/test-remotefilelog-sparse.t
--- a/tests/test-remotefilelog-sparse.t
+++ b/tests/test-remotefilelog-sparse.t
@@ -48,6 +48,7 @@
   $ printf "[remotefilelog]\npullprefetch=bookmark()\n" >> .hg/hgrc
   $ hg strip tip
   saved backup bundle to 
$TESTTMP/shallow/.hg/strip-backup/876b1317060d-b2e91d8d-backup.hg (glob)
+  2 files fetched over 2 fetches - (2 misses, 0.00% hit ratio) over *s (glob)
 
   $ hg debugsparse --delete z
 
diff --git a/tests/test-remotefilelog-prefetch.t 
b/tests/test-remotefilelog-prefetch.t
--- a/tests/test-remotefilelog-prefetch.t
+++ b/tests/test-remotefilelog-prefetch.t
@@ -86,6 +86,7 @@
   $ printf "[remotefilelog]\npullprefetch=bookmark()\n" >> .hg/hgrc
   $ hg strip tip
   saved backup bundle to 
$TESTTMP/shallow/.hg/strip-backup/109c3a557a73-3f43405e-backup.hg (glob)
+  1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob)
 
   $ clearcache
   $ hg pull
diff --git a/tests/test-remotefilelog-local.t b/tests/test-remotefilelog-local.t
--- a/tests/test-remotefilelog-local.t
+++ b/tests/test-remotefilelog-local.t
@@ -116,7 +116,7 @@
   $ hg strip -r .
   2 files updated, 0 files merged, 1 files removed, 0 files unresolved
   saved backup bundle to 
$TESTTMP/shallow/.hg/strip-backup/19edf50f4de7-df3d0f74-backup.hg (glob)
-  4 files fetched over 2 fetches - (4 misses, 0.00% hit ratio) over *s (glob)
+  3 files fetched over 2 fetches - (3 misses, 0.00% hit ratio) over *s (glob)
 
 # unbundle
 
@@ -133,13 +133,14 @@
   adding changesets
   adding manifests
   adding file changes
-  added 1 changesets with 0 changes to 0 files
+  added 1 changesets with 3 changes to 3 files
   new changesets 19edf50f4de7 (1 drafts)
   (run 'hg update' to get a working copy)
+  2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob)
 
   $ hg up
   3 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  4 files fetched over 1 fetches - (4 misses, 0.00% hit ratio) over *s (glob)
+  1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob)
   $ cat a
   a
 
@@ -148,7 +149,7 @@
   $ clearcache
   $ hg revert -r .~2 y z
   no changes needed to z
-  2 files fetched over 2 fetches - (2 misses, 0.00% hit ratio) over *s (glob)
+  1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob)
   $ hg checkout -C -r . -q
 
 # explicit bundle should produce full bundle file
@@ -159,7 +160,7 @@
   $ cd ..
 
   $ hgcloneshallow ssh://user@dummy/master shallow2 -q
-  1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob)
+  2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob)
   $ cd shallow2
   $ hg unbundle ../local.bundle
   adding changesets
diff --git 

D10319: tests: add test-remotefilelog-strip.t to demonstrate an issue with linknodes

2021-04-06 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Background
  --
  
  Every time a commit is modified, remotefilelog updates the metadata for the 
file
  object to point to the new commit (I believe that this is different from
  non-remotefilelog hg, which leaves the linkrevs pointing to the obsolete
  commits; doing otherwise would involve changing data in the middle of 
revlogs).
  
  With `hg strip` (or other things that use repair.strip()), when you strip a
  commit that's not the tip of the revlog, there may be commits after it in 
revnum
  order that aren't descended from it and don't need to be (and shouldn't be)
  stripped. These are "saved" by strip in a bundle, and that bundle is reapplied
  after truncating the relevant revlogs.
  
  The problem
  ---
  
  Remotefilelog generally avoids being involved at all in strip. Currently, that
  includes even providing file contents to this backup bundle. This can cause 
the
  linknode to point to a changeset that is no longer in the repository.
  
  Example:
  
@  3 df91f74b871e
|
| x  2 70494d7ec5ef
|/
| x  1 1e423846dde0
|/
o  0 b292c1e3311f
  
  Commits 1, 2, and 3 are related via obsolescence, and are description-only
  changes. The linknode for the file in these commits changed each time we 
updated
  the description, so it's currently df91f7. If I strip commits 1 and 3, 
however,
  the linknode *remains* df91f7, which no longer exists in the repository. 
Commit
  70494d was "saved", stripped, and then reapplied, so it is in the repository 
(as
  revision 1 instead of 2 now), and was unobsoleted since the obsmarker was
  stripped as well. The linknode for the file should point to 70494d, the most
  recent commit that is in the repository that modified the file.
  
  Remotefilelog has some logic to handle broken linknodes, but it can be slow. 
We
  have actually disabled it internally because it's too slow for our purposes.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-remotefilelog-strip.t

CHANGE DETAILS

diff --git a/tests/test-remotefilelog-strip.t b/tests/test-remotefilelog-strip.t
new file mode 100644
--- /dev/null
+++ b/tests/test-remotefilelog-strip.t
@@ -0,0 +1,67 @@
+#require no-windows
+
+  $ . "$TESTDIR/remotefilelog-library.sh"
+
+  $ hg init master
+  $ cd master
+  $ cat >> .hg/hgrc < [remotefilelog]
+  > server=True
+  > EOF
+  $ echo x > x
+  $ hg commit -qAm x
+
+  $ cd ..
+
+  $ hgcloneshallow ssh://user@dummy/master shallow -q
+  1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob)
+  $ cd shallow
+
+  $ cat >> $TESTTMP/get_file_linknode.py < from mercurial import node, registrar, scmutil
+  > cmdtable = {}
+  > command = registrar.command(cmdtable)
+  > @command(b'debug-file-linknode', [(b'r', b'rev', b'.', b'rev')], b'hg 
debug-file-linknode FILE')
+  > def debug_file_linknode(ui, repo, file, **opts):
+  >   rflctx = scmutil.revsingle(repo.unfiltered(), opts['rev']).filectx(file)
+  >   ui.status(b'%s\n' % node.hex(rflctx.ancestormap()[rflctx._filenode][2]))
+  > EOF
+
+  $ cat >> .hg/hgrc < [ui]
+  > interactive=1
+  > [extensions]
+  > strip=
+  > get_file_linknode=$TESTTMP/get_file_linknode.py
+  > [experimental]
+  > evolution=createmarkers,allowunstable
+  > EOF
+  $ echo a > a
+  $ hg commit -qAm msg1
+  $ hg commit --amend 're:^$' -m msg2
+  $ hg commit --amend 're:^$' -m msg3
+  $ hg --hidden log -G -T '{rev} {node|short}'
+  @  3 df91f74b871e
+  |
+  | x  2 70494d7ec5ef
+  |/
+  | x  1 1e423846dde0
+  |/
+  o  0 b292c1e3311f
+  
+  $ hg debug-file-linknode -r 70494d a
+  df91f74b871e064c89afa1fe9e2f66afa2c125df
+  $ hg --hidden strip -r 1 3
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  saved backup bundle to 
$TESTTMP/shallow/.hg/strip-backup/df91f74b871e-c94d67be-backup.hg
+
+  $ hg --hidden log -G -T '{rev} {node|short}'
+  o  1 70494d7ec5ef
+  |
+  @  0 b292c1e3311f
+  
+FIXME: This should point to a commit that actually exists in the repo. 
Otherwise
+remotefilelog has to search every commit in the repository looking for a valid
+linkrev every time it's queried, such as during push.
+  $ hg debug-file-linknode -r 70494d a
+  df91f74b871e064c89afa1fe9e2f66afa2c125df



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


D10295: exthelper: improve docs to indicate what module vars are needed

2021-04-01 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I recently tried creating an extension "from scratch" using exthelper, and it
  wasn't obvious that you needed these. I believe that a careful reading of one 
of
  the comments would tell you that they were required, but it's easy to miss and
  having the examples be "complete" is helpful.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/exthelper.py

CHANGE DETAILS

diff --git a/mercurial/exthelper.py b/mercurial/exthelper.py
--- a/mercurial/exthelper.py
+++ b/mercurial/exthelper.py
@@ -46,13 +46,22 @@
 # ext.py
 eh = exthelper.exthelper()
 
-# As needed:
+# As needed (failure to do this will mean your registration will not
+# happen):
 cmdtable = eh.cmdtable
 configtable = eh.configtable
 filesetpredicate = eh.filesetpredicate
 revsetpredicate = eh.revsetpredicate
 templatekeyword = eh.templatekeyword
 
+# As needed (failure to do this will mean your eh.wrap*-decorated
+# functions will not wrap, and/or your eh.*setup-decorated functions
+# will not execute):
+uisetup = eh.finaluisetup
+extsetup = eh.finalextsetup
+reposetup = eh.finalreposetup
+uipopulate = eh.finaluipopulate
+
 @eh.command(b'mynewcommand',
 [(b'r', b'rev', [], _(b'operate on these revisions'))],
 _(b'-r REV...'),
@@ -155,7 +164,7 @@
 c(ui)
 
 def finalextsetup(self, ui):
-"""Method to be used as a the extension extsetup
+"""Method to be used as the extension extsetup
 
 The following operations belong here:
 
@@ -201,6 +210,9 @@
 
 example::
 
+# Required, otherwise your uisetup function(s) will not execute.
+uisetup = eh.finaluisetup
+
 @eh.uisetup
 def setupbabar(ui):
 print('this is uisetup!')
@@ -213,6 +225,9 @@
 
 example::
 
+# Required, otherwise your uipopulate function(s) will not execute.
+uipopulate = eh.finaluipopulate
+
 @eh.uipopulate
 def setupfoo(ui):
 print('this is uipopulate!')
@@ -225,6 +240,9 @@
 
 example::
 
+# Required, otherwise your extsetup function(s) will not execute.
+extsetup = eh.finalextsetup
+
 @eh.extsetup
 def setupcelestine(ui):
 print('this is extsetup!')
@@ -237,6 +255,9 @@
 
 example::
 
+# Required, otherwise your reposetup function(s) will not execute.
+reposetup = eh.finalreposetup
+
 @eh.reposetup
 def setupzephir(ui, repo):
 print('this is reposetup!')
@@ -258,6 +279,11 @@
 
 example::
 
+# Required if `extension` is not provided
+uisetup = eh.finaluisetup
+# Required if `extension` is provided
+extsetup = eh.finalextsetup
+
 @eh.wrapcommand(b'summary')
 def wrapsummary(orig, ui, repo, *args, **kwargs):
 ui.note(b'Barry!')
@@ -298,8 +324,11 @@
 
 example::
 
-@eh.function(discovery, b'checkheads')
-def wrapfunction(orig, *args, **kwargs):
+# Required, otherwise the function will not be wrapped
+uisetup = eh.finaluisetup
+
+@eh.wrapfunction(discovery, b'checkheads')
+def wrapcheckheads(orig, *args, **kwargs):
 ui.note(b'His head smashed in and his heart cut out')
 return orig(*args, **kwargs)
 """



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


D10294: match: convert O(n) to O(log n) in exactmatcher.visitchildrenset

2021-04-01 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  When using narrow, during rebase this is called (at least) once per directory 
in
  the set of files in the commit being rebased. Every time it's called, we did 
the
  set arithmetic (now extracted and cached), which was probably pretty cheap but
  not necessary to repeat each time, looped over every item in the matcher and
  kept things that started with the directory we were querying.
  
  With very large narrowspecs, and a commit that touched a file in a large 
number
  of directories, this was slow. In a pathological repo, the rebase of a single
  commit (that touched over 17k files, I believe in approximately as many
  directories) with a narrowspec that had >32k entries took 8,246s of profiled
  time, with 5,007s of that spent in visitchildrenset (transitively). With this
  change, the time spent in visitchildrenset is less than 34s (which is where my
  profile cut off). Most of the remaining time was network access due to our
  custom remotefilelog-based setup not properly prefetching.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/match.py

CHANGE DETAILS

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -7,6 +7,7 @@
 
 from __future__ import absolute_import, print_function
 
+import bisect
 import copy
 import itertools
 import os
@@ -798,14 +799,38 @@
 def visitdir(self, dir):
 return dir in self._dirs
 
+@propertycache
+def _visitchildrenset_candidates(self):
+"""A memoized set of candidates for visitchildrenset."""
+return self._fileset | self._dirs - {b''}
+
+@propertycache
+def _sorted_visitchildrenset_candidates(self):
+"""A memoized sorted list of candidates for visitchildrenset."""
+return sorted(self._visitchildrenset_candidates)
+
 def visitchildrenset(self, dir):
 if not self._fileset or dir not in self._dirs:
 return set()
 
-candidates = self._fileset | self._dirs - {b''}
-if dir != b'':
+if dir == b'':
+candidates = self._visitchildrenset_candidates
+else:
+candidates = self._sorted_visitchildrenset_candidates
 d = dir + b'/'
-candidates = {c[len(d) :] for c in candidates if c.startswith(d)}
+# Use bisect to find the first element potentially starting with d
+# (i.e. >= d). This should always find at least one element (we'll
+# assert later if this is not the case).
+first = bisect.bisect_left(candidates, d)
+# We need a representation of the first element that is > d that
+# does not start with d, so since we added a `/` on the end of dir,
+# we'll add whatever comes after slash (we could probably assume
+# that `0` is after `/`, but let's not) to the end of dir instead.
+dnext = dir + encoding.strtolocal(chr(ord(b'/') + 1))
+# Use bisect to find the first element >= d_next
+last = bisect.bisect_left(candidates, dnext, lo=first)
+dlen = len(d)
+candidates = {c[dlen :] for c in candidates[first:last]}
 # self._dirs includes all of the directories, recursively, so if
 # we're attempting to match foo/bar/baz.txt, it'll have '', 'foo',
 # 'foo/bar' in it. Thus we can safely ignore a candidate that has a



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


D10292: deb: avoid use of [[ in 'rules' file

2021-03-30 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  It's not supported by posix shell, and apparently my build system uses that.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/packaging/debian/rules

CHANGE DETAILS

diff --git a/contrib/packaging/debian/rules b/contrib/packaging/debian/rules
--- a/contrib/packaging/debian/rules
+++ b/contrib/packaging/debian/rules
@@ -96,7 +96,7 @@
cp contrib/bash_completion 
"$(CURDIR)"/debian/mercurial/usr/share/bash-completion/completions/hg
mkdir -p "$(CURDIR)"/debian/mercurial/usr/share/zsh/vendor-completions
cp contrib/zsh_completion 
"$(CURDIR)"/debian/mercurial/usr/share/zsh/vendor-completions/_hg
-   if [[ "$(DEB_HG_CHG_BY_DEFAULT)" -eq 1 ]]; then \
+   if [ "$(DEB_HG_CHG_BY_DEFAULT)" -eq 1 ]; then \
mkdir -p "$(CURDIR)"/debian/mercurial/usr/lib/mercurial; \
mv "$(CURDIR)"/debian/mercurial/usr/bin/hg 
"$(CURDIR)"/debian/mercurial/usr/lib/mercurial/hg; \
ln -s chg "$(CURDIR)"/debian/mercurial/usr/bin/hg; \



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


D10020: debian: support a "chg-first" installation mechanism (hg is actually chg)

2021-02-18 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This mechanism builds chg such that it looks for `hg` to be available at
  /usr/lib/mercurial/hg instead of in the $PATH as `hg`, and makes the `hg` in
  /usr/bin be a symlink to `chg`.
  
  It's important to note that the hg binary must continue to be named `hg`. If 
we
  wanted to instead place it at /usr/bin/pyhg or something similar, we would 
need
  to modify Mercurial to allow that basename. Failure to do so would break
  Mercurial's shell aliases that use `hg`, `chg`, or `$HG`.
  
  I don't know if we should ever have a setup like this be the default setup, 
but
  I'm willing to get more information on our experience with it for making such 
a
  determination. Actually making it the default might be rather involved, as we
  don't maintain the official debian packaging rules.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/packaging/debian/rules

CHANGE DETAILS

diff --git a/contrib/packaging/debian/rules b/contrib/packaging/debian/rules
--- a/contrib/packaging/debian/rules
+++ b/contrib/packaging/debian/rules
@@ -18,6 +18,10 @@
 #   DEB_HG_PYTHON_VERSIONS="3.7 3.8" make deb
 DEB_HG_MULTI_VERSION?=0
 
+# Set to 1 to make /usr/bin/hg a symlink to chg, and move hg to
+# /usr/lib/mercurial/hg.
+DEB_HG_CHG_BY_DEFAULT?=0
+
 CPUS=$(shell cat /proc/cpuinfo | grep -E ^processor | wc -l)
 
 # By default, only build for the version of python3 that the system considers
@@ -40,6 +44,12 @@
DEB_HG_PYTHON_VERSIONS?=$(shell py3versions -vd)
 endif
 
+ifeq ($(DEB_HG_CHG_BY_DEFAULT), 1)
+   # Important: the "real" hg must have a 'basename' of 'hg'. Otherwise, hg
+   # behaves differently when setting $HG and breaks aliases that use that.
+   export HGPATH=/usr/lib/mercurial/hg
+endif
+
 export HGPYTHON3=1
 export PYTHON=python3
 
@@ -86,3 +96,8 @@
cp contrib/bash_completion 
"$(CURDIR)"/debian/mercurial/usr/share/bash-completion/completions/hg
mkdir -p "$(CURDIR)"/debian/mercurial/usr/share/zsh/vendor-completions
cp contrib/zsh_completion 
"$(CURDIR)"/debian/mercurial/usr/share/zsh/vendor-completions/_hg
+   if [[ "$(DEB_HG_CHG_BY_DEFAULT)" -eq 1 ]]; then \
+   mkdir -p "$(CURDIR)"/debian/mercurial/usr/lib/mercurial; \
+   mv "$(CURDIR)"/debian/mercurial/usr/bin/hg 
"$(CURDIR)"/debian/mercurial/usr/lib/mercurial/hg; \
+   ln -s chg "$(CURDIR)"/debian/mercurial/usr/bin/hg; \
+   fi



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


D9990: gendoc: use an empty comment so aliases are separated from previous elements

2021-02-12 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  For commands like `hg bookmarks`, where there's no `[+] marked option can be
  specified multiple times`, this causes the final option in the option list to
  not be the parent of the aliases definition. The aliases section is thus 
marked
  as a blockquote like on commands that do have text separating the option list
  and the aliases definition.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  doc/gendoc.py

CHANGE DETAILS

diff --git a/doc/gendoc.py b/doc/gendoc.py
--- a/doc/gendoc.py
+++ b/doc/gendoc.py
@@ -317,7 +317,11 @@
 ui.write(b"\n")
 # aliases
 if d[b'aliases']:
-ui.write(_(b"aliases: %s\n\n") % b" ".join(d[b'aliases']))
+# Note the empty comment, this is required to separate this
+# (which should be a blockquote) from any preceding things 
(such
+# as a definition list).
+ui.write(_(b"..\n\naliases: %s\n\n") %
+ b" ".join(d[b'aliases']))
 
 
 def allextensionnames():



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


D9989: gendoc: add support for loading extensions from config settings

2021-02-12 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We manage our installation and ship some extensions, enabled by default for 
our
  users, that are in hgext3rd or other directories not scanned by this tool by
  default. We want to generate docs during the build process, and having those
  docs include the extensions that users don't have to manually enable is
  desirable.
  
  This is *not* desirable for the normal build process, however, and should 
never
  be enabled by default.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  doc/gendoc.py

CHANGE DETAILS

diff --git a/doc/gendoc.py b/doc/gendoc.py
--- a/doc/gendoc.py
+++ b/doc/gendoc.py
@@ -330,6 +330,11 @@
 doc = encoding.strtolocal(sys.argv[1])
 
 ui = uimod.ui.load()
+# Trigger extensions to load. This is disabled by default because it uses
+# the current user's configuration, which is often not what is wanted.
+if encoding.environ.get(b'GENDOC_LOAD_CONFIGURED_EXTENSIONS', b'0') != 
b'0':
+extensions.loadall(ui)
+
 if doc == b'hg.1.gendoc':
 showdoc(ui)
 else:



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


D9988: gendoc: support defaults on customopts a bit better

2021-02-12 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Without this, a customopt will very likely render like this:
  
-foo   does foo (default: )
  
  I copied this logic from how this is handled in mercurial/help.py.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  doc/gendoc.py

CHANGE DETAILS

diff --git a/doc/gendoc.py b/doc/gendoc.py
--- a/doc/gendoc.py
+++ b/doc/gendoc.py
@@ -31,6 +31,7 @@
 commands,
 encoding,
 extensions,
+fancyopts,
 help,
 minirst,
 pycompat,
@@ -86,6 +87,8 @@
 if b'\n' in desc:
 # only remove line breaks and indentation
 desc = b' '.join(l.lstrip() for l in desc.split(b'\n'))
+if isinstance(default, fancyopts.customopt):
+default = default.getdefaultvalue()
 if default:
 default = stringutil.forcebytestr(default)
 desc += _(b" (default: %s)") % default



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


D9983: packaging: add Provides: python3-mercurial and Homepage to debian package

2021-02-11 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  There are other packages that depend on python3-mercurial, like debian's
  mercurial-git, so we should mark ourselves as providing it.
  
  I compared the control file we generate to the one that the debian maintainers
  generate, and noticed several differences:
  
  - the Homepage bit. I included this, because why not
  - a more robust Suggests list that includes a graphical merge tool
  - a more robust Breaks list
  - debian's Recommends openssh-client, we only Recommends ca-certificates
  - a split into `mercurial` and `mercurial-common` (and possibly others?)
  - a slightly different description

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/packaging/debian/control

CHANGE DETAILS

diff --git a/contrib/packaging/debian/control b/contrib/packaging/debian/control
--- a/contrib/packaging/debian/control
+++ b/contrib/packaging/debian/control
@@ -25,7 +25,9 @@
 Suggests: wish
 Replaces: mercurial-common
 Breaks: mercurial-common
+Provides: python3-mercurial
 Architecture: any
+Homepage: https://www.mercurial-scm.org/
 Description: fast, easy to use, distributed revision control tool.
  Mercurial is a fast, lightweight Source Control Management system designed
  for efficient handling of very large distributed projects.



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


D9952: revlog: add a mechanism to verify expected file position before appending

2021-02-03 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  If someone uses `hg debuglocks`, or some non-hg process writes to the .hg
  directory without respecting the locks, or if the repo's on a networked
  filesystem, it's possible for the revlog code to write out corrupted data.
  
  The form of this corruption can vary depending on what data was written and 
how
  that happened. We are in the "networked filesystem" case (though I've had 
users
  also do this to themselves with the "`hg debuglocks`" scenario), and most 
often
  see this with the changelog. What ends up happening is we produce two items
  (let's call them rev1 and rev2) in the .i file that have the same linkrev,
  baserev, and offset into the .d file, while the data in the .d file is 
appended
  properly. rev2's compressed_size is accurate for rev2, but when we go to
  decompress the data in the .d file, we use the offset that's recorded in the
  index file, which is the same as rev1, and attempt to decompress
  rev2.compressed_size bytes of rev1's data. This usually does not succeed. :)
  
  When using inline data, this also fails, though I haven't investigated why too
  closely. This shows up as a "patch decode" error. I believe what's happening
  there is that we're basically ignoring the offset field, getting the data
  properly, but since baserev != rev, it thinks this is a delta based on rev
  (instead of a full text) and can't actually apply it as such.
  
  For now, I'm going to make this an optional component and default it to 
entirely
  off. I may increase the default severity of this in the future, once I've
  enabled it for my users and we gain more experience with it. Luckily, most of 
my
  users have a versioned filesystem and can roll back to before the corruption 
has
  been written, it's just a hassle to do so and not everyone knows how (so it's 
a
  support burden). Users on other filesystems will not have that luxury, and 
this
  can cause them to have a corrupted repository that they are unlikely to know 
how
  to resolve, and they'll see this as a data-loss event. Refusing to create the
  corruption is a much better user experience.
  
  This mechanism is not perfect. There may be false-negatives (racy writes that
  are not detected). There should not be any false-positives (non-racy writes 
that
  are detected as such). This is not a mechanism that makes putting a repo on a
  networked filesystem "safe" or "supported", just *less* likely to cause
  corruption.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/changelog.py
  mercurial/configitems.py
  mercurial/localrepo.py
  mercurial/revlog.py
  mercurial/revlogutils/concurrency_checker.py
  mercurial/store.py
  tests/test-racy-mutations.t

CHANGE DETAILS

diff --git a/tests/test-racy-mutations.t b/tests/test-racy-mutations.t
new file mode 100644
--- /dev/null
+++ b/tests/test-racy-mutations.t
@@ -0,0 +1,102 @@
+#testcases skip-detection fail-if-detected
+
+Test situations that "should" only be reproducible:
+- on networked filesystems, or
+- user using `hg debuglocks` to eliminate the lock file, or
+- something (that doesn't respect the lock file) writing to the .hg directory
+while we're running
+
+  $ hg init a
+  $ cd a
+
+  $ cat > "$TESTTMP/waitlock_editor.sh" < [ -n "\${WAITLOCK_ANNOUNCE:-}" ] && touch "\${WAITLOCK_ANNOUNCE}"
+  > f="\${WAITLOCK_FILE}"
+  > start=\`date +%s\`
+  > timeout=5
+  > while [ \\( ! -f \$f \\) -a \\( ! -L \$f \\) ]; do
+  > now=\`date +%s\`
+  > if [ "\`expr \$now - \$start\`" -gt \$timeout ]; then
+  > echo "timeout: \$f was not created in \$timeout seconds (it is 
now \$(date +%s))"
+  > exit 1
+  > fi
+  > sleep 0.1
+  > done
+  > if [ \$# -gt 1 ]; then
+  > cat "\$@"
+  > fi
+  > EOF
+  $ chmod +x "$TESTTMP/waitlock_editor.sh"
+
+Things behave differently if we don't already have a 00changelog.i file when
+this all starts, so let's make one.
+
+  $ echo r0 > r0
+  $ hg commit -qAm 'r0'
+
+Start an hg commit that will take a while
+  $ EDITOR_STARTED="$(pwd)/.editor_started"
+  $ MISCHIEF_MANAGED="$(pwd)/.mischief_managed"
+  $ JOBS_FINISHED="$(pwd)/.jobs_finished"
+
+#if fail-if-detected
+  $ cat >> .hg/hgrc << EOF
+  > [debug]
+  > revlog.verifyposition.changelog = fail
+  > EOF
+#endif
+
+  $ echo foo > foo
+  $ (WAITLOCK_ANNOUNCE="${EDITOR_STARTED}" \
+  >  WAITLOCK_FILE="${MISCHIEF_MANAGED}" \
+  >   HGEDITOR="$TESTTMP/waitlock_editor.sh" \
+  >   hg commit -qAm 'r1 (foo)' --edit foo > .foo_commit_out 2>&1 ; 
touch "${JOBS_FINISHED}") &
+
+Wait for the "editor" to actually start
+  $ WAITLOCK_FILE="${EDITOR_STARTED}" "$TESTTMP/waitlock_editor.sh"
+
+Break the locks, and make another commit.
+  $ hg debuglocks -LW
+  $ 

D9953: tests: add a comment in a test that will hopefully save someone some time

2021-02-03 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I spent at least an hour, probably closer to 1.5, trying to figure out what 
this
  was complaining about. Hopefully anyone else in my position will see this note
  and not waste the time.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-check-module-imports.t

CHANGE DETAILS

diff --git a/tests/test-check-module-imports.t 
b/tests/test-check-module-imports.t
--- a/tests/test-check-module-imports.t
+++ b/tests/test-check-module-imports.t
@@ -14,6 +14,10 @@
 Known-bad files are excluded by -X as some of them would produce unstable
 outputs, which should be fixed later.
 
+NOTE: the `hg locate` command here only works on files that are known to
+Mercurial. If you add an import of a new file and haven't yet `hg add`ed it, 
you
+will likely receive warnings about a direct import.
+
   $ testrepohg locate 'set:**.py or grep(r"^#!.*?python")' \
   > 'tests/**.t' \
   > -X hgweb.cgi \



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


D9891: wix: tell ComponentSearch that it is finding a directory (not a file)

2021-01-27 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is to fix an issue we've noticed where fresh installations start at
  `C:\Program Files\Mercurial`, and then upgrades "walk up" the tree and end up 
in
  `C:\Program Files` and finally `C:\` (where they stay).
  
  ComponentSearch defaults to finding files, which I think means "it produces a
  string like `C:\Program Files\Mercurial`", whereas with the type being
  explicitly a directory, it would return `C:\Program Files\Mercurial\` (note 
the
  final trailing backslash). Presumably, a latter step then tries to turn that
  file name into a proper directory, by removing everything after the last `\`.
  
  This could likely also be fixed by actually searching for the component for
  hg.exe itself. That seemed a lot more complicated, as the GUID for hg.exe 
isn't
  known in this file (it's one of the "auto-derived" ones). We could also 
consider
  adding a Condition that I think could check the Property and ensure it's 
either
  empty or ends in a trailing slash, but that would be an installer runtime 
check
  and I'm not convinced it'd actually be useful.
  
  This will *not* cause existing installations that are in one of the bad
  directories to fix themselves. Doing that would require a fair amount more
  understanding of wix and windows installer than I have, and it *probably*
  wouldn't be possible to be 100% correct about it either (there's nothing
  preventing a user from intentionally installing it in C:\, though I don't know
  why they would do so).
  
  If someone wants to tackle fixing existing installations, I think that the 
first
  installation is actually the only one that shows up in "Add or Remove 
Programs",
  and that its registry keys still exist. You might be able to find something
  under HKEY_USERS that lists both the "good" and the "bad" InstallDirs. Mine 
was
  under `HKEY_USERS\S-1-5-18\Software\Mercurial\InstallDir` (C:\), and
  `HKEY_USERS\S-1-5-21-..numbers..\Software\Mercurial\InstallDir` (C:\Program
  Files\Mercurial). If you find exactly two, with one being the default path, 
and
  the other being a prefix of it, the user almost certainly hit this bug :D
  
  We had originally thought that this bug might be due to unattended
  installations/upgrades, but I no longer think that's the case. We were able to
  reproduce the issue by uninstalling all copies of Mercurial I could find,
  installing one version (it chose the correct location), and then starting the
  installer for a different version (higher or lower didn't matter). I did not
  need to deal with an unattended or headless installation/upgrade to trigger 
the
  issue, but it's possible that my system was "primed" for this bug to happen
  because of a previous unattended installation/upgrade.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/packaging/wix/mercurial.wxs

CHANGE DETAILS

diff --git a/contrib/packaging/wix/mercurial.wxs 
b/contrib/packaging/wix/mercurial.wxs
--- a/contrib/packaging/wix/mercurial.wxs
+++ b/contrib/packaging/wix/mercurial.wxs
@@ -39,7 +39,8 @@
 
 
   
+   Guid='$(var.ComponentMainExecutableGUID)'
+   Type='directory' />
 
 
 



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


D9729: patch: handle filenames with trailing spaces

2021-01-12 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I have no idea if this is *actually* supported by the patch file format, but 
at
  least when reading from a patch file created by running `hg shelve`, it is
  written out such that there's a trailing space after the second (`b`) 
filename.
  When we read the patch file, we remove the space before parsing the filenames,
  so it doesn't end up matching the other sources of what files are in the 
shelve.
  
  We observed this internally due to a wrapper around unshelve that called into
  patch.changedfiles, but `hg patch` is able to reproduce the issue as well, so
  I've included both tests.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/patch.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
@@ -1512,3 +1512,26 @@
   $ hg unshelve -i --keep
   abort: --keep on --interactive is not yet supported
   [255]
+
+  $ hg update -q --clean .
+
+Test that we can successfully shelve and unshelve a file with a trailing space
+in the filename. Such filenames are supposedly unsupported on Windows, so we
+wrap it in the no-windows check. Also test `hg patch` of the .patch file
+produced by `hg shelve`.
+#if no-windows
+  $ echo hi > 'my filename '
+  $ hg add 'my filename '
+  warning: filename ends with ' ', which is not allowed on Windows: 'my 
filename '
+  $ hg shelve
+  shelved as default-01
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ cp .hg/shelved/default-01.patch test_patch.patch
+  $ hg unshelve
+  unshelving change 'default-01'
+  $ cat 'my filename '
+  hi
+  $ hg update -q --clean .
+  $ hg patch -p1 test_patch.patch
+  applying test_patch.patch
+#endif
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -393,7 +393,7 @@
 gp = None
 gitpatches = []
 for line in lr:
-line = line.rstrip(b' \r\n')
+line = line.rstrip(b'\r\n')
 if line.startswith(b'diff --git a/'):
 m = gitre.match(line)
 if m:
@@ -2073,7 +2073,7 @@
 yield b'file', (afile, bfile, h, gp and gp.copy() or None)
 yield b'hunk', h
 elif x.startswith(b'diff --git a/'):
-m = gitre.match(x.rstrip(b' \r\n'))
+m = gitre.match(x.rstrip(b'\r\n'))
 if not m:
 continue
 if gitpatches is None:



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


D9567: copies: make calculating lazy for dir move detection's "addedfiles"

2020-12-11 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The information calculated here was only needed if (a) --debug was specified, 
or
  (b) a directory move was plausibly detected. With tree manifests (especially 
in
  my pathological repo and with our custom setup), pre-calculating the `u1` and
  `u2` can be quite slow, and it's not even necessary in many cases. Let's delay
  calculating it until we know it's actually necessary. This should have no
  observable differences in output.
  
  Performance
  ---
  
  I ran a rebase command in my pathological repo, rebasing two nodes across
  several public phase commits, but where no directory copies exist in any of 
the
  paths I'm tracking.
  
  Before
  --
  
Time (mean ± σ):  3.711 s ±  0.061 s[User: 0.3 ms, System: 1.5 ms]
Range (min … max):3.640 s …  3.827 s10 runs
  
  
  
  After
  -
  
Time (mean ± σ): 868.3 ms ±  10.1 ms[User: 0.5 ms, System: 1.2 ms]
Range (min … max):   856.6 ms … 883.6 ms10 runs

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -896,18 +896,30 @@
 )
 
 # find interesting file sets from manifests
-addedinm1 = m1.filesnotin(mb, repo.narrowmatch())
-addedinm2 = m2.filesnotin(mb, repo.narrowmatch())
-u1 = sorted(addedinm1 - addedinm2)
-u2 = sorted(addedinm2 - addedinm1)
+cache = []
+def _get_addedfiles(idx):
+if not cache:
+addedinm1 = m1.filesnotin(mb, repo.narrowmatch())
+addedinm2 = m2.filesnotin(mb, repo.narrowmatch())
+u1 = sorted(addedinm1 - addedinm2)
+u2 = sorted(addedinm2 - addedinm1)
+cache.extend((u1, u2))
+return cache[idx]
 
-header = b"  unmatched files in %s"
-if u1:
-repo.ui.debug(b"%s:\n   %s\n" % (header % b'local', b"\n   ".join(u1)))
-if u2:
-repo.ui.debug(b"%s:\n   %s\n" % (header % b'other', b"\n   ".join(u2)))
+u1fn = lambda: _get_addedfiles(0)
+u2fn = lambda: _get_addedfiles(1)
+if repo.ui.debugflag:
+u1 = u1fn()
+u2 = u2fn()
 
-if repo.ui.debugflag:
+header = b"  unmatched files in %s"
+if u1:
+repo.ui.debug(b"%s:\n   %s\n" %
+  (header % b'local', b"\n   ".join(u1)))
+if u2:
+repo.ui.debug(b"%s:\n   %s\n" %
+  (header % b'other', b"\n   ".join(u2)))
+
 renamedeleteset = set()
 divergeset = set()
 for dsts in diverge.values():
@@ -941,8 +953,8 @@
 
 repo.ui.debug(b"  checking for directory renames\n")
 
-dirmove1, movewithdir2 = _dir_renames(repo, c1, copy1, copies1, u2)
-dirmove2, movewithdir1 = _dir_renames(repo, c2, copy2, copies2, u1)
+dirmove1, movewithdir2 = _dir_renames(repo, c1, copy1, copies1, u2fn)
+dirmove2, movewithdir1 = _dir_renames(repo, c2, copy2, copies2, u1fn)
 
 branch_copies1 = branch_copies(copy1, renamedelete1, dirmove1, 
movewithdir1)
 branch_copies2 = branch_copies(copy2, renamedelete2, dirmove2, 
movewithdir2)
@@ -950,14 +962,15 @@
 return branch_copies1, branch_copies2, diverge
 
 
-def _dir_renames(repo, ctx, copy, fullcopy, addedfiles):
+def _dir_renames(repo, ctx, copy, fullcopy, addedfilesfn):
 """Finds moved directories and files that should move with them.
 
 ctx: the context for one of the sides
 copy: files copied on the same side (as ctx)
 fullcopy: files copied on the same side (as ctx), including those that
   merge.manifestmerge() won't care about
-addedfiles: added files on the other side (compared to ctx)
+addedfilesfn: function returning added files on the other side (compared to
+  ctx)
 """
 # generate a directory move map
 invalid = set()
@@ -997,7 +1010,7 @@
 
 movewithdir = {}
 # check unaccounted nonoverlapping files against directory moves
-for f in addedfiles:
+for f in addedfilesfn():
 if f not in fullcopy:
 for d in dirmove:
 if f.startswith(d):



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


D9553: treemanifest: stop storing full path for each item in manifest._lazydirs

2020-12-09 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This information is obtainable, if needed, based on the lazydirs key (which is
  the entry name) and the manifest's `dir()` method.
  
  Performance
  ---
  
  This is actually both a memory and a performance improvement, but it's likely 
to
  be a very small one in most situations. In the pathological repo I've been 
using
  for testing other performance work I've done recently, this reduced the time 
for
  a rebase operation (rebasing two commits across a public-phase change that
  touches a sibling of one of my tracked directories where the common parent is
  massive (>>10k entries)):
  
  Before
  --
  
Time (mean ± σ):  4.059 s ±  0.121 s[User: 0.9 ms, System: 0.6 ms]
Range (min … max):3.941 s …  4.352 s10 runs
  
  
  
  After
  -
  
Time (mean ± σ):  3.707 s ±  0.060 s[User: 0.8 ms, System: 0.8 ms]
Range (min … max):3.648 s …  3.818 s10 runs

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/manifest.py

CHANGE DETAILS

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -818,23 +818,24 @@
 
 def _loadalllazy(self):
 selfdirs = self._dirs
-for d, (path, node, readsubtree, docopy) in pycompat.iteritems(
+subpath = self._subpath
+for d, (node, readsubtree, docopy) in pycompat.iteritems(
 self._lazydirs
 ):
 if docopy:
-selfdirs[d] = readsubtree(path, node).copy()
+selfdirs[d] = readsubtree(subpath(d), node).copy()
 else:
-selfdirs[d] = readsubtree(path, node)
+selfdirs[d] = readsubtree(subpath(d), node)
 self._lazydirs = {}
 
 def _loadlazy(self, d):
 v = self._lazydirs.get(d)
 if v:
-path, node, readsubtree, docopy = v
+node, readsubtree, docopy = v
 if docopy:
-self._dirs[d] = readsubtree(path, node).copy()
+self._dirs[d] = readsubtree(self._subpath(d), node).copy()
 else:
-self._dirs[d] = readsubtree(path, node)
+self._dirs[d] = readsubtree(self._subpath(d), node)
 del self._lazydirs[d]
 
 def _loadchildrensetlazy(self, visit):
@@ -861,7 +862,7 @@
 toloadlazy = []
 for d, v1 in pycompat.iteritems(t1._lazydirs):
 v2 = t2._lazydirs.get(d)
-if not v2 or v2[1] != v1[1]:
+if not v2 or v2[0] != v1[0]:
 toloadlazy.append(d)
 for d, v1 in pycompat.iteritems(t2._lazydirs):
 if d not in t1._lazydirs:
@@ -1092,8 +1093,8 @@
 def _copyfunc(s):
 self._load()
 s._lazydirs = {
-d: (p, n, r, True)
-for d, (p, n, r, c) in pycompat.iteritems(self._lazydirs)
+d: (n, r, True)
+for d, (n, r, c) in pycompat.iteritems(self._lazydirs)
 }
 sdirs = s._dirs
 for d, v in pycompat.iteritems(self._dirs):
@@ -1317,13 +1318,12 @@
 
 def parse(self, text, readsubtree):
 selflazy = self._lazydirs
-subpath = self._subpath
 for f, n, fl in _parse(text):
 if fl == b't':
 f = f + b'/'
 # False below means "doesn't need to be copied" and can use the
 # cached value from readsubtree directly.
-selflazy[f] = (subpath(f), n, readsubtree, False)
+selflazy[f] = (n, readsubtree, False)
 elif b'/' in f:
 # This is a flat manifest, so use __setitem__ and setflag 
rather
 # than assigning directly to _files and _flags, so we can
@@ -1351,7 +1351,7 @@
 self._load()
 flags = self.flags
 lazydirs = [
-(d[:-1], v[1], b't') for d, v in pycompat.iteritems(self._lazydirs)
+(d[:-1], v[0], b't') for d, v in pycompat.iteritems(self._lazydirs)
 ]
 dirs = [(d[:-1], self._dirs[d]._node, b't') for d in self._dirs]
 files = [(f, self._files[f], flags(f)) for f in self._files]
@@ -1373,7 +1373,7 @@
 def getnode(m, d):
 ld = m._lazydirs.get(d)
 if ld:
-return ld[1]
+return ld[0]
 return m._dirs.get(d, emptytree)._node
 
 # let's skip investigating things that `match` says we do not need.



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


D9511: statprof: separate functions and "line", assume 4 digit line numbers

2020-12-02 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Previously, the profile output looked like this (I've removed many lines that
  are mostly inconsequential):
  
| 100.0%  0.02s  hg:   line 43:  dispatch.run()
| 100.0%  0.02s  dispatch.py:run   line 115:  status = 
dispatch(req)
| 100.0%  0.02s  dispatch.py:_runcatchfunc line 432:  return 
_dispatch(req)
 \ 50.0%  0.01s  dispatch.py:_dispatch line 1228:  return 
runcommand(
   | 50.0%  0.01s  dispatch.py:runcommand  line 883:  ret = 
_runcommand(ui, optio...
   | 50.0%  0.01s  dispatch.py:_runcommand line 1240:  return 
cmdfunc()
   | 50.0%  0.01s  localrepo.py:   __getitem__ line 1670:  quick_access 
= self._quick_...
   | 50.0%  0.01s  localrepo.py:   _quick_access_changeidline 1650:  return 
self._quick_access_c...
   | 50.0%  0.01s  localrepo.py:   __get__ line 179:  return 
getattr(unfi, self.n...
   | 50.0%  0.01s  util.py:__get__ line 1747:  result = 
self.func(obj)
   | 50.0%  0.01s  localrepo.py:   _quick_access_changeid_wcline  1611:  cl 
= self.unfiltered().chan...
   | 50.0%  0.01s  localrepo.py:   __get__ line 110:  return 
super(_basefilecache...
   | 50.0%  0.01s  util.py:__getattribute__line 245:  
self.__spec__.loader.exec_m...
   | 50.0%  0.01s  : exec_moduleline  
  783:
   | 50.0%  0.01s  : 
_call_with_frames_removedline 219:
   | 50.0%  0.01s  changelog.py:   line 376:  class 
changelog(revlog.revl...
   | 50.0%  0.01s  util.py:__getattribute__line 245:  
self.__spec__.loader.exec_m...
   | 50.0%  0.01s  : exec_moduleline  
  779:
   | 50.0%  0.01s  : get_codeline 
868:
   | 50.0%  0.01s  : path_statsline   
1012:
   | 50.0%  0.01s  : _path_statline   
87:
  
  This has a few problems, though I'm only addressing some of them.
  
  1. If the stuff before "line ###" is long, there's no separation between the 
function name and the "line" string.
  2. If the stuff before "line ###" is really long, there's excessive 
separation between the "line" string and the line number.
  3. We frequently have 4-digit line numbers, the code on the right wasn't 
dynamically indented and ended up quite messy looking.
  
  To solve these problems, I've added a ", " prefix before "line" iff it would
  otherwise not have any separation such as spaces. I've added a 'max' so that 
we
  never use a negative width (which is the cause of problem #2 above), and I've
  added a default assumption of 4 digit line numbers (but again using a 'max' so
  this shouldn't cause problems if we go beyond that.
  
  With these changes, it now looks like this:
  
| 100.0%  0.02s  hg:   line 43:   dispatch.run()
| 100.0%  0.02s  dispatch.py:run   line 115:  status = 
dispatch(req)
| 100.0%  0.02s  dispatch.py:_runcatchfunc line 432:  return 
_dispatch(req)
 \ 50.0%  0.01s  dispatch.py:_dispatch line 1228: return 
runcommand(
   | 50.0%  0.01s  dispatch.py:runcommand  line 883:  ret = 
_runcommand(ui, optio...
   | 50.0%  0.01s  dispatch.py:_runcommand line 1240: return 
cmdfunc()
   | 50.0%  0.01s  localrepo.py:   __getitem__ line 1670: quick_access 
= self._quick_...
   | 50.0%  0.01s  localrepo.py:   _quick_access_changeid, line 1650: 
return self._quick_access_c...
   | 50.0%  0.01s  localrepo.py:   __get__ line 179:  return 
getattr(unfi, self.n...
   | 50.0%  0.01s  util.py:__get__ line 1747: result = 
self.func(obj)
   | 50.0%  0.01s  localrepo.py:   _quick_access_changeid_wc, line 1611: cl 
= self.unfiltered().chan...
   | 50.0%  0.01s  localrepo.py:   __get__ line 110:  return 
super(_basefilecache...
   | 50.0%  0.01s  util.py:__getattribute__, line 245:  
self.__spec__.loader.exec_m...
   | 50.0%  0.01s  : exec_module, 
line 783:
   | 50.0%  0.01s  : 
_call_with_frames_removed, line 219:
   | 50.0%  0.01s  changelog.py:   line 376:  class 
changelog(revlog.revl...
   | 50.0%  0.01s  util.py:__getattribute__, line 245:  
self.__spec__.loader.exec_m...
   | 50.0%  0.01s  : exec_module, 
line 779:
   | 50.0%  0.01s  : get_code, line 
868:
   | 50.0%  0.01s  : path_stats, line 
1012:
   | 50.0%  0.01s  : _path_stat, line 
87:

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/statprof.py
  tests/test-profile.t

CHANGE DETAILS

diff --git a/tests/test-profile.t b/tests/test-profile.t
--- a/tests/test-profile.t
+++ b/tests/test-profile.t
@@ -64,19 +64,19 @@
 
 Install an extension that can sleep and guarantee a profiler has time to 

D9510: statprof: fix off-by-one-line error in output

2020-12-02 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  martinvonz claims they thought that this was intentional, but couldn't 
remember
  the reasoning for it. I can't understand why it would be preferable, and I
  didn't see anything in the comments in the file about why this would be 
useful,
  so I'm hopefully not breaking anything by "fixing" it.
  
  Old output
  --
  
| 100.0%  0.01s  dispatch.py:run   line 43:  dispatch.run()
| 100.0%  0.01s  dispatch.py:dispatch  line 115:  status = 
dispatch(req)
| 100.0%  0.01s  dispatch.py:_runcatch line 266:  ret = 
_runcatch(req) or 0
| 100.0%  0.01s  dispatch.py:_callcatchline 442:  return 
_callcatch(ui, _runc...
| 100.0%  0.01s  scmutil.py: callcatch line 451:  return 
scmutil.callcatch(ui...
| 100.0%  0.01s  dispatch.py:_runcatchfunc line 155:  return func()
| 100.0%  0.01s  dispatch.py:_dispatch line 432:  return 
_dispatch(req)
| 100.0%  0.01s  hg.py:  repositoryline 1179:  repo = 
hg.repository(
| 100.0%  0.01s  hg.py:  _peerorrepo   line 221:  peer = 
_peerorrepo(
| 100.0%  0.01s  util.py:__getattribute__  line 188:  obj = 
_peerlookup(path).ins...
| 100.0%  0.01s  localrepo.py:   makelocalrepositoryline 3227:  return 
makelocalrepository(...
| 100.0%  0.01s  localrepo.py:   __init__  line 683:  return cls(
| 100.0%  0.01s  util.py:__getattribute__  line 1262:  
self._extrafilterid = repov...
| 100.0%  0.01s  : exec_moduleline
  245:  self.__spec__.loader.exec_m...
| 100.0%  0.01s  : get_codeline   
779:
| 100.0%  0.01s  : path_statsline 
868:
| 100.0%  0.01s  : _path_statline 
1012:
  
  
  
  New output
  --
  
| 100.0%  0.01s  hg:   line 43:  dispatch.run()
| 100.0%  0.01s  dispatch.py:run   line 115:  status = 
dispatch(req)
| 100.0%  0.01s  dispatch.py:dispatch  line 266:  ret = 
_runcatch(req) or 0
| 100.0%  0.01s  dispatch.py:_runcatch line 442:  return 
_callcatch(ui, _runc...
| 100.0%  0.01s  dispatch.py:_callcatchline 451:  return 
scmutil.callcatch(ui...
| 100.0%  0.01s  scmutil.py: callcatch line 155:  return func()
| 100.0%  0.01s  dispatch.py:_runcatchfunc line 432:  return 
_dispatch(req)
| 100.0%  0.01s  dispatch.py:_dispatch line 1179:  repo = 
hg.repository(
| 100.0%  0.01s  hg.py:  repositoryline 221:  peer = 
_peerorrepo(
| 100.0%  0.01s  hg.py:  _peerorrepo   line 188:  obj = 
_peerlookup(path).ins...
| 100.0%  0.01s  localrepo.py:   instance  line 3227:  return 
makelocalrepository(...
| 100.0%  0.01s  localrepo.py:   makelocalrepositoryline 683:  return cls(
| 100.0%  0.01s  localrepo.py:   __init__  line 1262:  
self._extrafilterid = repov...
| 100.0%  0.01s  util.py:__getattribute__  line 245:  
self.__spec__.loader.exec_m...
| 100.0%  0.01s  : exec_moduleline
  779:
| 100.0%  0.01s  : get_codeline   
868:
| 100.0%  0.01s  : path_statsline 
1012:
| 100.0%  0.01s  : _path_statline 
87:

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/statprof.py
  tests/test-profile.t

CHANGE DETAILS

diff --git a/tests/test-profile.t b/tests/test-profile.t
--- a/tests/test-profile.t
+++ b/tests/test-profile.t
@@ -100,6 +100,8 @@
 
   $ hg --profile --config profiling.statformat=hotpath sleep 2>../out || cat 
../out
   $ cat ../out | statprofran
+  $ grep sleepext.py ../out
+  .* [0-9.]+%  [0-9.]+s  sleepext.py:\s*sleep   line 7:  time\.sleep.* 
(re)
 
   $ hg --profile --config profiling.statformat=json sleep 2>../out || cat 
../out
   $ cat ../out
diff --git a/mercurial/statprof.py b/mercurial/statprof.py
--- a/mercurial/statprof.py
+++ b/mercurial/statprof.py
@@ -732,6 +732,9 @@
 i += 1
 if i < len(stack):
 child.add(stack[i:], time)
+else:
+# Normally this is done by the .add() calls
+child.count += time
 
 root = HotNode(None)
 lasttime = data.samples[0].time
@@ -749,12 +752,8 @@
 ]
 if site:
 indent = depth * 2 - 1
-filename = b''
-function = b''
-if len(node.children) > 0:
-childsite = list(pycompat.itervalues(node.children))[0].site
-filename = (childsite.filename() + b':').ljust(15)
-function = childsite.function
+filename = (site.filename() + b':').ljust(15)
+function = site.function
 
 # lots of string formatting

D9503: copies: avoid materializing a full directory map during copy tracing

2020-12-02 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Materializing a full copy of every directory in a treemanifest repo can be 
quite
  expensive, even with a narrow matcher. For flat manifest repos, this should be
  equivalent - it will still materialize (and cache) a dict of all of the dirs
  inside of the manifest object, we just don't get a copy of it.
  
  In a repo I have here, this brings the time for a simple rebase from 11.197s 
to
  4.609s.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -929,8 +929,6 @@
   merge.manifestmerge() won't care about
 addedfiles: added files on the other side (compared to ctx)
 """
-# generate a directory move map
-d = ctx.dirs()
 invalid = set()
 dirmove = {}
 
@@ -941,7 +939,7 @@
 if dsrc in invalid:
 # already seen to be uninteresting
 continue
-elif dsrc in d and ddst in d:
+elif ctx.hasdir(dsrc) and ctx.hasdir(ddst):
 # directory wasn't entirely moved locally
 invalid.add(dsrc)
 elif dsrc in dirmove and dirmove[dsrc] != ddst:
@@ -954,7 +952,7 @@
 for i in invalid:
 if i in dirmove:
 del dirmove[i]
-del d, invalid
+del invalid
 
 if not dirmove:
 return {}, {}



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


D9488: match: skip walking up the directory hierarchy if the number of pats are small

2020-12-01 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Previously, we would receive a path like abc/def/ghi and "walk up" the 
directory
  hierarchy, checking abc/def, abc, and `b''` to see if they were in the set of
  prefixes that this matcher covered. We did this indiscriminately - we 
generated
  all of these paths even if the set of prefixes the matcher covered was
  completely empty, which is the case for a lot of repos at my company (the 
narrow
  matcher we use is usually non-recursive).
  
  This brings the time for a rebase in one of my repos from 12.20s to 10.87s. In
  this particular repo, this is entirely due to the `len(prefix_set) == 0` 
check,
  as I do not have any recursive patterns in the narrowspec.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/match.py

CHANGE DETAILS

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -563,6 +563,36 @@
 return b'' % s
 
 
+def path_or_parents_in_set(path, prefix_set):
+"""Returns True if `path` (or any parent of `path`) is in `prefix_set`."""
+l = len(prefix_set)
+if l == 0:
+return False
+if path in prefix_set:
+return True
+# If there's more than 5 paths in prefix_set, it's *probably* quicker to
+# "walk up" the directory hierarchy instead, with the assumption that most
+# directory hierarchies are relatively shallow and hash lookup is cheap.
+if l > 5:
+return any(
+parentdir in prefix_set for parentdir in 
pathutil.finddirs(path)
+)
+
+# FIXME: Ideally we'd never get to this point if this is the case - we'd
+# recognize ourselves as an 'always' matcher and skip this.
+if b'' in prefix_set:
+return True
+
+if pycompat.ispy3:
+sl = ord(b'/')
+else:
+sl = '/'
+
+# We already checked that path isn't in prefix_set exactly, so
+# `path[len(pf)] should never raise IndexError.
+return any(path.startswith(pf) and path[len(pf)] == sl for pf in 
prefix_set)
+
+
 class patternmatcher(basematcher):
 r"""Matches a set of (kind, pat, source) against a 'root' directory.
 
@@ -611,12 +641,8 @@
 if self._prefix and dir in self._fileset:
 return b'all'
 return (
-dir in self._fileset
-or dir in self._dirs
-or any(
-parentdir in self._fileset
-for parentdir in pathutil.finddirs(dir)
-)
+dir in self._dirs
+or path_or_parents_in_set(dir, self._fileset)
 )
 
 def visitchildrenset(self, dir):
@@ -698,12 +724,9 @@
 if self._prefix and dir in self._roots:
 return b'all'
 return (
-dir in self._roots
-or dir in self._dirs
+dir in self._dirs
 or dir in self._parents
-or any(
-parentdir in self._roots for parentdir in 
pathutil.finddirs(dir)
-)
+or path_or_parents_in_set(dir, self._roots)
 )
 
 @propertycache
@@ -726,11 +749,8 @@
 # visitdir, that's handled below.
 if (
 b'' in self._roots
-or dir in self._roots
 or dir in self._dirs
-or any(
-parentdir in self._roots for parentdir in 
pathutil.finddirs(dir)
-)
+or path_or_parents_in_set(dir, self._roots)
 ):
 return b'this'
 



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


D9207: record: when backing up, avoid generating very long filenames

2020-10-14 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  If the original file's path is longer than the individual filename maximum
  length (256 on Linux, I believe?), then this mechanism of "replace slashes 
with
  underscores" causes an error.
  
  Now, we'll produce just the "basename" of the file, plus some stuff to ensure
  it's unique. This can be potentially confusing for users if there's a file 
with
  the same name in multiple directories, but I suspect that this is better than
  just breaking.
  
  Example:
  `/a/long/path/to/somefile.txt` used to be backed up as
  `/.hg/record-backups/a_long_path_to_somefile.txt.abcdefgh`, it will
  now be backed up as `/.hg/record-backups/somefile.txt.abcdefgh`
  
  We could do the naive thing (what we were doing before) and have it to doing
  something with either subdirectories
  (`/a/long/path/to/somefile.txt.abcdefgh` or minimize #dirs with
  `/a_long_path/to_somefile.txt.abcdefgh`), prefix-truncated paths
  (such as `/__ath_to_somefile.txt.abcdefgh`, where that `__` elides
  enough to get us under 255 chars (counting the +9 we need to add!)), or
  hash-of-dirname (`//somefile.txt.abcdefgh`), 
but
  ultimately every option felt over engineered and that it would be more likely 
to
  cause problems than it would be to solve any, especially if it was conditional
  on directory length.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -558,7 +558,7 @@
 # backup continues
 for f in tobackup:
 fd, tmpname = pycompat.mkstemp(
-prefix=f.replace(b'/', b'_') + b'.', dir=backupdir
+prefix=os.path.basename(f) + b'.', dir=backupdir
 )
 os.close(fd)
 ui.debug(b'backup %r as %r\n' % (f, tmpname))



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


D9023: branchmap: add a cache validation cache, avoid expensive re-hash on every use

2020-09-15 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  In a pathological `hg log` case, we end up executing the branchmap validity
  checking twice per commit displayed. Or maybe we always do, and I just noticed
  because it's really slow in this repo for some reason.
  
  Before:
  
Time (mean ± σ):  9.816 s ±  0.071 s[User: 9.435 s, System: 0.392 s]

Range (min … max):9.709 s …  9.920 s
  
  After:
  
Time (mean ± σ):  8.671 s ±  0.078 s[User: 8.309 s, System: 0.392 s]

Range (min … max):8.594 s …  8.816 s

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hg
  mercurial/changelog.py
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -363,13 +363,15 @@
 cl = repo.changelog
 if not cl.filteredrevs:
 return None
-key = None
-revs = sorted(r for r in cl.filteredrevs if r <= maxrev)
-if revs:
-s = hashutil.sha1()
-for rev in revs:
-s.update(b'%d;' % rev)
-key = s.digest()
+key = cl._filteredrevs_hashcache.get(maxrev)
+if not key:
+revs = sorted(r for r in cl.filteredrevs if r <= maxrev)
+if revs:
+s = hashutil.sha1()
+for rev in revs:
+s.update(b'%d;' % rev)
+key = s.digest()
+cl._filteredrevs_hashcache[maxrev] = key
 return key
 
 
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -403,9 +403,21 @@
 self._delayed = False
 self._delaybuf = None
 self._divert = False
-self.filteredrevs = frozenset()
+self._filteredrevs = frozenset()
+self._filteredrevs_hashcache = {}
 self._copiesstorage = opener.options.get(b'copies-storage')
 
+@property
+def filteredrevs(self):
+return self._filteredrevs
+
+@filteredrevs.setter
+def filteredrevs(self, val):
+# Ensure all updates go through this function
+assert isinstance(val, frozenset)
+self._filteredrevs = val
+self._filteredrevs_hashcache = {}
+
 def delayupdate(self, tr):
 """delay visibility of index updates to other readers"""
 
diff --git a/hg b/hg
--- a/hg
+++ b/hg
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3.8
 #
 # mercurial - scalable distributed SCM
 #



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


D9022: repo: avoid copying/updating a dict on every `repo.__getitem__`

2020-09-15 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This has some mild performance benefits. I'm looking into a pathological case
  where one of our `hg log` invocations takes several seconds, and according to
  hyperfine this reduces the wall time of the entire operation (running in chg)
  from:
  
Time (mean ± σ):  7.390 s ±  0.106 s[User: 7.058 s, System: 0.271 s]

Range (min … max):7.300 s …  7.625 s
  
  to:
  
Time (mean ± σ):  7.046 s ±  0.091 s[User: 6.714 s, System: 0.279 s]

Range (min … max):6.916 s …  7.169 s
  
  Note: the log command is slow due to an issue in our custom stuff executing
  `repo[]` 298,800 times. This performance improvement is likely not
  noticeable during normal operation, but I don't feel like it's making the code
  more difficult to understand, and every small bit helps.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -1570,7 +1570,7 @@
 def _quick_access_changeid_wc(self):
 # also fast path access to the working copy parents
 # however, only do it for filter that ensure wc is visible.
-quick = {}
+quick = self._quick_access_changeid_null.copy()
 cl = self.unfiltered().changelog
 for node in self.dirstate.parents():
 if node == nullid:
@@ -1609,11 +1609,9 @@
 This contains a list of symbol we can recognise right away without
 further processing.
 """
-mapping = self._quick_access_changeid_null
 if self.filtername in repoview.filter_has_wc:
-mapping = mapping.copy()
-mapping.update(self._quick_access_changeid_wc)
-return mapping
+return self._quick_access_changeid_wc
+return self._quick_access_changeid_null
 
 def __getitem__(self, changeid):
 # dealing with special cases



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


D8814: tests: make check-py3-compat.py actually load the specified files correctly

2020-07-24 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  For most uses, this change is essentially a no-op, as this script is generally
  only run by test-check-py3-compat.t, which will already put `$TESTDIR/..` in
  `$PYTHONPATH`.
  
  When running outside of tests, however, `$PYTHONPATH` is likely not set, 
causing
  check-py3-compat.py to parse the file from the repo, but then import the
  installed version, and raise any errors about the installed version, not the 
one
  currently in the repo.
  
  Additionally, this helps users (like me) who have a strange set up where their
  home directory (and thus their hg repos) happen to be in a subdirectory of
  sys.prefix (which is /usr on my system). Since the '.' entry added to sys.path
  takes precedence over the absolute path of `$TESTDIR/..` in `$PYTHONPATH`, the
  path to the modules that it imports (and that show up in any stack trace) are
  *relative*, meaning that we don't detect them as starting with `sys.prefix`.
  
  Sample non-test invocation, and the difference this change makes (the path for
  'error at :' is correct now)::
  
  Before:
  
$ python3 contrib/check-py3-compat.py mercurial/win*.py
mercurial/win32.py: error importing:  _type_ 'v' not supported 
(error at check-py3-compat.py:65)
mercurial/windows.py: error importing:  No module 
named 'msvcrt' (error at check-py3-compat.py:65)
  
  After:
  
$ python3 contrib/check-py3-compat.py mercurial/win*.py
mercurial/win32.py: error importing:  _type_ 'v' not supported 
(error at win32.py:11)
mercurial/windows.py: error importing:  No module 
named 'msvcrt' (error at windows.py:12)

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/check-py3-compat.py

CHANGE DETAILS

diff --git a/contrib/check-py3-compat.py b/contrib/check-py3-compat.py
--- a/contrib/check-py3-compat.py
+++ b/contrib/check-py3-compat.py
@@ -97,6 +97,15 @@
 if sys.version_info[0] == 2:
 fn = check_compat_py2
 else:
+# check_compat_py3 will import every filename we specify as long as it
+# starts with one of a few prefixes. It does this by converting
+# specified filenames like 'mercurial/foo.py' to 'mercurial.foo' and
+# importing that. When running standalone (not as part of a test), this
+# means we actually import the installed versions, not the files we 
just
+# specified. When running as test-check-py3-compat.t, we technically
+# would import the correct paths, but it's cleaner to have both cases
+# use the same import logic.
+sys.path.insert(0, '.')
 fn = check_compat_py3
 
 for f in sys.argv[1:]:



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


D8813: tests: make test-install.t work on debian systems

2020-07-24 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Debian systems, at least as of their version of python3.8 on my machine, have
  rewritten some logic in ensurepip to make it not use the wheels in 
pip._bundled,
  but instead to use wheels installed in /usr/share/python-wheels. It copies 
these
  wheels into the virtual environment when it's created, and installenv/bin/pip 
is
  able to see them and use them, so it thinks that 'wheel' is installed, and 
that
  it can build the mercurial wheel instead of just installing it. For some 
reason,
  when it subprocesses to run `python3 setup.py bdist_wheel`, it setup.py does
  *not* have the 'wheel' wheel available, and we get an error message.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-install.t

CHANGE DETAILS

diff --git a/tests/test-install.t b/tests/test-install.t
--- a/tests/test-install.t
+++ b/tests/test-install.t
@@ -187,6 +187,14 @@
 #if py3 ensurepip
   $ "$PYTHON" -m venv installenv >> pip.log
 
+Hack: Debian does something a bit different in ensurepip.bootstrap. This makes
+it so that pip thinks the 'wheel' wheel is installed so it can build wheels;
+when it goes to try, however, it shells out to run `python3 -u `,
+that *doesn't* get the 'wheel' wheel, and it fails with an invalid command
+'bdist_wheel'. To fix this, we just delete the wheel from where Debian put it 
in
+our virtual env. Then pip doesn't think it's installed and doesn't try to 
build.
+  $ rm installenv/share/python-wheels/wheel-*.whl >/dev/null 2>&1 || true
+
 Note: we use this weird path to run pip and hg to avoid platform differences,
 since it's bin on most platforms but Scripts on Windows.
   $ ./installenv/*/pip install --no-index $TESTDIR/.. >> pip.log



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


D8812: tests: virtualenv is only used on py2, rename and conditionalize

2020-07-24 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  If I have I have the Debian `python3-virtualenv` package installed on my
  machine, the import succeeds but then I receive an AttributeError because the
  package is essentially completely different between py2 and py3, and
  test-hghave fails.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/hghave.py
  tests/test-install.t

CHANGE DETAILS

diff --git a/tests/test-install.t b/tests/test-install.t
--- a/tests/test-install.t
+++ b/tests/test-install.t
@@ -214,7 +214,7 @@
   no problems detected
 #endif
 
-#if no-py3 virtualenv
+#if py2virtualenv
 
 Note: --no-site-packages is deprecated, but some places have an
 ancient virtualenv from their linux distro or similar and it's not yet
diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -886,8 +886,11 @@
 return False
 
 
-@check("virtualenv", "Python virtualenv support")
-def has_virtualenv():
+@check("py2virtualenv", "Python2 virtualenv support")
+def has_py2virtualenv():
+if sys.version_info[0] != 2:
+return False
+
 try:
 import virtualenv
 



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


D8811: morestatus: mention --stop even if not using --verbose

2020-07-24 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/state.py
  tests/test-absorb-unfinished.t
  tests/test-fix.t
  tests/test-rebase-abort.t
  tests/test-rebase-inmemory.t
  tests/test-rebase-obsolete.t

CHANGE DETAILS

diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -2055,7 +2055,7 @@
 
   $ hg rebase -s 3 -d 5
   abort: rebase in progress
-  (use 'hg rebase --continue' or 'hg rebase --abort')
+  (use 'hg rebase --continue', 'hg rebase --abort', or 'hg rebase --stop')
   [255]
   $ hg rebase --stop --continue
   abort: cannot specify both --stop and --continue
diff --git a/tests/test-rebase-inmemory.t b/tests/test-rebase-inmemory.t
--- a/tests/test-rebase-inmemory.t
+++ b/tests/test-rebase-inmemory.t
@@ -901,7 +901,7 @@
   [1]
   $ hg rebase -r 3 -d 1 -t:merge3
   abort: rebase in progress
-  (use 'hg rebase --continue' or 'hg rebase --abort')
+  (use 'hg rebase --continue', 'hg rebase --abort', or 'hg rebase --stop')
   [255]
   $ hg resolve --list
   U foo
diff --git a/tests/test-rebase-abort.t b/tests/test-rebase-abort.t
--- a/tests/test-rebase-abort.t
+++ b/tests/test-rebase-abort.t
@@ -327,7 +327,7 @@
   $ echo new > a
   $ hg up 1   # user gets an error saying to run hg rebase --abort
   abort: rebase in progress
-  (use 'hg rebase --continue' or 'hg rebase --abort')
+  (use 'hg rebase --continue', 'hg rebase --abort', or 'hg rebase --stop')
   [255]
 
   $ cat a
@@ -397,20 +397,20 @@
 
   $ hg rebase -s 3 -d tip
   abort: rebase in progress
-  (use 'hg rebase --continue' or 'hg rebase --abort')
+  (use 'hg rebase --continue', 'hg rebase --abort', or 'hg rebase --stop')
   [255]
   $ hg up .
   abort: rebase in progress
-  (use 'hg rebase --continue' or 'hg rebase --abort')
+  (use 'hg rebase --continue', 'hg rebase --abort', or 'hg rebase --stop')
   [255]
   $ hg up -C .
   abort: rebase in progress
-  (use 'hg rebase --continue' or 'hg rebase --abort')
+  (use 'hg rebase --continue', 'hg rebase --abort', or 'hg rebase --stop')
   [255]
 
   $ hg graft 3
   abort: rebase in progress
-  (use 'hg rebase --continue' or 'hg rebase --abort')
+  (use 'hg rebase --continue', 'hg rebase --abort', or 'hg rebase --stop')
   [255]
 
   $ hg abort
diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -878,7 +878,7 @@
 
   $ hg --config extensions.rebase= fix -r .
   abort: rebase in progress
-  (use 'hg rebase --continue' or 'hg rebase --abort')
+  (use 'hg rebase --continue', 'hg rebase --abort', or 'hg rebase --stop')
   [255]
 
   $ cd ..
diff --git a/tests/test-absorb-unfinished.t b/tests/test-absorb-unfinished.t
--- a/tests/test-absorb-unfinished.t
+++ b/tests/test-absorb-unfinished.t
@@ -25,6 +25,6 @@
 
   $ hg --config extensions.rebase= absorb
   abort: rebase in progress
-  (use 'hg rebase --continue' or 'hg rebase --abort')
+  (use 'hg rebase --continue', 'hg rebase --abort', or 'hg rebase --stop')
   [255]
 
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -164,10 +164,19 @@
 operation
 """
 if not self._cmdhint:
-return _(b"use 'hg %s --continue' or 'hg %s --abort'") % (
-self._opname,
-self._opname,
-)
+if not self._stopflag:
+return _(b"use 'hg %s --continue' or 'hg %s --abort'") % (
+self._opname,
+self._opname,
+)
+else:
+return _(b"use 'hg %s --continue', 'hg %s --abort', "
+ b"or 'hg %s --stop'") % (
+self._opname,
+self._opname,
+self._opname,
+)
+
 return self._cmdhint
 
 def msg(self):



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


D8642: debian: support building a single deb for multiple py3 versions

2020-06-19 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Around transitions from one python minor version to another (such as 3.7 to
  3.8), the current packaging can be slightly problematic - it produces a
  `control` file that requires that the version of `python3` that's installed be
  exactly the one that was used on the build machine for the `mercurial` 
package,
  by containing a line like:
  
Depends: sensible-utils, libc6 (>= 2.14), python3 (<< 3.8), python3 (>= 
3.7~), python3:any (>= 3.5~)
  
  This is because it "knows" we only built for v3.7, which is the current 
default
  on my system. By building the native components for multiple versions, we can
  make it produce a line like this, which is compatible with 3.7 AND 3.8:
  
Depends: sensible-utils, libc6 (>= 2.14), python3 (<< 3.9), python3 (>= 
3.7~), python3:any (>= 3.5~)
  
  This isn't *normally* required, so I'm not making it the default. For those 
that
  receive their python3 and mercurial packages from their distro, and/or don't
  have to worry about a situation where the team that manages the python3
  installation isn't the same as the team that manages the mercurial 
installation,
  this is probably not necessary.
  
  I chose the names `DEB_HG_*` because `DEB_*` is passed through `debuild`
  automatically (otherwise we'd have to explicitly allow the options through,
  which is a nuisance), and the `HG` part is to make it clear that this isn't a
  "standard" debian option that other packages might respect.

TEST PLAN
  1. "nothing changed":
- built a deb without these changes
- built a deb with these changes but everything at the default
- used diffoscope to compare, all differences were due to timestamps
  2. "explicit is the same as implicit" (single version)
- built a deb with everything at the default
- built a deb with DEB_HG_PYTHON_VERSIONS=3.7
- used diffoscope to compare, all differences were due to timestamps
  3. "explicit is the same as implicit" (multi version)
- built a deb with DEB_HG_MULTI_VERSION=1
- built a deb with DEB_HG_PYTHON_VERSIONS=3.7
- used diffoscope to compare, all differences were due to timestamps
  4. (single version, 3.7) doesn't work with python3.8
- `/usr/bin/python3.7 /usr/bin/hg debuginstall` works
- `/usr/bin/python3.8 /usr/bin/hg debuginstall` crashes
  5. (multi version, 3.7 + 3.8)
- `/usr/bin/python3.7 /usr/bin/hg debuginstall` works
- `/usr/bin/python3.8 /usr/bin/hg debuginstall` works

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/packaging/debian/rules

CHANGE DETAILS

diff --git a/contrib/packaging/debian/rules b/contrib/packaging/debian/rules
--- a/contrib/packaging/debian/rules
+++ b/contrib/packaging/debian/rules
@@ -2,14 +2,51 @@
 # Uncomment this to turn on verbose mode.
 # export DH_VERBOSE=1
 
+# By default we build a .deb where the native components are built with the
+# current "default" version of py3 on the build machine. If you wish to build a
+# .deb that has native components built for multiple versions of py3:
+#
+#   1. install python3.x and python3.x-dev for each version you want
+#   2. set DEB_HG_MULTI_VERSION=1 or DEB_HG_PYTHON_VERSIONS in your environment
+#  (if both are set, DEB_HG_PYTHON_VERSIONS has precedence)
+#
+# If you choose `DEB_HG_MULTI_VERSION=1`, it will build for every "supported"
+# version of py3 that's installed on the build machine. This may not be equal 
to
+# the actual versions that are installed, see the comment above where we set
+# DEB_HG_PYTHON_VERSIONS below. If you choose to set `DEB_HG_PYTHON_VERSIONS`
+# yourself, set it to a space-separated string of python version numbers, like:
+#   DEB_HG_PYTHON_VERSIONS="3.7 3.8" make deb
+DEB_HG_MULTI_VERSION?=0
+
 CPUS=$(shell cat /proc/cpuinfo | grep -E ^processor | wc -l)
 
+# By default, only build for the version of python3 that the system considers
+# the 'default' (which should be the one invoked by just running 'python3'
+# without a minor version). If DEB_HG_PYTHON_VERSIONS is set, this is ignored.
+ifeq ($(DEB_HG_MULTI_VERSION), 1)
+   # If we're building for multiple versions, use all of the "supported" 
versions
+   # on the build machine. Note: the mechanism in use here (`py3versions`) 
is the
+   # recommended one, but it relies on a file written by the 
python3-minimal
+   # package, and this file is not dynamic and does not account for manual
+   # installations, just the ones that would be installed by 
`python3-all`. This
+   # includes the `-i` flag, which claims it's to list all "installed" 
versions,
+   # but it doesn't. This was quite confusing, hence this tale of woe. :)
+   DEB_HG_PYTHON_VERSIONS?=$(shell py3versions -vs)
+else
+   # If we're building for only one version, identify the "default" 
version on
+   # 

D8639: py3: fix broken man page generation, it was generating `(default: NUL*)`

2020-06-17 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  `bytes(default)` was producing things like `(default: \x00)` when handed
  non-bytes values such as `1`, `10`, or `True`. The man page generation would
  apparently ignore these bytes and produce man pages that had the string
  `(default: )`.

TEST PLAN
  - Ran `cd doc; python3 gendoc.py "hg.1.gendoc"` and grepped for bad output
  - Ran `make deb`, extracted the deb, manually inspected `hg.1` file.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  doc/gendoc.py

CHANGE DETAILS

diff --git a/doc/gendoc.py b/doc/gendoc.py
--- a/doc/gendoc.py
+++ b/doc/gendoc.py
@@ -85,7 +85,12 @@
 if b'\n' in desc:
 # only remove line breaks and indentation
 desc = b' '.join(l.lstrip() for l in desc.split(b'\n'))
-desc += default and _(b" (default: %s)") % bytes(default) or b""
+if default:
+defaulttmpl = _(b" (default: %s)")
+if defaulttmpl:
+if not isinstance(default, bytes):
+default = repr(default).encode('latin1')
+desc += defaulttmpl % default
 yield (b", ".join(allopts), desc)
 
 



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


D8464: locking: wait for locks in `hg cp` and `hg mv`

2020-04-21 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I traced this back to revision 1822 (64df422 
), 
and there's no explanation why we
  would prefer to error out instead of waiting for the locks.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2350,7 +2350,7 @@
 Returns 0 on success, 1 if errors are encountered.
 """
 opts = pycompat.byteskwargs(opts)
-with repo.wlock(False):
+with repo.wlock():
 return cmdutil.copy(ui, repo, pats, opts)
 
 
@@ -5807,7 +5807,7 @@
 Returns 0 on success, 1 if errors are encountered.
 """
 opts = pycompat.byteskwargs(opts)
-with repo.wlock(False):
+with repo.wlock():
 return cmdutil.copy(ui, repo, pats, opts, rename=True)
 
 



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


D8385: hgk: remove a "b" used on a kwargs expansion, the keys are strs

2020-04-07 Thread spectral (Kyle Lippincott)
Closed by commit rHG1756f75873bf: hgk: remove a b used on a kwargs 
expansion, the keys are strs (authored by spectral).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8385?vs=21001=21002

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

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

AFFECTED FILES
  hgext/hgk.py

CHANGE DETAILS

diff --git a/hgext/hgk.py b/hgext/hgk.py
--- a/hgext/hgk.py
+++ b/hgext/hgk.py
@@ -358,7 +358,7 @@
 )
 def revlist(ui, repo, *revs, **opts):
 """print revisions"""
-if opts[b'header']:
+if opts['header']:
 full = b"commit"
 else:
 full = None



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


D8385: hgk: remove a "b" used on a kwargs expansion, the keys are strs

2020-04-06 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/hgk.py

CHANGE DETAILS

diff --git a/hgext/hgk.py b/hgext/hgk.py
--- a/hgext/hgk.py
+++ b/hgext/hgk.py
@@ -358,7 +358,7 @@
 )
 def revlist(ui, repo, *revs, **opts):
 """print revisions"""
-if opts[b'header']:
+if opts['header']:
 full = b"commit"
 else:
 full = None



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


D8354: histedit: add missing b prefix to a string

2020-04-01 Thread spectral (Kyle Lippincott)
Closed by commit rHG8fca7e8449a8: histedit: add missing b prefix to a string 
(authored by spectral).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8354?vs=20955=20956

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

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

AFFECTED FILES
  hgext/histedit.py

CHANGE DETAILS

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -291,7 +291,7 @@
 Commands are only included once.
 """
 intro = _(
-"""Edit history between %s and %s
+b"""Edit history between %s and %s
 
 Commits are listed from least to most recent
 



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


D8354: histedit: add missing b prefix to a string

2020-04-01 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  If i18n is disabled (such as via HGPLAIN=1), `_()` doesn't convert from str to
  bytes, so this raises a TypeError on py3.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/histedit.py

CHANGE DETAILS

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -291,7 +291,7 @@
 Commands are only included once.
 """
 intro = _(
-"""Edit history between %s and %s
+b"""Edit history between %s and %s
 
 Commits are listed from least to most recent
 



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


D8321: darwin: use vim, not vi, to avoid data-loss inducing posix behavior

2020-03-25 Thread spectral (Kyle Lippincott)
Closed by commit rHGc23877cb25a5: darwin: use vim, not vi, to avoid data-loss 
inducing posix behavior (authored by spectral).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8321?vs=20864=20877

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

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

AFFECTED FILES
  mercurial/ui.py

CHANGE DETAILS

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1914,6 +1914,12 @@
 # instead default to E to plumb commit messages to
 # avoid confusion.
 editor = b'E'
+elif pycompat.isdarwin:
+# vi on darwin is POSIX compatible to a fault, and that includes
+# exiting non-zero if you make any mistake when running an ex
+# command. Proof: `vi -c ':unknown' -c ':qa'; echo $?` produces 1,
+# while s/vi/vim/ doesn't.
+editor = b'vim'
 else:
 editor = b'vi'
 return encoding.environ.get(b"HGEDITOR") or self.config(



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


D8321: darwin: use vim, not vi, to avoid data-loss inducing posix behavior

2020-03-23 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Apple's version of vim, available at
  opensource.apple.com/release/macos-1015.html (for Catalina, but this behavior
  has been there for a while) has several tweaks from the version of vim from
  vim.org. Most of these tweaks appear to be for "Unix2003" compatibility.
  
  One of the tweaks is that if any ex command raises an error, the entire
  process will (when you exit, possibly minutes/hours later) also exit non-zero.
  Ex commands are things like `:foo`.
  
  Luckily, they only enabled this if vim was executed (via a symlink or copying
  the binary) as `vi` or `ex`. If you start it as `vim`, it doesn't have this
  behavior, so let's do that.
  
  To see this in action, run the following two commands on macOS:
  
$ vi -c ':unknown' -c ':qa' ; echo $?
1
$ vim -c ':unknown' -c ':qa' ; echo $?
0
  
  We don't want to start ignoring non-zero return types from the editor because
  that will mean you can't use `:cquit` to intentionally exit 1 (which,
  shows up as 2 if you combine an ex command error and a cquit, but only a 1 if
  you just use cquit, so we can't differentiate between the two statuses). Since
  we can't differentiate, we have to assume that all non-zero exit codes are
  intentional and an indication of the user's desire to not continue with 
whatever
  we're doing. If this was a complicated `hg split` or `hg histedit`, this is
  especially disastrous :(

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/ui.py

CHANGE DETAILS

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1914,6 +1914,12 @@
 # instead default to E to plumb commit messages to
 # avoid confusion.
 editor = b'E'
+elif pycompat.isdarwin:
+# vi on darwin is POSIX compatible to a fault, and that includes
+# exiting non-zero if you make any mistake when running an ex
+# command. Proof: `vi -c ':unknown' -c ':qa'; echo $?` produces 1,
+# while s/vi/vim/ doesn't.
+editor = b'vim'
 else:
 editor = b'vi'
 return encoding.environ.get(b"HGEDITOR") or self.config(



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


D8281: narrow: escape includepats/excludepats when sending over the wire

2020-03-20 Thread spectral (Kyle Lippincott)
spectral added a comment.


  In D8281#124247 , @martinvonz 
wrote:
  
  > In D8281#124246 , @spectral 
wrote:
  >
  >> - Server emits a new capability `narrow-exp-1-escaped` (in addition to the 
current `narrow-exp-1`, this is not replacing the existing capability)
  >
  > nit: I *think* the "1" in the name was supposed to be a version number, so 
the new capability's name would be `narrow-exp-2`.
  
  Yes, I had assumed that as well. This isn't really a new version of the 
protocol, though, just a minor tweak, and it's primarily to the 'csv' type used 
in getbundle (see the current version of this patch that adds 'qcsv' for the 
actual locations it's used). Honestly I went back and forth between announcing 
it as `getbundle-csv-escaped` and something related to narrow (and ended up on 
narrow, as you see, since while it's generically useful besides narrow, nothing 
else needs it today, and future things wouldn't need this to be announced 
forever - they'll always have used foo.escaped and been transmitted as escaped).
  
  > Maybe no one uses the "widen" command so we don't even need to worry about 
compatibility there?
  
  I don't know how often it's used :) I just know that there's something *not* 
getbundle-related in narrowwirepeer.py (looks like it's called `narrow_widen` 
that needed to be modified or else the tests wouldn't pass. I honestly don't 
even know if we're using it internally at Google right now. If not, that's 
fewer things to change, which I'm OK with :)

REPOSITORY
  rHG Mercurial

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

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

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


D8281: narrow: escape includepats/excludepats when sending over the wire

2020-03-20 Thread spectral (Kyle Lippincott)
spectral added a comment.


  In D8281#124129 , @durin42 wrote:
  
  > In D8281#124058 , @marmoute 
wrote:
  >
  >> Since narrow is still experimental, I don't think we should try too hard 
for backward compatibility. We could introduce a new end-point for a new 
encoding and drop the old one in a couple of version.
  >
  > +0, honestly. I won't require it, but I'd really rather we shaved this yak 
_now_ rather than when narrow has even more users.
  
  I'm getting a bit frustrated with how much time I've spent on this, made 
worse by the fact that I agree with everything everyone's saying and so it's 
not like I'm frustrated at the review process, just how slow I've been at 
accomplishing this.
  
  So, before I go down another rabbit hole, here's what I'm thinking:
  
  - Server emits a new capability `narrow-exp-1-escaped` (in addition to the 
current `narrow-exp-1`, this is not replacing the existing capability)
  - wireprototypes's map will change these items from csv to csv.escaped
  - Compatible clients will detect this capability from the server and send 
items of type csv.escaped during getbundle with keys like 
`.escaped` (ex: `include.escaped`). If the server doesn't support 
csv.escaped, the client sends with the old names (unescaped).
  - The escaping will be urllibcompat.quote
  - The server will strip the `.escaped` suffix on the keys, split on comma, 
and urllibcompat.unquote the individual items
  - I'm *not* expecting to do anything about `\` -> `/` conversion.
  
  Since these are part of `getbundle`, I haven't found a way of doing this 
that's not one of:
  
  - a custom escaping mechanism that's backwards compatible
  - adding a capability and renaming the keys that are sent (so the server can 
tell when it needs to unescape)
  - having the client always send duplicate items (i.e. send `include` and 
`include.escaped`). I'm not even sure that older servers would tolerate 
receiving keys they aren't expecting.
  - having the client only escape when necessary (i.e. it includes a comma), 
and then always send the path as include.escaped (which runs into the problem 
of old servers rejecting).
  - having the server always unescape and the client always escape. This breaks 
the server's ability to interact with older clients that aren't escaping (which 
we'll need to support for at least a week or two).
  
  For the non-getbundle parts (I think the wireproto command is 'widen'), we 
can easily make a widen2 or something, but it's probably easier to just keep 
the same command name and do the same thing as in getbundle: detect the 
capability, send as foo.escaped if supported.

REPOSITORY
  rHG Mercurial

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

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

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


D8281: narrow: escape includepats/excludepats when sending over the wire

2020-03-17 Thread spectral (Kyle Lippincott)
spectral updated this revision to Diff 20819.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8281?vs=20818=20819

BRANCH
  default

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

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

AFFECTED FILES
  hgext/narrow/narrowbundle2.py
  hgext/narrow/narrowwirepeer.py
  mercurial/wireprototypes.py
  mercurial/wireprotov1peer.py
  mercurial/wireprotov1server.py
  relnotes/next
  tests/test-doctest.py
  tests/test-narrow-exchange.t

CHANGE DETAILS

diff --git a/tests/test-narrow-exchange.t b/tests/test-narrow-exchange.t
--- a/tests/test-narrow-exchange.t
+++ b/tests/test-narrow-exchange.t
@@ -223,3 +223,62 @@
   remote: rollback completed (lfs-on !)
   remote: abort: data/inside2/f.i@f59b4e021835: no match found! (lfs-on !)
   abort: stream ended unexpectedly (got 0 bytes, expected 4) (lfs-on !)
+
+Test paths with commas in them
+  $ cd $TESTTMP
+  $ hg init commas-master
+  $ cd commas-master
+  $ mkdir a,b
+  $ mkdir a,b/c,d
+  $ mkdir a,b/e,f
+  $ mkdir g
+  $ echo abcd > a,b/c,d/abcd
+  $ echo abef > a,b/e,f/abef
+  $ echo ghi > g/h,i
+  $ hg ci -qAm r0
+  $ echo abcd2 >> a,b/c,d/abcd
+  $ echo abef2 >> a,b/e,f/abef
+  $ echo ghi2 >> g/h,i
+  $ hg ci -qm r1
+  $ cd ..
+
+Test that we can pull and push with a file that has a comma in the name, even
+though the commas don't appear in the narrowspec file (since they're just
+filenames)
+  $ hg clone --narrow ssh://user@dummy/commas-master commas-in-file \
+  >   --include g -qr 0
+  $ cd commas-in-file
+  $ hg pull -q
+  $ echo ghi3 >> g/h,i
+  $ hg ci -qm 'modify g/h,i'
+  $ hg push -qf
+  $ cd ..
+
+Test commas in the --include, plus pull+push
+  $ hg clone --narrow ssh://user@dummy/commas-master commas-in-dir \
+  >   --include a,b --exclude a,b/c,d -qr 0
+  $ cd commas-in-dir
+  $ hg pull -q
+  $ echo abef3 >> a,b/e,f/abef
+  $ hg ci -qm 'modify a,b/e,f'
+  $ hg push -qf
+
+Test that --{add,remove}{include,exclude} work with commas in the directory
+names.
+  $ hg tracked
+  I path:a,b
+  X path:a,b/c,d
+  $ hg tracked --removeexclude a,b/c,d --addinclude a,b/e,f -q
+  $ hg tracked
+  I path:a,b
+  I path:a,b/e,f
+  $ hg files
+  a,b/c,d/abcd
+  a,b/e,f/abef
+  $ hg tracked --removeinclude a,b/e,f --addexclude a,b/c,d -q
+  $ hg tracked
+  I path:a,b
+  X path:a,b/c,d
+  $ hg files
+  a,b/e,f/abef
+  $ cd ..
diff --git a/tests/test-doctest.py b/tests/test-doctest.py
--- a/tests/test-doctest.py
+++ b/tests/test-doctest.py
@@ -137,6 +137,7 @@
 ('mercurial.revlogutils.deltas', '{}'),
 ('mercurial.revset', '{}'),
 ('mercurial.revsetlang', '{}'),
+('mercurial.wireprototypes', '{}'),
 ('mercurial.simplemerge', '{}'),
 ('mercurial.smartset', '{}'),
 ('mercurial.store', '{}'),
diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -29,6 +29,10 @@
  * `hg debugmergestate` output is now templated, which may be useful
e.g. for IDEs that want to help the user resolve merge conflicts.
 
+ * The experimental `narrow` extension will now be able to have include or
+   exclude patterns that have a comma in the name when both client and server
+   are updated.
+
 
 == New Experimental Features ==
 
diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py
--- a/mercurial/wireprotov1server.py
+++ b/mercurial/wireprotov1server.py
@@ -448,6 +448,8 @@
 opts[k] = list(v.split(b','))
 elif keytype == b'scsv':
 opts[k] = set(v.split(b','))
+elif keytype == b'qcsv':
+opts[k] = wireprototypes.decode_qcsv(v)
 elif keytype == b'boolean':
 # Client should serialize False as '0', which is a non-empty string
 # so it evaluates as a True bool.
diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py
--- a/mercurial/wireprotov1peer.py
+++ b/mercurial/wireprotov1peer.py
@@ -462,6 +462,8 @@
 value = b','.join(value)
 elif keytype == b'scsv':
 value = b','.join(sorted(value))
+elif keytype == b'qcsv':
+value = wireprototypes.encode_qcsv(value)
 elif keytype == b'boolean':
 value = b'%i' % bool(value)
 elif keytype != b'plain':
diff --git a/mercurial/wireprototypes.py b/mercurial/wireprototypes.py
--- a/mercurial/wireprototypes.py
+++ b/mercurial/wireprototypes.py
@@ -161,6 +161,7 @@
 # :nodes: list of binary nodes, transmitted as space-separated hex nodes
 # :csv:   list of values, transmitted as comma-separated values
 # :scsv:  set of values, transmitted as comma-separated values
+# :qcsv:  list of values, transmitted as quote-escaped comma-separated values
 # :plain: string with no transformation needed.
 GETBUNDLE_ARGUMENTS = {
 b'heads': b'nodes',
@@ -173,11 +174,194 @@
 b'cg': b'boolean',
 b'cbattempted': b'boolean',
 b'stream': b'boolean',

D8281: narrow: escape includepats/excludepats when sending over the wire

2020-03-17 Thread spectral (Kyle Lippincott)
spectral updated this revision to Diff 20818.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8281?vs=20813=20818

BRANCH
  default

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

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

AFFECTED FILES
  hgext/narrow/narrowbundle2.py
  hgext/narrow/narrowwirepeer.py
  mercurial/wireprototypes.py
  mercurial/wireprotov1peer.py
  mercurial/wireprotov1server.py
  relnotes/next
  tests/test-doctest.py
  tests/test-narrow-exchange.t

CHANGE DETAILS

diff --git a/tests/test-narrow-exchange.t b/tests/test-narrow-exchange.t
--- a/tests/test-narrow-exchange.t
+++ b/tests/test-narrow-exchange.t
@@ -223,3 +223,62 @@
   remote: rollback completed (lfs-on !)
   remote: abort: data/inside2/f.i@f59b4e021835: no match found! (lfs-on !)
   abort: stream ended unexpectedly (got 0 bytes, expected 4) (lfs-on !)
+
+Test paths with commas in them
+  $ cd $TESTTMP
+  $ hg init commas-master
+  $ cd commas-master
+  $ mkdir a,b
+  $ mkdir a,b/c,d
+  $ mkdir a,b/e,f
+  $ mkdir g
+  $ echo abcd > a,b/c,d/abcd
+  $ echo abef > a,b/e,f/abef
+  $ echo ghi > g/h,i
+  $ hg ci -qAm r0
+  $ echo abcd2 >> a,b/c,d/abcd
+  $ echo abef2 >> a,b/e,f/abef
+  $ echo ghi2 >> g/h,i
+  $ hg ci -qm r1
+  $ cd ..
+
+Test that we can pull and push with a file that has a comma in the name, even
+though the commas don't appear in the narrowspec file (since they're just
+filenames)
+  $ hg clone --narrow ssh://user@dummy/commas-master commas-in-file \
+  >   --include g -qr 0
+  $ cd commas-in-file
+  $ hg pull -q
+  $ echo ghi3 >> g/h,i
+  $ hg ci -qm 'modify g/h,i'
+  $ hg push -qf
+  $ cd ..
+
+Test commas in the --include, plus pull+push
+  $ hg clone --narrow ssh://user@dummy/commas-master commas-in-dir \
+  >   --include a,b --exclude a,b/c,d -qr 0
+  $ cd commas-in-dir
+  $ hg pull -q
+  $ echo abef3 >> a,b/e,f/abef
+  $ hg ci -qm 'modify a,b/e,f'
+  $ hg push -qf
+
+Test that --{add,remove}{include,exclude} work with commas in the directory
+names.
+  $ hg tracked
+  I path:a,b
+  X path:a,b/c,d
+  $ hg tracked --removeexclude a,b/c,d --addinclude a,b/e,f -q
+  $ hg tracked
+  I path:a,b
+  I path:a,b/e,f
+  $ hg files
+  a,b/c,d/abcd
+  a,b/e,f/abef
+  $ hg tracked --removeinclude a,b/e,f --addexclude a,b/c,d -q
+  $ hg tracked
+  I path:a,b
+  X path:a,b/c,d
+  $ hg files
+  a,b/e,f/abef
+  $ cd ..
diff --git a/tests/test-doctest.py b/tests/test-doctest.py
--- a/tests/test-doctest.py
+++ b/tests/test-doctest.py
@@ -137,6 +137,7 @@
 ('mercurial.revlogutils.deltas', '{}'),
 ('mercurial.revset', '{}'),
 ('mercurial.revsetlang', '{}'),
+('mercurial.wireprototypes', '{}'),
 ('mercurial.simplemerge', '{}'),
 ('mercurial.smartset', '{}'),
 ('mercurial.store', '{}'),
diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -29,6 +29,10 @@
  * `hg debugmergestate` output is now templated, which may be useful
e.g. for IDEs that want to help the user resolve merge conflicts.
 
+ * The experimental `narrow` extension will now be able to have include or
+   exclude patterns that have a comma in the name when both client and server
+   are updated.
+
 
 == New Experimental Features ==
 
diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py
--- a/mercurial/wireprotov1server.py
+++ b/mercurial/wireprotov1server.py
@@ -448,6 +448,8 @@
 opts[k] = list(v.split(b','))
 elif keytype == b'scsv':
 opts[k] = set(v.split(b','))
+elif keytype == b'qcsv':
+opts[k] = wireprototypes.decode_qcsv(v)
 elif keytype == b'boolean':
 # Client should serialize False as '0', which is a non-empty string
 # so it evaluates as a True bool.
diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py
--- a/mercurial/wireprotov1peer.py
+++ b/mercurial/wireprotov1peer.py
@@ -462,6 +462,8 @@
 value = b','.join(value)
 elif keytype == b'scsv':
 value = b','.join(sorted(value))
+elif keytype == b'qcsv':
+value = wireprototypes.encode_qcsv(value)
 elif keytype == b'boolean':
 value = b'%i' % bool(value)
 elif keytype != b'plain':
diff --git a/mercurial/wireprototypes.py b/mercurial/wireprototypes.py
--- a/mercurial/wireprototypes.py
+++ b/mercurial/wireprototypes.py
@@ -161,6 +161,7 @@
 # :nodes: list of binary nodes, transmitted as space-separated hex nodes
 # :csv:   list of values, transmitted as comma-separated values
 # :scsv:  set of values, transmitted as comma-separated values
+# :qcsv:  list of values, transmitted as quote-escaped comma-separated values
 # :plain: string with no transformation needed.
 GETBUNDLE_ARGUMENTS = {
 b'heads': b'nodes',
@@ -173,11 +174,195 @@
 b'cg': b'boolean',
 b'cbattempted': b'boolean',
 b'stream': b'boolean',

D8296: chistedit: support histedit.summary-template in curses histedit plan

2020-03-17 Thread spectral (Kyle Lippincott)
Closed by commit rHGad5a10f49dfa: chistedit: support histedit.summary-template 
in curses histedit plan (authored by spectral).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8296?vs=20811=20815

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

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

AFFECTED FILES
  hgext/histedit.py

CHANGE DETAILS

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1113,7 +1113,8 @@
 
 
 class histeditrule(object):
-def __init__(self, ctx, pos, action=b'pick'):
+def __init__(self, ui, ctx, pos, action=b'pick'):
+self.ui = ui
 self.ctx = ctx
 self.action = action
 self.origpos = pos
@@ -1153,6 +1154,14 @@
 
 @property
 def desc(self):
+summary = (
+cmdutil.rendertemplate(
+self.ctx, self.ui.config(b'histedit', b'summary-template')
+)
+or b''
+)
+if summary:
+return summary
 # This is split off from the prefix property so that we can
 # separately make the description for 'roll' red (since it
 # will get discarded).
@@ -1700,7 +1709,7 @@
 
 ctxs = []
 for i, r in enumerate(revs):
-ctxs.append(histeditrule(repo[r], i))
+ctxs.append(histeditrule(ui, repo[r], i))
 # Curses requires setting the locale or it will default to the C
 # locale. This sets the locale to the user's default system
 # locale.



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


D8297: vfs: fix typo in comment (remove extra "l")

2020-03-17 Thread spectral (Kyle Lippincott)
Closed by commit rHG77d48738b8e0: vfs: fix typo in comment (remove extra 
l) (authored by spectral).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8297?vs=20812=20814

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

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

AFFECTED FILES
  mercurial/vfs.py

CHANGE DETAILS

diff --git a/mercurial/vfs.py b/mercurial/vfs.py
--- a/mercurial/vfs.py
+++ b/mercurial/vfs.py
@@ -417,7 +417,7 @@
file were opened multiple times, there could be unflushed data
because the original file handle hasn't been flushed/closed yet.)
 
-``checkambig`` argument is passed to atomictemplfile (valid
+``checkambig`` argument is passed to atomictempfile (valid
 only for writing), and is useful only if target file is
 guarded by any lock (e.g. repo.lock or repo.wlock).
 



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


D8281: narrow: escape includepats/excludepats when sending over the wire

2020-03-17 Thread spectral (Kyle Lippincott)
spectral edited the summary of this revision.
spectral retitled this revision from "narrow: escape includepats/excludepats 
when sending over the wire (BC)" to "narrow: escape includepats/excludepats 
when sending over the wire".
spectral updated this revision to Diff 20813.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8281?vs=20789=20813

BRANCH
  default

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

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

AFFECTED FILES
  hgext/narrow/narrowbundle2.py
  hgext/narrow/narrowwirepeer.py
  mercurial/wireprototypes.py
  mercurial/wireprotov1peer.py
  mercurial/wireprotov1server.py
  relnotes/next
  tests/test-doctest.py
  tests/test-narrow-exchange.t

CHANGE DETAILS

diff --git a/tests/test-narrow-exchange.t b/tests/test-narrow-exchange.t
--- a/tests/test-narrow-exchange.t
+++ b/tests/test-narrow-exchange.t
@@ -223,3 +223,62 @@
   remote: rollback completed (lfs-on !)
   remote: abort: data/inside2/f.i@f59b4e021835: no match found! (lfs-on !)
   abort: stream ended unexpectedly (got 0 bytes, expected 4) (lfs-on !)
+
+Test paths with commas in them
+  $ cd $TESTTMP
+  $ hg init commas-master
+  $ cd commas-master
+  $ mkdir a,b
+  $ mkdir a,b/c,d
+  $ mkdir a,b/e,f
+  $ mkdir g
+  $ echo abcd > a,b/c,d/abcd
+  $ echo abef > a,b/e,f/abef
+  $ echo ghi > g/h,i
+  $ hg ci -qAm r0
+  $ echo abcd2 >> a,b/c,d/abcd
+  $ echo abef2 >> a,b/e,f/abef
+  $ echo ghi2 >> g/h,i
+  $ hg ci -qm r1
+  $ cd ..
+
+Test that we can pull and push with a file that has a comma in the name, even
+though the commas don't appear in the narrowspec file (since they're just
+filenames)
+  $ hg clone --narrow ssh://user@dummy/commas-master commas-in-file \
+  >   --include g -qr 0
+  $ cd commas-in-file
+  $ hg pull -q
+  $ echo ghi3 >> g/h,i
+  $ hg ci -qm 'modify g/h,i'
+  $ hg push -qf
+  $ cd ..
+
+Test commas in the --include, plus pull+push
+  $ hg clone --narrow ssh://user@dummy/commas-master commas-in-dir \
+  >   --include a,b --exclude a,b/c,d -qr 0
+  $ cd commas-in-dir
+  $ hg pull -q
+  $ echo abef3 >> a,b/e,f/abef
+  $ hg ci -qm 'modify a,b/e,f'
+  $ hg push -qf
+
+Test that --{add,remove}{include,exclude} work with commas in the directory
+names.
+  $ hg tracked
+  I path:a,b
+  X path:a,b/c,d
+  $ hg tracked --removeexclude a,b/c,d --addinclude a,b/e,f -q
+  $ hg tracked
+  I path:a,b
+  I path:a,b/e,f
+  $ hg files
+  a,b/c,d/abcd
+  a,b/e,f/abef
+  $ hg tracked --removeinclude a,b/e,f --addexclude a,b/c,d -q
+  $ hg tracked
+  I path:a,b
+  X path:a,b/c,d
+  $ hg files
+  a,b/e,f/abef
+  $ cd ..
diff --git a/tests/test-doctest.py b/tests/test-doctest.py
--- a/tests/test-doctest.py
+++ b/tests/test-doctest.py
@@ -137,6 +137,7 @@
 ('mercurial.revlogutils.deltas', '{}'),
 ('mercurial.revset', '{}'),
 ('mercurial.revsetlang', '{}'),
+('mercurial.wireprototypes', '{}'),
 ('mercurial.simplemerge', '{}'),
 ('mercurial.smartset', '{}'),
 ('mercurial.store', '{}'),
diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -29,6 +29,10 @@
  * `hg debugmergestate` output is now templated, which may be useful
e.g. for IDEs that want to help the user resolve merge conflicts.
 
+ * The experimental `narrow` extension will now be able to have include or
+   exclude patterns that have a comma in the name when both client and server
+   are updated.
+
 
 == New Experimental Features ==
 
diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py
--- a/mercurial/wireprotov1server.py
+++ b/mercurial/wireprotov1server.py
@@ -448,6 +448,8 @@
 opts[k] = list(v.split(b','))
 elif keytype == b'scsv':
 opts[k] = set(v.split(b','))
+elif keytype == b'encode_qcsv':
+opts[k] = wireprototypes.encode_qcsv(v)
 elif keytype == b'boolean':
 # Client should serialize False as '0', which is a non-empty string
 # so it evaluates as a True bool.
diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py
--- a/mercurial/wireprotov1peer.py
+++ b/mercurial/wireprotov1peer.py
@@ -462,6 +462,8 @@
 value = b','.join(value)
 elif keytype == b'scsv':
 value = b','.join(sorted(value))
+elif keytype == b'qcsv':
+value = wireprototypes.encode_qcsv(value)
 elif keytype == b'boolean':
 value = b'%i' % bool(value)
 elif keytype != b'plain':
diff --git a/mercurial/wireprototypes.py b/mercurial/wireprototypes.py
--- a/mercurial/wireprototypes.py
+++ b/mercurial/wireprototypes.py
@@ -161,6 +161,7 @@
 # :nodes: list of binary nodes, transmitted as space-separated hex nodes
 # :csv:   list of values, transmitted as comma-separated values
 # :scsv:  set of values, transmitted as comma-separated values
+# :qcsv:  list of values, transmitted as 

D8297: vfs: fix typo in comment (remove extra "l")

2020-03-17 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/vfs.py

CHANGE DETAILS

diff --git a/mercurial/vfs.py b/mercurial/vfs.py
--- a/mercurial/vfs.py
+++ b/mercurial/vfs.py
@@ -417,7 +417,7 @@
file were opened multiple times, there could be unflushed data
because the original file handle hasn't been flushed/closed yet.)
 
-``checkambig`` argument is passed to atomictemplfile (valid
+``checkambig`` argument is passed to atomictempfile (valid
 only for writing), and is useful only if target file is
 guarded by any lock (e.g. repo.lock or repo.wlock).
 



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


D8296: chistedit: support histedit.summary-template in curses histedit plan

2020-03-17 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/histedit.py

CHANGE DETAILS

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1113,7 +1113,8 @@
 
 
 class histeditrule(object):
-def __init__(self, ctx, pos, action=b'pick'):
+def __init__(self, ui, ctx, pos, action=b'pick'):
+self.ui = ui
 self.ctx = ctx
 self.action = action
 self.origpos = pos
@@ -1153,6 +1154,14 @@
 
 @property
 def desc(self):
+summary = (
+cmdutil.rendertemplate(
+self.ctx, self.ui.config(b'histedit', b'summary-template')
+)
+or b''
+)
+if summary:
+return summary
 # This is split off from the prefix property so that we can
 # separately make the description for 'roll' red (since it
 # will get discarded).
@@ -1700,7 +1709,7 @@
 
 ctxs = []
 for i, r in enumerate(revs):
-ctxs.append(histeditrule(repo[r], i))
+ctxs.append(histeditrule(ui, repo[r], i))
 # Curses requires setting the locale or it will default to the C
 # locale. This sets the locale to the user's default system
 # locale.



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


D8294: tests: make test-doctest.t automatically find files to run tests on

2020-03-16 Thread spectral (Kyle Lippincott)
Closed by commit rHG0af56d3ee24c: tests: make test-doctest.t automatically find 
files to run tests on (authored by spectral).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8294?vs=20788=20810

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

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

AFFECTED FILES
  tests/test-doctest.py

CHANGE DETAILS

diff --git a/tests/test-doctest.py b/tests/test-doctest.py
--- a/tests/test-doctest.py
+++ b/tests/test-doctest.py
@@ -1,10 +1,12 @@
 # this is hack to make sure no escape characters are inserted into the output
 
 from __future__ import absolute_import
+from __future__ import print_function
 
 import doctest
 import os
 import re
+import subprocess
 import sys
 
 ispy3 = sys.version_info[0] >= 3
@@ -49,46 +51,116 @@
 runner.summarize()
 
 
-testmod('mercurial.changelog')
-testmod('mercurial.cmdutil')
-testmod('mercurial.color')
-testmod('mercurial.config')
-testmod('mercurial.dagparser', optionflags=doctest.NORMALIZE_WHITESPACE)
-testmod('mercurial.encoding')
-testmod('mercurial.fancyopts')
-testmod('mercurial.formatter')
-testmod('mercurial.hg')
-testmod('mercurial.hgweb.hgwebdir_mod')
-testmod('mercurial.match')
-testmod('mercurial.mdiff')
-testmod('mercurial.minirst')
-testmod('mercurial.parser')
-testmod('mercurial.patch')
-testmod('mercurial.pathutil')
-testmod('mercurial.pycompat')
-testmod('mercurial.revlogutils.deltas')
-testmod('mercurial.revset')
-testmod('mercurial.revsetlang')
-testmod('mercurial.simplemerge')
-testmod('mercurial.smartset')
-testmod('mercurial.store')
-testmod('mercurial.subrepo')
-testmod('mercurial.templater')
-testmod('mercurial.ui')
-testmod('mercurial.util')
-testmod('mercurial.util', testtarget='platform')  # windows.py or posix.py
-testmod('mercurial.utils.dateutil')
-testmod('mercurial.utils.stringutil')
-testmod('hgext.convert.convcmd')
-testmod('hgext.convert.cvsps')
-testmod('hgext.convert.filemap')
-testmod('hgext.convert.p4')
-testmod('hgext.convert.subversion')
-testmod('hgext.fix')
-testmod('hgext.mq')
-# Helper scripts in tests/ that have doctests:
-testmod('drawdag')
-testmod('test-run-tests')
+DONT_RUN = []
+
+# Exceptions to the defaults for a given detected module. The value for each
+# module name is a list of dicts that specify the kwargs to pass to testmod.
+# testmod is called once per item in the list, so an empty list will cause the
+# module to not be tested.
+testmod_arg_overrides = {
+'i18n.check-translation': DONT_RUN,  # may require extra installation
+'mercurial.dagparser': [{'optionflags': doctest.NORMALIZE_WHITESPACE}],
+'mercurial.keepalive': DONT_RUN,  # >>> is an example, not a doctest
+'mercurial.posix': DONT_RUN,  # run by mercurial.platform
+'mercurial.statprof': DONT_RUN,  # >>> is an example, not a doctest
+'mercurial.util': [{}, {'testtarget': 'platform'}],  # run twice!
+'mercurial.windows': DONT_RUN,  # run by mercurial.platform
+'tests.test-url': [{'optionflags': doctest.NORMALIZE_WHITESPACE}],
+}
+
+doctest_indicator = '\n\\s*>>> '
+fileset = 'set:(**.py and grep("%s"))' % doctest_indicator
+
+files = subprocess.check_output(
+"hg files --print0 '%s'" % fileset,
+shell=True,
+cwd=os.path.dirname(os.environ['TESTDIR']),
+).split(b'\0')
+
+mods_tested = set()
+for f in files:
+if not f:
+continue
+
+if ispy3:
+f = f.decode()
+
+modname = f.replace('.py', '').replace('\\', '.').replace('/', '.')
+
+# Third-party modules aren't our responsibility to test, and the modules in
+# contrib generally do not have doctests in a good state, plus they're hard
+# to import if this test is running with py2, so we just skip both for now.
+if modname.startswith('mercurial.thirdparty.') or modname.startswith(
+'contrib.'
+):
+continue
+
+for kwargs in testmod_arg_overrides.get(modname, [{}]):
+mods_tested.add((modname, '%r' % (kwargs,)))
+if modname.startswith('tests.'):
+# On py2, we can't import from tests.foo, but it works on both py2
+# and py3 with the way that PYTHONPATH is setup to import without
+# the 'tests.' prefix, so we do that.
+modname = modname[len('tests.') :]
+
+testmod(modname, **kwargs)
 
-# Disabled since it requires extra modules that might not be installed.
-# testmod('i18n.check-translation')
+# Meta-test: let's make sure that we actually ran what we expected to, above.
+# Each item in the set is a 2-tuple of module name and stringified kwargs 
passed
+# to testmod.
+expected_mods_tested = set(
+[
+('hgext.convert.convcmd', '{}'),
+('hgext.convert.cvsps', '{}'),
+('hgext.convert.filemap', '{}'),
+('hgext.convert.p4', '{}'),
+

D8280: tests: make test-doctest.t module list match reality

2020-03-16 Thread spectral (Kyle Lippincott)
Closed by commit rHG529cb23155bc: tests: make test-doctest.t module list match 
reality (authored by spectral).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8280?vs=20766=20809

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

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

AFFECTED FILES
  tests/test-doctest.py

CHANGE DETAILS

diff --git a/tests/test-doctest.py b/tests/test-doctest.py
--- a/tests/test-doctest.py
+++ b/tests/test-doctest.py
@@ -49,14 +49,11 @@
 runner.summarize()
 
 
-testmod('mercurial.changegroup')
 testmod('mercurial.changelog')
 testmod('mercurial.cmdutil')
 testmod('mercurial.color')
 testmod('mercurial.config')
-testmod('mercurial.context')
 testmod('mercurial.dagparser', optionflags=doctest.NORMALIZE_WHITESPACE)
-testmod('mercurial.dispatch')
 testmod('mercurial.encoding')
 testmod('mercurial.fancyopts')
 testmod('mercurial.formatter')
@@ -65,23 +62,21 @@
 testmod('mercurial.match')
 testmod('mercurial.mdiff')
 testmod('mercurial.minirst')
+testmod('mercurial.parser')
 testmod('mercurial.patch')
 testmod('mercurial.pathutil')
-testmod('mercurial.parser')
 testmod('mercurial.pycompat')
-testmod('mercurial.revlog')
 testmod('mercurial.revlogutils.deltas')
 testmod('mercurial.revset')
 testmod('mercurial.revsetlang')
+testmod('mercurial.simplemerge')
 testmod('mercurial.smartset')
 testmod('mercurial.store')
 testmod('mercurial.subrepo')
-testmod('mercurial.templatefilters')
 testmod('mercurial.templater')
 testmod('mercurial.ui')
-testmod('mercurial.url')
 testmod('mercurial.util')
-testmod('mercurial.util', testtarget='platform')
+testmod('mercurial.util', testtarget='platform')  # windows.py or posix.py
 testmod('mercurial.utils.dateutil')
 testmod('mercurial.utils.stringutil')
 testmod('hgext.convert.convcmd')
@@ -93,3 +88,7 @@
 testmod('hgext.mq')
 # Helper scripts in tests/ that have doctests:
 testmod('drawdag')
+testmod('test-run-tests')
+
+# Disabled since it requires extra modules that might not be installed.
+# testmod('i18n.check-translation')



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


D8279: tests: remove doctest in narrowspec, it is broken

2020-03-16 Thread spectral (Kyle Lippincott)
Closed by commit rHG1922694d638f: tests: remove doctest in narrowspec, it is 
broken (authored by spectral).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8279?vs=20763=20808

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

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

AFFECTED FILES
  mercurial/narrowspec.py

CHANGE DETAILS

diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py
--- a/mercurial/narrowspec.py
+++ b/mercurial/narrowspec.py
@@ -233,21 +233,6 @@
 :param repo_includes: repo includes
 :param repo_excludes: repo excludes
 :return: include patterns, exclude patterns, and invalid include patterns.
-
->>> restrictpatterns({'f1','f2'}, {}, ['f1'], [])
-(set(['f1']), {}, [])
->>> restrictpatterns({'f1'}, {}, ['f1','f2'], [])
-(set(['f1']), {}, [])
->>> restrictpatterns({'f1/fc1', 'f3/fc3'}, {}, ['f1','f2'], [])
-(set(['f1/fc1']), {}, [])
->>> restrictpatterns({'f1_fc1'}, {}, ['f1','f2'], [])
-([], set(['path:.']), [])
->>> restrictpatterns({'f1/../f2/fc2'}, {}, ['f1','f2'], [])
-(set(['f2/fc2']), {}, [])
->>> restrictpatterns({'f1/../f3/fc3'}, {}, ['f1','f2'], [])
-([], set(['path:.']), [])
->>> restrictpatterns({'f1/$non_exitent_var'}, {}, ['f1','f2'], [])
-(set(['f1/$non_exitent_var']), {}, [])
 """
 res_excludes = set(req_excludes)
 res_excludes.update(repo_excludes)



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


D8280: tests: make test-doctest.t module list match reality

2020-03-13 Thread spectral (Kyle Lippincott)
spectral added a comment.
spectral marked an inline comment as done.


  In D8280#123642 , @marmoute 
wrote:
  
  > Should we try to move to some automatic detection of file with doctest? 
That would be more reliable.
  
  D8294 , though it got a bit complicated 
:)

REPOSITORY
  rHG Mercurial

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

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

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


D8281: narrow: escape includepats/excludepats when sending over the wire (BC)

2020-03-13 Thread spectral (Kyle Lippincott)
spectral updated this revision to Diff 20789.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8281?vs=20767=20789

BRANCH
  default

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

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

AFFECTED FILES
  hgext/narrow/narrowbundle2.py
  hgext/narrow/narrowwirepeer.py
  mercurial/wireprototypes.py
  mercurial/wireprotov1peer.py
  mercurial/wireprotov1server.py
  relnotes/next
  tests/test-narrow-exchange.t

CHANGE DETAILS

diff --git a/tests/test-narrow-exchange.t b/tests/test-narrow-exchange.t
--- a/tests/test-narrow-exchange.t
+++ b/tests/test-narrow-exchange.t
@@ -223,3 +223,62 @@
   remote: rollback completed (lfs-on !)
   remote: abort: data/inside2/f.i@f59b4e021835: no match found! (lfs-on !)
   abort: stream ended unexpectedly (got 0 bytes, expected 4) (lfs-on !)
+
+Test paths with commas in them
+  $ cd $TESTTMP
+  $ hg init commas-master
+  $ cd commas-master
+  $ mkdir a,b
+  $ mkdir a,b/c,d
+  $ mkdir a,b/e,f
+  $ mkdir g
+  $ echo abcd > a,b/c,d/abcd
+  $ echo abef > a,b/e,f/abef
+  $ echo ghi > g/h,i
+  $ hg ci -qAm r0
+  $ echo abcd2 >> a,b/c,d/abcd
+  $ echo abef2 >> a,b/e,f/abef
+  $ echo ghi2 >> g/h,i
+  $ hg ci -qm r1
+  $ cd ..
+
+Test that we can pull and push with a file that has a comma in the name, even
+though the commas don't appear in the narrowspec file (since they're just
+filenames)
+  $ hg clone --narrow ssh://user@dummy/commas-master commas-in-file \
+  >   --include g -qr 0
+  $ cd commas-in-file
+  $ hg pull -q
+  $ echo ghi3 >> g/h,i
+  $ hg ci -qm 'modify g/h,i'
+  $ hg push -qf
+  $ cd ..
+
+Test commas in the --include, plus pull+push
+  $ hg clone --narrow ssh://user@dummy/commas-master commas-in-dir \
+  >   --include a,b --exclude a,b/c,d -qr 0
+  $ cd commas-in-dir
+  $ hg pull -q
+  $ echo abef3 >> a,b/e,f/abef
+  $ hg ci -qm 'modify a,b/e,f'
+  $ hg push -qf
+
+Test that --{add,remove}{include,exclude} work with commas in the directory
+names.
+  $ hg tracked
+  I path:a,b
+  X path:a,b/c,d
+  $ hg tracked --removeexclude a,b/c,d --addinclude a,b/e,f -q
+  $ hg tracked
+  I path:a,b
+  I path:a,b/e,f
+  $ hg files
+  a,b/c,d/abcd
+  a,b/e,f/abef
+  $ hg tracked --removeinclude a,b/e,f --addexclude a,b/c,d -q
+  $ hg tracked
+  I path:a,b
+  X path:a,b/c,d
+  $ hg files
+  a,b/e,f/abef
+  $ cd ..
diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -23,6 +23,10 @@
Will use `zstd` compression for new repositories is available, and will
simply fall back to `zlib` if not.
 
+ * The experimental `narrow` extension will now be able to have include or
+   exclude patterns that have a comma in the name when both client and server
+   are updated.
+
 == New Experimental Features ==
 
  * `hg copy` now supports a `--at-rev` argument to mark files as
@@ -49,6 +53,15 @@
  * `hg recover` does not verify the validity of the whole repository
anymore. You can pass `--verify` or call `hg verify` if necessary.
 
+ * The experimental `narrow` extension wireproto serialization format is
+   changing slightly. Windows clients will transmit paths with `/` as the path
+   separator instead of `\`. Any `,` or `\` in the path for include or exclude
+   patterns will be escaped. Newer servers speaking with older clients may
+   accidentally unescape paths that weren't actually escaped by the client, but
+   this is extremely unlikely to happen in practice. Newer clients speaking 
with
+   older servers will escape any `\` character and this will not be interpreted
+   properly by the server, causing the path to not match.
+
 == Internal API Changes ==
 
  * The deprecated `ui.progress()` has now been deleted. Please use
diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py
--- a/mercurial/wireprotov1server.py
+++ b/mercurial/wireprotov1server.py
@@ -448,6 +448,8 @@
 opts[k] = list(v.split(b','))
 elif keytype == b'scsv':
 opts[k] = set(v.split(b','))
+elif keytype == b'csvpaths':
+opts[k] = wireprototypes.decodecsvpaths(v)
 elif keytype == b'boolean':
 # Client should serialize False as '0', which is a non-empty string
 # so it evaluates as a True bool.
diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py
--- a/mercurial/wireprotov1peer.py
+++ b/mercurial/wireprotov1peer.py
@@ -462,6 +462,8 @@
 value = b','.join(value)
 elif keytype == b'scsv':
 value = b','.join(sorted(value))
+elif keytype == b'csvpaths':
+value = wireprototypes.encodecsvpaths(value)
 elif keytype == b'boolean':
 value = b'%i' % bool(value)
 elif keytype != b'plain':
diff --git a/mercurial/wireprototypes.py b/mercurial/wireprototypes.py
--- a/mercurial/wireprototypes.py
+++ b/mercurial/wireprototypes.py
@@ -161,6 +161,8 @@
 # 

D8294: tests: make test-doctest.t automatically find files to run tests on

2020-03-13 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-doctest.py

CHANGE DETAILS

diff --git a/tests/test-doctest.py b/tests/test-doctest.py
--- a/tests/test-doctest.py
+++ b/tests/test-doctest.py
@@ -1,10 +1,12 @@
 # this is hack to make sure no escape characters are inserted into the output
 
 from __future__ import absolute_import
+from __future__ import print_function
 
 import doctest
 import os
 import re
+import subprocess
 import sys
 
 ispy3 = sys.version_info[0] >= 3
@@ -49,46 +51,116 @@
 runner.summarize()
 
 
-testmod('mercurial.changelog')
-testmod('mercurial.cmdutil')
-testmod('mercurial.color')
-testmod('mercurial.config')
-testmod('mercurial.dagparser', optionflags=doctest.NORMALIZE_WHITESPACE)
-testmod('mercurial.encoding')
-testmod('mercurial.fancyopts')
-testmod('mercurial.formatter')
-testmod('mercurial.hg')
-testmod('mercurial.hgweb.hgwebdir_mod')
-testmod('mercurial.match')
-testmod('mercurial.mdiff')
-testmod('mercurial.minirst')
-testmod('mercurial.parser')
-testmod('mercurial.patch')
-testmod('mercurial.pathutil')
-testmod('mercurial.pycompat')
-testmod('mercurial.revlogutils.deltas')
-testmod('mercurial.revset')
-testmod('mercurial.revsetlang')
-testmod('mercurial.simplemerge')
-testmod('mercurial.smartset')
-testmod('mercurial.store')
-testmod('mercurial.subrepo')
-testmod('mercurial.templater')
-testmod('mercurial.ui')
-testmod('mercurial.util')
-testmod('mercurial.util', testtarget='platform')  # windows.py or posix.py
-testmod('mercurial.utils.dateutil')
-testmod('mercurial.utils.stringutil')
-testmod('hgext.convert.convcmd')
-testmod('hgext.convert.cvsps')
-testmod('hgext.convert.filemap')
-testmod('hgext.convert.p4')
-testmod('hgext.convert.subversion')
-testmod('hgext.fix')
-testmod('hgext.mq')
-# Helper scripts in tests/ that have doctests:
-testmod('drawdag')
-testmod('test-run-tests')
+DONT_RUN = []
+
+# Exceptions to the defaults for a given detected module. The value for each
+# module name is a list of dicts that specify the kwargs to pass to testmod.
+# testmod is called once per item in the list, so an empty list will cause the
+# module to not be tested.
+testmod_arg_overrides = {
+'i18n.check-translation': DONT_RUN,  # may require extra installation
+'mercurial.dagparser': [{'optionflags': doctest.NORMALIZE_WHITESPACE}],
+'mercurial.keepalive': DONT_RUN,  # >>> is an example, not a doctest
+'mercurial.posix': DONT_RUN,  # run by mercurial.platform
+'mercurial.statprof': DONT_RUN,  # >>> is an example, not a doctest
+'mercurial.util': [{}, {'testtarget': 'platform'}],  # run twice!
+'mercurial.windows': DONT_RUN,  # run by mercurial.platform
+'tests.test-url': [{'optionflags': doctest.NORMALIZE_WHITESPACE}],
+}
+
+doctest_indicator = '\n\\s*>>> '
+fileset = 'set:(**.py and grep("%s"))' % doctest_indicator
+
+files = subprocess.check_output(
+"hg files --print0 '%s'" % fileset,
+shell=True,
+cwd=os.path.dirname(os.environ['TESTDIR']),
+).split(b'\0')
+
+mods_tested = set()
+for f in files:
+if not f:
+continue
+
+if ispy3:
+f = f.decode()
+
+modname = f.replace('.py', '').replace('\\', '.').replace('/', '.')
+
+# Third-party modules aren't our responsibility to test, and the modules in
+# contrib generally do not have doctests in a good state, plus they're hard
+# to import if this test is running with py2, so we just skip both for now.
+if modname.startswith('mercurial.thirdparty.') or modname.startswith(
+'contrib.'
+):
+continue
+
+for kwargs in testmod_arg_overrides.get(modname, [{}]):
+mods_tested.add((modname, '%r' % (kwargs,)))
+if modname.startswith('tests.'):
+# On py2, we can't import from tests.foo, but it works on both py2
+# and py3 with the way that PYTHONPATH is setup to import without
+# the 'tests.' prefix, so we do that.
+modname = modname[len('tests.') :]
+
+testmod(modname, **kwargs)
 
-# Disabled since it requires extra modules that might not be installed.
-# testmod('i18n.check-translation')
+# Meta-test: let's make sure that we actually ran what we expected to, above.
+# Each item in the set is a 2-tuple of module name and stringified kwargs 
passed
+# to testmod.
+expected_mods_tested = set(
+[
+('hgext.convert.convcmd', '{}'),
+('hgext.convert.cvsps', '{}'),
+('hgext.convert.filemap', '{}'),
+('hgext.convert.p4', '{}'),
+('hgext.convert.subversion', '{}'),
+('hgext.fix', '{}'),
+('hgext.mq', '{}'),
+('mercurial.changelog', '{}'),
+('mercurial.cmdutil', '{}'),
+('mercurial.color', '{}'),
+('mercurial.config', '{}'),
+('mercurial.dagparser', "{'optionflags': 4}"),
+   

D8281: narrow: escape includepats/excludepats when sending over the wire (BC)

2020-03-12 Thread spectral (Kyle Lippincott)
spectral added a comment.


  In D8281#123621 , @mharbison72 
wrote:
  
  > The Windows path changes seem like a good idea.
  > Would quoting paths with commas eliminate the need for custom escaping?  I 
don't feel strongly about it, but custom escaping always feels weird to me.  (I 
fact, a coworker did some homebrew escaping for CSV files a few days ago, but I 
forget how it ultimately ended up.)
  
  Let me play with that a bit, I think it'll work and be detectable on the 
server since the first character can't currently be a double-quote, so there 
wouldn't really be any BC issues aside from the pconvert (which wouldn't be as 
important anymore, but still probably a good idea?)

REPOSITORY
  rHG Mercurial

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

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

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


D8281: narrow: escape includepats/excludepats when sending over the wire (BC)

2020-03-12 Thread spectral (Kyle Lippincott)
spectral updated this revision to Diff 20767.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8281?vs=20765=20767

BRANCH
  default

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

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

AFFECTED FILES
  hgext/narrow/narrowbundle2.py
  hgext/narrow/narrowwirepeer.py
  mercurial/wireprototypes.py
  mercurial/wireprotov1peer.py
  mercurial/wireprotov1server.py
  relnotes/next
  tests/test-doctest.py
  tests/test-narrow-exchange.t

CHANGE DETAILS

diff --git a/tests/test-narrow-exchange.t b/tests/test-narrow-exchange.t
--- a/tests/test-narrow-exchange.t
+++ b/tests/test-narrow-exchange.t
@@ -223,3 +223,62 @@
   remote: rollback completed (lfs-on !)
   remote: abort: data/inside2/f.i@f59b4e021835: no match found! (lfs-on !)
   abort: stream ended unexpectedly (got 0 bytes, expected 4) (lfs-on !)
+
+Test paths with commas in them
+  $ cd $TESTTMP
+  $ hg init commas-master
+  $ cd commas-master
+  $ mkdir a,b
+  $ mkdir a,b/c,d
+  $ mkdir a,b/e,f
+  $ mkdir g
+  $ echo abcd > a,b/c,d/abcd
+  $ echo abef > a,b/e,f/abef
+  $ echo ghi > g/h,i
+  $ hg ci -qAm r0
+  $ echo abcd2 >> a,b/c,d/abcd
+  $ echo abef2 >> a,b/e,f/abef
+  $ echo ghi2 >> g/h,i
+  $ hg ci -qm r1
+  $ cd ..
+
+Test that we can pull and push with a file that has a comma in the name, even
+though the commas don't appear in the narrowspec file (since they're just
+filenames)
+  $ hg clone --narrow ssh://user@dummy/commas-master commas-in-file \
+  >   --include g -qr 0
+  $ cd commas-in-file
+  $ hg pull -q
+  $ echo ghi3 >> g/h,i
+  $ hg ci -qm 'modify g/h,i'
+  $ hg push -qf
+  $ cd ..
+
+Test commas in the --include, plus pull+push
+  $ hg clone --narrow ssh://user@dummy/commas-master commas-in-dir \
+  >   --include a,b --exclude a,b/c,d -qr 0
+  $ cd commas-in-dir
+  $ hg pull -q
+  $ echo abef3 >> a,b/e,f/abef
+  $ hg ci -qm 'modify a,b/e,f'
+  $ hg push -qf
+
+Test that --{add,remove}{include,exclude} work with commas in the directory
+names.
+  $ hg tracked
+  I path:a,b
+  X path:a,b/c,d
+  $ hg tracked --removeexclude a,b/c,d --addinclude a,b/e,f -q
+  $ hg tracked
+  I path:a,b
+  I path:a,b/e,f
+  $ hg files
+  a,b/c,d/abcd
+  a,b/e,f/abef
+  $ hg tracked --removeinclude a,b/e,f --addexclude a,b/c,d -q
+  $ hg tracked
+  I path:a,b
+  X path:a,b/c,d
+  $ hg files
+  a,b/e,f/abef
+  $ cd ..
diff --git a/tests/test-doctest.py b/tests/test-doctest.py
--- a/tests/test-doctest.py
+++ b/tests/test-doctest.py
@@ -79,6 +79,7 @@
 testmod('mercurial.util', testtarget='platform')  # windows.py or posix.py
 testmod('mercurial.utils.dateutil')
 testmod('mercurial.utils.stringutil')
+testmod('mercurial.wireprototypes')
 testmod('hgext.convert.convcmd')
 testmod('hgext.convert.cvsps')
 testmod('hgext.convert.filemap')
diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -23,6 +23,10 @@
Will use `zstd` compression for new repositories is available, and will
simply fall back to `zlib` if not.
 
+ * The experimental `narrow` extension will now be able to have include or
+   exclude patterns that have a comma in the name when both client and server
+   are updated.
+
 == New Experimental Features ==
 
  * `hg copy` now supports a `--at-rev` argument to mark files as
@@ -49,6 +53,15 @@
  * `hg recover` does not verify the validity of the whole repository
anymore. You can pass `--verify` or call `hg verify` if necessary.
 
+ * The experimental `narrow` extension wireproto serialization format is
+   changing slightly. Windows clients will transmit paths with `/` as the path
+   separator instead of `\`. Any `,` or `\` in the path for include or exclude
+   patterns will be escaped. Newer servers speaking with older clients may
+   accidentally unescape paths that weren't actually escaped by the client, but
+   this is extremely unlikely to happen in practice. Newer clients speaking 
with
+   older servers will escape any `\` character and this will not be interpreted
+   properly by the server, causing the path to not match.
+
 == Internal API Changes ==
 
  * The deprecated `ui.progress()` has now been deleted. Please use
diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py
--- a/mercurial/wireprotov1server.py
+++ b/mercurial/wireprotov1server.py
@@ -448,6 +448,8 @@
 opts[k] = list(v.split(b','))
 elif keytype == b'scsv':
 opts[k] = set(v.split(b','))
+elif keytype == b'csvpaths':
+opts[k] = wireprototypes.decodecsvpaths(v)
 elif keytype == b'boolean':
 # Client should serialize False as '0', which is a non-empty string
 # so it evaluates as a True bool.
diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py
--- a/mercurial/wireprotov1peer.py
+++ b/mercurial/wireprotov1peer.py
@@ -462,6 +462,8 @@
 value = b','.join(value)
 elif keytype == b'scsv':
 

D8280: tests: make test-doctest.t module list match reality

2020-03-12 Thread spectral (Kyle Lippincott)
spectral updated this revision to Diff 20766.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8280?vs=20764=20766

BRANCH
  default

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

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

AFFECTED FILES
  tests/test-doctest.py

CHANGE DETAILS

diff --git a/tests/test-doctest.py b/tests/test-doctest.py
--- a/tests/test-doctest.py
+++ b/tests/test-doctest.py
@@ -49,14 +49,11 @@
 runner.summarize()
 
 
-testmod('mercurial.changegroup')
 testmod('mercurial.changelog')
 testmod('mercurial.cmdutil')
 testmod('mercurial.color')
 testmod('mercurial.config')
-testmod('mercurial.context')
 testmod('mercurial.dagparser', optionflags=doctest.NORMALIZE_WHITESPACE)
-testmod('mercurial.dispatch')
 testmod('mercurial.encoding')
 testmod('mercurial.fancyopts')
 testmod('mercurial.formatter')
@@ -65,23 +62,21 @@
 testmod('mercurial.match')
 testmod('mercurial.mdiff')
 testmod('mercurial.minirst')
+testmod('mercurial.parser')
 testmod('mercurial.patch')
 testmod('mercurial.pathutil')
-testmod('mercurial.parser')
 testmod('mercurial.pycompat')
-testmod('mercurial.revlog')
 testmod('mercurial.revlogutils.deltas')
 testmod('mercurial.revset')
 testmod('mercurial.revsetlang')
+testmod('mercurial.simplemerge')
 testmod('mercurial.smartset')
 testmod('mercurial.store')
 testmod('mercurial.subrepo')
-testmod('mercurial.templatefilters')
 testmod('mercurial.templater')
 testmod('mercurial.ui')
-testmod('mercurial.url')
 testmod('mercurial.util')
-testmod('mercurial.util', testtarget='platform')
+testmod('mercurial.util', testtarget='platform')  # windows.py or posix.py
 testmod('mercurial.utils.dateutil')
 testmod('mercurial.utils.stringutil')
 testmod('hgext.convert.convcmd')
@@ -93,3 +88,7 @@
 testmod('hgext.mq')
 # Helper scripts in tests/ that have doctests:
 testmod('drawdag')
+testmod('test-run-tests')
+
+# Disabled since it requires extra modules that might not be installed.
+# testmod('i18n.check-translation')



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


D8281: narrow: escape includepats/excludepats when sending over the wire (BC)

2020-03-12 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: martinvonz.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  When transmitting data over the wire, first run util.pconvert on each item 
(this is
  just good practice in general to have the wire protocol have posix style 
paths).
  Then, escape any existing backslash with \SlAsH, and any existing comma with
  \CoMmA.  Finally, join everything together with commas like before.
  
  This has a minor breaking change in some scenarios:
  
  Old server, old client:
  
  - paths with commas in them will cause errors if added to the narrowspec
  
  Old server, new client:
  
  - commas in paths will be interpreted by the server as `\CoMmA`, and not match
  - backslashes in paths will be interpreted by the server as `\SlAsH`, and not 
match.  Due to the pconvert, windows clients shouldn't have any `\` characters 
in their paths, and it's still probably very rare for non-windows clients to 
have paths with a \ in the name.
  
  New server, old client:
  
  - paths with commas in them will cause errors if added to the narrowspec
  - any path that (pre-escaping) contains the substring `\SlAsH` or `\CoMmA` 
will have these converted to `\` and `,` respectively, and likely not match. 
This is a case-sensitive comparison, so it's extremely unlikely to be a problem 
in practice.
  
  New server, new client:
  
  - everything should work

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/narrow/narrowbundle2.py
  hgext/narrow/narrowwirepeer.py
  mercurial/wireprototypes.py
  mercurial/wireprotov1peer.py
  mercurial/wireprotov1server.py
  relnotes/next
  tests/test-doctest.py
  tests/test-narrow-exchange.t

CHANGE DETAILS

diff --git a/tests/test-narrow-exchange.t b/tests/test-narrow-exchange.t
--- a/tests/test-narrow-exchange.t
+++ b/tests/test-narrow-exchange.t
@@ -223,3 +223,62 @@
   remote: rollback completed (lfs-on !)
   remote: abort: data/inside2/f.i@f59b4e021835: no match found! (lfs-on !)
   abort: stream ended unexpectedly (got 0 bytes, expected 4) (lfs-on !)
+
+Test paths with commas in them
+  $ cd $TESTTMP
+  $ hg init commas-master
+  $ cd commas-master
+  $ mkdir a,b
+  $ mkdir a,b/c,d
+  $ mkdir a,b/e,f
+  $ mkdir g
+  $ echo abcd > a,b/c,d/abcd
+  $ echo abef > a,b/e,f/abef
+  $ echo ghi > g/h,i
+  $ hg ci -qAm r0
+  $ echo abcd2 >> a,b/c,d/abcd
+  $ echo abef2 >> a,b/e,f/abef
+  $ echo ghi2 >> g/h,i
+  $ hg ci -qm r1
+  $ cd ..
+
+Test that we can pull and push with a file that has a comma in the name, even
+though the commas don't appear in the narrowspec file (since they're just
+filenames)
+  $ hg clone --narrow ssh://user@dummy/commas-master commas-in-file \
+  >   --include g -qr 0
+  $ cd commas-in-file
+  $ hg pull -q
+  $ echo ghi3 >> g/h,i
+  $ hg ci -qm 'modify g/h,i'
+  $ hg push -qf
+  $ cd ..
+
+Test commas in the --include, plus pull+push
+  $ hg clone --narrow ssh://user@dummy/commas-master commas-in-dir \
+  >   --include a,b --exclude a,b/c,d -qr 0
+  $ cd commas-in-dir
+  $ hg pull -q
+  $ echo abef3 >> a,b/e,f/abef
+  $ hg ci -qm 'modify a,b/e,f'
+  $ hg push -qf
+
+Test that --{add,remove}{include,exclude} work with commas in the directory
+names.
+  $ hg tracked
+  I path:a,b
+  X path:a,b/c,d
+  $ hg tracked --removeexclude a,b/c,d --addinclude a,b/e,f -q
+  $ hg tracked
+  I path:a,b
+  I path:a,b/e,f
+  $ hg files
+  a,b/c,d/abcd
+  a,b/e,f/abef
+  $ hg tracked --removeinclude a,b/e,f --addexclude a,b/c,d -q
+  $ hg tracked
+  I path:a,b
+  X path:a,b/c,d
+  $ hg files
+  a,b/e,f/abef
+  $ cd ..
diff --git a/tests/test-doctest.py b/tests/test-doctest.py
--- a/tests/test-doctest.py
+++ b/tests/test-doctest.py
@@ -83,6 +83,7 @@
 testmod('mercurial.utils.stringutil')
 if os.name == 'nt':
 testmod('mercurial.windows')
+testmod('mercurial.wireprototypes')
 testmod('hgext.convert.convcmd')
 testmod('hgext.convert.cvsps')
 testmod('hgext.convert.filemap')
diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -23,6 +23,10 @@
Will use `zstd` compression for new repositories is available, and will
simply fall back to `zlib` if not.
 
+ * The experimental `narrow` extension will now be able to have include or
+   exclude patterns that have a comma in the name when both client and server
+   are updated.
+
 == New Experimental Features ==
 
  * `hg copy` now supports a `--at-rev` argument to mark files as
@@ -49,6 +53,15 @@
  * `hg recover` does not verify the validity of the whole repository
anymore. You can pass `--verify` or call `hg verify` if necessary.
 
+ * The experimental `narrow` extension wireproto serialization format is
+   changing slightly. Windows clients will transmit paths with `/` as the path
+   separator instead of `\`. Any `,` or `\` in the path for include or exclude
+   patterns will be escaped. Newer 

D8280: tests: make test-doctest.t module list match reality

2020-03-12 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-doctest.py

CHANGE DETAILS

diff --git a/tests/test-doctest.py b/tests/test-doctest.py
--- a/tests/test-doctest.py
+++ b/tests/test-doctest.py
@@ -49,12 +49,10 @@
 runner.summarize()
 
 
-testmod('mercurial.changegroup')
 testmod('mercurial.changelog')
 testmod('mercurial.cmdutil')
 testmod('mercurial.color')
 testmod('mercurial.config')
-testmod('mercurial.context')
 testmod('mercurial.dagparser', optionflags=doctest.NORMALIZE_WHITESPACE)
 testmod('mercurial.dispatch')
 testmod('mercurial.encoding')
@@ -65,25 +63,26 @@
 testmod('mercurial.match')
 testmod('mercurial.mdiff')
 testmod('mercurial.minirst')
+testmod('mercurial.parser')
 testmod('mercurial.patch')
 testmod('mercurial.pathutil')
-testmod('mercurial.parser')
+testmod('mercurial.posix')
 testmod('mercurial.pycompat')
-testmod('mercurial.revlog')
 testmod('mercurial.revlogutils.deltas')
 testmod('mercurial.revset')
 testmod('mercurial.revsetlang')
+testmod('mercurial.simplemerge')
 testmod('mercurial.smartset')
 testmod('mercurial.store')
 testmod('mercurial.subrepo')
-testmod('mercurial.templatefilters')
 testmod('mercurial.templater')
 testmod('mercurial.ui')
-testmod('mercurial.url')
 testmod('mercurial.util')
 testmod('mercurial.util', testtarget='platform')
 testmod('mercurial.utils.dateutil')
 testmod('mercurial.utils.stringutil')
+if os.name == 'nt':
+testmod('mercurial.windows')
 testmod('hgext.convert.convcmd')
 testmod('hgext.convert.cvsps')
 testmod('hgext.convert.filemap')



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


D8279: tests: remove doctest in narrowspec, it is broken

2020-03-12 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I think every item here is considered incorrect (if we fix doctest to run it),
  so let's just delete it.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/narrowspec.py

CHANGE DETAILS

diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py
--- a/mercurial/narrowspec.py
+++ b/mercurial/narrowspec.py
@@ -233,21 +233,6 @@
 :param repo_includes: repo includes
 :param repo_excludes: repo excludes
 :return: include patterns, exclude patterns, and invalid include patterns.
-
->>> restrictpatterns({'f1','f2'}, {}, ['f1'], [])
-(set(['f1']), {}, [])
->>> restrictpatterns({'f1'}, {}, ['f1','f2'], [])
-(set(['f1']), {}, [])
->>> restrictpatterns({'f1/fc1', 'f3/fc3'}, {}, ['f1','f2'], [])
-(set(['f1/fc1']), {}, [])
->>> restrictpatterns({'f1_fc1'}, {}, ['f1','f2'], [])
-([], set(['path:.']), [])
->>> restrictpatterns({'f1/../f2/fc2'}, {}, ['f1','f2'], [])
-(set(['f2/fc2']), {}, [])
->>> restrictpatterns({'f1/../f3/fc3'}, {}, ['f1','f2'], [])
-([], set(['path:.']), [])
->>> restrictpatterns({'f1/$non_exitent_var'}, {}, ['f1','f2'], [])
-(set(['f1/$non_exitent_var']), {}, [])
 """
 res_excludes = set(req_excludes)
 res_excludes.update(repo_excludes)



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


D8140: shelve: fix ordering of merge labels

2020-02-22 Thread spectral (Kyle Lippincott)
Closed by commit rHG69b091cdc506: shelve: fix ordering of merge labels 
(authored by spectral).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8140?vs=20273=20275

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

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

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

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -253,11 +253,11 @@
   M f
   ? f.orig
   $ cat f
-  <<< shelve:   d44eae5c3d33 - shelve: pending changes temporary commit
+  <<< working-copy: d44eae5c3d33 - shelve: pending changes temporary commit
   g
   ===
   f
-  >>> working-copy: aef214a5229c - shelve: changes to: commit stuff
+  >>> shelve:   aef214a5229c - shelve: changes to: commit stuff
   $ cat f.orig
   g
   $ hg unshelve --abort -t false
@@ -295,11 +295,11 @@
   M f
   ? f.orig
   $ cat f
-  <<< shelve:   6b563750f973 - test: intermediate other change
+  <<< working-copy: 6b563750f973 - test: intermediate other change
   g
   ===
   f
-  >>> working-copy: aef214a5229c - shelve: changes to: commit stuff
+  >>> shelve:   aef214a5229c - shelve: changes to: commit stuff
   $ cat f.orig
   g
 
@@ -937,9 +937,9 @@
   [1]
   $ cat foo
   r0
-  <<< shelve:   0b2fcf2a90e9 - shelve: pending changes temporary commit
+  <<< working-copy: 0b2fcf2a90e9 - shelve: pending changes temporary commit
   this is in wdir, conflicts with shelve
   ===
   this will be shelved
-  >>> working-copy: 9c072a2163db - shelve: changes to: r0
+  >>> shelve:   9c072a2163db - shelve: changes to: r0
   $ cd ..
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -408,11 +408,11 @@
   +++ b/a/a
   @@ -1,2 +1,6 @@
a
-  +<<< shelve:   2377350b6337 - shelve: pending changes temporary 
commit
+  +<<< working-copy: 2377350b6337 - shelve: pending changes temporary 
commit
c
   +===
   +a
-  +>>> working-copy: a68ec3400638 - shelve: changes to: [mq]: second.patch
+  +>>> shelve:   a68ec3400638 - shelve: changes to: [mq]: second.patch
   diff --git a/b/b b/b.rename/b
   rename from b/b
   rename to b.rename/b
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -997,7 +997,7 @@
 repo,
 shelvectx,
 shelvectx.p1(),
-labels=[b'shelve', b'working-copy'],
+labels=[b'working-copy', b'shelve'],
 keepconflictparent=True,
 )
 if stats.unresolvedcount:



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


D8139: shelve: add test clearly demonstrating that the conflict labels are backwards

2020-02-22 Thread spectral (Kyle Lippincott)
Closed by commit rHG2527c10a2569: shelve: add test clearly demonstrating that 
the conflict labels are backwards (authored by spectral).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8139?vs=20263=20274

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

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

AFFECTED FILES
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -921,3 +921,25 @@
   @  initial commit  test  1970-01-01 00:00 +
   
   $ cd ..
+
+Demonstrate that the labels are correct in the merge conflict
+-
+  $ hg init labels
+  $ cd labels
+  $ echo r0 > foo
+  $ hg ci -qAm r0
+  $ echo "this will be shelved" >> foo
+  $ hg shelve -q
+  $ echo "this is in wdir, conflicts with shelve" >> foo
+  $ hg unshelve -q
+  warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
+  [1]
+  $ cat foo
+  r0
+  <<< shelve:   0b2fcf2a90e9 - shelve: pending changes temporary commit
+  this is in wdir, conflicts with shelve
+  ===
+  this will be shelved
+  >>> working-copy: 9c072a2163db - shelve: changes to: r0
+  $ cd ..



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


D8140: shelve: fix ordering of merge labels

2020-02-21 Thread spectral (Kyle Lippincott)
spectral updated this revision to Diff 20273.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8140?vs=20264=20273

BRANCH
  stable

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

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

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

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -253,11 +253,11 @@
   M f
   ? f.orig
   $ cat f
-  <<< shelve:   d44eae5c3d33 - shelve: pending changes temporary commit
+  <<< working-copy: d44eae5c3d33 - shelve: pending changes temporary commit
   g
   ===
   f
-  >>> working-copy: aef214a5229c - shelve: changes to: commit stuff
+  >>> shelve:   aef214a5229c - shelve: changes to: commit stuff
   $ cat f.orig
   g
   $ hg unshelve --abort -t false
@@ -295,11 +295,11 @@
   M f
   ? f.orig
   $ cat f
-  <<< shelve:   6b563750f973 - test: intermediate other change
+  <<< working-copy: 6b563750f973 - test: intermediate other change
   g
   ===
   f
-  >>> working-copy: aef214a5229c - shelve: changes to: commit stuff
+  >>> shelve:   aef214a5229c - shelve: changes to: commit stuff
   $ cat f.orig
   g
 
@@ -937,9 +937,9 @@
   [1]
   $ cat foo
   r0
-  <<< shelve:   0b2fcf2a90e9 - shelve: pending changes temporary commit
+  <<< working-copy: 0b2fcf2a90e9 - shelve: pending changes temporary commit
   this is in wdir, conflicts with shelve
   ===
   this will be shelved
-  >>> working-copy: 9c072a2163db - shelve: changes to: r0
+  >>> shelve:   9c072a2163db - shelve: changes to: r0
   $ cd ..
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -408,11 +408,11 @@
   +++ b/a/a
   @@ -1,2 +1,6 @@
a
-  +<<< shelve:   2377350b6337 - shelve: pending changes temporary 
commit
+  +<<< working-copy: 2377350b6337 - shelve: pending changes temporary 
commit
c
   +===
   +a
-  +>>> working-copy: a68ec3400638 - shelve: changes to: [mq]: second.patch
+  +>>> shelve:   a68ec3400638 - shelve: changes to: [mq]: second.patch
   diff --git a/b/b b/b.rename/b
   rename from b/b
   rename to b.rename/b
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -997,7 +997,7 @@
 repo,
 shelvectx,
 shelvectx.p1(),
-labels=[b'shelve', b'working-copy'],
+labels=[b'working-copy', b'shelve'],
 keepconflictparent=True,
 )
 if stats.unresolvedcount:



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


D8141: darwin: add another preemptive gui() call when using chg

2020-02-21 Thread spectral (Kyle Lippincott)
Closed by commit rHG6392bd7c26a8: darwin: add another preemptive gui() call 
when using chg (authored by spectral).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8141?vs=20265=20268

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

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

AFFECTED FILES
  mercurial/commandserver.py

CHANGE DETAILS

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -545,6 +545,10 @@
 if maxlen < 0:
 raise error.Abort(_(b'negative max-repo-cache size not allowed'))
 self._repoloader = repocache.repoloader(ui, maxlen)
+# attempt to avoid crash in CoreFoundation when using chg after fix in
+# a89381e04c58
+if pycompat.isdarwin:
+procutil.gui()
 
 def init(self):
 self._sock = socket.socket(socket.AF_UNIX)



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


D8141: darwin: add another preemptive gui() call when using chg

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

REVISION SUMMARY
  Changeset a89381e04c58 
 
added this gui() call before background forks, and
  Google's extensions do background forks on essentially every invocation for
  logging purposes. The crash is reliably (though not 100%) reproducible without
  this change when running `HGPLAIN=1 chg status` in one of our repos. With this
  fix, I haven't been able to trigger the crash anymore.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/commandserver.py

CHANGE DETAILS

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -545,6 +545,10 @@
 if maxlen < 0:
 raise error.Abort(_(b'negative max-repo-cache size not allowed'))
 self._repoloader = repocache.repoloader(ui, maxlen)
+# attempt to avoid crash in CoreFoundation when using chg after fix in
+# a89381e04c58
+if pycompat.isdarwin:
+procutil.gui()
 
 def init(self):
 self._sock = socket.socket(socket.AF_UNIX)



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


D8140: shelve: fix ordering of merge labels

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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -253,11 +253,11 @@
   M f
   ? f.orig
   $ cat f
-  <<< shelve:   d44eae5c3d33 - shelve: pending changes temporary commit
+  <<< working-copy: d44eae5c3d33 - shelve: pending changes temporary commit
   g
   ===
   f
-  >>> working-copy: aef214a5229c - shelve: changes to: commit stuff
+  >>> shelve:   aef214a5229c - shelve: changes to: commit stuff
   $ cat f.orig
   g
   $ hg unshelve --abort -t false
@@ -295,11 +295,11 @@
   M f
   ? f.orig
   $ cat f
-  <<< shelve:   6b563750f973 - test: intermediate other change
+  <<< working-copy: 6b563750f973 - test: intermediate other change
   g
   ===
   f
-  >>> working-copy: aef214a5229c - shelve: changes to: commit stuff
+  >>> shelve:   aef214a5229c - shelve: changes to: commit stuff
   $ cat f.orig
   g
 
@@ -937,9 +937,9 @@
   [1]
   $ cat foo
   r0
-  <<< shelve:   0b2fcf2a90e9 - shelve: pending changes temporary commit
+  <<< working-copy: 0b2fcf2a90e9 - shelve: pending changes temporary commit
   this is in wdir, conflicts with shelve
   ===
   this will be shelved
-  >>> working-copy: 9c072a2163db - shelve: changes to: r0
+  >>> shelve:   9c072a2163db - shelve: changes to: r0
   $ cd ..
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -419,11 +419,11 @@
   +++ b/a/a
   @@ -1,2 +1,6 @@
a
-  +<<< shelve:   2377350b6337 - shelve: pending changes temporary 
commit
+  +<<< working-copy: 2377350b6337 - shelve: pending changes temporary 
commit
c
   +===
   +a
-  +>>> working-copy: 203c9f771d2b - shelve: changes to: [mq]: second.patch
+  +>>> shelve:   203c9f771d2b - shelve: changes to: [mq]: second.patch
   diff --git a/b/b b/b.rename/b
   rename from b/b
   rename to b.rename/b
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -996,7 +996,7 @@
 stats = merge.graft(
 repo,
 shelvectx,
-labels=[b'shelve', b'working-copy'],
+labels=[b'working-copy', b'shelve'],
 keepconflictparent=True,
 )
 if stats.unresolvedcount:



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


D8139: shelve: add test clearly demonstrating that the conflict labels are backwards

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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -921,3 +921,25 @@
   @  initial commit  test  1970-01-01 00:00 +
   
   $ cd ..
+
+Demonstrate that the labels are correct in the merge conflict
+-
+  $ hg init labels
+  $ cd labels
+  $ echo r0 > foo
+  $ hg ci -qAm r0
+  $ echo "this will be shelved" >> foo
+  $ hg shelve -q
+  $ echo "this is in wdir, conflicts with shelve" >> foo
+  $ hg unshelve -q
+  warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
+  [1]
+  $ cat foo
+  r0
+  <<< shelve:   0b2fcf2a90e9 - shelve: pending changes temporary commit
+  this is in wdir, conflicts with shelve
+  ===
+  this will be shelved
+  >>> working-copy: 9c072a2163db - shelve: changes to: r0
+  $ cd ..



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


D8023: chg: read CHGORIG_ values from env and handle these appropriately

2020-02-10 Thread spectral (Kyle Lippincott)
spectral added a comment.
spectral abandoned this revision.


  We decided to use a different method to resolve this issue.

REPOSITORY
  rHG Mercurial

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

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

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


D8091: py3: fully fix bundlepart.__repr__ to return str not bytes

2020-02-07 Thread spectral (Kyle Lippincott)
Closed by commit rHG74172a234dd3: py3: fully fix bundlepart.__repr__ to return 
str not bytes (authored by spectral).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8091?vs=19978=19994

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

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

AFFECTED FILES
  mercurial/bundle2.py

CHANGE DETAILS

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1013,10 +1013,9 @@
 self._generated = None
 self.mandatory = mandatory
 
-@encoding.strmethod
 def __repr__(self):
-cls = b"%s.%s" % (self.__class__.__module__, self.__class__.__name__)
-return b'<%s object at %x; id: %s; type: %s; mandatory: %s>' % (
+cls = "%s.%s" % (self.__class__.__module__, self.__class__.__name__)
+return '<%s object at %x; id: %s; type: %s; mandatory: %s>' % (
 cls,
 id(self),
 self.id,



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


D8089: py3: __repr__ needs to return str, not bytes

2020-02-06 Thread spectral (Kyle Lippincott)
spectral added inline comments.

INLINE COMMENTS

> mharbison72 wrote in bundle2.py:1018
> Aren't `self.__class__.__module__` and `self.__class__.__name__` str?

Yep, so this instance fails for other reasons as well. Sigh.  I've sent a 
followup (D8091 ). This may cause output 
like .

I didn't actually test most of these, obviously :P  I just did a grep for 
__repr__ returning bytes...

REPOSITORY
  rHG Mercurial

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

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

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


D8091: py3: fully fix bundlepart.__repr__ to return str not bytes

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

REVISION SUMMARY
  My previous fix did not fully fix the issue: it would attempt to use
  %-formatting to combine two strs into a bytes, which won't work. Let's just
  switch the entire function to operating in strs. This can cause a small output
  difference that will likely not be noticed since no one noticed that the 
method
  wasn't working at all before: if `id` or `type` are not-None, they'll be shown
  as `b'val'` instead of `val`. Since this is a debugging aid and these strings
  shouldn't be shown to the user, slightly rough output is most likely fine and
  it's likely not worthwhile to add the necessary conditionals to marginally
  improve it.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/bundle2.py

CHANGE DETAILS

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1013,10 +1013,9 @@
 self._generated = None
 self.mandatory = mandatory
 
-@encoding.strmethod
 def __repr__(self):
-cls = b"%s.%s" % (self.__class__.__module__, self.__class__.__name__)
-return b'<%s object at %x; id: %s; type: %s; mandatory: %s>' % (
+cls = "%s.%s" % (self.__class__.__module__, self.__class__.__name__)
+return '<%s object at %x; id: %s; type: %s; mandatory: %s>' % (
 cls,
 id(self),
 self.id,



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


  1   2   3   4   5   6   7   >