D9832: simplemerge: delete unused find_unconflicted()

2021-01-18 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The function has been unused ever since it was introduced in
  465b9ea02868 
 
(Import 3-way merge code from bzr, 2007-04-16).

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/simplemerge.py
  tests/test-simplemerge.py

CHANGE DETAILS

diff --git a/tests/test-simplemerge.py b/tests/test-simplemerge.py
--- a/tests/test-simplemerge.py
+++ b/tests/test-simplemerge.py
@@ -141,8 +141,6 @@
 """No conflicts because nothing changed"""
 m3 = Merge3([b'aaa', b'bbb'], [b'aaa', b'bbb'], [b'aaa', b'bbb'])
 
-self.assertEqual(m3.find_unconflicted(), [(0, 2)])
-
 self.assertEqual(
 list(m3.find_sync_regions()),
 [(0, 2, 0, 2, 0, 2), (2, 2, 2, 2, 2, 2)],
@@ -189,8 +187,6 @@
 [b'aaa', b'bbb'], [b'aaa', b'111', b'bbb'], [b'aaa', b'bbb']
 )
 
-self.assertEqual(m3.find_unconflicted(), [(0, 1), (1, 2)])
-
 self.assertEqual(
 list(m3.find_sync_regions()),
 [(0, 1, 0, 1, 0, 1), (1, 2, 2, 3, 1, 2), (2, 2, 3, 3, 2, 2)],
@@ -271,8 +267,6 @@
 [b'aaa\n', b'222\n', b'bbb\n'],
 )
 
-self.assertEqual(m3.find_unconflicted(), [(0, 1), (1, 2)])
-
 self.assertEqual(
 list(m3.find_sync_regions()),
 [(0, 1, 0, 1, 0, 1), (1, 2, 2, 3, 2, 3), (2, 2, 3, 3, 3, 3)],
@@ -323,8 +317,6 @@
 [b'aaa', b'222', b'bbb'],
 )
 
-self.assertEqual(m3.find_unconflicted(), [(0, 1), (2, 3)])
-
 self.assertEqual(
 list(m3.find_sync_regions()),
 [(0, 1, 0, 1, 0, 1), (2, 3, 2, 3, 2, 3), (3, 3, 3, 3, 3, 3)],
@@ -338,8 +330,6 @@
 [b'aaa', b'222', b'222', b'222', b'222', b'bbb'],
 )
 
