D11671: path: add a new argument to control path validation

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

REVISION SUMMARY
  During pull, unvalidated path might be used, having the option to do so 
directly will allow use to simplify some code and unlock more `path` usage 
later in the series.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/utils/urlutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/urlutil.py b/mercurial/utils/urlutil.py
--- a/mercurial/utils/urlutil.py
+++ b/mercurial/utils/urlutil.py
@@ -818,7 +818,14 @@
 class path(object):
 """Represents an individual path and its configuration."""
 
-def __init__(self, ui=None, name=None, rawloc=None, suboptions=None):
+def __init__(
+self,
+ui=None,
+name=None,
+rawloc=None,
+suboptions=None,
+validate_path=True,
+):
 """Construct a path from its config options.
 
 ``ui`` is the ``ui`` instance the path is coming from.
@@ -856,7 +863,8 @@
 self.rawloc = rawloc
 self.loc = b'%s' % u
 
-self._validate_path()
+if validate_path:
+self._validate_path()
 
 _path, sub_opts = ui.configsuboptions(b'paths', b'*')
 self._own_sub_opts = {}



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


D11672: path: unify path creation in `get_pull_paths`

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

REVISION SUMMARY
  This remove a special case and will make it possible to return `path` instance
  directly.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/utils/urlutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/urlutil.py b/mercurial/utils/urlutil.py
--- a/mercurial/utils/urlutil.py
+++ b/mercurial/utils/urlutil.py
@@ -512,13 +512,8 @@
 for p in ui.paths[source]:
 yield parseurl(p.rawloc, default_branches)
 else:
-# Try to resolve as a local path or URI.
-path = try_path(ui, source)
-if path is not None:
-url = path.rawloc
-else:
-url = source
-yield parseurl(url, default_branches)
+p = path(ui, None, source, validate_path=False)
+yield parseurl(p.rawloc, default_branches)
 
 
 def get_unique_push_path(action, repo, ui, dest=None):



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


D11673: path: return path instance directly from get_pull_paths

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

REVISION SUMMARY
  This means the caller has to do a bit more work, however it give access to the
  `path` instance and the information it contains.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/hg.py
  mercurial/utils/urlutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/urlutil.py b/mercurial/utils/urlutil.py
--- a/mercurial/utils/urlutil.py
+++ b/mercurial/utils/urlutil.py
@@ -503,17 +503,17 @@
 yield path
 
 
-def get_pull_paths(repo, ui, sources, default_branches=()):
+def get_pull_paths(repo, ui, sources):
 """yields all the `(path, branch)` selected as pull source by `sources`"""
 if not sources:
 sources = [b'default']
 for source in sources:
 if source in ui.paths:
 for p in ui.paths[source]:
-yield parseurl(p.rawloc, default_branches)
+yield p
 else:
 p = path(ui, None, source, validate_path=False)
-yield parseurl(p.rawloc, default_branches)
+yield p
 
 
 def get_unique_push_path(action, repo, ui, dest=None):
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -1261,13 +1261,14 @@
 (remoterepo, incomingchangesetlist, displayer) parameters,
 and is supposed to contain only code that can't be unified.
 """