-self.assertEqual(m3.find_unconflicted(), [(0, 1), (3, 4)])
-
 self.assertEqual(
 list(m3.find_sync_regions()),
 [(0, 1, 0, 1, 0, 1), (3, 4, 4, 5, 5, 6), (4, 4, 5, 5, 6, 6)],
diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -402,31 +402,6 @@
 
 return sl
 
-def find_unconflicted(self):
-"""Return a list of ranges in base that are not conflicted."""
-am = mdiff.get_matching_blocks(self.basetext, self.atext)
-bm = mdiff.get_matching_blocks(self.basetext, self.btext)
-
-unc = []
-
-while am and bm:
-# there is an unconflicted block at i; how long does it
-# extend?  until whichever one ends earlier.
-a1 = am[0][0]
-a2 = a1 + am[0][2]
-b1 = bm[0][0]
-b2 = b1 + bm[0][2]
-i = intersect((a1, a2), (b1, b2))
-if i:
-unc.append(i)
-
-if a2 < b2:
-del am[0]
-else:
-del bm[0]
-
-return unc
-
 
 def _verifytext(text, path, ui, opts):
 """verifies that text is non-binary (unless opts[text] is passed,



To: martinvonz, #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


mercurial@46239: 16 new changesets

2021-01-18 Thread Mercurial Commits
16 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/fcc324a228fe
changeset:   46224:fcc324a228fe
user:Jun Wu 
date:Tue Jan 12 14:45:32 2021 -0800
summary: revlog: use size_t for nodetree capacity

https://www.mercurial-scm.org/repo/hg/rev/88dfe1c279bb
changeset:   46225:88dfe1c279bb
user:Martin von Zweigbergk 
date:Tue Jan 12 17:32:08 2021 -0800
summary: tests: make test-subrepo-git.t compatible with git's master->main 
rename

https://www.mercurial-scm.org/repo/hg/rev/0826d684a1b5
changeset:   46226:0826d684a1b5
user:Pierre-Yves David 
date:Tue Jan 12 22:43:55 2021 +0100
summary: test: replace a many occurence of `python` with `$PYTHON`

https://www.mercurial-scm.org/repo/hg/rev/5bae4bc9bd42
changeset:   46227:5bae4bc9bd42
user:Dan Villiom Podlaski Christiansen 
date:Wed Dec 30 00:14:28 2020 +0100
summary: rust: fix file folding map

https://www.mercurial-scm.org/repo/hg/rev/e73b40c790ec
changeset:   46228:e73b40c790ec
user:Simon Sapin 
date:Tue Jan 12 18:36:22 2021 +0100
summary: rhg: use a release-mode executable in tests

https://www.mercurial-scm.org/repo/hg/rev/52abb1af2995
changeset:   46229:52abb1af2995
user:Pulkit Goyal <7895pul...@gmail.com>
date:Thu Dec 31 14:28:00 2020 +0530
summary: engine: prevent a function call for each store file

https://www.mercurial-scm.org/repo/hg/rev/1fcab88ab85c
changeset:   46230:1fcab88ab85c
user:Pulkit Goyal <7895pul...@gmail.com>
date:Fri Jan 08 23:06:38 2021 +0530
summary: downgrade: if a compression is removed, consider that too

https://www.mercurial-scm.org/repo/hg/rev/d3113c4cf52c
changeset:   46231:d3113c4cf52c
user:Pulkit Goyal <7895pul...@gmail.com>
date:Fri Jan 08 23:08:39 2021 +0530
summary: upgrade: don't perform anything if nothing to do

https://www.mercurial-scm.org/repo/hg/rev/eb01d6d00a50
changeset:   46232:eb01d6d00a50
user:Pulkit Goyal <7895pul...@gmail.com>
date:Wed Jan 13 15:42:15 2021 +0530
summary: largefiles: remove unused imports

https://www.mercurial-scm.org/repo/hg/rev/172b294b6d65
changeset:   46233:172b294b6d65
user:Dan Villiom Podlaski Christiansen 
date:Mon Jan 11 13:48:13 2021 +0100
summary: setup: don't import distutils prior to checking FORCE_SETUPTOOLS

https://www.mercurial-scm.org/repo/hg/rev/9804162a4053
changeset:   46234:9804162a4053
user:Pulkit Goyal <7895pul...@gmail.com>
date:Wed Jan 06 16:01:19 2021 +0530
summary: localrepo: move storevfs calculation out of if statement

https://www.mercurial-scm.org/repo/hg/rev/0babe12ef35d
changeset:   46235:0babe12ef35d
user:Pulkit Goyal <7895pul...@gmail.com>
date:Wed Jan 06 16:18:06 2021 +0530
summary: sharesafe: introduce functionality to automatically upgrade shares

https://www.mercurial-scm.org/repo/hg/rev/eec47efe219d
changeset:   46236:eec47efe219d
user:Pulkit Goyal <7895pul...@gmail.com>
date:Wed Jan 06 18:31:16 2021 +0530
summary: sharesafe: add functionality to automatically downgrade shares

https://www.mercurial-scm.org/repo/hg/rev/bc884e31b8c8
changeset:   46237:bc884e31b8c8
user:Pulkit Goyal <7895pul...@gmail.com>
date:Fri Jan 08 18:07:33 2021 +0530
summary: debuglock: rename flag names to better clarity

https://www.mercurial-scm.org/repo/hg/rev/9796cf108e4e
changeset:   46238:9796cf108e4e
user:Pulkit Goyal <7895pul...@gmail.com>
date:Fri Jan 08 21:34:16 2021 +0530
summary: sharesafe: make warning about outdated share configurable

https://www.mercurial-scm.org/repo/hg/rev/d159d0fafa78
changeset:   46239:d159d0fafa78
bookmark:@
tag: tip
user:Pulkit Goyal <7895pul...@gmail.com>
date:Fri Jan 08 21:47:31 2021 +0530
summary: sharesafe: introduce config to disallow outdated shares if upgrade 
fails

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


D9831: exchangev2: avoid second look-up by node

2021-01-18 Thread joerg.sonnenberger (Joerg Sonnenberger)
joerg.sonnenberger created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Accessing the revlog by node is slightly more expensive than by
  revision, so look up the revision first and use it afterwards.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/exchangev2.py

CHANGE DETAILS

diff --git a/mercurial/exchangev2.py b/mercurial/exchangev2.py
--- a/mercurial/exchangev2.py
+++ b/mercurial/exchangev2.py
@@ -364,12 +364,13 @@
 def onchangeset(cl, node):
 progress.increment()
 
-revision = cl.changelogrevision(node)
+rev = cl.rev(node)
+revision = cl.changelogrevision(rev)
 added.append(node)
 
 # We need to preserve the mapping of changelog revision to node
 # so we can set the linkrev accordingly when manifests are added.
-manifestnodes[cl.rev(node)] = revision.manifest
+manifestnodes[rev] = revision.manifest
 
 nodesbyphase = {phase: set() for phase in phases.phasenames.values()}
 remotebookmarks = {}



To: joerg.sonnenberger, #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


D9830: commit: look-up new revision once

2021-01-18 Thread joerg.sonnenberger (Joerg Sonnenberger)
joerg.sonnenberger created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Look-up by node is slightly more expensive, so since it is necessary
  more than once, do it explicitly.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/commit.py

CHANGE DETAILS

diff --git a/mercurial/commit.py b/mercurial/commit.py
--- a/mercurial/commit.py
+++ b/mercurial/commit.py
@@ -96,6 +96,7 @@
 ctx.date(),
 extra,
 )
+rev = repo[n].rev()
 xp1, xp2 = p1.hex(), p2 and p2.hex() or b''
 repo.hook(
 b'pretxncommit',
@@ -108,7 +109,7 @@
 targetphase = subrepoutil.newcommitphase(repo.ui, ctx)
 
 # prevent unmarking changesets as public on recommit
-waspublic = oldtip == repo.changelog.tiprev() and not repo[n].phase()
+waspublic = oldtip == repo.changelog.tiprev() and not repo[rev].phase()
 
 if targetphase and not waspublic:
 # retract boundary do not alter parent changeset.
@@ -116,7 +117,7 @@
 # be compliant anyway
 #
 # if minimal phase was 0 we don't need to retract anything
-phases.registernew(repo, tr, targetphase, [repo[n].rev()])
+phases.registernew(repo, tr, targetphase, [rev])
 return n
 
 



To: joerg.sonnenberger, #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


D9829: clang-format: reorder includes to appease the formatter

2021-01-18 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The back order was introduced in d0225a22040c 
.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cext/revlog.c

CHANGE DETAILS

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -16,9 +16,9 @@
 #include 
 #include 
 
-#include "compat.h"
 #include "bitmanipulation.h"
 #include "charencode.h"
+#include "compat.h"
 #include "revlog.h"
 #include "util.h"
 



To: marmoute, #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


D9826: callback: add a new_cl_rev_callback

2021-01-18 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This will be useful for consistency and cache warming.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/changelog.py
  mercurial/localrepo.py
  mercurial/transaction.py

CHANGE DETAILS

diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -134,6 +134,7 @@
 releasefn=None,
 checkambigfiles=None,
 name='',
+new_cl_rev_callback=None,
 ):
 """Begin a new transaction
 
@@ -168,6 +169,11 @@
 releasefn = lambda tr, success: None
 self._releasefn = releasefn
 
+# A callback to do thing for any new changelog revision
+if new_cl_rev_callback is None:
+new_cl_rev_callback = lambda rev: None
+self.new_cl_rev_callback = new_cl_rev_callback
+
 self._checkambigfiles = set()
 if checkambigfiles:
 self._checkambigfiles.update(checkambigfiles)
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2380,6 +2380,7 @@
 releasefn=releasefn,
 checkambigfiles=_cachedfiles,
 name=desc,
+new_cl_rev_callback=self.new_cl_rev_callback,
 )
 tr.changes[b'origrepolen'] = len(self)
 tr.changes[b'obsmarkers'] = set()