-srcs = urlutil.get_pull_paths(repo, ui, [source], opts.get(b'branch'))
+srcs = urlutil.get_pull_paths(repo, ui, [source])
 srcs = list(srcs)
 if len(srcs) != 1:
 msg = _(b'for now, incoming supports only a single source, %d 
provided')
 msg %= len(srcs)
 raise error.Abort(msg)
-source, branches = srcs[0]
+path = srcs[0]
+source, branches = urlutil.parseurl(path.rawloc, opts.get(b'branch'))
 if subpath is not None:
 subpath = urlutil.url(subpath)
 if subpath.isabs():
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4346,8 +4346,11 @@
 cmdutil.check_incompatible_arguments(opts, b'subrepos', [b'bundle'])
 
 if opts.get(b'bookmarks'):
-srcs = urlutil.get_pull_paths(repo, ui, [source], opts.get(b'branch'))
-for source, branches in srcs:
+srcs = urlutil.get_pull_paths(repo, ui, [source])
+for path in srcs:
+source, branches = urlutil.parseurl(
+path.rawloc, opts.get(b'branch')
+)
 other = hg.peer(repo, opts, source)
 try:
 if b'bookmarks' not in other.listkeys(b'namespaces'):
@@ -5393,8 +5396,8 @@
 hint = _(b'use hg pull followed by hg update DEST')
 raise error.InputError(msg, hint=hint)
 
-sources = urlutil.get_pull_paths(repo, ui, sources, opts.get(b'branch'))
-for source, branches in sources:
+for path in urlutil.get_pull_paths(repo, ui, sources):
+source, branches = urlutil.parseurl(path.rawloc, opts.get(b'branch'))
 ui.status(_(b'pulling from %s\n') % urlutil.hidepassword(source))
 ui.flush()
 other = hg.peer(repo, opts, source)



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


D11674: path: keep the path instance in the `pulloperation`

2021-10-15 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 allow more pull code to use the path options. Ideally we would 
modify
  the peer API to keep the path instance. However that is much more churn that I
  can deal with for my current goal: adjusting a user facing API for a new
  feature before we release it in the 6.0 changesets. So I am taking a shortcut
  that seems reasonable.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/exchange.py

CHANGE DETAILS

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1378,6 +1378,7 @@
 self,
 repo,
 remote,
+path,
 heads=None,
 force=False,
 bookmarks=(),
@@ -1391,6 +1392,10 @@
 self.repo = repo
 # repo we pull from
 self.remote = remote
+# path object used to build this remote
+#
+# Ideally, the remote peer would carry that directly.
+self.remote_path = path
 # revision we try to pull (None is "all")
 self.heads = heads
 # bookmark pulled explicitly
@@ -1556,6 +1561,7 @@
 def pull(
 repo,
 remote,
+path,
 heads=None,
 force=False,
 bookmarks=(),
@@ -1611,8 +1617,9 @@
 pullop = pulloperation(
 repo,
 remote,
-heads,
-force,
+path=path,
+heads=heads,
+force=force,
 bookmarks=bookmarks,
 streamclonerequested=streamclonerequested,
 includepats=includepats,
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5454,6 +5454,7 @@
 modheads = exchange.pull(
 repo,
 other,
+path=path,
 heads=nodes,
 force=opts.get(b'force'),
 bookmarks=opts.get(b'bookmark', ()),



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


D11676: bookmarks: add support for `mirror` mode to `incoming`

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

REVISION SUMMARY
  This is more consistent.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/bookmarks.py
  mercurial/commands.py
  tests/test-bookmarks-pushpull.t

CHANGE DETAILS

diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -503,6 +503,20 @@
* foobar1:9b140be10808
   $ cp .hg/bookmarks .hg/bookmarks.bak
   $ hg book -d X
+  $ hg incoming --bookmark  -v ../a
+  comparing with ../a
+  searching for changed bookmarks
+ @ 0d2164f0ce0d diverged
+ X 0d2164f0ce0d added
+  $ hg incoming --bookmark  -v ../a --config 'paths.*:bookmarks.mode=mirror'
+  comparing with ../a
+  searching for changed bookmarks
+ @ 0d2164f0ce0d changed
+ @foo   removed
+ X 0d2164f0ce0d added
+ X@foo  removed
+ foo    removed
+ foobar removed
   $ hg pull ../a --config 'paths.*:bookmarks.mode=mirror'
   pulling from ../a
   searching for changes
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4360,7 +4360,9 @@
 ui.status(
 _(b'comparing with %s\n') % urlutil.hidepassword(source)
 )
-return bookmarks.incoming(ui, repo, other)
+return bookmarks.incoming(
+ui, repo, other, mode=path.bookmarks_mode
+)
 finally:
 other.close()
 
diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -791,7 +791,7 @@
 repo._bookmarks.applychanges(repo, tr, changes)
 
 
-def incoming(ui, repo, peer):
+def incoming(ui, repo, peer, mode=None):
 """Show bookmarks incoming from other to repo"""
 ui.status(_(b"searching for changed bookmarks\n"))
 
@@ -805,9 +805,6 @@
 ).result()
 )
 
-r = comparebookmarks(repo, remotemarks, repo._bookmarks)
-addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r
-
 incomings = []
 if ui.debugflag:
 getid = lambda id: id
@@ -816,25 +813,47 @@
 if ui.verbose:
 
 def add(b, id, st):
-incomings.append(b"   %-25s %s %s\n" % (b, getid(id), st))
+pattern = b"   %-25s %s %s\n"
+data = (b, getid(id), st)
+incomings.append(pattern % data)
 
 else:
 
 def add(b, id, st):
-incomings.append(b"   %-25s %s\n" % (b, getid(id)))
+pattern = b"   %-25s %s\n"
+data = (b, getid(id))
+incomings.append(pattern % data)
 
-for b, scid, dcid in addsrc:
-# i18n: "added" refers to a bookmark
-add(b, hex(scid), _(b'added'))
-for b, scid, dcid in advsrc:
-# i18n: "advanced" refers to a bookmark
-add(b, hex(scid), _(b'advanced'))
-for b, scid, dcid in diverge:
-# i18n: "diverged" refers to a bookmark
-add(b, hex(scid), _(b'diverged'))
-for b, scid, dcid in differ:
-# i18n: "changed" refers to a bookmark
-add(b, hex(scid), _(b'changed'))
+if mode == b'mirror':
+localmarks = repo._bookmarks
+allmarks = set(remotemarks) | set(repo._bookmarks)
+for b in sorted(allmarks):
+loc = localmarks.get(b)
+rem = remotemarks.get(b)
+if loc == rem:
+continue
+elif loc is None:
+add(b, hex(rem), _(b'added'))
+elif rem is None:
+add(b, hex(repo.nullid), _(b'removed'))
+else:
+add(b, hex(rem), _(b'changed'))
+else:
+r = comparebookmarks(repo, remotemarks, repo._bookmarks)
+addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r
+
+for b, scid, dcid in addsrc:
+# i18n: "added" refers to a bookmark
+add(b, hex(scid), _(b'added'))
+for b, scid, dcid in advsrc:
+# i18n: "advanced" refers to a bookmark
+add(b, hex(scid), _(b'advanced'))
+for b, scid, dcid in diverge:
+# i18n: "diverged" refers to a bookmark
+add(b, hex(scid), _(b'diverged'))
+for b, scid, dcid in differ:
+# i18n: "changed" refers to a bookmark
+add(b, hex(scid), _(b'changed'))
 
 if not incomings:
 ui.status(_(b"no changed bookmarks found\n"))



To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Me

D11677: bookmarks: add a `ignore` variant of the bookmark mode

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

REVISION SUMMARY
  This new mode allow to disable bookmark exchange with some path (or all path).

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/bookmarks.py
  mercurial/helptext/config.txt
  mercurial/utils/urlutil.py
  tests/test-bookmarks-pushpull.t

CHANGE DETAILS

diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -517,6 +517,21 @@
  X@foo  removed
  foo    removed
  foobar removed
+  $ hg incoming --bookmark  -v ../a --config 'paths.*:bookmarks.mode=ignore'
+  comparing with ../a
+  bookmarks exchange disabled with this path
+  $ hg pull ../a --config 'paths.*:bookmarks.mode=ignore'
+  pulling from ../a
+  searching for changes
+  no changes found
+  $ hg book
+ @ 1:9b140be10808
+ @foo  2:0d2164f0ce0d
+ X@foo 2:0d2164f0ce0d
+ Y 0:4e3505fd9583
+ Z 2:0d2164f0ce0d
+ foo   -1:
+   * foobar1:9b140be10808
   $ hg pull ../a --config 'paths.*:bookmarks.mode=mirror'
   pulling from ../a
   searching for changes
diff --git a/mercurial/utils/urlutil.py b/mercurial/utils/urlutil.py
--- a/mercurial/utils/urlutil.py
+++ b/mercurial/utils/urlutil.py
@@ -769,6 +769,7 @@
 KNOW_BOOKMARKS_MODE = {
 b'default',
 b'mirror',
+b'ignore',
 }
 
 
diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt
--- a/mercurial/helptext/config.txt
+++ b/mercurial/helptext/config.txt
@@ -1757,6 +1757,9 @@
   - ``mirror``: when pulling, replace local bookmarks by remote bookmarks. This
 is useful to replicate a repository, or as an optimization.
 
+  - ``ignore``: ignore bookmarks during exchange.
+(This currently only affect pulling)
+
 The following special named paths exist:
 
 ``default``
diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -775,6 +775,9 @@
 def updatefromremote(
 ui, repo, remotemarks, path, trfunc, explicit=(), mode=None
 ):
+if mode == b'ignore':
+# This should move to an higher level to avoid fetching bookmark at all
+return
 ui.debug(b"checking for updated bookmarks\n")
 if mode == b'mirror':
 changed = mirroring_remote(ui, repo, remotemarks)
@@ -793,6 +796,9 @@
 
 def incoming(ui, repo, peer, mode=None):
 """Show bookmarks incoming from other to repo"""
+if mode == b'ignore':
+ui.status(_(b"bookmarks exchange disabled with this path\n"))
+return 0
 ui.status(_(b"searching for changed bookmarks\n"))
 
 with peer.commandexecutor() as e:



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


D11675: bookmarks: move the `mirror` option to the `paths` section

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

REVISION SUMMARY
  A new `bookmarks` section with a `mirror` option have been added. That option
  has never been released yet.
  
  This new options is limited since it affect all paths without distinction. In
  case where a repository is interacting with multiple peers, being able to
  control behavior on a path basis can be quite valuable.
  
  In addition, having more variant of behavior would be interesting, especially 
a
  mode where no bookmark exchanged is tried at all. Such new mode (implemented
  later) make a lot of sense for configuration on a path-basis.
  
  Configuration of the default behavior is still possible through the usage of
  generic path configuration. The "old" config, becomes:
  
[bookmarks]
mirror=True
  
  becomes:
  
[path]
*:bookmarks.mode=mirror

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/bookmarks.py
  mercurial/configitems.py
  mercurial/exchange.py
  mercurial/helptext/config.txt
  mercurial/utils/urlutil.py
  tests/test-bookmarks-pushpull.t

CHANGE DETAILS

diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -503,7 +503,7 @@
* foobar1:9b140be10808
   $ cp .hg/bookmarks .hg/bookmarks.bak
   $ hg book -d X
-  $ hg pull ../a --config bookmarks.mirror=true
+  $ hg pull ../a --config 'paths.*:bookmarks.mode=mirror'
   pulling from ../a
   searching for changes
   no changes found
diff --git a/mercurial/utils/urlutil.py b/mercurial/utils/urlutil.py
--- a/mercurial/utils/urlutil.py
+++ b/mercurial/utils/urlutil.py
@@ -766,6 +766,23 @@
 return value
 
 
+KNOW_BOOKMARKS_MODE = {
+b'default',
+b'mirror',
+}
+
+
+@pathsuboption(b'bookmarks.mode', b'bookmarks_mode')
+def bookmarks_mode_option(ui, path, value):
+if value not in KNOW_BOOKMARKS_MODE:
+msg = _(b'(paths.%s:bookmarks.mode as unknown value %s)\n')
+msg %= (path.name, value)
+ui.warn(msg)
+if value == b'default':
+value = None
+return value
+
+
 @pathsuboption(b'multi-urls', b'multi_urls')
 def multiurls_pathoption(ui, path, value):
 res = stringutil.parsebool(value)
diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt
--- a/mercurial/helptext/config.txt
+++ b/mercurial/helptext/config.txt
@@ -418,16 +418,6 @@
 If no suitable authentication entry is found, the user is prompted
 for credentials as usual if required by the remote.
 
-``bookmarks``
--
-
-Controls some aspect of bookmarks.
-
-``mirror``
-When pulling, instead of merging local bookmarks and remote bookmarks,
-replace local bookmarks by remote bookmarks. This is useful to replicate
-a repository, or as an optimization. (default: False)
-
 ``cmdserver``
 -
 
@@ -1758,6 +1748,15 @@
Revsets specifying bookmarks will not result in the bookmark being
pushed.
 
+``bookmarks.mode``
+  How bookmark will be dealt during the exchange. It support the following 
value
+
+  - ``default``: the default behavior, local and remote bookmarks are "merged"
+on push/pull.
+
+  - ``mirror``: when pulling, replace local bookmarks by remote bookmarks. This
+is useful to replicate a repository, or as an optimization.
+
 The following special named paths exist:
 
 ``default``
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -2028,6 +2028,9 @@
 pullop.stepsdone.add(b'bookmarks')
 repo = pullop.repo
 remotebookmarks = pullop.remotebookmarks
+bookmarks_mode = None
+if pullop.remote_path is not None:
+bookmarks_mode = pullop.remote_path.bookmarks_mode
 bookmod.updatefromremote(
 repo.ui,
 repo,
@@ -2035,6 +2038,7 @@
 pullop.remote.url(),
 pullop.gettransaction,
 explicit=pullop.explicitbookmarks,
+mode=bookmarks_mode,
 )
 
 
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -207,11 +207,6 @@
 b'pushing',
 default=list,
 )
-coreconfigitem(
-b'bookmarks',
-b'mirror',
-default=False,
-)
 # bundle.mainreporoot: internal hack for bundlerepo
 coreconfigitem(
 b'bundle',
diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -772,9 +772,11 @@
 return changed
 
 
-def updatefromremote(ui, repo, remotemarks, path, trfunc, explicit=()):
+def updatefromremote(
+ui, repo, remotemarks, path, trfunc, explicit=(), mode=None
+):
 ui.debug(b"checking for updated bookmarks\n")
-if ui.configbool(b'bookmarks', b'mirror'):
+if mode == b'mirror':
 changed = mirroring_remote(ui, repo, remotemar

D11678: rust: reformat Rust code

2021-10-15 Thread SimonSapin
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
(cd rust && cargo +nightly fmt)

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/operations/cat.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/operations/cat.rs 
b/rust/hg-core/src/operations/cat.rs
--- a/rust/hg-core/src/operations/cat.rs
+++ b/rust/hg-core/src/operations/cat.rs
@@ -104,10 +104,8 @@
 bytes.extend(file_log.data_for_node(file_node)?.data()?);
 }
 
-let missing: Vec = missing
-.iter()
-.map(|file| (*file).to_owned())
-.collect();
+let missing: Vec =
+missing.iter().map(|file| (*file).to_owned()).collect();
 Ok(CatOutput {
 found_any,
 concatenated: bytes,



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


Re: Call for comments on new dirstate format contents

2021-10-15 Thread Pierre-Yves David


On 10/13/21 10:57 AM, Simon Sapin wrote:

On 28/06/2021 11:49, Raphaël Gomès wrote:

Hello all,

As you probably know my colleagues at Octobus and I have been working on
a new version of the dirstate, and we're coming pretty close to
something usable in production, so we need to freeze the format soon.


Hello again,

Together with the Rust implementation of the new status algorithm, 
this dirstate-v2 file format enables great performance improvements of 
`hg status` on large repositories.


We Octobus are hoping to stabilize it very soon after a few remaining 
changes, so that the format will not be experimental anymore in the 
upcoming Mercurial 6.0 release. It will not yet be enabled by default, 
but future Mercurial versions will need to be compatible both ways 
with 6.0 when accessing a given local repository that uses dirstate-v2.



A short user guide (how to enable, upgrade, or downgrade) as well as 
detailed documentation of the file format can be found at:


https://www.mercurial-scm.org/repo/hg-committed/file/tip/mercurial/helptext/internals/dirstate-v2.txt 



… or in a source repository by running `make local` then `./hg help 
internals.dirstate-v2`



The remaining format changes we have planned are:

* Add sub-second precision to stored file/symlink mtime, and share its 
location with that of directory mtime. (This part of the format is a 
bit of a mess right now since we’re in the middle of this change.)


* Maybe add a flag bit to allow marking files as "known modified at 
this mtime". `hg status` sometimes needs to read the contents of files 
in case of possible size-preserving changes. If there is indeed a 
change, currently this read is repeated every time status runs again. 
The new bit would record that result.


* Maybe add some node-specific or dirstate-wide flags or a "mode 
switch" to make the format and its storage of directory mtimes less 
tied to details of the current readdir-skipping optimization. (For 
example, a future version of Mercurial might want to add dirstate 
nodes for unknown or/and ignored files to skip readdir in more cases.)



Non-format changes that we want to have in 6.0:

* Merge D11520 and the rest of that stack to have a Python 
implementation of the format, so that repositories that use it are 
usable when Rust extensions are not enabled. This is slower, in the 
order of 0.1 to 0.3 seconds added to `hg status` commands taking 0.4 
to 2.5 seconds with dirstate-v1 without Rust on various repositories.


* Add configuration to either abort, warn, or silently continue when 
this slow code path is or would be used. And decide its default. I’m 
personally inclined at least not to abort by default since the slow 
path is not *horribly* slow.



Please let us know of any question or comment!



I remember discussion about storing WC exec-bit and symlink status to 
help system without support for thoses (Windows we are looking at you). 
That is necessary to solve things like "issue5883".


Storage wise this should be fairly simpler, so we should be able to 
reserve some useful value for that in the new format. Regarding the 
implementation of a behavior fixing the associated issues, it seems 
complicated to get something done as the freeze is a couple of days away.


I just remembered this and I am not actively working on it today so I 
don't have a very concret idea about it yet. Matt Harbison might have 
more concretes idea about this.


Cheers,

--
Pierre-Yves David

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


[Bug 6603] New: Wrong modified file in hg status in share context

2021-10-15 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=6603

Bug ID: 6603
   Summary: Wrong modified file in hg status in share context
   Product: Mercurial
   Version: 5.7.1
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: feature
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: georges.raci...@octobus.net
CC: mercurial-devel@mercurial-scm.org
Python Version: ---

I have a case where a file is always displayed as modified in `hg status`, even
after `hg revert` or `hg update -C` or even after a sequence of updates.

The repository was cloned with the `share-pool` configuration item (the `share`
extension is active).

Recreating the share or recloning the actual repository in the pool resolves
the problem.

I tried both hg 5.7.1 on Python 3.8 and 5.9.2 on Python 3.9 (the latter with or
without Rust).

I have not been able in a limited time to find a small reproduction, so I made
a tarball with the full repo and an offending share (6MB). 

Here's how to download the tarball and reproduce the bug (more details in the
README file)

$ cd /tmp
/tmp $ curl -o status-bug.tgz
https://static.octobus.net/bug-reproductions/gracinet-status-bug-2021-10-15.tgz 
/tmp $ tar xzf status-bug.tgz 

(if one untars in some other directory, the status-bug/share/.hg/sharedpath
file will have to be adjusted accordingly).

/tmp $ cd status-bug
/tmp/status-bug $ ls
README share  share-pool
/tmp/status-bug $ cd share
/tmp/status-bug/share $ hg st
M heptapod-ci.yml
/tmp/status-bug/share $ hg rev heptapod-ci.yml 
/tmp/status-bug/share $ hg st
M heptapod-ci.yml
/tmp/status-bug/share $ hg update -C .
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
/tmp/status-bug/share $ hg st 
M heptapod-ci.yml
/tmp/status-bug/share $ hg debugdirstate | grep heptapod-ci
n 644   1787 unset   heptapod-ci.yml

(notice the 'unset' mtime)

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


D11679: rhg: simplify the type of FilelogEntry

2021-10-15 Thread aalekseyev (Arseniy Alekseyev)
aalekseyev created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  rhg: add FilelogEntry.into_data
  
  rhg: internally, return a structured representatioon from hg cat

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/operations/cat.rs
  rust/hg-core/src/revlog/filelog.rs
  rust/rhg/src/commands/cat.rs

CHANGE DETAILS

diff --git a/rust/rhg/src/commands/cat.rs b/rust/rhg/src/commands/cat.rs
--- a/rust/rhg/src/commands/cat.rs
+++ b/rust/rhg/src/commands/cat.rs
@@ -66,6 +66,7 @@
 .map_err(|e| CommandError::abort(e.to_string()))?;
 files.push(hg_file);
 }
+let files = files.iter().map(|file| file.as_ref()).collect();
 // TODO probably move this to a util function like `repo.default_rev` or
 // something when it's used somewhere else
 let rev = match rev {
@@ -74,7 +75,9 @@
 };
 
 let output = cat(&repo, &rev, files).map_err(|e| (e, rev.as_str()))?;
-invocation.ui.write_stdout(&output.concatenated)?;
+for (_file, contents) in output.results {
+invocation.ui.write_stdout(&contents)?;
+}
 if !output.missing.is_empty() {
 let short = format!("{:x}", output.node.short()).into_bytes();
 for path in &output.missing {
diff --git a/rust/hg-core/src/revlog/filelog.rs 
b/rust/hg-core/src/revlog/filelog.rs
--- a/rust/hg-core/src/revlog/filelog.rs
+++ b/rust/hg-core/src/revlog/filelog.rs
@@ -7,7 +7,6 @@
 use crate::utils::files::get_path_from_bytes;
 use crate::utils::hg_path::HgPath;
 use crate::utils::SliceExt;
-use std::borrow::Cow;
 use std::path::PathBuf;
 
 /// A specialized `Revlog` to work with file data logs.
@@ -40,7 +39,7 @@
 &self,
 file_rev: Revision,
 ) -> Result {
-let data = self.revlog.get_rev_data(file_rev)?;
+let data: Vec = self.revlog.get_rev_data(file_rev)?;
 Ok(FilelogEntry(data.into()))
 }
 }
@@ -51,22 +50,32 @@
 get_path_from_bytes(&encoded_bytes).into()
 }
 
-pub struct FilelogEntry<'filelog>(Cow<'filelog, [u8]>);
+pub struct FilelogEntry(Vec);
 