@@ -2633,6 +2634,9 @@
 
 return updater
 
+def new_cl_rev_callback(self, rev):
+"""called when new revision are added to the repository"""
+
 @unfilteredmethod
 def updatecaches(self, tr=None, full=False):
 """warm appropriate caches
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -610,3 +610,12 @@
 # We track them in a list to preserve their order from the source 
bundle
 duplicates = transaction.changes.setdefault(b'revduplicates', [])
 duplicates.append(self.rev(node))
+
+def _addrevision(self, rawtext, transaction, *args, **kwargs):
+next_tip = len(self)
+node = super(changelog, self)._addrevision(
+rawtext, transaction, *args, **kwargs
+)
+if next_tip < len(self):
+transaction.new_cl_rev_callback(next_tip)
+return node



To: marmoute, #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


D9828: changelog: use revision number as the cache key internally

2021-01-18 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This allow both rev and node request to match the cache.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/changelog.py

CHANGE DETAILS

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -523,9 +523,14 @@
 
 def changelogrevision(self, nodeorrev):
 """Obtain a ``changelogrevision`` for a node or revision."""
-if nodeorrev == self._changelogrevision_key:
+if not isinstance(nodeorrev, int):
+rev = self.rev(nodeorrev)
+else:
+rev = nodeorrev
+
+if rev == self._changelogrevision_key:
 return self._changelogrevision_cache
-text, sidedata = self._revisiondata(nodeorrev)
+text, sidedata = self._revisiondata(rev)
 cr = changelogrevision(
 text, sidedata, self._copiesstorage == b'changeset-sidedata'
 )



To: marmoute, #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


D9827: changelog: cache the latest `changelogrevision` access

2021-01-18 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This will speedup repeated call to the same data. Which can be common when
  warming various cache after adding a revision.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/changelog.py

CHANGE DETAILS

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -418,6 +418,8 @@
 self._filteredrevs = frozenset()
 self._filteredrevs_hashcache = {}
 self._copiesstorage = opener.options.get(b'copies-storage')
+self._changelogrevision_cache = None
+self._changelogrevision_key = None
 
 @property
 def filteredrevs(self):
@@ -521,10 +523,14 @@
 
 def changelogrevision(self, nodeorrev):
 """Obtain a ``changelogrevision`` for a node or revision."""
+if nodeorrev == self._changelogrevision_key:
+return self._changelogrevision_cache
 text, sidedata = self._revisiondata(nodeorrev)
-return changelogrevision(
+cr = changelogrevision(
 text, sidedata, self._copiesstorage == b'changeset-sidedata'
 )
+self._changelogrevision_cache = cr
+self._changelogrevision_key = nodeorrev
 
 def readfiles(self, node):
 """



To: marmoute, #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


D9825: cext: add Python 3.10 support

2021-01-18 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  - Replace "Py_TYPE(obj) = type;" with "Py_SET_TYPE(obj, type);"
  - Add pythoncapi_compat.h header file to get Py_SET_TYPE() on Python 2.7-3.8. 
Header file added to mercurial/ and contrib/python-zstandard/zstd/common/.
  
  In Python 3.10, Py_TYPE(obj) must not longer be used as an l-value.
  
  pythoncapi_compat.h comes from:
  https://github.com/pythoncapi/pythoncapi_compat

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/clang-format-ignorelist
  contrib/python-zstandard/c-ext/bufferutil.c
  contrib/python-zstandard/c-ext/compressionchunker.c
  contrib/python-zstandard/c-ext/compressiondict.c
  contrib/python-zstandard/c-ext/compressionparams.c
  contrib/python-zstandard/c-ext/compressionreader.c
  contrib/python-zstandard/c-ext/compressionwriter.c
  contrib/python-zstandard/c-ext/compressobj.c
  contrib/python-zstandard/c-ext/compressor.c
  contrib/python-zstandard/c-ext/compressoriterator.c
  contrib/python-zstandard/c-ext/decompressionreader.c
  contrib/python-zstandard/c-ext/decompressionwriter.c
  contrib/python-zstandard/c-ext/decompressobj.c
  contrib/python-zstandard/c-ext/decompressor.c
  contrib/python-zstandard/c-ext/decompressoriterator.c
  contrib/python-zstandard/c-ext/frameparams.c
  contrib/python-zstandard/c-ext/python-zstandard.h
  contrib/python-zstandard/zstd/common/pythoncapi_compat.h
  mercurial/cext/osutil.c
  mercurial/cext/pathencode.c
  mercurial/pythoncapi_compat.h
  tests/test-check-code.t

CHANGE DETAILS

diff --git a/tests/test-check-code.t b/tests/test-check-code.t
--- a/tests/test-check-code.t
+++ b/tests/test-check-code.t
@@ -11,6 +11,7 @@
   > -X contrib/python-zstandard \
   > -X hgext/fsmonitor/pywatchman \
   > -X mercurial/thirdparty \
+  > -X mercurial/pythoncapi_compat.h \
   > | sed 's-\\-/-g' | "$check_code" --warnings --per-file=0 - || false
   Skipping contrib/automation/hgautomation/__init__.py it has no-che?k-code 
(glob)
   Skipping contrib/automation/hgautomation/aws.py it has no-che?k-code (glob)
diff --git a/mercurial/pythoncapi_compat.h b/mercurial/pythoncapi_compat.h
new file mode 100644
--- /dev/null
+++ b/mercurial/pythoncapi_compat.h
@@ -0,0 +1,278 @@
+// Header file providing new functions of the Python C API to old Python
+// versions.
+//
+// File distributed under the MIT license.
+//
+// Homepage:
+// https://github.com/pythoncapi/pythoncapi_compat
+//
+// Latest version:
+// 
https://raw.githubusercontent.com/pythoncapi/pythoncapi_compat/master/pythoncapi_compat.h
+
+#ifndef PYTHONCAPI_COMPAT
+#define PYTHONCAPI_COMPAT
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+#include "frameobject.h"  // PyFrameObject, PyFrame_GetBack()
+
+
+// Cast argument to PyObject* type.
+#ifndef _PyObject_CAST
+#  define _PyObject_CAST(op) ((PyObject*)(op))
+#endif
+
+
+// bpo-42262 added Py_NewRef() to Python 3.10.0a3
+#if PY_VERSION_HEX < 0x030a00A3 && !defined(Py_NewRef)
+static inline PyObject* _Py_NewRef(PyObject *obj)
+{
+Py_INCREF(obj);
+return obj;
+}
+#define Py_NewRef(obj) _Py_NewRef(_PyObject_CAST(obj))
+#endif
+
+
+// bpo-42262 added Py_XNewRef() to Python 3.10.0a3
+#if PY_VERSION_HEX < 0x030a00A3 && !defined(Py_XNewRef)
+static inline PyObject* _Py_XNewRef(PyObject *obj)
+{
+Py_XINCREF(obj);
+return obj;
+}
+#define Py_XNewRef(obj) _Py_XNewRef(_PyObject_CAST(obj))
+#endif
+
+
+// bpo-39573 added Py_SET_REFCNT() to Python 3.9.0a4
+#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_REFCNT)
+static inline void _Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt)
+{
+ob->ob_refcnt = refcnt;
+}
+#define Py_SET_REFCNT(ob, refcnt) _Py_SET_REFCNT((PyObject*)(ob), refcnt)
+#endif
+
+
+// bpo-39573 added Py_SET_TYPE() to Python 3.9.0a4
+#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_TYPE)
+static inline void
+_Py_SET_TYPE(PyObject *ob, PyTypeObject *type)
+{
+ob->ob_type = type;
+}
+#define Py_SET_TYPE(ob, type) _Py_SET_TYPE((PyObject*)(ob), type)
+#endif
+
+
+// bpo-39573 added Py_SET_SIZE() to Python 3.9.0a4
+#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_SIZE)
+static inline void
+_Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size)
+{
+ob->ob_size = size;
+}
+#define Py_SET_SIZE(ob, size) _Py_SET_SIZE((PyVarObject*)(ob), size)
+#endif
+
+
+// bpo-40421 added PyFrame_GetCode() to Python 3.9.0b1
+#if PY_VERSION_HEX < 0x030900B1
+static inline PyCodeObject*
+PyFrame_GetCode(PyFrameObject *frame)
+{
+PyCodeObject *code;
+assert(frame != NULL);
+code = frame->f_code;
+assert(code != NULL);
+Py_INCREF(code);
+return code;
+}
+#endif
+
+static inline PyCodeObject*
+_PyFrame_GetCodeBorrow(PyFrameObject *frame)
+{
+PyCodeObject *code = PyFrame_GetCode(frame);
+Py_DECREF(code);
+return code;  // borrowed reference
+}
+
+
+// bpo-40421 added PyFrame_GetCode() to Python 

D9824: share: make different options for upgrade and downgrade share-safe

2021-01-18 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This makes things more configurable.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/helptext/config.txt
  mercurial/localrepo.py
  mercurial/upgrade.py
  tests/test-share-safe.t

CHANGE DETAILS