-impl<'filelog> FilelogEntry<'filelog> {
+impl FilelogEntry {
 /// Split into metadata and data
-pub fn split(&self) -> Result<(Option<&[u8]>, &[u8]), HgError> {
+/// Returns None if there is no metadata, so the entire entry is data.
+fn split_metadata(&self) -> Result, HgError> {
 const DELIMITER: &[u8; 2] = &[b'\x01', b'\n'];
 
 if let Some(rest) = self.0.drop_prefix(DELIMITER) {
 if let Some((metadata, data)) = rest.split_2_by_slice(DELIMITER) {
-Ok((Some(metadata), data))
+Ok(Some((metadata, data)))
 } else {
 Err(HgError::corrupted(
 "Missing metadata end delimiter in filelog entry",
 ))
 }
 } else {
+Ok(None)
+}
+}
+
+/// Split into metadata and data
+pub fn split(&self) -> Result<(Option<&[u8]>, &[u8]), HgError> {
+if let Some((metadata, data)) = self.split_metadata()? {
+Ok((Some(metadata), data))
+} else {
 Ok((None, &self.0))
 }
 }
@@ -76,4 +85,12 @@
 let (_metadata, data) = self.split()?;
 Ok(data)
 }
+
+pub fn into_data(self) -> Result, HgError> {
+if let Some((_metadata, data)) = self.split_metadata()? {
+Ok(data.to_owned())
+} else {
+Ok(self.0)
+}
+}
 }
diff --git a/rust/hg-core/src/operations/cat.rs 
b/rust/hg-core/src/operations/cat.rs
--- a/rust/hg-core/src/operations/cat.rs
+++ b/rust/hg-core/src/operations/cat.rs
@@ -10,20 +10,19 @@
 use crate::revlog::Node;
 
 use crate::utils::hg_path::HgPath;
-use crate::utils::hg_path::HgPathBuf;
 
 use itertools::put_back;
 use itertools::PutBack;
 use std::cmp::Ordering;
 
-pub struct CatOutput {
+pub struct CatOutput<'a> {
 /// Whether any file in the manifest matched the paths given as CLI
 /// arguments
 pub found_any: bool,
 /// The contents of matching files, in manifest order
-pub concatenated: Vec,
+pub results: Vec<(&'a HgPath, Vec)>,
 /// Which of the CLI arguments did not match any manifest file
-pub missing: Vec,
+pub missing: Vec<&'a HgPath>,
 /// The node ID that the given revset was resolved to
 pub node: Node,
 }
@@ -32,7 +31,7 @@
 fn find_item<'a, 'b, 'c, D, I: Iterator>(
 i: &mut PutBack,
 needle: &'b HgPath,
-) -> Option {
+) -> Option {
 loop {
 match i.next() {
 None => return None,
@@ -42,7 +41,7 @@
 return None;
 }
 Ordering::Greater => continue,
-Ordering::Equal => return Some(val),
+Ordering::Equal => return Some(val.1),
 },
 }
 }