diff --git a/tests/test-share-safe.t b/tests/test-share-safe.t
--- a/tests/test-share-safe.t
+++ b/tests/test-share-safe.t
@@ -486,12 +486,12 @@
 Testing automatic downgrade of shares when config is set
 
   $ touch ../ss-share/.hg/wlock
-  $ hg log -GT "{node}: {desc}\n" -R ../ss-share --config 
share.source-safe-mismatch=upgrade-abort
+  $ hg log -GT "{node}: {desc}\n" -R ../ss-share --config 
share.safe-mismatch.source-not-safe=downgrade-abort
   abort: failed to downgrade share, got error: Lock held
   [255]
   $ rm ../ss-share/.hg/wlock
 
-  $ hg log -GT "{node}: {desc}\n" -R ../ss-share --config 
share.source-safe-mismatch=upgrade-abort
+  $ hg log -GT "{node}: {desc}\n" -R ../ss-share --config 
share.safe-mismatch.source-not-safe=downgrade-abort
   repository downgraded to not use share-safe mode
   @  f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
   |
@@ -533,31 +533,31 @@
   [255]
 
 Check that if lock is taken, upgrade fails but read operation are successful
-  $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config 
share.source-safe-mismatch=upgra
+  $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config 
share.safe-mismatch.source-safe=upgra
   abort: share-safe mismatch with source.
-  Unrecognized value 'upgra' of `share.source-safe-mismatch` set.
-  (run `hg help config.share.source-safe-mismatch`)
+  Unrecognized value 'upgra' of `share.safe-mismatch.source-safe` set.
+  (run `hg help config.share.safe-mismatch.source-safe`)
   [255]
   $ touch ../nss-share/.hg/wlock
-  $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config 
share.source-safe-mismatch=upgrade-allow
+  $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config 
share.safe-mismatch.source-safe=upgrade-allow
   failed to upgrade share, got error: Lock held
   @  f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
   |
   o  f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
   
 
-  $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config 
share.source-safe-mismatch=upgrade-allow --config 
share.source-safe-mismatch.warn=False
+  $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config 
share.safe-mismatch.source-safe=upgrade-allow --config 
share.source-safe-mismatch.warn=False
   @  f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
   |
   o  f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
   
 
-  $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config 
share.source-safe-mismatch=upgrade-abort
+  $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config 
share.safe-mismatch.source-safe=upgrade-abort
   abort: failed to upgrade share, got error: Lock held
   [255]
 
   $ rm ../nss-share/.hg/wlock
-  $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config 
share.source-safe-mismatch=upgrade-abort
+  $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config 
share.safe-mismatch.source-safe=upgrade-abort
   repository upgraded to use share-safe mode
   @  f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
   |
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -340,7 +340,7 @@
 except error.LockError as e:
 # If upgrade-abort is set, abort when upgrade fails, else let the
 # process continue as `upgrade-allow` is set
-if mismatch_config == b'upgrade-abort':
+if mismatch_config == b'downgrade-abort':
 raise error.Abort(
 _(b'failed to downgrade share, got error: %s')
 % stringutil.forcebytestr(e.strerror)
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -568,7 +568,6 @@
 # repository was shared the old way. We check the share source .hg/requires
 # for SHARESAFE_REQUIREMENT to detect whether the current repository needs
 # to be reshared
-mismatch_config = ui.config(b'share', b'source-safe-mismatch')
 mismatch_warn = ui.configbool(b'share', b'source-safe-mismatch.warn')
 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
 
@@ -577,10 +576,13 @@
 and requirementsmod.SHARESAFE_REQUIREMENT
 not in _readrequires(sharedvfs, True)
 ):
+mismatch_config = ui.config(
+b'share', b'safe-mismatch.source-not-safe'
+)
 if mismatch_config in (
-b'upgrade-allow',
+b'downgrade-allow',
 b'allow',
-b'upgrade-abort',
+b'downgrade-abort',
 ):
 # prevent cyclic import 

D9823: share: move share safe functionality out of experimental

2021-01-18 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
pulkit updated this revision to Diff 25119.

REVISION SUMMARY
  The share-safe functionality is complete and all configuration options are
  implemented. The behavior is well discussed on mailing list and in reviews.
  
  Let's unmark this as experimental to solve a chichen and egg issue.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/helptext/config.txt
  mercurial/helptext/internals/requirements.txt
  mercurial/localrepo.py
  mercurial/requirements.py
  mercurial/upgrade_utils/actions.py
  tests/test-copies-chain-merge.t
  tests/test-copies-in-changeset.t
  tests/test-help.t
  tests/test-persistent-nodemap.t
  tests/test-share-bookmarks.t
  tests/test-share-safe.t
  tests/test-share.t
  tests/test-sidedata.t
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -56,7 +56,7 @@
   fncache:yes
   dotencode:  yes
   generaldelta:   yes
-  exp-sharesafe:   no
+  share-safe:  no
   sparserevlog:   yes
   sidedata:no
   persistent-nodemap:  no
@@ -69,7 +69,7 @@
   fncache:yesyes yes
   dotencode:  yesyes yes
   generaldelta:   yesyes yes
-  exp-sharesafe:   no no  no
+  share-safe:  no no  no
   sparserevlog:   yesyes yes
   sidedata:no no  no
   persistent-nodemap:  no no  no
@@ -82,7 +82,7 @@
   fncache:yes no yes
   dotencode:  yes no yes
   generaldelta:   yesyes yes
-  exp-sharesafe:   no no  no
+  share-safe:  no no  no
   sparserevlog:   yesyes yes
   sidedata:no no  no
   persistent-nodemap:  no no  no
@@ -95,7 +95,7 @@
   [formatvariant.name.mismatchconfig|fncache:   
][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special| 
no][formatvariant.default| yes]
   [formatvariant.name.mismatchconfig|dotencode: 
][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special| 
no][formatvariant.default| yes]
   [formatvariant.name.uptodate|generaldelta:  
][formatvariant.repo.uptodate| yes][formatvariant.config.default|
yes][formatvariant.default| yes]
-  [formatvariant.name.uptodate|exp-sharesafe: 
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
+  [formatvariant.name.uptodate|share-safe:
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
   [formatvariant.name.uptodate|sparserevlog:  
][formatvariant.repo.uptodate| yes][formatvariant.config.default|
yes][formatvariant.default| yes]
   [formatvariant.name.uptodate|sidedata:  
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
   
[formatvariant.name.uptodate|persistent-nodemap:][formatvariant.repo.uptodate|  
no][formatvariant.config.default| no][formatvariant.default|  no]
@@ -126,7 +126,7 @@
{
 "config": false,
 "default": false,
-"name": "exp-sharesafe",
+"name": "share-safe",
 "repo": false
},
{
@@ -301,7 +301,7 @@
   fncache: no
   dotencode:   no
   generaldelta:no
-  exp-sharesafe:   no
+  share-safe:  no
   sparserevlog:no
   sidedata:no
   persistent-nodemap:  no
@@ -314,7 +314,7 @@
   fncache: noyes yes
   dotencode:   noyes yes
   generaldelta:noyes yes
-  exp-sharesafe:   no no  no
+  share-safe:  no no  no
   sparserevlog:noyes yes
   sidedata:no no  no
   persistent-nodemap:  no no  no
@@ -327,7 +327,7 @@
   fncache: noyes yes
   dotencode:   noyes yes
   generaldelta:no no yes
-  exp-sharesafe:   no no  no
+  share-safe:  no no  no
   sparserevlog:no no yes
   sidedata:no no  no
   persistent-nodemap:  no no  no
@@ -340,7 +340,7 @@
   [formatvariant.name.mismatchconfig|fncache:   
][formatvariant.repo.mismatchconfig|  no][formatvariant.config.default|
yes][formatvariant.default| yes]
   [formatvariant.name.mismatchconfig|dotencode: 
][formatvariant.repo.mismatchconfig|  no][formatvariant.config.default|
yes][formatvariant.default| yes]
   [formatvariant.name.mismatchdefault|generaldelta:  
][formatvariant.repo.mismatchdefault|  no][formatvariant.config.special| 

D9822: upgrade: re-read current requirements after taking lock

2021-01-18 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Since we are writing to repository, it's better to re-read after taking the
  lock.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/upgrade.py

CHANGE DETAILS

diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -254,6 +254,19 @@
 current_requirements.add(requirementsmod.SHARESAFE_REQUIREMENT)
 try:
 wlock = lockmod.trylock(ui, hgvfs, b'wlock', 0, 0)
+# some process might change the requirement in between, re-read
+# and update current_requirements
+locked_requirements = localrepo._readrequires(hgvfs, True)
+if locked_requirements >= current_requirements and 
current_requirements >= locked_requirements:
+removed = current_requirements - locked_requirements
+# update current_requirements in place because it's passed
+# as reference
+current_requirements -= removed
+current_requirements |= locked_requirements
+diffrequires = current_requirements - store_requirements
+# add share-safe requirement as it will mark the share as 
share-safe
+diffrequires.add(requirementsmod.SHARESAFE_REQUIREMENT)
+current_requirements.add(requirementsmod.SHARESAFE_REQUIREMENT)
 scmutil.writerequires(hgvfs, diffrequires)
 ui.warn(_(b'repository upgraded to use share-safe mode\n'))
 except error.LockError as e:
@@ -290,6 +303,17 @@
 
 try:
 wlock = lockmod.trylock(ui, hgvfs, b'wlock', 0, 0)
+# some process might change the requirement in between, re-read
+# and update current_requirements
+locked_requirements = localrepo._readrequires(hgvfs, True)
+if locked_requirements >= current_requirements and 
current_requirements >= locked_requirements:
+removed = current_requirements - locked_requirements
+# update current_requirements in place because it's passed
+# as reference
+current_requirements -= removed
+current_requirements |= locked_requirements
+current_requirements |= source_requirements
+current_requirements -= set(requirementsmod.SHARESAFE_REQUIREMENT)
 scmutil.writerequires(hgvfs, current_requirements)
 ui.warn(_(b'repository downgraded to not use share-safe mode\n'))
 except error.LockError as e:



To: pulkit, #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


D9821: sqlitestore: disable test with chg

2021-01-18 Thread joerg.sonnenberger (Joerg Sonnenberger)
joerg.sonnenberger created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  There are known issues with transactions not being closed in a timely
  fashion, making the test flakey.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-sqlitestore.t

CHANGE DETAILS

diff --git a/tests/test-sqlitestore.t b/tests/test-sqlitestore.t
--- a/tests/test-sqlitestore.t
+++ b/tests/test-sqlitestore.t
@@ -1,4 +1,4 @@
-#require sqlite
+#require sqlite no-chg
 
   $ cat >> $HGRCPATH < [extensions]



To: joerg.sonnenberger, #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


D9820: purge: move extension into core mercurial

2021-01-18 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The motivation is simple: it's nicer to avoid gating basic
  functionality.
  
  To reduce the risk of people shooting themselves in the feet, `--confirm` is 
now
  the default, unless the extensions is loaded..
  
  For review of the body of the purge command, use this instead of what
  hg/phabricator will show (the block of code is modified, not just
  moved):

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/largefiles/overrides.py
  hgext/purge.py
  mercurial/commands.py
  relnotes/next
  tests/test-completion.t
  tests/test-globalopts.t
  tests/test-help-hide.t
  tests/test-help.t
  tests/test-hgweb-json.t
  tests/test-purge.t

CHANGE DETAILS

diff --git a/tests/test-purge.t b/tests/test-purge.t
--- a/tests/test-purge.t
+++ b/tests/test-purge.t
@@ -1,8 +1,3 @@
-  $ cat <> $HGRCPATH
-  > [extensions]
-  > purge =
-  > EOF
-
 init
 
   $ hg init t
@@ -18,6 +13,26 @@
   $ echo 'ignored' > .hgignore
   $ hg ci -qAmr3 -d'2 0'
 
+purge without the extension
+
+  $ hg st
+  $ touch foo
+  $ hg purge
+  permanently delete 1 unkown files? (yN) n
+  abort: removal cancelled
+  [250]
+  $ hg st
+  ? foo
+  $ hg purge --no-confirm
+  $ hg st
+
+now enabling the extension
+
+  $ cat <> $HGRCPATH
+  > [extensions]
+  > purge =
+  > EOF
+
 delete an empty directory
 
   $ mkdir empty_dir
diff --git a/tests/test-hgweb-json.t b/tests/test-hgweb-json.t
--- a/tests/test-hgweb-json.t
+++ b/tests/test-hgweb-json.t
@@ -2190,6 +2190,10 @@
 "topic": "phase"
   },
   {
+"summary": "removes files not tracked by Mercurial",
+"topic": "purge"
+  },
+  {
 "summary": "roll back an interrupted transaction",
 "topic": "recover"
   },
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -107,6 +107,7 @@
addremove add all new files, delete all missing files
files list tracked files
forgetforget the specified files on the next commit
+   purge removes files not tracked by Mercurial
removeremove the specified files on the next commit
renamerename files; equivalent of copy + remove
resolve   redo merges or set/view the merge status of files
@@ -235,6 +236,7 @@
addremove add all new files, delete all missing files
files list tracked files
forgetforget the specified files on the next commit
+   purge removes files not tracked by Mercurial
removeremove the specified files on the next commit
renamerename files; equivalent of copy + remove
resolve   redo merges or set/view the merge status of files
@@ -375,8 +377,6 @@
mqmanage a stack of patches
notifyhooks for sending email push notifications
patchbomb command to send changesets as (a series of) patch emails
-   purge command to delete untracked files from the working
- directory
relinkrecreates hardlinks between repository clones
schemes   extend schemes with shortcuts to repository swarms
share share a common history between several working directories
@@ -2718,6 +2718,13 @@
   set or show the current phase name
   
   
+  
+  purge
+  
+  
+  removes files not tracked by Mercurial
+  
+  
   
   recover
   
diff --git a/tests/test-help-hide.t b/tests/test-help-hide.t
--- a/tests/test-help-hide.t
+++ b/tests/test-help-hide.t
@@ -55,6 +55,7 @@
addremove add all new files, delete all missing files
files list tracked files
forgetforget the specified files on the next commit
+   purge removes files not tracked by Mercurial
removeremove the specified files on the next commit
renamerename files; equivalent of copy + remove
resolve   redo merges or set/view the merge status of files
@@ -191,6 +192,7 @@
addremove add all new files, delete all missing files
files list tracked files
forgetforget the specified files on the next commit
+   purge removes files not tracked by Mercurial
removeremove the specified files on the next commit
renamerename files; equivalent of copy + remove
resolve   redo merges or set/view the merge status of files
diff --git a/tests/test-globalopts.t b/tests/test-globalopts.t
--- a/tests/test-globalopts.t
+++ b/tests/test-globalopts.t
@@ -351,6 +351,7 @@
addremove add all new files, delete all missing files
files list tracked files
forgetforget the specified files on the next commit
+   purge removes files not tracked by Mercurial
removeremove the specified files on the next commit
rename

D9819: purge: also deal with directory with --confirm

2021-01-18 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Getting the exact number is simple (you have to project the result of previous
  deletion to detect super-directory with only about-to-be-deleted content). So 
we
  use a vaguer message.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/tests/test-purge.t b/tests/test-purge.t
--- a/tests/test-purge.t
+++ b/tests/test-purge.t
@@ -23,6 +23,10 @@
   $ mkdir empty_dir
   $ hg purge -p -v
   empty_dir
+  $ hg purge --confirm
+  permanently delete at least 1 empty directories? (yN) n
+  abort: removal cancelled
+  [250]
   $ hg purge -v
   removing directory empty_dir
   $ ls -A
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -2386,9 +2386,19 @@
 elif nb_ignored:
 msg = _(b"permanently delete %d ignored files?")
 msg %= nb_ignored
-else:
-# XXX we might be missing directory there
-return res
+elif removeemptydirs:
+dir_count = 0
+for f in directories:
+if matcher(f) and not repo.wvfs.listdir(f):
+dir_count += 1
+if dir_count:
+msg = _(
+b"permanently delete at least %d empty directories?"
+)
+msg %= dir_count
+else:
+# XXX we might be missing directory there
+return res
 msg += b" (yN)$$  $$ "
 if repo.ui.promptchoice(msg, default=1) == 1:
 raise error.CanceledError(_(b'removal cancelled'))



To: marmoute, #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


D9818: purge: add a --confirm option

2021-01-18 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The options provide a prompt to the user before permanent deletion are made.
  
  The prompt is currently not aware of directory deletion. I'll fix this in the
  next changesets.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/purge.py
  mercurial/merge.py
  tests/test-purge.t

CHANGE DETAILS

diff --git a/tests/test-purge.t b/tests/test-purge.t
--- a/tests/test-purge.t
+++ b/tests/test-purge.t
@@ -62,6 +62,10 @@
   $ hg purge -p
   untracked_file
   untracked_file_readonly
+  $ hg purge --confirm
+  permanently delete 2 unkown files? (yN) n
+  abort: removal cancelled
+  [250]
   $ hg purge -v
   removing file untracked_file
   removing file untracked_file_readonly
@@ -121,6 +125,10 @@
   $ cd directory
   $ hg purge -p ../untracked_directory
   untracked_directory/nested_directory
+  $ hg purge --confirm
+  permanently delete 1 unkown files? (yN) n
+  abort: removal cancelled
+  [250]
   $ hg purge -v ../untracked_directory
   removing directory untracked_directory/nested_directory
   removing directory untracked_directory
@@ -138,6 +146,7 @@
 
   $ touch ignored
   $ hg purge -p
+  $ hg purge --confirm
   $ hg purge -v
   $ touch untracked_file
   $ ls
@@ -147,6 +156,10 @@
   untracked_file
   $ hg purge -p -i
   ignored
+  $ hg purge --confirm -i
+  permanently delete 1 ignored files? (yN) n
+  abort: removal cancelled
+  [250]
   $ hg purge -v -i
   removing file ignored
   $ ls -A
@@ -159,6 +172,10 @@
   $ hg purge -p --all
   ignored
   untracked_file
+  $ hg purge --confirm --all
+  permanently delete 1 unkown and 1 ignored files? (yN) n
+  abort: removal cancelled
+  [250]
   $ hg purge -v --all
   removing file ignored
   removing file untracked_file
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -2324,6 +2324,7 @@
 removefiles=True,
 abortonerror=False,
 noop=False,
+confirm=False,
 ):
 """Purge the working directory of untracked files.
 
@@ -2344,6 +2345,8 @@
 ``noop`` controls whether to actually remove files. If not defined, actions
 will be taken.
 
+``confirm`` ask confirmation before actually removing anything.
+
 Returns an iterable of relative paths in the working directory that were
 or would be removed.
 """
@@ -2371,6 +2374,25 @@
 
 status = repo.status(match=matcher, ignored=ignored, unknown=unknown)
 
+if confirm:
+nb_ignored = len(status.ignored)
+nb_unkown = len(status.unknown)
+if nb_unkown and nb_ignored:
+msg = _(b"permanently delete %d unkown and %d ignored files?")
+msg %= (nb_unkown, nb_ignored)
+elif nb_unkown:
+msg = _(b"permanently delete %d unkown files?")
+msg %= nb_unkown
+elif nb_ignored:
+msg = _(b"permanently delete %d ignored files?")
+msg %= nb_ignored
+else:
+# XXX we might be missing directory there
+return res
+msg += b" (yN)$$  $$ "
+if repo.ui.promptchoice(msg, default=1) == 1:
+raise error.CanceledError(_(b'removal cancelled'))
+
 if removefiles:
 for f in sorted(status.unknown + status.ignored):
 if not noop:
diff --git a/hgext/purge.py b/hgext/purge.py
--- a/hgext/purge.py
+++ b/hgext/purge.py
@@ -61,6 +61,7 @@
 b' (implies -p/--print)'
 ),
 ),
+(b'', b'confirm', None, _(b'ask before permanently deleting files')),
 ]
 + cmdutil.walkopts,
 _(b'hg purge [OPTION]... [DIR]...'),
@@ -113,6 +114,7 @@
 
 removefiles = opts.get(b'files')
 removedirs = opts.get(b'dirs')
+confirm = opts.get(b'confirm')
 
 if not removefiles and not removedirs:
 removefiles = True
@@ -129,6 +131,7 @@
 removefiles=removefiles,
 abortonerror=opts.get(b'abort_on_err'),
 noop=not act,
+confirm=confirm,
 )
 
 for path in paths:



To: marmoute, #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


D9817: relnote: remove the reference to `debugstrip`

2021-01-18 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The `debug` namespace is not intended for end user and advertising it is a 
path
  to confusion and trouble. I think we should wait for the `admin` namespace to
  exists and the command to be available as `admin--strip` before we advertise 
it.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  relnotes/next

CHANGE DETAILS

diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -17,9 +17,6 @@
can be e.g. `rebase`. As part of this effort, the default format
from `hg rebase` was reorganized a bit.
 
- * `hg strip`, from the strip extension, is now a core command, `hg
-   debugstrip`. The extension remains for compatibility.
-
  * `hg diff` and `hg extdiff` now support `--from ` and `--to `
arguments as clearer alternatives to `-r `. `-r ` has been
deprecated.



To: marmoute, #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