@@ -57,7 +56,7 @@
 >(
 manifest: I,
 files: 

mercurial-devel | Failed pipeline for branch/default | 80b457ca

2021-10-15 Thread Heptapod


Pipeline #27825 has failed!

Project: mercurial-devel ( https://foss.heptapod.net/mercurial/mercurial-devel )
Branch: branch/default ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/commits/branch/default )

Commit: 80b457ca ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/commit/80b457cae94fb4bee81da4ce274788870b91b8d0
 )
Commit Message: dirstate-v2: add an option to prevent unintenti...
Commit Author: Pierre-Yves David ( https://foss.heptapod.net/marmoute )

Pipeline #27825 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/pipelines/27825 ) 
triggered by Administrator ( https://foss.heptapod.net/root )
had 6 failed jobs.

Job #254045 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/254045/raw )

Stage: tests
Name: test-py3-rhg
Job #254046 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/254046/raw )

Stage: tests
Name: test-py2-chg
Job #254039 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/254039/raw )

Stage: tests
Name: test-py2
Job #254043 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/254043/raw )

Stage: tests
Name: test-py2-rust
Job #254041 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/254041/raw )

Stage: tests
Name: test-py2-pure
Job #254035 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/254035/raw )

Stage: tests
Name: checks-py2

-- 
You're receiving this email because of your account on foss.heptapod.net.



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


D11680: push: add option to abort on dirty working copy if parent is pushed

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

REVISION SUMMARY
  This patch adds a config option to make it an error to push the parent
  of the working copy when the working copy is dirty. We have had this
  feature enabled by default internally for a few years. I think most
  users have found it helpful.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/configitems.py
  tests/test-completion.t
  tests/test-push.t

CHANGE DETAILS

diff --git a/tests/test-push.t b/tests/test-push.t
--- a/tests/test-push.t
+++ b/tests/test-push.t
@@ -400,3 +400,73 @@
   searching for changes
   no changes found
   [1]
+
+
+Test `push.on-dirty-working-copy`
+-
+
+  $ cat >> $HGRCPATH << EOF
+  > [extensions]
+  > drawdag=$TESTDIR/drawdag.py
+  > EOF
+  $ cd $TESTTMP
+  $ mkdir dirty-working-copy
+  $ cd dirty-working-copy
+  $ hg init source
+  $ cat >> source/.hg/hgrc << EOF
+  > [phases]
+  > publish=false
+  > EOF
+  $ hg clone source dest
+  updating to branch default
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd dest
+  $ hg debugdrawdag << 'EOF'
+  >   D
+  >   |
+  > F C
+  > | |
+  > E B
+  > |/
+  > A
+  > EOF
+  $ cat >> .hg/hgrc << EOF
+  > [push]
+  > on-dirty-working-copy=abort
+  > EOF
+# Push all commits just to make the output from further pushes consistently
+# "no changes found".
+  $ hg push -q -r 'head()'
+  $ hg co C
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo modified >> A
+# Cannot push the parent commit with a dirty working copy
+  $ hg push -q -r .
+  abort: won't push with dirty working directory
+  (maybe you meant to commit or amend the changes; if you want to push
+  anyway, use --allow-dirty, or set on-dirty-working-copy=ignore in
+  the [push] section of your ~/.hgrc)
+  [20]
+# Cannot push a descendant either
+  $ hg push -q -r D
+  abort: won't push with dirty working directory
+  (maybe you meant to commit or amend the changes; if you want to push
+  anyway, use --allow-dirty, or set on-dirty-working-copy=ignore in
+  the [push] section of your ~/.hgrc)
+  [20]
+# Typo in config value results in default behavior (which is to allow push)
+  $ hg push --config push.on-dirty-working-copy=abirt -q -r .
+  [1]
+# Can override config
+  $ hg push -q -r . --allow-dirty
+  [1]
+# Can push an ancestor
+  $ hg push -q -r B
+  [1]
+# Can push a sibling
+  $ hg push -q -r F
+  [1]
+# Can push descendant if the working copy parent is public
+  $ hg phase -p
+  $ hg push -q -r D
+  [1]
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -362,7 +362,7 @@
   phase: public, draft, secret, force, rev
   pull: update, force, confirm, rev, bookmark, branch, ssh, remotecmd, insecure
   purge: abort-on-err, all, ignored, dirs, files, print, print0, confirm, 
include, exclude
-  push: force, rev, bookmark, all-bookmarks, branch, new-branch, pushvars, 
publish, ssh, remotecmd, insecure
+  push: force, rev, bookmark, all-bookmarks, branch, new-branch, pushvars, 
publish, allow-dirty, ssh, remotecmd, insecure
   recover: verify
   remove: after, force, subrepos, include, exclude, dry-run
   rename: forget, after, at-rev, force, include, exclude, dry-run
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1869,6 +1869,12 @@
 default=False,
 )
 coreconfigitem(
+b'push',
+b'on-dirty-working-copy',
+default=b"ignore",
+experimental=True,
+)
+coreconfigitem(
 b'rewrite',
 b'backup-bundle',
 default=True,
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5633,6 +5633,15 @@
 False,
 _(b'push the changeset as public (EXPERIMENTAL)'),
 ),
+(
+b'',
+b'allow-dirty',
+False,
+_(
+b'allow pushing with a dirty working copy, overriding '
+b'push.on-dirty-working-copy=abort (EXPERIMENTAL)'
+),
+),
 ]
 + remoteopts,
 _(b'[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]...'),
@@ -5735,8 +5744,10 @@
 
 try:
 if revs:
-revs = [repo[r].node() for r in logcmdutil.revrange(repo, 
revs)]
-if not revs:
+nodes = [
+repo[r].node() for r in logcmdutil.revrange(repo, revs)
+]
+if not nodes:
 raise error.InputError(
 _(b"specified revisions evaluate to an empty set"),
 hint=_(b"use different revision arguments"),
@@ -5746,8 +5757,8 @@
 # to DAG h

[Bug 6604] New: _TextTestResult was removed in favour TextTestResult in Python 3.11

2021-10-15 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=6604

Bug ID: 6604
   Summary: _TextTestResult was removed in favour TextTestResult
in Python 3.11
   Product: Mercurial
   Version: default branch
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: bug
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: tir.kar...@gmail.com
CC: mercurial-devel@mercurial-scm.org
Python Version: ---

CPython commit :
https://github.com/python/cpython/commit/b0a6ede3d0bd6fa4ffe413ab4dfc1059201df25b

Following files might need to be updated 

tests/basic_test_result.py
6:class TestResult(unittest._TextTestResult):

tests/run-tests.py
2239:class TestResult(unittest._TextTestResult):

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