D6828: uncommit: add options to update to the current user or current date

2019-09-07 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  These are also from the evolve extension's version of uncommit.
  
  I tried adding validation that both forms of user or date can't be specified 
at
  the same time, but that fails because these show up in `opts` with a None 
value
  whether or not the option was given on the command line.  Presumably that 
means
  the conditional in `resolvecommitoptions` could be simplified.  But this is 
how
  both evolve and MQ handle it.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/uncommit.py
  mercurial/cmdutil.py
  mercurial/commands.py
  tests/test-uncommit.t

CHANGE DETAILS

diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t
--- a/tests/test-uncommit.t
+++ b/tests/test-uncommit.t
@@ -42,6 +42,8 @@
-l --logfile FILE read commit message from file
-d --date DATErecord the specified date as commit date
-u --user USERrecord the specified user as committer
+   -D --current-date record the current date as commit date
+   -U --current-user record the current user as committer
   
   (some details hidden, use --verbose to show complete help)
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -118,6 +118,7 @@
 walkopts = cmdutil.walkopts
 commitopts = cmdutil.commitopts
 commitopts2 = cmdutil.commitopts2
+commitopts3 = cmdutil.commitopts3
 formatteropts = cmdutil.formatteropts
 templateopts = cmdutil.templateopts
 logopts = cmdutil.logopts
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -100,6 +100,13 @@
  _('record the specified user as committer'), _('USER')),
 ]
 
+commitopts3 = [
+(b'D', b'current-date', None,
+ _(b'record the current date as commit date')),
+(b'U', b'current-user', None,
+ _(b'record the current user as committer')),
+]
+
 formatteropts = [
 ('T', 'template', '',
  _('display with template'), _('TEMPLATE')),
@@ -175,6 +182,15 @@
 # editor text
 _linebelow = "^HG:  >8 $"
 
+def resolvecommitoptions(ui, opts):
+"""modify commit options dict to handle related options
+"""
+# N.B. this is extremely similar to setupheaderopts() in mq.py
+if not opts.get(b'date') and opts.get(b'current_date'):
+opts[b'date'] = b'%d %d' % dateutil.makedate()
+if not opts.get(b'user') and opts.get(b'current_user'):
+opts[b'user'] = ui.username()
+
 def ishunk(x):
 hunkclasses = (crecordmod.uihunk, patch.recordhunk)
 return isinstance(x, hunkclasses)
diff --git a/hgext/uncommit.py b/hgext/uncommit.py
--- a/hgext/uncommit.py
+++ b/hgext/uncommit.py
@@ -112,7 +112,8 @@
 [('', 'keep', None, _('allow an empty commit after uncommiting')),
  ('', 'allow-dirty-working-copy', False,
 _('allow uncommit with outstanding changes'))
-] + commands.walkopts + commands.commitopts + commands.commitopts2,
+] + commands.walkopts + commands.commitopts + commands.commitopts2
++ commands.commitopts3,
 _('[OPTION]... [FILE]...'),
 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT)
 def uncommit(ui, repo, *pats, **opts):
@@ -128,6 +129,8 @@
 """
 opts = pycompat.byteskwargs(opts)
 
+cmdutil.resolvecommitoptions(ui, opts)
+
 with repo.wlock(), repo.lock():
 
 m, a, r, d = repo.status()[:4]



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


D6827: uncommit: add support to modify the commit message and date

2019-09-07 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Currently, the evolve extension's version of this command supports it.

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS

diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t
--- a/tests/test-uncommit.t
+++ b/tests/test-uncommit.t
@@ -38,6 +38,10 @@
   --allow-dirty-working-copy allow uncommit with outstanding changes
-I --include PATTERN [+]  include names matching the given patterns
-X --exclude PATTERN [+]  exclude names matching the given patterns
+   -m --message TEXT use text as commit message
+   -l --logfile FILE read commit message from file
+   -d --date DATErecord the specified date as commit date
+   -u --user USERrecord the specified user as committer
   
   (some details hidden, use --verbose to show complete help)
 
@@ -531,9 +535,18 @@
   $ mkdir dir
   $ echo 1 > dir/file.txt
   $ hg ci -Aqm 'add file in directory'
-  $ hg uncommit dir
+  $ hg uncommit dir -m 'uncommit with message' -u 'different user' \
+  > -d 'Jun 30 12:12:12 1980 +'
   $ hg status
   A dir/file.txt
+  $ hg log -r .
+  changeset:   8:b4dd26dc42e0
+  tag: tip
+  parent:  6:2278a4c24330
+  user:different user
+  date:Mon Jun 30 12:12:12 1980 +
+  summary: uncommit with message
+  
 
 `uncommit ` and `cd  && uncommit .` behave the same...
 
diff --git a/hgext/uncommit.py b/hgext/uncommit.py
--- a/hgext/uncommit.py
+++ b/hgext/uncommit.py
@@ -55,7 +55,8 @@
 # leave the attribute unspecified.
 testedwith = 'ships-with-hg-core'
 
-def _commitfiltered(repo, ctx, match, keepcommit):
+def _commitfiltered(repo, ctx, match, keepcommit, message=None, user=None,
+date=None):
 """Recommit ctx with changed files not in match. Return the new
 node identifier, or None if nothing changed.
 """
@@ -90,13 +91,20 @@
 if not files:
 repo.ui.status(_("note: keeping empty commit\n"))
 
+if message is None:
+message = ctx.description()
+if not user:
+user = ctx.user()
+if not date:
+date = ctx.date()
+
 new = context.memctx(repo,
  parents=[base.node(), node.nullid],
- text=ctx.description(),
+ text=message,
  files=files,
  filectxfn=filectxfn,
- user=ctx.user(),
- date=ctx.date(),
+ user=user,
+ date=date,
  extra=ctx.extra())
 return repo.commitctx(new)
 
@@ -104,7 +112,7 @@
 [('', 'keep', None, _('allow an empty commit after uncommiting')),
  ('', 'allow-dirty-working-copy', False,
 _('allow uncommit with outstanding changes'))
-] + commands.walkopts,
+] + commands.walkopts + commands.commitopts + commands.commitopts2,
 _('[OPTION]... [FILE]...'),
 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT)
 def uncommit(ui, repo, *pats, **opts):
@@ -162,13 +170,19 @@
   % scmutil.getuipathfn(repo)(f), hint=hint)
 
 with repo.transaction('uncommit'):
+if not (opts[b'message'] or opts[b'logfile']):
+opts[b'message'] = old.description()
+message = cmdutil.logmessage(ui, pycompat.byteskwargs(opts))
+
 keepcommit = pats
 if not keepcommit:
 if opts.get('keep') is not None:
 keepcommit = opts.get('keep')
 else:
 keepcommit = ui.configbool('experimental', 'uncommit.keep')
-newid = _commitfiltered(repo, old, match, keepcommit)
+newid = _commitfiltered(repo, old, match, keepcommit,
+message=message, user=opts.get(b'user'),
+date=opts.get(b'date'))
 if newid is None:
 ui.status(_("nothing to uncommit\n"))
 return 1



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


mercurial@42848: new changeset (1 on stable)

2019-09-07 Thread Mercurial Commits
New changeset (1 on stable) in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/344a086bb764
changeset:   42848:344a086bb764
branch:  stable
tag: tip
user:Pierre-Yves David 
date:Sat Sep 07 14:51:18 2019 +0200
summary: tests: register test-merge-combination.t as small but slow

-- 
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


Re: [PATCH] discovery: replace "heads" by "changesets" in a output note (BC)

2019-09-07 Thread Yuya Nishihara
On Sat, 07 Sep 2019 13:44:38 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David 
> # Date 1556323445 -7200
> #  Sat Apr 27 02:04:05 2019 +0200
> # Node ID 74dad98f3309bf86e6993c23a5cff0ebb42dc511
> # Parent  69195b6f8f974ba56aec9b9bd4cd0a259a646f72
> # EXP-Topic discovery-more
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> 74dad98f3309
> discovery: replace "heads" by "changesets" in a output note (BC)

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


Re: [PATCH STABLE] tests: register test-merge-combination.t as small but slow

2019-09-07 Thread Gregory Szorc
On Sat, Sep 7, 2019 at 6:17 AM Pierre-Yves David <
pierre-yves.da...@ens-lyon.org> wrote:

> # HG changeset patch
> # User Pierre-Yves David 
> # Date 1567860678 -7200
> #  Sat Sep 07 14:51:18 2019 +0200
> # Branch stable
> # Node ID 0552670ad381a377768b40ee8ddd3454f5a400d5
> # Parent  b22a8dadc6f52fd3d8f45ac71e71fe2be381017b
> # EXP-Topic run-tests-scheduling
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
> 0552670ad381
> tests: register test-merge-combination.t as small but slow
>

Queued for stable.


>
> run-tests.py use file size as an heuristic for test run time. The new
> `test-merge-combination.t` is a small file that do a lot of processing. As
> a
> result it tend to be scheduled really late but delay the full test run by
> a lot.
>
> On an example test run, the one-before-last test completed 279s after the
> start
> of the run, while `test-merge-combination.t` finished 355s after it. A 76s
> delay. This delay can be avoided since `test-merge-combination.t` only got
> started
> 175s after the start of the run.
>
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -2513,6 +2513,7 @@ def sorttests(testdescs, previoustimes,
>  b'check': 100,
>  b'gendoc': 100,
>  b'contrib-perf': 200,
> +b'merge-combination': 100,
>  }
>  perf = {}
>
> ___
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


mercurial@42847: 3 new changesets (1 on stable)

2019-09-07 Thread Mercurial Commits
3 new changesets (1 on stable) in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/f75f47b3ea41
changeset:   42845:f75f47b3ea41
parent:  42842:2c74337e6483
user:Pierre-Yves David 
date:Mon Sep 02 16:28:43 2019 +0200
summary: revlog: deprecate the use of `revision(..., raw=True)`

https://www.mercurial-scm.org/repo/hg/rev/01d3ce3281cf
changeset:   42846:01d3ce3281cf
bookmark:@
user:Yuya Nishihara 
date:Sun Sep 01 17:35:14 2019 +0900
summary: rust-cpython: fix unsafe inner(py).borrow_mut() calls

https://www.mercurial-scm.org/repo/hg/rev/da2c360899c9
changeset:   42847:da2c360899c9
branch:  stable
tag: tip
parent:  42844:b22a8dadc6f5
user:Julien Cristau 
date:Fri Sep 06 11:48:49 2019 +0200
summary: test: allow different result for zstd compression (issue6188)

-- 
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


D6825: contrib: start building a library for simple hooks

2019-09-07 Thread indygreg (Gregory Szorc)
indygreg added a comment.


  I think we should go a step further and have some built-in hooks in Mercurial 
itself, like we do extensions. A good first implementation would be to define 
those hooks somewhere where they can be imported, add tests like they are 
standalone hooks. As a follow-up (read: slightly more work), we can define a 
new config syntax for using these hooks. e.g. `builtin:reject_new_heads`.
  
  What do others think?

REPOSITORY
  rHG Mercurial

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

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

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


D6826: py3: drop incorrect fsencode(findexe(...)) in procutil

2019-09-07 Thread martinvonz (Martin von Zweigbergk)
Closed by commit rHGacf80f9edc85: py3: drop incorrect fsencode(findexe(...)) in 
procutil (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6826?vs=16442=16447

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

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

AFFECTED FILES
  mercurial/utils/procutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -245,11 +245,8 @@
 pycompat.fsencode(getattr(mainmod, '__file__', ''))) == 'hg'):
 _sethgexecutable(pycompat.fsencode(mainmod.__file__))
 else:
-exe = findexe('hg')
-if exe:
-_sethgexecutable(pycompat.fsencode(exe))
-else:
-_sethgexecutable(os.path.basename(pycompat.sysargv[0]))
+_sethgexecutable(findexe('hg') or
+ os.path.basename(pycompat.sysargv[0]))
 return _hgexecutable
 
 def _sethgexecutable(path):



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


D6808: revlog: introduce a `sidedata` method

2019-09-07 Thread indygreg (Gregory Szorc)
indygreg added a comment.


  I think I see where you are going with this and it seems potentially very 
useful.
  
  I do wish the flag processors code could have been refactored without 
involving `sidedata`, as I would have taken the patches later in this series to 
remove the temporary `mixin` in a heartbeat. But since `sidedata` is involved, 
I want to have others weigh in.
  
  It would be extremely useful to see an actual use case for `sidedata`. As it 
stands, I have questions like whether we'll need to further evolve the storage 
APIs to accommodate things like cherry-picking which pieces of `sidedata` are 
desired. Also, incorporating `sidedata` in the revlog write APIs (in later 
patches) seems a bit odd, as the revlog format is rather stable and I'm not 
sure how additional data will be incorporated without introducing a new flag 
processor to accommodate extra data next to the revision. Again, I'd really 
like to see a real world use case for `sidedata` to help give me confidence 
this is the correct storage abstraction.

REPOSITORY
  rHG Mercurial

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

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

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


D6814: revlog: add a `sidedata` parameters to addrevision

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute added inline comments.

INLINE COMMENTS

> indygreg wrote in remotefilelog.py:133
> Why an empty tuple here? Isn't `None` more Pythonic?

because it can be iterated over as a noop.

REPOSITORY
  rHG Mercurial

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

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

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


D6814: revlog: add a `sidedata` parameters to addrevision

2019-09-07 Thread indygreg (Gregory Szorc)
indygreg added inline comments.

INLINE COMMENTS

> remotefilelog.py:133
>  def addrevision(self, text, transaction, linknode, p1, p2, 
> cachedelta=None,
> -node=None, flags=revlog.REVIDX_DEFAULT_FLAGS):
> +node=None, flags=revlog.REVIDX_DEFAULT_FLAGS, 
> sidedata=()):
>  # text passed to "addrevision" includes hg filelog metadata header

Why an empty tuple here? Isn't `None` more Pythonic?

REPOSITORY
  rHG Mercurial

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

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

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


D6807: flagprocessors: small code update to clarify parameters

2019-09-07 Thread marmoute (Pierre-Yves David)
Closed by commit rHG3bed541aa65d: flagprocessors: small code update to clarify 
parameters (authored by marmoute).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6807?vs=16412=16446#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6807?vs=16412=16446

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

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

AFFECTED FILES
  mercurial/revlogutils/flagutil.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -154,13 +154,13 @@
 processed text and ``validatehash`` is a bool indicating whether the
 returned text should be checked for hash integrity.
 """
-return self._processflagsfunc(text, flags, 'read', raw=True)[1]
+return self._processflagsfunc(text, flags, 'raw')[1]
 
-def _processflagsfunc(self, text, flags, operation, raw=False):
+def _processflagsfunc(self, text, flags, operation):
 # fast path: no flag processors will run
 if flags == 0:
 return text, True
-if not operation in ('read', 'write'):
+if operation not in ('read', 'write', 'raw'):
 raise error.ProgrammingError(_("invalid '%s' operation") %
  operation)
 # Check all flags are known.
@@ -188,7 +188,7 @@
 if processor is not None:
 readtransform, writetransform, rawtransform = processor
 
-if raw:
+if operation == 'raw':
 vhash = rawtransform(self, text)
 elif operation == 'read':
 text, vhash = readtransform(self, text)



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


D6804: revlog: stop using `_processflags` directly

2019-09-07 Thread marmoute (Pierre-Yves David)
Closed by commit rHG4a3efe0febb5: revlog: stop using `_processflags` directly 
(authored by marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6804?vs=16409=16443

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

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1649,7 +1649,11 @@
 # no extra flags set, no flag processor runs, text = rawtext
 return rawtext
 
-text, validatehash = self._processflags(rawtext, flags, 'read', 
raw=raw)
+if raw:
+validatehash = self._processflagsraw(rawtext, flags)
+text = rawtext
+else:
+text, validatehash = self._processflagsread(rawtext, flags)
 if validatehash:
 self.checkhash(text, node, rev=rev)
 if not validated:



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


D6807: flagprocessors: small code update to clarify parameters

2019-09-07 Thread indygreg (Gregory Szorc)
This revision is now accepted and ready to land.
indygreg added inline comments.
indygreg accepted this revision.

INLINE COMMENTS

> flagutil.py:163
>  return text, True
> -if not operation in ('read', 'write'):
> +if not operation in ('read', 'write', 'raw'):
>  raise error.ProgrammingError(_("invalid '%s' operation") %

I'm going to change this to use `not in` in flight.

REPOSITORY
  rHG Mercurial

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

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

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


D6806: flagprocessors: _processflags

2019-09-07 Thread marmoute (Pierre-Yves David)
Closed by commit rHG519b45603880: flagprocessors: deprecate _processflags 
(authored by marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6806?vs=16411=16445

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

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

AFFECTED FILES
  mercurial/revlogutils/flagutil.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -91,6 +91,8 @@
 
 def _processflags(self, text, flags, operation, raw=False):
 """deprecated entry point to access flag processors"""
+msg = ('_processflag(...) use the specialized variant')
+util.nouideprecwarn(msg, '5.2', stacklevel=2)
 if raw:
 return text, self._processflagsraw(text, flags)
 elif operation == 'read':



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


D6800: flagprocessors: introduce specialized functions

2019-09-07 Thread indygreg (Gregory Szorc)
indygreg added inline comments.

INLINE COMMENTS

> flagutil.py:151
> +
> +Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
> +processed text and ``validatehash`` is a bool indicating whether the

Please follow-up with a fix for the docstring to reflect that this does not 
return a 2-tuple.

REPOSITORY
  rHG Mercurial

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

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

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


D6826: py3: drop incorrect fsencode(findexe(...)) in procutil

2019-09-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I recently added the bad call, thinking that findexe() was a standard
  library function returning a string result, but it's actually our own
  function returning bytes. Thanks to Yuya for noticing.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/utils/procutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -245,11 +245,8 @@
 pycompat.fsencode(getattr(mainmod, '__file__', ''))) == 'hg'):
 _sethgexecutable(pycompat.fsencode(mainmod.__file__))
 else:
-exe = findexe('hg')
-if exe:
-_sethgexecutable(pycompat.fsencode(exe))
-else:
-_sethgexecutable(os.path.basename(pycompat.sysargv[0]))
+_sethgexecutable(findexe('hg') or
+ os.path.basename(pycompat.sysargv[0]))
 return _hgexecutable
 
 def _sethgexecutable(path):



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


D6801: flagprocessors: use _processflagswrite for write operation

2019-09-07 Thread marmoute (Pierre-Yves David)
Closed by commit rHGdb4af1cb128a: flagprocessors: use _processflagswrite for 
write operation (authored by marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6801?vs=16406=16439

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

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

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py
  mercurial/revlog.py
  tests/simplestorerepo.py

CHANGE DETAILS

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -452,7 +452,7 @@
 if flags:
 node = node or storageutil.hashrevisionsha1(text, p1, p2)
 
-rawtext, validatehash = self._processflags(text, flags, 'write')
+rawtext, validatehash = self._processflagswrite(text, flags)
 
 node = node or storageutil.hashrevisionsha1(text, p1, p2)
 
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1823,7 +1823,7 @@
 if flags:
 node = node or self.hash(text, p1, p2)
 
-rawtext, validatehash = self._processflags(text, flags, 'write')
+rawtext, validatehash = self._processflagswrite(text, flags)
 
 # If the flag processor modifies the revision data, ignore any provided
 # cachedelta.
diff --git a/hgext/remotefilelog/remotefilelog.py 
b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -135,7 +135,7 @@
 node = storageutil.hashrevisionsha1(text, p1, p2)
 
 meta, metaoffset = storageutil.parsemeta(text)
-rawtext, validatehash = self._processflags(text, flags, 'write')
+rawtext, validatehash = self._processflagswrite(text, flags)
 return self.addrawrevision(rawtext, transaction, linknode, p1, p2,
node, flags, cachedelta,
_metatuple=(meta, metaoffset))



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


D6803: flagprocessors: use _processflagsraw in easy cases

2019-09-07 Thread marmoute (Pierre-Yves David)
Closed by commit rHG1ebf1a1e14dd: flagprocessors: use _processflagsraw in easy 
cases (authored by marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6803?vs=16408=16441

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

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

AFFECTED FILES
  mercurial/revlogutils/deltas.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py
+++ b/mercurial/revlogutils/deltas.py
@@ -521,8 +521,7 @@
 fulltext = mdiff.patch(basetext, delta)
 
 try:
-res = revlog._processflags(fulltext, flags, 'read', raw=True)
-fulltext, validatehash = res
+validatehash = revlog._processflagsraw(fulltext, flags)
 if validatehash:
 revlog.checkhash(fulltext, expectednode, p1=p1, p2=p2)
 if flags & REVIDX_ISCENSORED:



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


D6802: flagprocessors: use _processflagsread in simple cases

2019-09-07 Thread marmoute (Pierre-Yves David)
Closed by commit rHGa3665eed228f: flagprocessors: use _processflagsread in 
simple cases (authored by marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6802?vs=16407=16440

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

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

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py

CHANGE DETAILS

diff --git a/hgext/remotefilelog/remotefilelog.py 
b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -324,7 +324,7 @@
 flags = store.getmeta(self.filename, node).get(constants.METAKEYFLAG, 
0)
 if flags == 0:
 return rawtext
-text, verifyhash = self._processflags(rawtext, flags, 'read')
+text, verifyhash = self._processflagsread(rawtext, flags)
 return text
 
 def rawdata(self, node):



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


D6800: flagprocessors: introduce specialized functions

2019-09-07 Thread marmoute (Pierre-Yves David)
Closed by commit rHG87a934684c3b: flagprocessors: introduce specialized 
functions (authored by marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6800?vs=16405=16438

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

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

AFFECTED FILES
  mercurial/revlogutils/flagutil.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -90,12 +90,20 @@
 _flagserrorclass = error.RevlogError
 
 def _processflags(self, text, flags, operation, raw=False):
-"""Inspect revision data flags and applies transforms defined by
-registered flag processors.
+"""deprecated entry point to access flag processors"""
+if raw:
+return text, self._processflagsraw(text, flags)
+elif operation == 'read':
+return self._processflagsread(text, flags)
+else: # write operation
+return self._processflagswrite(text, flags)
+
+def _processflagsread(self, text, flags):
+"""Inspect revision data flags and applies read transformations defined
+by registered flag processors.
 
 ``text`` - the revision data to process
 ``flags`` - the revision flags
-``operation`` - the operation being performed (read or write)
 ``raw`` - an optional argument describing if the raw transform should 
be
 applied.
 
@@ -107,10 +115,46 @@
 Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
 processed text and ``validatehash`` is a bool indicating whether the
 returned text should be checked for hash integrity.
+"""
+return self._processflagsfunc(text, flags, 'read')
 
-Note: If the ``raw`` argument is set, it has precedence over the
-operation and will only update the value of ``validatehash``.
+def _processflagswrite(self, text, flags):
+"""Inspect revision data flags and applies write transformations 
defined
+by registered flag processors.
+
+``text`` - the revision data to process
+``flags`` - the revision flags
+
+This method processes the flags in the order (or reverse order if
+``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
+flag processors registered for present flags. The order of flags 
defined
+in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
+
+Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
+processed text and ``validatehash`` is a bool indicating whether the
+returned text should be checked for hash integrity.
 """
+return self._processflagsfunc(text, flags, 'write')
+
+def _processflagsraw(self, text, flags):
+"""Inspect revision data flags to check is the content hash should be
+validated.
+
+``text`` - the revision data to process
+``flags`` - the revision flags
+
+This method processes the flags in the order (or reverse order if
+``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
+flag processors registered for present flags. The order of flags 
defined
+in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
+
+Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
+processed text and ``validatehash`` is a bool indicating whether the
+returned text should be checked for hash integrity.
+"""
+return self._processflagsfunc(text, flags, 'read', raw=True)[1]
+
+def _processflagsfunc(self, text, flags, operation, raw=False):
 # fast path: no flag processors will run
 if flags == 0:
 return text, True



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


D6800: flagprocessors: introduce specialized functions

2019-09-07 Thread indygreg (Gregory Szorc)
This revision is now accepted and ready to land.
indygreg added inline comments.
indygreg accepted this revision.

INLINE COMMENTS

> flagutil.py:98
> +return self._processflagsread(text, flags)
> +else: # write operation
> +return self._processflagswrite(text, flags)

Please follow up to make this more strongly typed by checking `operation == 
'write'`.

REPOSITORY
  rHG Mercurial

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

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

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


D6796: flagutil: introduce a flagprocessorsmixin class

2019-09-07 Thread marmoute (Pierre-Yves David)
Closed by commit rHG5bb68fb72df2: flagutil: introduce a flagprocessorsmixin 
class (authored by marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6796?vs=16401=16434

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

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

AFFECTED FILES
  mercurial/revlog.py
  mercurial/revlogutils/flagutil.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -78,3 +78,74 @@
 msg = _("cannot register multiple processors on flag '%#x'.") % (flag)
 raise error.Abort(msg)
 flagprocessors[flag] = processor
+
+class flagprocessorsmixin(object):
+"""basic mixin to support revlog flag processing
+
+Make sure the `_flagprocessors` attribute is set at ``__init__`` time.
+
+See the documentation of the ``_processflags`` method for details.
+"""
+
+def _processflags(self, text, flags, operation, raw=False):
+"""Inspect revision data flags and applies transforms defined by
+registered flag processors.
+
+``text`` - the revision data to process
+``flags`` - the revision flags
+``operation`` - the operation being performed (read or write)
+``raw`` - an optional argument describing if the raw transform should 
be
+applied.
+
+This method processes the flags in the order (or reverse order if
+``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
+flag processors registered for present flags. The order of flags 
defined
+in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
+
+Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
+processed text and ``validatehash`` is a bool indicating whether the
+returned text should be checked for hash integrity.
+
+Note: If the ``raw`` argument is set, it has precedence over the
+operation and will only update the value of ``validatehash``.
+"""
+# fast path: no flag processors will run
+if flags == 0:
+return text, True
+if not operation in ('read', 'write'):
+raise error.ProgrammingError(_("invalid '%s' operation") %
+ operation)
+# Check all flags are known.
+if flags & ~REVIDX_KNOWN_FLAGS:
+raise error.RevlogError(_("incompatible revision flag '%#x'") %
+(flags & ~REVIDX_KNOWN_FLAGS))
+validatehash = True
+# Depending on the operation (read or write), the order might be
+# reversed due to non-commutative transforms.
+orderedflags = REVIDX_FLAGS_ORDER
+if operation == 'write':
+orderedflags = reversed(orderedflags)
+
+for flag in orderedflags:
+# If a flagprocessor has been registered for a known flag, apply 
the
+# related operation transform and update result tuple.
+if flag & flags:
+vhash = True
+
+if flag not in self._flagprocessors:
+message = _("missing processor for flag '%#x'") % (flag)
+raise error.RevlogError(message)
+
+processor = self._flagprocessors[flag]
+if processor is not None:
+readtransform, writetransform, rawtransform = processor
+
+if raw:
+vhash = rawtransform(self, text)
+elif operation == 'read':
+text, vhash = readtransform(self, text)
+else: # write operation
+text, vhash = writetransform(self, text)
+validatehash = validatehash and vhash
+
+return text, validatehash
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -261,7 +261,7 @@
 p = versionformat_pack(version) + p[4:]
 return p
 
-class revlog(object):
+class revlog(flagutil.flagprocessorsmixin):
 """
 the underlying revision storage object
 
@@ -1715,69 +1715,6 @@
 """
 return storageutil.hashrevisionsha1(text, p1, p2)
 
-def _processflags(self, text, flags, operation, raw=False):
-"""Inspect revision data flags and applies transforms defined by
-registered flag processors.
-
-``text`` - the revision data to process
-``flags`` - the revision flags
-``operation`` - the operation being performed (read or write)
-``raw`` - an optional argument describing if the raw transform should 
be
-applied.
-
-This method processes the flags in the order (or reverse order if
-``operation`` is 

D6799: flagutil: use it in simplestorerepo

2019-09-07 Thread marmoute (Pierre-Yves David)
Closed by commit rHG705428da231f: flagutil: use it in simplestorerepo (authored 
by marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6799?vs=16404=16437

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

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

AFFECTED FILES
  tests/simplestorerepo.py

CHANGE DETAILS

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -91,7 +91,7 @@
 node = attr.ib(default=None)
 
 @interfaceutil.implementer(repository.ifilestorage)
-class filestorage(object):
+class filestorage(flagutil.flagprocessorsmixin):
 """Implements storage for a tracked path.
 
 Data is stored in the VFS in a directory corresponding to the tracked
@@ -102,6 +102,8 @@
 Fulltext data is stored in files having names of the node.
 """
 
+_flagserrorclass = simplestoreerror
+
 def __init__(self, svfs, path):
 self._svfs = svfs
 self._path = path
@@ -119,6 +121,8 @@
 self._index = []
 self._refreshindex()
 
+self._flagprocessors = dict(flagutil.flagprocessors)
+
 def _refreshindex(self):
 self._indexbynode.clear()
 self._indexbyrev.clear()
@@ -263,45 +267,6 @@
 
 return True
 
-def _processflags(self, text, flags, operation, raw=False):
-if flags == 0:
-return text, True
-
-if flags & ~flagutil.REVIDX_KNOWN_FLAGS:
-raise simplestoreerror(_("incompatible revision flag '%#x'") %
-   (flags & ~flagutil.REVIDX_KNOWN_FLAGS))
-
-validatehash = True
-# Depending on the operation (read or write), the order might be
-# reversed due to non-commutative transforms.
-orderedflags = revlog.REVIDX_FLAGS_ORDER
-if operation == 'write':
-orderedflags = reversed(orderedflags)
-
-for flag in orderedflags:
-# If a flagprocessor has been registered for a known flag, apply 
the
-# related operation transform and update result tuple.
-if flag & flags:
-vhash = True
-
-if flag not in revlog._flagprocessors:
-message = _("missing processor for flag '%#x'") % (flag)
-raise simplestoreerror(message)
-
-processor = revlog._flagprocessors[flag]
-if processor is not None:
-readtransform, writetransform, rawtransform = processor
-
-if raw:
-vhash = rawtransform(self, text)
-elif operation == 'read':
-text, vhash = readtransform(self, text)
-else:  # write operation
-text, vhash = writetransform(self, text)
-validatehash = validatehash and vhash
-
-return text, validatehash
-
 def checkhash(self, text, node, p1=None, p2=None, rev=None):
 if p1 is None and p2 is None:
 p1, p2 = self.parents(node)



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


D6798: flagutil: make the error class used by the mixin configurable

2019-09-07 Thread marmoute (Pierre-Yves David)
Closed by commit rHG7907008a0bb5: flagutil: make the error class used by the 
mixin configurable (authored by marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6798?vs=16403=16436

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

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

AFFECTED FILES
  mercurial/revlogutils/flagutil.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -87,6 +87,8 @@
 See the documentation of the ``_processflags`` method for details.
 """
 
+_flagserrorclass = error.RevlogError
+
 def _processflags(self, text, flags, operation, raw=False):
 """Inspect revision data flags and applies transforms defined by
 registered flag processors.
@@ -117,8 +119,8 @@
  operation)
 # Check all flags are known.
 if flags & ~REVIDX_KNOWN_FLAGS:
-raise error.RevlogError(_("incompatible revision flag '%#x'") %
-(flags & ~REVIDX_KNOWN_FLAGS))
+raise self._flagserrorclass(_("incompatible revision flag '%#x'") %
+(flags & ~REVIDX_KNOWN_FLAGS))
 validatehash = True
 # Depending on the operation (read or write), the order might be
 # reversed due to non-commutative transforms.
@@ -134,7 +136,7 @@
 
 if flag not in self._flagprocessors:
 message = _("missing processor for flag '%#x'") % (flag)
-raise error.RevlogError(message)
+raise self._flagserrorclass(message)
 
 processor = self._flagprocessors[flag]
 if processor is not None:



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


D6797: flagutil: use the new mixin use in remotefilelog

2019-09-07 Thread marmoute (Pierre-Yves David)
Closed by commit rHGa5c088966d6c: flagutil: use the new mixin use in 
remotefilelog (authored by marmoute).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6797?vs=16402=16435#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6797?vs=16402=16435

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

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

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py

CHANGE DETAILS

diff --git a/hgext/remotefilelog/remotefilelog.py 
b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -24,6 +24,7 @@
 revlog,
 )
 from mercurial.utils import storageutil
+from mercurial.revlogutils import flagutil
 
 from . import (
 constants,
@@ -45,7 +46,7 @@
 raise KeyError(node)
 return node
 
-class remotefilelog(object):
+class remotefilelog(flagutil.flagprocessorsmixin):
 
 _generaldelta = True
 
@@ -57,6 +58,8 @@
 
 self.version = 1
 
+self._flagprocessors = dict(flagutil.flagprocessors)
+
 def read(self, node):
 """returns the file contents at this node"""
 t = self.revision(node)
@@ -327,28 +330,6 @@
 def rawdata(self, node):
 return self.revision(node, raw=False)
 
-def _processflags(self, text, flags, operation, raw=False):
-# mostly copied from hg/mercurial/revlog.py
-validatehash = True
-orderedflags = revlog.REVIDX_FLAGS_ORDER
-if operation == 'write':
-orderedflags = reversed(orderedflags)
-for flag in orderedflags:
-if flag & flags:
-vhash = True
-if flag not in revlog._flagprocessors:
-message = _("missing processor for flag '%#x'") % (flag)
-raise revlog.RevlogError(message)
-readfunc, writefunc, rawfunc = revlog._flagprocessors[flag]
-if raw:
-vhash = rawfunc(self, text)
-elif operation == 'read':
-text, vhash = readfunc(self, text)
-elif operation == 'write':
-text, vhash = writefunc(self, text)
-validatehash = validatehash and vhash
-return text, validatehash
-
 def _read(self, id):
 """reads the raw file blob from disk, cache, or server"""
 fileservice = self.repo.fileservice



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


D6789: check-code: allow command substitution with $(command)

2019-09-07 Thread martinvonz (Martin von Zweigbergk)
Closed by commit rHG4257c33e24b7: check-code: allow command substitution with 
$(command) (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6789?vs=16394=16433

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

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

AFFECTED FILES
  contrib/check-code.py

CHANGE DETAILS

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -116,7 +116,6 @@
 (r'\bls\b.*-\w*R', "don't use 'ls -R', use 'find'"),
 (r'printf.*[^\\]\\([1-9]|0\d)', r"don't use 'printf \NNN', use Python"),
 (r'printf.*[^\\]\\x', "don't use printf \\x, use Python"),
-(r'\$\(.*\)', "don't use $(expr), use `expr`"),
 (r'rm -rf \*', "don't use naked rm -rf, target a directory"),
 (r'\[[^\]]+==', '[ foo == bar ] is a bashism, use [ foo = bar ] instead'),
 (r'(^|\|\s*)grep (-\w\s+)*[^|]*[(|]\w',



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


D6796: flagutil: introduce a flagprocessorsmixin class

2019-09-07 Thread indygreg (Gregory Szorc)
indygreg added a comment.


  I'm going to attempt to look at this series...

REPOSITORY
  rHG Mercurial

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

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

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


D6788: hgweb: fix websub regex flag syntax on Python 3

2019-09-07 Thread indygreg (Gregory Szorc)
This revision now requires changes to proceed.
indygreg added a comment.
indygreg requested changes to this revision.


  Nice catch!

INLINE COMMENTS

> webutil.py:794
>  if flagin:
> -for flag in flagin.upper():
> +for flag in flagin.upper().decode('ascii'):
>  flags |= re.__dict__[flag]

I think `pycompat.sysstr()` is more appropriate here, since it won't convert 
the `str` to `unicode` on Python 2.

REPOSITORY
  rHG Mercurial

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

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

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


D6787: test: allow different result for zstd compression (issue6188)

2019-09-07 Thread jcristau (Julien Cristau)
Closed by commit rHGda2c360899c9: test: allow different result for zstd 
compression (issue6188) (authored by jcristau).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6787?vs=16390=16432

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

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

AFFECTED FILES
  tests/test-repo-compengines.t

CHANGE DETAILS

diff --git a/tests/test-repo-compengines.t b/tests/test-repo-compengines.t
--- a/tests/test-repo-compengines.t
+++ b/tests/test-repo-compengines.t
@@ -171,7 +171,7 @@
   $ $RUNTESTDIR/f -s zstd-*/.hg/store/data/*
   zstd-level-1/.hg/store/data/a.i: size=4097
   zstd-level-22/.hg/store/data/a.i: size=4091
-  zstd-level-default/.hg/store/data/a.i: size=4094
+  zstd-level-default/\.hg/store/data/a\.i: size=(4094|4102) (re)
 
 Test error cases
 



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


Re: [PATCH 1 of 9] run-tests: use symbolic constant instead of arbitrary number line matching

2019-09-07 Thread Gregory Szorc
On Sat, Sep 7, 2019 at 5:31 AM Pierre-Yves David <
pierre-yves.da...@ens-lyon.org> wrote:

> # HG changeset patch
> # User Pierre-Yves David 
> # Date 1560517187 -3600
> #  Fri Jun 14 13:59:47 2019 +0100
> # Node ID f927343f31b96019d36f0546f71ebe9a357b0123
> # Parent  69195b6f8f974ba56aec9b9bd4cd0a259a646f72
> # EXP-Topic test-match
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
> f927343f31b9
> run-tests: use symbolic constant instead of arbitrary number line matching
>

Queued parts 1-4.


>
> (This is a gratuitous cleanup that I made while investigating a bug).
>
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -1302,6 +1302,10 @@ bchr = chr
>  if PYTHON3:
>  bchr = lambda x: bytes([x])
>
> +WARN_UNDEFINED = 1
> +WARN_YES = 2
> +WARN_NO = 3
> +
>  class TTest(Test):
>  """A "t test" is a test backed by a .t file."""
>
> @@ -1601,9 +1605,9 @@ class TTest(Test):
>
>  def _processoutput(self, exitcode, output, salt, after, expected):
>  # Merge the script output back into a unified test.
> -warnonly = 1 # 1: not yet; 2: yes; 3: for sure not
> +warnonly = WARN_UNDEFINED # 1: not yet; 2: yes; 3: for sure not
>  if exitcode != 0:
> -warnonly = 3
> +warnonly = WARN_NO
>
>  pos = -1
>  postout = []
> @@ -1670,9 +1674,9 @@ class TTest(Test):
> lout.rstrip(b'\n'))
>  postout.append(b'  ' + lout) # Let diff deal with it.
>  if r != '': # If line failed.
> -warnonly = 3 # for sure not
> -elif warnonly == 1: # Is "not yet" and line is warn
> only.
> -warnonly = 2 # Yes do warn.
> +warnonly = WARN_NO
> +elif warnonly == WARN_UNDEFINED:
> +warnonly = WARN_YES
>  break
>  else:
>  # clean up any optional leftovers
> @@ -1704,7 +1708,7 @@ class TTest(Test):
>  if pos in after:
>  postout += after.pop(pos)
>
> -if warnonly == 2:
> +if warnonly == WARN_YES:
>  exitcode = False # Set exitcode to warned.
>
>  return exitcode, postout
> ___
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6825: contrib: start building a library for simple hooks

2019-09-07 Thread joerg.sonnenberger (Joerg Sonnenberger)
joerg.sonnenberger updated this revision to Diff 16431.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6825?vs=16430=16431

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

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

AFFECTED FILES
  contrib/hooks/enforce_draft_commits.py
  contrib/hooks/reject_merge_commits.py
  contrib/hooks/reject_new_heads.py

CHANGE DETAILS

diff --git a/contrib/hooks/reject_new_heads.py 
b/contrib/hooks/reject_new_heads.py
new file mode 100644
--- /dev/null
+++ b/contrib/hooks/reject_new_heads.py
@@ -0,0 +1,25 @@
+# This hook checks branches touched by new changesets have at most one
+# open head. It can be used to enforce policies for merge-before-push
+# or rebase-before-push. It does not handle pre-existing hydras.
+#
+# Usage:
+# [hooks]
+# pretxnclose.reject_new_heads = python:../reject_new_heads.py:hook
+
+from mercurial import (
+error,
+)
+from mercurial.i18n import _
+
+def hook(ui, repo, hooktype, node = None, **kwargs):
+if hooktype != "pretxnclose":
+   raise error.Abort(_('Unsupported hook type %s') % hooktype)
+ctx = repo.unfiltered()[node]
+branches = set()
+for rev in repo.changelog.revs(start=ctx.rev()):
+rev = repo[rev]
+branches.add(rev.branch())
+for branch in branches:
+if len(repo.revs("head() and not closed() and branch(%s)", branch)) > 
1:
+raise error.Abort(_('Changes on branch "%s" resulted '
+'in multiple heads') % branch)
diff --git a/contrib/hooks/reject_merge_commits.py 
b/contrib/hooks/reject_merge_commits.py
new file mode 100644
--- /dev/null
+++ b/contrib/hooks/reject_merge_commits.py
@@ -0,0 +1,27 @@
+# This hook checks new changesets for merge commits. Merge commits are allowed
+# only between different branches, i.e. merging a feature branch into the main
+# development branch. This can be used to enforce policies for linear commit
+# histories.
+#
+# Usage:
+# [hooks]
+# pretxnchangegroup.reject_merge_commits = 
python:../reject_merge_commits.py:hook
+
+from mercurial import (
+error,
+)
+from mercurial.i18n import _
+
+def hook(ui, repo, hooktype, node = None, **kwargs):
+if hooktype != "pretxnchangegroup":
+   raise error.Abort(_('Unsupported hook type %s'), hooktype)
+
+ctx = repo.unfiltered()[node]
+for rev in repo.changelog.revs(start=ctx.rev()):
+rev = repo[rev]
+parents = rev.parents()
+if len(parents) < 2:
+continue
+if all(repo[p].branch() == rev.branch() for p in parents):
+raise error.Abort(_('%s rejected as merge on the same branch. '
+'Please consider rebase.') % rev)
diff --git a/contrib/hooks/enforce_draft_commits.py 
b/contrib/hooks/enforce_draft_commits.py
new file mode 100644
--- /dev/null
+++ b/contrib/hooks/enforce_draft_commits.py
@@ -0,0 +1,25 @@
+# This hook checks that all new changesets are in the draft phase. This allows
+# enforcing policies for work-in-progress changes in overlay repositories,
+# i.e. a shared hidden repositories with different views for work-in-progress
+# code and public history.
+#
+# Usage:
+# [hooks]
+# pretxnclose-phase.enforce_draft_commits = 
python:../enforce_draft_commits.py:hook
+
+from mercurial import (
+error,
+phases,
+)
+from mercurial.i18n import _
+
+def hook(ui, repo, hooktype, node = None, **kwargs):
+if hooktype != "pretxnclose-phase":
+   raise error.Abort(_('Unsupported hook type %s'), hooktype)
+ctx = repo.unfiltered()[node]
+if kwargs['oldphase']:
+raise error.Abort(_('Phase change from %s to %s for %s rejected') %
+(kwargs['oldphase'], kwargs['phase'], ctx))
+elif kwargs['phase'] != 'draft':
+raise error.Abort(_('New changeset %s in phase %s rejected') %
+(ctx, kwargs['phase']))



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


D6825: contrib: start building a library for simple hooks

2019-09-07 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  Thanks a lot for putting efforts here. I am +1 on this. I haven't looked at 
the code though, will try to review if no one else beats me to it.

REPOSITORY
  rHG Mercurial

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

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

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


Re: Interest in integrating hg-git into Mercurial

2019-09-07 Thread Joerg Sonnenberger
On Thu, Aug 01, 2019 at 10:01:08AM -0700, Gregory Szorc wrote:
> Is there any interest in integrating hg-git (or hg-git functionality) into
> the Mercurial distribution as an officially supported extension?

We've been discussing this topic a bit during the Leipzig mini-sprint
now. I think there are three different cases for hg <-> git interaction
to be considered:

(1) Migrating a repository from git to hg, potentially multiple times.
(2) Migrating a repository from hg to git, potentially multiple times.
(3) Two-way synchronisation between hg and git.

The requirements in the the first two cases are quite different from the
third and it is useful to consider them standalone for that reason. Both
cases are addressed by supporting the fastimport format, either reading
or writing. I've needed a couple of changes for the hg-fastimport
extension to work well, but it is an integral part of the NetBSD
conversion chain right now. Changes are primarily dealing with non-UTF8
input (something "real" git shouldn't show) and smarter blob handling
(partially due to the way Fossil output is structured). I'm currently
looking at the fastexport (https://repo.or.cz/w/fast-export.git) tool,
but the performance looks mostly reasonable. One-way mirroring is much
simpler, because it doesn't have to try to provide stable mappings for
roundtrip consistency, the tooling just has to ensure that the mapping
is deterministic, so that rerunning the tool will result in identical
output. I believe having fastimport support in hgext would be a win,
without the need for vendoring dulwich etc.

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


Re: [PATCH 6 of 9] run-tests: extract a `process_cmd_line` from the main function

2019-09-07 Thread Joerg Sonnenberger
On Sat, Sep 07, 2019 at 02:16:45PM +0200, Pierre-Yves David wrote:
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -1619,6 +1619,7 @@ class TTest(Test):
>  if salt in out_rawline:
>  out_line, cmd_line = out_rawline.split(salt, 1)
>  
> +
>  while out_line:
>  if not out_line.endswith(b'\n'):
>  out_line += b' (no-eol)\n'

Extra newline?

> @@ -1699,15 +1700,8 @@ class TTest(Test):
>  continue
>  postout.append(b'  ' + el)
>  
> -if cmd_line:
> -# Add on last return code.
> -ret = int(cmd_line.split()[1])
> -if ret != 0:
> -postout.append(b'  [%d]\n' % ret)
> -if pos in after:
> -# Merge in non-active test bits.
> -postout += after.pop(pos)
> -pos = int(cmd_line.split()[0])
> +pos, postout = self._process_cmd_line(cmd_line, pos, postout, 
> after)
> +

I find the behavior with postout here a bit surprising. It is modified
in place, but also returned as value. IMO it should be either one or the
other? Also extra newline.

> @@ -1717,6 +1711,19 @@ class TTest(Test):
>  
>  return exitcode, postout
>  
> +def _process_cmd_line(self, cmd_line, pos, postout, after):
> +"""process a "command" part of a line from unified test output"""
> +if cmd_line:
> +# Add on last return code.
> +ret = int(cmd_line.split()[1])
> +if ret != 0:
> +postout.append(b'  [%d]\n' % ret)
> +if pos in after:
> +# Merge in non-active test bits.
> +postout += after.pop(pos)
> +pos = int(cmd_line.split()[0])
> +return pos, postout
> +

Does it make sense to mark it as staticmethod?

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


[PATCH STABLE] tests: register test-merge-combination.t as small but slow

2019-09-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1567860678 -7200
#  Sat Sep 07 14:51:18 2019 +0200
# Branch stable
# Node ID 0552670ad381a377768b40ee8ddd3454f5a400d5
# Parent  b22a8dadc6f52fd3d8f45ac71e71fe2be381017b
# EXP-Topic run-tests-scheduling
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
0552670ad381
tests: register test-merge-combination.t as small but slow

run-tests.py use file size as an heuristic for test run time. The new
`test-merge-combination.t` is a small file that do a lot of processing. As a
result it tend to be scheduled really late but delay the full test run by a lot.

On an example test run, the one-before-last test completed 279s after the start
of the run, while `test-merge-combination.t` finished 355s after it. A 76s
delay. This delay can be avoided since `test-merge-combination.t` only got 
started
175s after the start of the run.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -2513,6 +2513,7 @@ def sorttests(testdescs, previoustimes, 
 b'check': 100,
 b'gendoc': 100,
 b'contrib-perf': 200,
+b'merge-combination': 100,
 }
 perf = {}
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 5 of 9] run-tests: document the `pos` variable in the matching code

2019-09-07 Thread Joerg Sonnenberger
On Sat, Sep 07, 2019 at 02:16:44PM +0200, Pierre-Yves David wrote:
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -1609,6 +1609,9 @@ class TTest(Test):
>  if exitcode != 0:
>  warnonly = WARN_NO
>  
> +# `pos` is the key for the currently expected output it should match 
> an
> +# entry in `expected`. This `pos` is provided by "command" in the
> +# output stream. These command are recognised using the `salt`

That should be *on* entry.

>  pos = -1
>  postout = []
>  for out_rawline in output:
> @@ -1628,6 +1631,7 @@ class TTest(Test):
>  optional = []
>  for i, el in enumerate(els):
>  r = False
> +assert el is None or bool(el)
>  if el:
>  r, exact = self.linematch(el, out_line)
>  if isinstance(r, str):

Is this chunk intentional?

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


Re: D6824: notify: add option for deterministic message-id generation

2019-09-07 Thread Joerg Sonnenberger
On Sat, Sep 07, 2019 at 11:40:44AM +, joerg.sonnenberger (Joerg 
Sonnenberger) wrote:
> REVISION DETAIL
>   https://phab.mercurial-scm.org/D6824

Pierre-Yves asked offline why I asked a new option for this and why it
is not the default. Message-Id is supposed to be unique world-wide and
while it is desirable to have a deterministic mechanism for them for
creating follow-up emails, it needs organisational control for ensuring
the uniqueness.

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


D6825: contrib: start building a library for simple hooks

2019-09-07 Thread joerg.sonnenberger (Joerg Sonnenberger)
joerg.sonnenberger created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Many workflows depend on hooks to enforce certain policies, e.g. to
  prevent forced pushes. The Mercurial Guide includes some cases and
  Google can help finding others, but it can save users a lot of time
  if hg itself has a couple of examples for further customization.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/hooks/enforce_draft_commits.py
  contrib/hooks/reject_merge_commits.py
  contrib/hooks/reject_new_heads.py

CHANGE DETAILS

diff --git a/contrib/hooks/reject_new_heads.py 
b/contrib/hooks/reject_new_heads.py
new file mode 100644
--- /dev/null
+++ b/contrib/hooks/reject_new_heads.py
@@ -0,0 +1,25 @@
+# This hook checks branches touched new changesets have at most one
+# open head. It can be used to enforce policies for merge-before-push
+# or rebase-before-push. It does not handle pre-existing hydras.
+#
+# Usage:
+# [hooks]
+# pretxnclose.reject_new_heads = python:../reject_new_heads.py:hook
+
+from mercurial import (
+error,
+)
+from mercurial.i18n import _
+
+def hook(ui, repo, hooktype, node = None, **kwargs):
+if hooktype != "pretxnclose":
+   raise error.Abort(_('Unsupported hook type %s') % hooktype)
+ctx = repo.unfiltered()[node]
+branches = set()
+for rev in repo.changelog.revs(start=ctx.rev()):
+rev = repo[rev]
+branches.add(rev.branch())
+for branch in branches:
+if len(repo.revs("head() and not closed() and branch(%s)", branch)) > 
1:
+raise error.Abort(_('Changes on branch "%s" resulted '
+'in multiple heads') % branch)
diff --git a/contrib/hooks/reject_merge_commits.py 
b/contrib/hooks/reject_merge_commits.py
new file mode 100644
--- /dev/null
+++ b/contrib/hooks/reject_merge_commits.py
@@ -0,0 +1,27 @@
+# This hook checks new changesets for merge commits. Merge commits are allowed
+# only between different branches, i.e. merging a feature branch into the main
+# development branch. This can be used to enforce policies for linear commit
+# histories.
+#
+# Usage:
+# [hooks]
+# pretxnchangegroup.reject_merge_commits = 
python:../reject_merge_commits.py:hook
+
+from mercurial import (
+error,
+)
+from mercurial.i18n import _
+
+def hook(ui, repo, hooktype, node = None, **kwargs):
+if hooktype != "pretxnchangegroup":
+   raise error.Abort(_('Unsupported hook type %s'), hooktype)
+
+ctx = repo.unfiltered()[node]
+for rev in repo.changelog.revs(start=ctx.rev()):
+rev = repo[rev]
+parents = rev.parents()
+if len(parents) < 2:
+continue
+if all(repo[p].branch() == rev.branch() for p in parents):
+raise error.Abort(_('%s rejected as merge on the same branch. '
+'Please consider rebase.') % rev)
diff --git a/contrib/hooks/enforce_draft_commits.py 
b/contrib/hooks/enforce_draft_commits.py
new file mode 100644
--- /dev/null
+++ b/contrib/hooks/enforce_draft_commits.py
@@ -0,0 +1,25 @@
+# This hook checks that all new changesets are in drafts. This allows
+# enforcing policies for work-in-progress changes in overlay repositories,
+# i.e. a shared hidden repositories with different views for work-in-progress
+# code and public history.
+#
+# Usage:
+# [hooks]
+# pretxnclose-phase.enforce_draft_commits = 
python:../enforce_draft_commits.py:hook
+
+from mercurial import (
+error,
+phases,
+)
+from mercurial.i18n import _
+
+def hook(ui, repo, hooktype, node = None, **kwargs):
+if hooktype != "pretxnclose-phase":
+   raise error.Abort(_('Unsupported hook type %s'), hooktype)
+ctx = repo.unfiltered()[node]
+if kwargs['oldphase']:
+raise error.Abort(_('Phase change from %s to %s for %s rejected') %
+(kwargs['oldphase'], kwargs['phase'], ctx))
+elif kwargs['phase'] != 'draft':
+raise error.Abort(_('New changeset %s in phase %s rejected') %
+(ctx, kwargs['phase']))



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


[PATCH 8 of 9] run-tests: remove the artificial indentation

2019-09-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1560530356 -3600
#  Fri Jun 14 17:39:16 2019 +0100
# Node ID df7d3a5c505f6f0dd7e0ed63dd91b526e2ef1893
# Parent  37175973a3ca496e7d32044e342f88ad8894f69b
# EXP-Topic test-match
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
df7d3a5c505f
run-tests: remove the artificial indentation

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1638,86 +1638,85 @@ class TTest(Test):
 return exitcode, postout
 
 def _process_out_line(self, out_line, pos, postout, expected, warnonly):
-if True:
-while out_line:
-if not out_line.endswith(b'\n'):
-out_line += b' (no-eol)\n'
-
-# Find the expected output at the current position.
-els = [None]
-if expected.get(pos, None):
-els = expected[pos]
-
-optional = []
-for i, el in enumerate(els):
-r = False
-assert el is None or bool(el)
-if el:
-r, exact = self.linematch(el, out_line)
-if isinstance(r, str):
-if r == '-glob':
-out_line = ''.join(el.rsplit(' (glob)', 1))
-r = '' # Warn only this line.
-elif r == "retry":
-postout.append(b'  ' + el)
-else:
-log('\ninfo, unknown linematch result: %r\n' % r)
-r = False
-if r:
+while out_line:
+if not out_line.endswith(b'\n'):
+out_line += b' (no-eol)\n'
+
+# Find the expected output at the current position.
+els = [None]
+if expected.get(pos, None):
+els = expected[pos]
+
+optional = []
+for i, el in enumerate(els):
+r = False
+assert el is None or bool(el)
+if el:
+r, exact = self.linematch(el, out_line)
+if isinstance(r, str):
+if r == '-glob':
+out_line = ''.join(el.rsplit(' (glob)', 1))
+r = '' # Warn only this line.
+elif r == "retry":
+postout.append(b'  ' + el)
+else:
+log('\ninfo, unknown linematch result: %r\n' % r)
+r = False
+if r:
+els.pop(i)
+break
+if el:
+if el.endswith(b" (?)\n"):
+optional.append(i)
+else:
+m = optline.match(el)
+if m:
+conditions = [
+c for c in m.group(2).split(b' ')]
+
+if not self._iftest(conditions):
+optional.append(i)
+if exact:
+# Don't allow line to be matches against a later
+# line in the output
 els.pop(i)
 break
-if el:
-if el.endswith(b" (?)\n"):
-optional.append(i)
+
+if r:
+if r == "retry":
+continue
+# clean up any optional leftovers
+for i in optional:
+postout.append(b'  ' + els[i])
+for i in reversed(optional):
+del els[i]
+postout.append(b'  ' + el)
+else:
+if self.NEEDESCAPE(out_line):
+out_line = TTest._stringescape(b'%s (esc)\n' %
+   out_line.rstrip(b'\n'))
+postout.append(b'  ' + out_line) # Let diff deal with it.
+if r != '': # If line failed.
+warnonly = WARN_NO
+elif warnonly == WARN_UNDEFINED:
+warnonly = WARN_YES
+break
+else:
+# clean up any optional leftovers
+while expected.get(pos, None):
+el = expected[pos].pop(0)
+if el:
+if not el.endswith(b" (?)\n"):
+m = optline.match(el)
+if m:
+conditions = [c for c in m.group(2).split(b' ')]
+
+if self._iftest(conditions):
+# Don't append as optional line
+continue
 else:
-  

[PATCH 9 of 9] run-tests: add a dedicated 'isoptional' function

2019-09-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1560531004 -3600
#  Fri Jun 14 17:50:04 2019 +0100
# Node ID 8ab000ab9c72847951a986b931da2e035283c6c7
# Parent  df7d3a5c505f6f0dd7e0ed63dd91b526e2ef1893
# EXP-Topic test-match
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
8ab000ab9c72
run-tests: add a dedicated 'isoptional' function

This is clearer than repeated manual call to to 'endswith'.

(This is a gratuitous cleanup that I made while investigating a bug).

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1306,6 +1306,11 @@ WARN_UNDEFINED = 1
 WARN_YES = 2
 WARN_NO = 3
 
+MARK_OPTIONAL = b" (?)\n"
+
+def isoptional(line):
+return line.endswith(MARK_OPTIONAL)
+
 class TTest(Test):
 """A "t test" is a test backed by a .t file."""
 
@@ -1666,7 +1671,7 @@ class TTest(Test):
 els.pop(i)
 break
 if el:
-if el.endswith(b" (?)\n"):
+if isoptional(el):
 optional.append(i)
 else:
 m = optline.match(el)
@@ -1706,7 +1711,7 @@ class TTest(Test):
 while expected.get(pos, None):
 el = expected[pos].pop(0)
 if el:
-if not el.endswith(b" (?)\n"):
+if not isoptional(el):
 m = optline.match(el)
 if m:
 conditions = [c for c in m.group(2).split(b' ')]
@@ -1779,9 +1784,9 @@ class TTest(Test):
 if el == l: # perfect match (fast)
 return True, True
 retry = False
-if el.endswith(b" (?)\n"):
+if isoptional(el):
 retry = "retry"
-el = el[:-5] + b"\n"
+el = el[:-len(MARK_OPTIONAL)] + b"\n"
 else:
 m = optline.match(el)
 if m:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 6 of 9] run-tests: extract a `process_cmd_line` from the main function

2019-09-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1560529827 -3600
#  Fri Jun 14 17:30:27 2019 +0100
# Node ID e9d8154ab03d353fcc5284a10d943be0129e4f4e
# Parent  a8b6d502b98abcb4853d062d06cbb9d8168c8a32
# EXP-Topic test-match
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
e9d8154ab03d
run-tests: extract a `process_cmd_line` from the main function

The main function doing line comparison is quite complex. Slicing it in smaller
piece should clarify it.

(This is a gratuitous cleanup that I made while investigating a bug).

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1619,6 +1619,7 @@ class TTest(Test):
 if salt in out_rawline:
 out_line, cmd_line = out_rawline.split(salt, 1)
 
+
 while out_line:
 if not out_line.endswith(b'\n'):
 out_line += b' (no-eol)\n'
@@ -1699,15 +1700,8 @@ class TTest(Test):
 continue
 postout.append(b'  ' + el)
 
-if cmd_line:
-# Add on last return code.
-ret = int(cmd_line.split()[1])
-if ret != 0:
-postout.append(b'  [%d]\n' % ret)
-if pos in after:
-# Merge in non-active test bits.
-postout += after.pop(pos)
-pos = int(cmd_line.split()[0])
+pos, postout = self._process_cmd_line(cmd_line, pos, postout, 
after)
+
 
 if pos in after:
 postout += after.pop(pos)
@@ -1717,6 +1711,19 @@ class TTest(Test):
 
 return exitcode, postout
 
+def _process_cmd_line(self, cmd_line, pos, postout, after):
+"""process a "command" part of a line from unified test output"""
+if cmd_line:
+# Add on last return code.
+ret = int(cmd_line.split()[1])
+if ret != 0:
+postout.append(b'  [%d]\n' % ret)
+if pos in after:
+# Merge in non-active test bits.
+postout += after.pop(pos)
+pos = int(cmd_line.split()[0])
+return pos, postout
+
 @staticmethod
 def rematch(el, l):
 try:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 7 of 9] run-tests: extract a `process_out_line` from the main function

2019-09-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1560530224 -3600
#  Fri Jun 14 17:37:04 2019 +0100
# Node ID 37175973a3ca496e7d32044e342f88ad8894f69b
# Parent  e9d8154ab03d353fcc5284a10d943be0129e4f4e
# EXP-Topic test-match
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
37175973a3ca
run-tests: extract a `process_out_line` from the main function

The main function doing line comparison is quite complex. Slicing it in smaller
piece should clarify it.

To avoid a huge diff, the code is kept at the same indentation. We'll re-indent
in the next changesets.

(This is a gratuitous cleanup that I made while investigating a bug).

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1620,6 +1620,25 @@ class TTest(Test):
 out_line, cmd_line = out_rawline.split(salt, 1)
 
 
+pos, postout, warnonly = self._process_out_line(out_line,
+pos,
+postout,
+expected,
+warnonly)
+pos, postout = self._process_cmd_line(cmd_line, pos, postout,
+  after)
+
+
+if pos in after:
+postout += after.pop(pos)
+
+if warnonly == WARN_YES:
+exitcode = False # Set exitcode to warned.
+
+return exitcode, postout
+
+def _process_out_line(self, out_line, pos, postout, expected, warnonly):
+if True:
 while out_line:
 if not out_line.endswith(b'\n'):
 out_line += b' (no-eol)\n'
@@ -1699,17 +1718,7 @@ class TTest(Test):
 else:
 continue
 postout.append(b'  ' + el)
-
-pos, postout = self._process_cmd_line(cmd_line, pos, postout, 
after)
-
-
-if pos in after:
-postout += after.pop(pos)
-
-if warnonly == WARN_YES:
-exitcode = False # Set exitcode to warned.
-
-return exitcode, postout
+return pos, postout, warnonly
 
 def _process_cmd_line(self, cmd_line, pos, postout, after):
 """process a "command" part of a line from unified test output"""
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 9] run-tests: rename `lout` variable to `out_line`

2019-09-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1560525874 -3600
#  Fri Jun 14 16:24:34 2019 +0100
# Node ID e1cadbe3265f0d4dd8fa6384a65254aee12a1a48
# Parent  fd5c60869c435d10960d060fd0bd37dfb7dcea3c
# EXP-Topic test-match
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
e1cadbe3265f
run-tests: rename `lout` variable to `out_line`

This is clearer and more in line with some other variable names.

(This is a gratuitous cleanup that I made while investigating a bug).

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1612,13 +1612,13 @@ class TTest(Test):
 pos = -1
 postout = []
 for out_rawline in output:
-lout, lcmd = out_rawline, None
+out_line, lcmd = out_rawline, None
 if salt in out_rawline:
-lout, lcmd = out_rawline.split(salt, 1)
-
-while lout:
-if not lout.endswith(b'\n'):
-lout += b' (no-eol)\n'
+out_line, lcmd = out_rawline.split(salt, 1)
+
+while out_line:
+if not out_line.endswith(b'\n'):
+out_line += b' (no-eol)\n'
 
 # Find the expected output at the current position.
 els = [None]
@@ -1629,10 +1629,10 @@ class TTest(Test):
 for i, el in enumerate(els):
 r = False
 if el:
-r, exact = self.linematch(el, lout)
+r, exact = self.linematch(el, out_line)
 if isinstance(r, str):
 if r == '-glob':
-lout = ''.join(el.rsplit(' (glob)', 1))
+out_line = ''.join(el.rsplit(' (glob)', 1))
 r = '' # Warn only this line.
 elif r == "retry":
 postout.append(b'  ' + el)
@@ -1669,10 +1669,10 @@ class TTest(Test):
 del els[i]
 postout.append(b'  ' + el)
 else:
-if self.NEEDESCAPE(lout):
-lout = TTest._stringescape(b'%s (esc)\n' %
-   lout.rstrip(b'\n'))
-postout.append(b'  ' + lout) # Let diff deal with it.
+if self.NEEDESCAPE(out_line):
+out_line = TTest._stringescape(b'%s (esc)\n' %
+   out_line.rstrip(b'\n'))
+postout.append(b'  ' + out_line) # Let diff deal with it.
 if r != '': # If line failed.
 warnonly = WARN_NO
 elif warnonly == WARN_UNDEFINED:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 5 of 9] run-tests: document the `pos` variable in the matching code

2019-09-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1560529354 -3600
#  Fri Jun 14 17:22:34 2019 +0100
# Node ID a8b6d502b98abcb4853d062d06cbb9d8168c8a32
# Parent  5a3595259384c15ebce94b662592e0091492a4b3
# EXP-Topic test-match
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
a8b6d502b98a
run-tests: document the `pos` variable in the matching code

3 months ago I took some time understand this code, let us not loose what I
learned.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1609,6 +1609,9 @@ class TTest(Test):
 if exitcode != 0:
 warnonly = WARN_NO
 
+# `pos` is the key for the currently expected output it should match an
+# entry in `expected`. This `pos` is provided by "command" in the
+# output stream. These command are recognised using the `salt`
 pos = -1
 postout = []
 for out_rawline in output:
@@ -1628,6 +1631,7 @@ class TTest(Test):
 optional = []
 for i, el in enumerate(els):
 r = False
+assert el is None or bool(el)
 if el:
 r, exact = self.linematch(el, out_line)
 if isinstance(r, str):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 4 of 9] run-tests: rename `lcmd` variable to `line_cmd`

2019-09-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1560525971 -3600
#  Fri Jun 14 16:26:11 2019 +0100
# Node ID 5a3595259384c15ebce94b662592e0091492a4b3
# Parent  e1cadbe3265f0d4dd8fa6384a65254aee12a1a48
# EXP-Topic test-match
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
5a3595259384
run-tests: rename `lcmd` variable to `line_cmd`

This is clearer and more in line with some other variable names.

(This is a gratuitous cleanup that I made while investigating a bug).

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1612,9 +1612,9 @@ class TTest(Test):
 pos = -1
 postout = []
 for out_rawline in output:
-out_line, lcmd = out_rawline, None
+out_line, cmd_line = out_rawline, None
 if salt in out_rawline:
-out_line, lcmd = out_rawline.split(salt, 1)
+out_line, cmd_line = out_rawline.split(salt, 1)
 
 while out_line:
 if not out_line.endswith(b'\n'):
@@ -1695,15 +1695,15 @@ class TTest(Test):
 continue
 postout.append(b'  ' + el)
 
-if lcmd:
+if cmd_line:
 # Add on last return code.
-ret = int(lcmd.split()[1])
+ret = int(cmd_line.split()[1])
 if ret != 0:
 postout.append(b'  [%d]\n' % ret)
 if pos in after:
 # Merge in non-active test bits.
 postout += after.pop(pos)
-pos = int(lcmd.split()[0])
+pos = int(cmd_line.split()[0])
 
 if pos in after:
 postout += after.pop(pos)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 9] run-tests: clarify "l" variable as "out_rawline"

2019-09-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1560518057 -3600
#  Fri Jun 14 14:14:17 2019 +0100
# Node ID fd5c60869c435d10960d060fd0bd37dfb7dcea3c
# Parent  f927343f31b96019d36f0546f71ebe9a357b0123
# EXP-Topic test-match
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
fd5c60869c43
run-tests: clarify "l" variable as "out_rawline"

More explicit variable name never hurt.

(This is a gratuitous cleanup that I made while investigating a bug).

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1611,10 +1611,10 @@ class TTest(Test):
 
 pos = -1
 postout = []
-for l in output:
-lout, lcmd = l, None
-if salt in l:
-lout, lcmd = l.split(salt, 1)
+for out_rawline in output:
+lout, lcmd = out_rawline, None
+if salt in out_rawline:
+lout, lcmd = out_rawline.split(salt, 1)
 
 while lout:
 if not lout.endswith(b'\n'):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 9] run-tests: use symbolic constant instead of arbitrary number line matching

2019-09-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1560517187 -3600
#  Fri Jun 14 13:59:47 2019 +0100
# Node ID f927343f31b96019d36f0546f71ebe9a357b0123
# Parent  69195b6f8f974ba56aec9b9bd4cd0a259a646f72
# EXP-Topic test-match
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
f927343f31b9
run-tests: use symbolic constant instead of arbitrary number line matching

(This is a gratuitous cleanup that I made while investigating a bug).

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1302,6 +1302,10 @@ bchr = chr
 if PYTHON3:
 bchr = lambda x: bytes([x])
 
+WARN_UNDEFINED = 1
+WARN_YES = 2
+WARN_NO = 3
+
 class TTest(Test):
 """A "t test" is a test backed by a .t file."""
 
@@ -1601,9 +1605,9 @@ class TTest(Test):
 
 def _processoutput(self, exitcode, output, salt, after, expected):
 # Merge the script output back into a unified test.
-warnonly = 1 # 1: not yet; 2: yes; 3: for sure not
+warnonly = WARN_UNDEFINED # 1: not yet; 2: yes; 3: for sure not
 if exitcode != 0:
-warnonly = 3
+warnonly = WARN_NO
 
 pos = -1
 postout = []
@@ -1670,9 +1674,9 @@ class TTest(Test):
lout.rstrip(b'\n'))
 postout.append(b'  ' + lout) # Let diff deal with it.
 if r != '': # If line failed.
-warnonly = 3 # for sure not
-elif warnonly == 1: # Is "not yet" and line is warn only.
-warnonly = 2 # Yes do warn.
+warnonly = WARN_NO
+elif warnonly == WARN_UNDEFINED:
+warnonly = WARN_YES
 break
 else:
 # clean up any optional leftovers
@@ -1704,7 +1708,7 @@ class TTest(Test):
 if pos in after:
 postout += after.pop(pos)
 
-if warnonly == 2:
+if warnonly == WARN_YES:
 exitcode = False # Set exitcode to warned.
 
 return exitcode, postout
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH] discovery: replace "heads" by "changesets" in a output note (BC)

2019-09-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1556323445 -7200
#  Sat Apr 27 02:04:05 2019 +0200
# Node ID 74dad98f3309bf86e6993c23a5cff0ebb42dc511
# Parent  69195b6f8f974ba56aec9b9bd4cd0a259a646f72
# EXP-Topic discovery-more
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
74dad98f3309
discovery: replace "heads" by "changesets" in a output note (BC)

When using `hg push --rev X`, the subset considered by discovery is only `::X`.
In addition, `X` can be any local revisions not just local heads. As a result
the message "all local heads known locally" can be misleading. We replace it
with the more accurate "all local changesets known remotely".

The message appears when in verbose not, so this is stricly speaking a BC
breakage. I am not sure this would be a real issue in practice...

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -389,7 +389,7 @@ def findcommonheads(ui, local, remote,
 return srvheadhashes, False, srvheadhashes
 
 if len(sample) == len(ownheads) and all(yesno):
-ui.note(_("all local heads known remotely\n"))
+ui.note(_("all local changesets known remotely\n"))
 ownheadhashes = [clnode(r) for r in ownheads]
 return ownheadhashes, True, srvheadhashes
 
diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t
--- a/tests/test-blackbox.t
+++ b/tests/test-blackbox.t
@@ -140,7 +140,7 @@ we must not cause a failure if we cannot
   comparing with $TESTTMP/blackboxtest
   query 1; heads
   searching for changes
-  all local heads known remotely
+  all local changesets known remotely
   changeset:   2:d02f48003e62c24e2659d97d30f2a83abe5d5d51
   tag: tip
   phase:   draft
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -1115,7 +1115,7 @@ redo pull with --lfrev and check it pull
   $ hg pull -v --lfrev 'heads(pulled())+min(pulled())'
   pulling from $TESTTMP/a
   searching for changes
-  all local heads known remotely
+  all local changesets known remotely
   6 changesets found
   uncompressed size of bundle content:
   1389 (changelog)
diff --git a/tests/test-narrow-widen-no-ellipsis.t 
b/tests/test-narrow-widen-no-ellipsis.t
--- a/tests/test-narrow-widen-no-ellipsis.t
+++ b/tests/test-narrow-widen-no-ellipsis.t
@@ -116,7 +116,7 @@ added upstream revisions.
   query 1; heads
   sending batch command
   searching for changes
-  all local heads known remotely
+  all local changesets known remotely
   sending narrow_widen command
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "changegroup" (params: * mandatory) supported (glob)
diff --git a/tests/test-setdiscovery.t b/tests/test-setdiscovery.t
--- a/tests/test-setdiscovery.t
+++ b/tests/test-setdiscovery.t
@@ -64,7 +64,7 @@ Small superset:
   comparing with b
   query 1; heads
   searching for changes
-  all local heads known remotely
+  all local changesets known remotely
   elapsed time:  * seconds (glob)
   heads summary:
 total common heads:  2
@@ -86,7 +86,7 @@ Small superset:
   comparing with b
   query 1; heads
   searching for changes
-  all local heads known remotely
+  all local changesets known remotely
   elapsed time:  * seconds (glob)
   heads summary:
 total common heads:  1
diff --git a/tests/test-wireproto-exchangev2-shallow.t 
b/tests/test-wireproto-exchangev2-shallow.t
--- a/tests/test-wireproto-exchangev2-shallow.t
+++ b/tests/test-wireproto-exchangev2-shallow.t
@@ -490,7 +490,7 @@ Incremental pull of shallow clone fetche
   received frame(size=2; request=3; stream=2; streamflags=encoded; 
type=command-response; flags=continuation)
   received frame(size=0; request=3; stream=2; streamflags=; 
type=command-response; flags=eos)
   searching for changes
-  all local heads known remotely
+  all local changesets known remotely
   sending 1 commands
   sending command changesetdata: {
 'fields': set([
diff --git a/tests/test-wireproto-exchangev2.t 
b/tests/test-wireproto-exchangev2.t
--- a/tests/test-wireproto-exchangev2.t
+++ b/tests/test-wireproto-exchangev2.t
@@ -299,7 +299,7 @@ Output is flaky, save it in a file and c
 ]
   }
   searching for changes
-  all local heads known remotely
+  all local changesets known remotely
   sending 1 commands
   sending command changesetdata: {
 'fields': set([
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6824: notify: add option for deterministic message-id generation

2019-09-07 Thread joerg.sonnenberger (Joerg Sonnenberger)
joerg.sonnenberger created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS

diff --git a/tests/test-notify.t b/tests/test-notify.t
--- a/tests/test-notify.t
+++ b/tests/test-notify.t
@@ -99,7 +99,13 @@
 "/long/path/repository" into "repository". Default: 0.
   
   notify.domain
-Default email domain for sender or recipients with no explicit domain.
+Default email domain for sender or recipients with no explicit domain. It 
is
+also used for the domain part of the "Message-Id" when using
+"notify.messageidseed".
+  
+  notify.messageidseed
+Create deterministic "Message-Id" headers for the mails based on the seed
+and the revision identifier of the first commit in the changeset.
   
   notify.style
 Style file to use when formatting emails.
@@ -190,7 +196,7 @@
 of the very long subject line
 pull (minimal config)
 
-  $ hg --traceback --cwd b pull ../a | "$PYTHON" $TESTTMP/filter.py
+  $ hg --traceback --cwd b --config notify.domain=example.com --config 
notify.messageidseed=example pull ../a | "$PYTHON" $TESTTMP/filter.py
   pulling from ../a
   searching for changes
   adding changesets
@@ -203,10 +209,10 @@
   Content-Transfer-Encoding: 7bit
   Date: * (glob)
   Subject: changeset in $TESTTMP/b: b
-  From: test
+  From: t...@example.com
   X-Hg-Notification: changeset 00a13f371396
-  Message-Id: <*> (glob)
-  To: baz, foo@bar
+  Message-Id: 

+  To: b...@example.com, foo@bar
   
   changeset 00a13f371396 in $TESTTMP/b
   details: $TESTTMP/b?cmd=changeset;node=00a13f371396
diff --git a/hgext/notify.py b/hgext/notify.py
--- a/hgext/notify.py
+++ b/hgext/notify.py
@@ -82,6 +82,12 @@
 
 notify.domain
   Default email domain for sender or recipients with no explicit domain.
+  It is also used for the domain part of the ``Message-Id`` when using
+  ``notify.messageidseed``.
+
+notify.messageidseed
+  Create deterministic ``Message-Id`` headers for the mails based on the seed
+  and the revision identifier of the first commit in the changeset.
 
 notify.style
   Style file to use when formatting emails.
@@ -144,6 +150,7 @@
 import email.errors as emailerrors
 import email.parser as emailparser
 import fnmatch
+import hashlib
 import socket
 import time
 
@@ -183,6 +190,9 @@
 configitem('notify', 'domain',
 default=None,
 )
+configitem('notify', 'messageidseed',
+default=None,
+)
 configitem('notify', 'fromauthor',
 default=None,
 )
@@ -268,6 +278,7 @@
 self.subs = self.subscribers()
 self.merge = self.ui.configbool('notify', 'merge')
 self.showfunc = self.ui.configbool('notify', 'showfunc')
+self.messageidseed = self.ui.config('notify', 'messageidseed')
 if self.showfunc is None:
 self.showfunc = self.ui.configbool('diff', 'showfunc')
 
@@ -412,10 +423,7 @@
 
 msg[r'X-Hg-Notification'] = r'changeset %s' % ctx
 if not msg[r'Message-Id']:
-msg[r'Message-Id'] = encoding.strfromlocal(
-'' % (ctx, int(time.time()),
-  hash(self.repo.root),
-  encoding.strtolocal(socket.getfqdn(
+msg[r'Message-Id'] = messageid(ctx, self.domain, 
self.messageidseed)
 msg[r'To'] = encoding.strfromlocal(', '.join(sorted(subs)))
 
 msgtext = encoding.strtolocal(msg.as_string())
@@ -517,3 +525,16 @@
 
 if count:
 n.send(ctx, count, data)
+
+def messageid(ctx, domain, messageidseed):
+if domain and messageidseed:
+host = domain
+else:
+host = encoding.strtolocal(socket.getfqdn())
+if messageidseed:
+messagehash = hashlib.sha512(ctx.hex() + messageidseed)
+messageid = '' % (messagehash.hexdigest()[:64], host)
+else:
+messageid = '' % (ctx, int(time.time()),
+  hash(ctx.repo().root), host)
+return encoding.strfromlocal(messageid)



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


D6823: flagprocessors: remove flagprocessorsmixin

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It became an empty shell.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py
  mercurial/revlog.py
  mercurial/revlogutils/flagutil.py
  tests/simplestorerepo.py

CHANGE DETAILS

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -91,7 +91,7 @@
 node = attr.ib(default=None)
 
 @interfaceutil.implementer(repository.ifilestorage)
-class filestorage(flagutil.flagprocessorsmixin):
+class filestorage(object):
 """Implements storage for a tracked path.
 
 Data is stored in the VFS in a directory corresponding to the tracked
diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -79,14 +79,6 @@
 raise error.Abort(msg)
 flagprocessors[flag] = processor
 
-class flagprocessorsmixin(object):
-"""basic mixin to support revlog flag processing
-
-Make sure the `_flagprocessors` attribute is set at ``__init__`` time.
-
-See the documentation of the ``_processflags`` method for details.
-"""
-
 def processflagswrite(revlog, text, flags, sidedata):
 """Inspect revision data flags and applies write transformations defined
 by registered flag processors.
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -261,7 +261,7 @@
 p = versionformat_pack(version) + p[4:]
 return p
 
-class revlog(flagutil.flagprocessorsmixin):
+class revlog(object):
 """
 the underlying revision storage object
 
diff --git a/hgext/remotefilelog/remotefilelog.py 
b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -48,7 +48,7 @@
 raise KeyError(node)
 return node
 
-class remotefilelog(flagutil.flagprocessorsmixin):
+class remotefilelog(object):
 
 _generaldelta = True
 _flagserrorclass = error.RevlogError



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


D6821: flagprocessors: directly duplicate the deprecated layer back into revlog

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The code duplication benign and will get removed in a couple of month anyway.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py
  mercurial/revlog.py
  mercurial/revlogutils/flagutil.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -89,17 +89,6 @@
 
 _flagserrorclass = error.RevlogError
 
-def _processflags(self, text, flags, operation, raw=False):
-"""deprecated entry point to access flag processors"""
-msg = ('_processflag(...) use the specialized variant')
-util.nouideprecwarn(msg, '5.2', stacklevel=2)
-if raw:
-return text, processflagsraw(self, text, flags)
-elif operation == 'read':
-return processflagsread(self, text, flags)
-else: # write operation
-return processflagswrite(self, text, flags)
-
 def processflagswrite(revlog, text, flags, sidedata):
 """Inspect revision data flags and applies write transformations defined
 by registered flag processors.
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1601,6 +1601,17 @@
 return mdiff.textdiff(self.rawdata(rev1),
   self.rawdata(rev2))
 
+def _processflags(self, text, flags, operation, raw=False):
+"""deprecated entry point to access flag processors"""
+msg = ('_processflag(...) use the specialized variant')
+util.nouideprecwarn(msg, '5.2', stacklevel=2)
+if raw:
+return text, flagutil.processflagsraw(self, text, flags)
+elif operation == 'read':
+return flagutil.processflagsread(self, text, flags)
+else: # write operation
+return flagutil.processflagswrite(self, text, flags)
+
 def revision(self, nodeorrev, _df=None, raw=False):
 """return an uncompressed revision of a given node or revision
 number.
diff --git a/hgext/remotefilelog/remotefilelog.py 
b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -22,6 +22,7 @@
 error,
 mdiff,
 revlog,
+util,
 )
 from mercurial.utils import storageutil
 
@@ -305,6 +306,17 @@
 'remotefilelog does not convert integer rev to node')
 return rev
 
+def _processflags(self, text, flags, operation, raw=False):
+"""deprecated entry point to access flag processors"""
+msg = ('_processflag(...) use the specialized variant')
+util.nouideprecwarn(msg, '5.2', stacklevel=2)
+if raw:
+return text, flagutil.processflagsraw(self, text, flags)
+elif operation == 'read':
+return flagutil.processflagsread(self, text, flags)
+else: # write operation
+return flagutil.processflagswrite(self, text, flags)
+
 def revision(self, node, raw=False):
 """returns the revlog contents at this node.
 this includes the meta data traditionally included in file revlogs.



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


D6820: flagprocessors: make `processflagsraw` a module level function

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  One more steps toward removing the mixin.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlog.py
  mercurial/revlogutils/deltas.py
  mercurial/revlogutils/flagutil.py
  tests/simplestorerepo.py

CHANGE DETAILS

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -291,7 +291,7 @@
 rawtext = self._svfs.read(path)
 
 if raw:
-validatehash = self._processflagsraw(rawtext, flags)
+validatehash = flagutil.processflagsraw(self, rawtext, flags)
 text = rawtext
 else:
 r = flagutil.processflagsread(self, rawtext, flags)
diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -94,30 +94,12 @@
 msg = ('_processflag(...) use the specialized variant')
 util.nouideprecwarn(msg, '5.2', stacklevel=2)
 if raw:
-return text, self._processflagsraw(text, flags)
+return text, processflagsraw(self, text, flags)
 elif operation == 'read':
 return processflagsread(self, text, flags)
 else: # write operation
 return processflagswrite(self, text, flags)
 
-def _processflagsraw(self, text, flags):
-"""Inspect revision data flags to check is the content hash should be
-validated.
-
-``text`` - the revision data to process
-``flags`` - the revision flags
-
-This method processes the flags in the order (or reverse order if
-``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
-flag processors registered for present flags. The order of flags 
defined
-in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
-
-Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
-processed text and ``validatehash`` is a bool indicating whether the
-returned text should be checked for hash integrity.
-"""
-return _processflagsfunc(self, text, flags, 'raw')[1]
-
 def processflagswrite(revlog, text, flags, sidedata):
 """Inspect revision data flags and applies write transformations defined
 by registered flag processors.
@@ -157,6 +139,24 @@
 """
 return _processflagsfunc(revlog, text, flags, 'read')
 
+def processflagsraw(revlog, text, flags):
+"""Inspect revision data flags to check is the content hash should be
+validated.
+
+``text`` - the revision data to process
+``flags`` - the revision flags
+
+This method processes the flags in the order (or reverse order if
+``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
+flag processors registered for present flags. The order of flags defined
+in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
+
+Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
+processed text and ``validatehash`` is a bool indicating whether the
+returned text should be checked for hash integrity.
+"""
+return _processflagsfunc(revlog, text, flags, 'raw')[1]
+
 def _processflagsfunc(revlog, text, flags, operation, sidedata=None):
 """internal function to process flag on a revlog
 
diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py
+++ b/mercurial/revlogutils/deltas.py
@@ -33,6 +33,10 @@
 util,
 )
 
+from . import (
+flagutil,
+)
+
 # maximum / ratio
 LIMIT_DELTA2TEXT = 2
 
@@ -521,7 +525,7 @@
 fulltext = mdiff.patch(basetext, delta)
 
 try:
-validatehash = revlog._processflagsraw(fulltext, flags)
+validatehash = flagutil.processflagsraw(revlog, fulltext, flags)
 if validatehash:
 revlog.checkhash(fulltext, expectednode, p1=p1, p2=p2)
 if flags & REVIDX_ISCENSORED:
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1657,7 +1657,7 @@
 
 sidedata = {}
 if raw:
-validatehash = self._processflagsraw(rawtext, flags)
+validatehash = flagutil.processflagsraw(self, rawtext, flags)
 text = rawtext
 else:
 r = flagutil.processflagsread(self, rawtext, flags)



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


D6819: flagprocessors: make `processflagsread` a module level function

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  One more steps toward removing the mixin.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py
  mercurial/revlog.py
  mercurial/revlogutils/flagutil.py
  tests/simplestorerepo.py

CHANGE DETAILS

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -294,7 +294,7 @@
 validatehash = self._processflagsraw(rawtext, flags)
 text = rawtext
 else:
-r = self._processflagsread(rawtext, flags)
+r = flagutil.processflagsread(self, rawtext, flags)
 text, validatehash, sidedata = r
 if validatehash:
 self.checkhash(text, node, rev=rev)
diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -96,30 +96,10 @@
 if raw:
 return text, self._processflagsraw(text, flags)
 elif operation == 'read':
-return self._processflagsread(text, flags)
+return processflagsread(self, text, flags)
 else: # write operation
 return processflagswrite(self, text, flags)
 
-def _processflagsread(self, text, flags):
-"""Inspect revision data flags and applies read transformations defined
-by registered flag processors.
-
-``text`` - the revision data to process
-``flags`` - the revision flags
-``raw`` - an optional argument describing if the raw transform should 
be
-applied.
-
-This method processes the flags in the order (or reverse order if
-``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
-flag processors registered for present flags. The order of flags 
defined
-in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
-
-Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
-processed text and ``validatehash`` is a bool indicating whether the
-returned text should be checked for hash integrity.
-"""
-return _processflagsfunc(self, text, flags, 'read')
-
 def _processflagsraw(self, text, flags):
 """Inspect revision data flags to check is the content hash should be
 validated.
@@ -157,6 +137,26 @@
 return _processflagsfunc(revlog, text, flags, 'write',
  sidedata=sidedata)[:2]
 
+def processflagsread(revlog, text, flags):
+"""Inspect revision data flags and applies read transformations defined
+by registered flag processors.
+
+``text`` - the revision data to process
+``flags`` - the revision flags
+``raw`` - an optional argument describing if the raw transform should be
+applied.
+
+This method processes the flags in the order (or reverse order if
+``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
+flag processors registered for present flags. The order of flags defined
+in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
+
+Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
+processed text and ``validatehash`` is a bool indicating whether the
+returned text should be checked for hash integrity.
+"""
+return _processflagsfunc(revlog, text, flags, 'read')
+
 def _processflagsfunc(revlog, text, flags, operation, sidedata=None):
 """internal function to process flag on a revlog
 
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1660,7 +1660,7 @@
 validatehash = self._processflagsraw(rawtext, flags)
 text = rawtext
 else:
-r = self._processflagsread(rawtext, flags)
+r = flagutil.processflagsread(self, rawtext, flags)
 text, validatehash, sidedata = r
 if validatehash:
 self.checkhash(text, node, rev=rev)
diff --git a/hgext/remotefilelog/remotefilelog.py 
b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -326,8 +326,7 @@
 flags = store.getmeta(self.filename, node).get(constants.METAKEYFLAG, 
0)
 if flags == 0:
 return rawtext
-text, verifyhash, sidedata = self._processflagsread(rawtext, flags)
-return text
+return flagutil.processflagsread(self, rawtext, flags)[0]
 
 def rawdata(self, node):
 return self.revision(node, raw=False)



To: marmoute, yuja, durin42, indygreg, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list

D6818: flagprocessors: make `processflagswrite` a module level function

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  One more step towards removing the mixin.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py
  mercurial/revlog.py
  mercurial/revlogutils/flagutil.py
  tests/simplestorerepo.py

CHANGE DETAILS

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -457,7 +457,7 @@
 if flags:
 node = node or storageutil.hashrevisionsha1(text, p1, p2)
 
-rawtext, validatehash = self._processflagswrite(text, flags)
+rawtext, validatehash = flagutil.processflagswrite(self, text, flags)
 
 node = node or storageutil.hashrevisionsha1(text, p1, p2)
 
diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -98,7 +98,7 @@
 elif operation == 'read':
 return self._processflagsread(text, flags)
 else: # write operation
-return self._processflagswrite(text, flags)
+return processflagswrite(self, text, flags)
 
 def _processflagsread(self, text, flags):
 """Inspect revision data flags and applies read transformations defined
@@ -120,25 +120,6 @@
 """
 return _processflagsfunc(self, text, flags, 'read')
 
-def _processflagswrite(self, text, flags, sidedata):
-"""Inspect revision data flags and applies write transformations 
defined
-by registered flag processors.
-
-``text`` - the revision data to process
-``flags`` - the revision flags
-
-This method processes the flags in the order (or reverse order if
-``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
-flag processors registered for present flags. The order of flags 
defined
-in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
-
-Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
-processed text and ``validatehash`` is a bool indicating whether the
-returned text should be checked for hash integrity.
-"""
-return _processflagsfunc(self, text, flags, 'write',
- sidedata=sidedata)[:2]
-
 def _processflagsraw(self, text, flags):
 """Inspect revision data flags to check is the content hash should be
 validated.
@@ -157,6 +138,25 @@
 """
 return _processflagsfunc(self, text, flags, 'raw')[1]
 
+def processflagswrite(revlog, text, flags, sidedata):
+"""Inspect revision data flags and applies write transformations defined
+by registered flag processors.
+
+``text`` - the revision data to process
+``flags`` - the revision flags
+
+This method processes the flags in the order (or reverse order if
+``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
+flag processors registered for present flags. The order of flags defined
+in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
+
+Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
+processed text and ``validatehash`` is a bool indicating whether the
+returned text should be checked for hash integrity.
+"""
+return _processflagsfunc(revlog, text, flags, 'write',
+ sidedata=sidedata)[:2]
+
 def _processflagsfunc(revlog, text, flags, operation, sidedata=None):
 """internal function to process flag on a revlog
 
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1836,8 +1836,8 @@
 if flags:
 node = node or self.hash(text, p1, p2)
 
-rawtext, validatehash = self._processflagswrite(text, flags,
-sidedata=sidedata)
+rawtext, validatehash = flagutil.processflagswrite(self, text, flags,
+   sidedata=sidedata)
 
 # If the flag processor modifies the revision data, ignore any provided
 # cachedelta.
diff --git a/hgext/remotefilelog/remotefilelog.py 
b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -136,8 +136,8 @@
 node = storageutil.hashrevisionsha1(text, p1, p2)
 
 meta, metaoffset = storageutil.parsemeta(text)
-rawtext, validatehash = self._processflagswrite(text, flags,
-sidedata=sidedata)
+rawtext, validatehash = flagutil.processflagswrite(self, text, flags,
+  

D6816: flagprocessors: writetransform function take side data as parameter (API)

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  If we want some flag processors to be able to store sidedata it needs to be
  actually fed that data.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/lfs/wrapper.py
  mercurial/revlog.py
  mercurial/revlogutils/flagutil.py
  tests/flagprocessorext.py
  tests/test-revlog-raw.py

CHANGE DETAILS

diff --git a/tests/test-revlog-raw.py b/tests/test-revlog-raw.py
--- a/tests/test-revlog-raw.py
+++ b/tests/test-revlog-raw.py
@@ -47,7 +47,7 @@
 text = rawtext[len(_extheader):].replace(b'i', b'1')
 return text, True, {}
 
-def writeprocessor(self, text):
+def writeprocessor(self, text, sidedata):
 # False: the returned rawtext shouldn't be used to verify hash
 rawtext = _extheader + text.replace(b'1', b'i')
 return rawtext, False
@@ -262,7 +262,7 @@
 
 # Verify text, rawtext, and rawsize
 if isext:
-rawtext = writeprocessor(None, text)[0]
+rawtext = writeprocessor(None, text, {})[0]
 else:
 rawtext = text
 if rlog.rawsize(rev) != len(rawtext):
diff --git a/tests/flagprocessorext.py b/tests/flagprocessorext.py
--- a/tests/flagprocessorext.py
+++ b/tests/flagprocessorext.py
@@ -30,19 +30,19 @@
 def bypass(self, text):
 return False
 
-def noopdonothing(self, text):
+def noopdonothing(self, text, sidedata):
 return (text, True)
 
 def noopdonothingread(self, text):
 return (text, True, {})
 
-def b64encode(self, text):
+def b64encode(self, text, sidedata):
 return (base64.b64encode(text), False)
 
 def b64decode(self, text):
 return (base64.b64decode(text), True, {})
 
-def gzipcompress(self, text):
+def gzipcompress(self, text, sidedata):
 return (zlib.compress(text), False)
 
 def gzipdecompress(self, text):
diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -136,8 +136,8 @@
 processed text and ``validatehash`` is a bool indicating whether the
 returned text should be checked for hash integrity.
 """
-assert not sidedata # XXX until it is actually processed
-return self._processflagsfunc(text, flags, 'write')[:2]
+return self._processflagsfunc(text, flags, 'write',
+  sidedata=sidedata)[:2]
 
 def _processflagsraw(self, text, flags):
 """Inspect revision data flags to check is the content hash should be
@@ -157,7 +157,7 @@
 """
 return self._processflagsfunc(text, flags, 'raw')[1]
 
-def _processflagsfunc(self, text, flags, operation):
+def _processflagsfunc(self, text, flags, operation, sidedata=None):
 # fast path: no flag processors will run
 if flags == 0:
 return text, True, {}
@@ -196,7 +196,7 @@
 text, vhash, s = readtransform(self, text)
 sidedata.update(s)
 else: # write operation
-text, vhash = writetransform(self, text)
+text, vhash = writetransform(self, text, sidedata)
 validatehash = validatehash and vhash
 
 return text, validatehash, sidedata
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -115,7 +115,7 @@
 def ellipsisreadprocessor(rl, text):
 return text, False, {}
 
-def ellipsiswriteprocessor(rl, text):
+def ellipsiswriteprocessor(rl, text, sidedata):
 return text, False
 
 def ellipsisrawprocessor(rl, text):
diff --git a/hgext/lfs/wrapper.py b/hgext/lfs/wrapper.py
--- a/hgext/lfs/wrapper.py
+++ b/hgext/lfs/wrapper.py
@@ -106,7 +106,7 @@
 
 return (text, True, {})
 
-def writetostore(self, text):
+def writetostore(self, text, sidedata):
 # hg filelog metadata (includes rename, etc)
 hgmeta, offset = storageutil.parsemeta(text)
 if offset and offset > 0:



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


D6815: flagprocessors: add a `sidedata` parameters to _processflagswrite

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  To read sidedata using flagprocessors, we need flag processors to store them. 
So
  we pass this information to the flag processing layer.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py
  mercurial/revlog.py
  mercurial/revlogutils/flagutil.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -120,7 +120,7 @@
 """
 return self._processflagsfunc(text, flags, 'read')
 
-def _processflagswrite(self, text, flags):
+def _processflagswrite(self, text, flags, sidedata):
 """Inspect revision data flags and applies write transformations 
defined
 by registered flag processors.
 
@@ -136,6 +136,7 @@
 processed text and ``validatehash`` is a bool indicating whether the
 returned text should be checked for hash integrity.
 """
+assert not sidedata # XXX until it is actually processed
 return self._processflagsfunc(text, flags, 'write')[:2]
 
 def _processflagsraw(self, text, flags):
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1836,7 +1836,8 @@
 if flags:
 node = node or self.hash(text, p1, p2)
 
-rawtext, validatehash = self._processflagswrite(text, flags)
+rawtext, validatehash = self._processflagswrite(text, flags,
+sidedata=sidedata)
 
 # If the flag processor modifies the revision data, ignore any provided
 # cachedelta.
diff --git a/hgext/remotefilelog/remotefilelog.py 
b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -136,7 +136,8 @@
 node = storageutil.hashrevisionsha1(text, p1, p2)
 
 meta, metaoffset = storageutil.parsemeta(text)
-rawtext, validatehash = self._processflagswrite(text, flags)
+rawtext, validatehash = self._processflagswrite(text, flags,
+sidedata=sidedata)
 return self.addrawrevision(rawtext, transaction, linknode, p1, p2,
node, flags, cachedelta,
_metatuple=(meta, metaoffset))



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


D6817: flagprocessors: make `_processflagsfunc` a module level function

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is the first step toward removing the flag processing mixin.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlogutils/flagutil.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -118,7 +118,7 @@
 processed text and ``validatehash`` is a bool indicating whether the
 returned text should be checked for hash integrity.
 """
-return self._processflagsfunc(text, flags, 'read')
+return _processflagsfunc(self, text, flags, 'read')
 
 def _processflagswrite(self, text, flags, sidedata):
 """Inspect revision data flags and applies write transformations 
defined
@@ -136,8 +136,8 @@
 processed text and ``validatehash`` is a bool indicating whether the
 returned text should be checked for hash integrity.
 """
-return self._processflagsfunc(text, flags, 'write',
-  sidedata=sidedata)[:2]
+return _processflagsfunc(self, text, flags, 'write',
+ sidedata=sidedata)[:2]
 
 def _processflagsraw(self, text, flags):
 """Inspect revision data flags to check is the content hash should be
@@ -155,48 +155,52 @@
 processed text and ``validatehash`` is a bool indicating whether the
 returned text should be checked for hash integrity.
 """
-return self._processflagsfunc(text, flags, 'raw')[1]
+return _processflagsfunc(self, text, flags, 'raw')[1]
+
+def _processflagsfunc(revlog, text, flags, operation, sidedata=None):
+"""internal function to process flag on a revlog
 
-def _processflagsfunc(self, text, flags, operation, sidedata=None):
-# fast path: no flag processors will run
-if flags == 0:
-return text, True, {}
-if not operation in ('read', 'write', 'raw'):
-raise error.ProgrammingError(_("invalid '%s' operation") %
- operation)
-# Check all flags are known.
-if flags & ~REVIDX_KNOWN_FLAGS:
-raise self._flagserrorclass(_("incompatible revision flag '%#x'") %
-(flags & ~REVIDX_KNOWN_FLAGS))
-validatehash = True
-# Depending on the operation (read or write), the order might be
-# reversed due to non-commutative transforms.
-orderedflags = REVIDX_FLAGS_ORDER
-if operation == 'write':
-orderedflags = reversed(orderedflags)
+This function is private to this module, code should never needs to call it
+directly."""
+# fast path: no flag processors will run
+if flags == 0:
+return text, True, {}
+if not operation in ('read', 'write', 'raw'):
+raise error.ProgrammingError(_("invalid '%s' operation") %
+ operation)
+# Check all flags are known.
+if flags & ~REVIDX_KNOWN_FLAGS:
+raise revlog._flagserrorclass(_("incompatible revision flag '%#x'") %
+  (flags & ~REVIDX_KNOWN_FLAGS))
+validatehash = True
+# Depending on the operation (read or write), the order might be
+# reversed due to non-commutative transforms.
+orderedflags = REVIDX_FLAGS_ORDER
+if operation == 'write':
+orderedflags = reversed(orderedflags)
 
-sidedata = {}
-for flag in orderedflags:
-# If a flagprocessor has been registered for a known flag, apply 
the
-# related operation transform and update result tuple.
-if flag & flags:
-vhash = True
+sidedata = {}
+for flag in orderedflags:
+# If a flagprocessor has been registered for a known flag, apply the
+# related operation transform and update result tuple.
+if flag & flags:
+vhash = True
 
-if flag not in self._flagprocessors:
-message = _("missing processor for flag '%#x'") % (flag)
-raise self._flagserrorclass(message)
+if flag not in revlog._flagprocessors:
+message = _("missing processor for flag '%#x'") % (flag)
+raise revlog._flagserrorclass(message)
 
-processor = self._flagprocessors[flag]
-if processor is not None:
-readtransform, writetransform, rawtransform = processor
+processor = revlog._flagprocessors[flag]
+if processor is not None:
+readtransform, writetransform, rawtransform = processor
 
-if operation == 'raw':
-

D6813: flagprocessors: have the read transform function return side data (API)

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This makes it possible for flag processors to -read- flag data.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/lfs/wrapper.py
  mercurial/revlog.py
  mercurial/revlogutils/flagutil.py
  tests/flagprocessorext.py
  tests/test-revlog-raw.py

CHANGE DETAILS

diff --git a/tests/test-revlog-raw.py b/tests/test-revlog-raw.py
--- a/tests/test-revlog-raw.py
+++ b/tests/test-revlog-raw.py
@@ -45,7 +45,7 @@
 def readprocessor(self, rawtext):
 # True: the returned text could be used to verify hash
 text = rawtext[len(_extheader):].replace(b'i', b'1')
-return text, True
+return text, True, {}
 
 def writeprocessor(self, text):
 # False: the returned rawtext shouldn't be used to verify hash
diff --git a/tests/flagprocessorext.py b/tests/flagprocessorext.py
--- a/tests/flagprocessorext.py
+++ b/tests/flagprocessorext.py
@@ -33,17 +33,20 @@
 def noopdonothing(self, text):
 return (text, True)
 
+def noopdonothingread(self, text):
+return (text, True, {})
+
 def b64encode(self, text):
 return (base64.b64encode(text), False)
 
 def b64decode(self, text):
-return (base64.b64decode(text), True)
+return (base64.b64decode(text), True, {})
 
 def gzipcompress(self, text):
 return (zlib.compress(text), False)
 
 def gzipdecompress(self, text):
-return (zlib.decompress(text), True)
+return (zlib.decompress(text), True, {})
 
 def supportedoutgoingversions(orig, repo):
 versions = orig(repo)
@@ -116,7 +119,7 @@
 flagutil.addflagprocessor(
 REVIDX_NOOP,
 (
-noopdonothing,
+noopdonothingread,
 noopdonothing,
 validatehash,
 )
diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -192,7 +192,8 @@
 if operation == 'raw':
 vhash = rawtransform(self, text)
 elif operation == 'read':
-text, vhash = readtransform(self, text)
+text, vhash, s = readtransform(self, text)
+sidedata.update(s)
 else: # write operation
 text, vhash = writetransform(self, text)
 validatehash = validatehash and vhash
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -113,7 +113,7 @@
 
 # Flag processors for REVIDX_ELLIPSIS.
 def ellipsisreadprocessor(rl, text):
-return text, False
+return text, False, {}
 
 def ellipsiswriteprocessor(rl, text):
 return text, False
diff --git a/hgext/lfs/wrapper.py b/hgext/lfs/wrapper.py
--- a/hgext/lfs/wrapper.py
+++ b/hgext/lfs/wrapper.py
@@ -104,7 +104,7 @@
 if hgmeta or text.startswith('\1\n'):
 text = storageutil.packmeta(hgmeta, text)
 
-return (text, True)
+return (text, True, {})
 
 def writetostore(self, text):
 # hg filelog metadata (includes rename, etc)



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


D6814: revlog: add a `sidedata` parameters to addrevision

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  If we want to eventually store sidedata we need to be able to pass them along.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1813,7 +1813,8 @@
 """
 
 def addrevision(self, text, transaction, link, p1, p2, cachedelta=None,
-node=None, flags=REVIDX_DEFAULT_FLAGS, deltacomputer=None):
+node=None, flags=REVIDX_DEFAULT_FLAGS, deltacomputer=None,
+sidedata=()):
 """add a revision to the log
 
 text - the revision data to add
diff --git a/hgext/remotefilelog/remotefilelog.py 
b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -130,7 +130,7 @@
 return data
 
 def addrevision(self, text, transaction, linknode, p1, p2, cachedelta=None,
-node=None, flags=revlog.REVIDX_DEFAULT_FLAGS):
+node=None, flags=revlog.REVIDX_DEFAULT_FLAGS, sidedata=()):
 # text passed to "addrevision" includes hg filelog metadata header
 if node is None:
 node = storageutil.hashrevisionsha1(text, p1, p2)



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


D6811: flagprocessors: return sidedata map in `_processflagsread`

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Right now, flag processors does not return sidedata, by they will. So, we
  prepare the caller to receive it.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py
  mercurial/revlog.py
  mercurial/revlogutils/flagutil.py
  tests/simplestorerepo.py

CHANGE DETAILS

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -294,7 +294,8 @@
 validatehash = self._processflagsraw(rawtext, flags)
 text = rawtext
 else:
-text, validatehash = self._processflagsread(rawtext, flags)
+r = self._processflagsread(rawtext, flags)
+text, validatehash, sidedata = r
 if validatehash:
 self.checkhash(text, node, rev=rev)
 
diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -118,7 +118,8 @@
 processed text and ``validatehash`` is a bool indicating whether the
 returned text should be checked for hash integrity.
 """
-return self._processflagsfunc(text, flags, 'read')
+text, vhash = self._processflagsfunc(text, flags, 'read')
+return text, vhash, {}
 
 def _processflagswrite(self, text, flags):
 """Inspect revision data flags and applies write transformations 
defined
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1660,7 +1660,8 @@
 validatehash = self._processflagsraw(rawtext, flags)
 text = rawtext
 else:
-text, validatehash = self._processflagsread(rawtext, flags)
+r = self._processflagsread(rawtext, flags)
+text, validatehash, sidedata = r
 if validatehash:
 self.checkhash(text, node, rev=rev)
 if not validated:
diff --git a/hgext/remotefilelog/remotefilelog.py 
b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -325,7 +325,7 @@
 flags = store.getmeta(self.filename, node).get(constants.METAKEYFLAG, 
0)
 if flags == 0:
 return rawtext
-text, verifyhash = self._processflagsread(rawtext, flags)
+text, verifyhash, sidedata = self._processflagsread(rawtext, flags)
 return text
 
 def rawdata(self, node):



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


D6810: revlog: use the new sidedata map return in the sidedata method

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  So far things, seems logical.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1619,8 +1619,8 @@
 mapping object will likely be used in the future for a more
 efficient/lazy code.
 """
-# XXX will actualy return data once storage is implemented.
-return {}
+text, sidemeta = self._revision(nodeorrev, _df)[1]
+return sidemeta
 
 def _revisiondata(self, nodeorrev, _df=None, raw=False):
 # deal with  argument type



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


D6812: flagprocessors: return flagdata in the main processing function

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This function input and return are becoming stranger and stranger bnut I don't
  have a good plan to make is saner without problematic code duplication, so it
  will be this way to now.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlogutils/flagutil.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -118,8 +118,7 @@
 processed text and ``validatehash`` is a bool indicating whether the
 returned text should be checked for hash integrity.
 """
-text, vhash = self._processflagsfunc(text, flags, 'read')
-return text, vhash, {}
+return self._processflagsfunc(text, flags, 'read')
 
 def _processflagswrite(self, text, flags):
 """Inspect revision data flags and applies write transformations 
defined
@@ -137,7 +136,7 @@
 processed text and ``validatehash`` is a bool indicating whether the
 returned text should be checked for hash integrity.
 """
-return self._processflagsfunc(text, flags, 'write')
+return self._processflagsfunc(text, flags, 'write')[:2]
 
 def _processflagsraw(self, text, flags):
 """Inspect revision data flags to check is the content hash should be
@@ -160,7 +159,7 @@
 def _processflagsfunc(self, text, flags, operation):
 # fast path: no flag processors will run
 if flags == 0:
-return text, True
+return text, True, {}
 if not operation in ('read', 'write', 'raw'):
 raise error.ProgrammingError(_("invalid '%s' operation") %
  operation)
@@ -175,6 +174,7 @@
 if operation == 'write':
 orderedflags = reversed(orderedflags)
 
+sidedata = {}
 for flag in orderedflags:
 # If a flagprocessor has been registered for a known flag, apply 
the
 # related operation transform and update result tuple.
@@ -197,4 +197,4 @@
 text, vhash = writetransform(self, text)
 validatehash = validatehash and vhash
 
-return text, validatehash
+return text, validatehash, sidedata



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


D6809: revlog: return sidedata map from `_revisiondata`

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Nothing extra any side data yet. However, it will happens in the future. So we
  better prepare the callers of the `_revisiondata` to deal with it.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1610,7 +1610,7 @@
 treated as raw data when applying flag transforms. 'raw' should be set
 to True when generating changegroups or in debug commands.
 """
-return self._revisiondata(nodeorrev, _df, raw=raw)
+return self._revisiondata(nodeorrev, _df, raw=raw)[0]
 
 def sidedata(self, nodeorrev, _df=None):
 """a map of extra data related to the changeset but not part of the 
hash
@@ -1633,7 +1633,7 @@
 
 # fast path the special `nullid` rev
 if node == nullid:
-return ""
+return "", {}
 
 # The text as stored inside the revlog. Might be the revision or might
 # need to be processed to retrieve the revision.
@@ -1644,7 +1644,7 @@
 if raw and validated:
 # if we don't want to process the raw text and that raw
 # text is cached, we can exit early.
-return rawtext
+return rawtext, {}
 if rev is None:
 rev = self.rev(node)
 # the revlog's flag for this revision
@@ -1653,8 +1653,9 @@
 
 if validated and flags == REVIDX_DEFAULT_FLAGS:
 # no extra flags set, no flag processor runs, text = rawtext
-return rawtext
-
+return rawtext, {}
+
+sidedata = {}
 if raw:
 validatehash = self._processflagsraw(rawtext, flags)
 text = rawtext
@@ -1665,7 +1666,7 @@
 if not validated:
 self._revisioncache = (node, rev, rawtext)
 
-return text
+return text, sidedata
 
 def _rawtext(self, node, rev, _df=None):
 """return the possibly unvalidated rawtext for a revision
@@ -1715,7 +1716,7 @@
 
 _df - an existing file handle to read from. (internal-only)
 """
-return self._revisiondata(nodeorrev, _df, raw=True)
+return self._revisiondata(nodeorrev, _df, raw=True)[0]
 
 def hash(self, text, p1, p2):
 """Compute a node hash.



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


D6808: revlog: introduce a `sidedata` method

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The method give access to extra information related to the revision. Such data
  will not be part of the hash be strongly related to the revision. Having them
  stored at the revlog level helps the storage consistency story and simplify
  various things.
  
  Example of data we could store there:
  
  - copy tracing related informations
  - graph structure related information (useful for discovery)
  - unresolved conflict data
  
  The full implementation will be introduced gradually in the coming changesets.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1612,6 +1612,16 @@
 """
 return self._revisiondata(nodeorrev, _df, raw=raw)
 
+def sidedata(self, nodeorrev, _df=None):
+"""a map of extra data related to the changeset but not part of the 
hash
+
+This function currently return a dictionary. However, more advanced
+mapping object will likely be used in the future for a more
+efficient/lazy code.
+"""
+# XXX will actualy return data once storage is implemented.
+return {}
+
 def _revisiondata(self, nodeorrev, _df=None, raw=False):
 # deal with  argument type
 if isinstance(nodeorrev, int):



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


D6807: flagprocessors: small code update to clarify parameters

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  'raw' is really a third mode, not a small variant.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlogutils/flagutil.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -154,13 +154,13 @@
 processed text and ``validatehash`` is a bool indicating whether the
 returned text should be checked for hash integrity.
 """
-return self._processflagsfunc(text, flags, 'read', raw=True)[1]
+return self._processflagsfunc(text, flags, 'raw')[1]
 
-def _processflagsfunc(self, text, flags, operation, raw=False):
+def _processflagsfunc(self, text, flags, operation):
 # fast path: no flag processors will run
 if flags == 0:
 return text, True
-if not operation in ('read', 'write'):
+if not operation in ('read', 'write', 'raw'):
 raise error.ProgrammingError(_("invalid '%s' operation") %
  operation)
 # Check all flags are known.
@@ -188,7 +188,7 @@
 if processor is not None:
 readtransform, writetransform, rawtransform = processor
 
-if raw:
+if operation == 'raw':
 vhash = rawtransform(self, text)
 elif operation == 'read':
 text, vhash = readtransform(self, text)



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


D6804: revlog: stop using `_processflags` directly

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We now use the specialized versions.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1645,7 +1645,11 @@
 # no extra flags set, no flag processor runs, text = rawtext
 return rawtext
 
-text, validatehash = self._processflags(rawtext, flags, 'read', 
raw=raw)
+if raw:
+validatehash = self._processflagsraw(rawtext, flags)
+text = rawtext
+else:
+text, validatehash = self._processflagsread(rawtext, flags)
 if validatehash:
 self.checkhash(text, node, rev=rev)
 if not validated:



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


D6806: flagprocessors: _processflags

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  People should use the specialized version instead now.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlogutils/flagutil.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -91,6 +91,8 @@
 
 def _processflags(self, text, flags, operation, raw=False):
 """deprecated entry point to access flag processors"""
+msg = ('_processflag(...) use the specialized variant')
+util.nouideprecwarn(msg, '5.2', stacklevel=2)
 if raw:
 return text, self._processflagsraw(text, flags)
 elif operation == 'read':



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


D6805: simplestorerepo: stop using `_processflags` directly

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We now use the specialized versions.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/simplestorerepo.py

CHANGE DETAILS

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -290,7 +290,11 @@
 path = b'/'.join([self._storepath, hex(node)])
 rawtext = self._svfs.read(path)
 
-text, validatehash = self._processflags(rawtext, flags, 'read', 
raw=raw)
+if raw:
+validatehash = self._processflagsraw(rawtext, flags)
+text = rawtext
+else:
+text, validatehash = self._processflagsread(rawtext, flags)
 if validatehash:
 self.checkhash(text, node, rev=rev)
 



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


D6801: flagprocessors: use _processflagswrite for write operation

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  There are no ambiguity for 'write' operation so it is simple to replace.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py
  mercurial/revlog.py
  tests/simplestorerepo.py

CHANGE DETAILS

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -452,7 +452,7 @@
 if flags:
 node = node or storageutil.hashrevisionsha1(text, p1, p2)
 
-rawtext, validatehash = self._processflags(text, flags, 'write')
+rawtext, validatehash = self._processflagswrite(text, flags)
 
 node = node or storageutil.hashrevisionsha1(text, p1, p2)
 
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1819,7 +1819,7 @@
 if flags:
 node = node or self.hash(text, p1, p2)
 
-rawtext, validatehash = self._processflags(text, flags, 'write')
+rawtext, validatehash = self._processflagswrite(text, flags)
 
 # If the flag processor modifies the revision data, ignore any provided
 # cachedelta.
diff --git a/hgext/remotefilelog/remotefilelog.py 
b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -136,7 +136,7 @@
 node = storageutil.hashrevisionsha1(text, p1, p2)
 
 meta, metaoffset = storageutil.parsemeta(text)
-rawtext, validatehash = self._processflags(text, flags, 'write')
+rawtext, validatehash = self._processflagswrite(text, flags)
 return self.addrawrevision(rawtext, transaction, linknode, p1, p2,
node, flags, cachedelta,
_metatuple=(meta, metaoffset))



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


D6803: flagprocessors: use _processflagsraw in easy cases

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  When there are no ambiguity regarding the `raw` value, we can simply use the 
new
  method.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlogutils/deltas.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py
+++ b/mercurial/revlogutils/deltas.py
@@ -521,8 +521,7 @@
 fulltext = mdiff.patch(basetext, delta)
 
 try:
-res = revlog._processflags(fulltext, flags, 'read', raw=True)
-fulltext, validatehash = res
+validatehash = revlog._processflagsraw(fulltext, flags)
 if validatehash:
 revlog.checkhash(fulltext, expectednode, p1=p1, p2=p2)
 if flags & REVIDX_ISCENSORED:



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


D6802: flagprocessors: use _processflagsread in simple cases

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  When there are no ambiguity regarding the `raw` value, we can simply use the 
new
  method.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py

CHANGE DETAILS

diff --git a/hgext/remotefilelog/remotefilelog.py 
b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -325,7 +325,7 @@
 flags = store.getmeta(self.filename, node).get(constants.METAKEYFLAG, 
0)
 if flags == 0:
 return rawtext
-text, verifyhash = self._processflags(rawtext, flags, 'read')
+text, verifyhash = self._processflagsread(rawtext, flags)
 return text
 
 def rawdata(self, node):



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


D6800: flagprocessors: introduce specialized functions

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This make the call site clearer and the open the way to more diverse return
  types.
  
  For now, the same old code is still in use under the hood.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlogutils/flagutil.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -90,12 +90,20 @@
 _flagserrorclass = error.RevlogError
 
 def _processflags(self, text, flags, operation, raw=False):
-"""Inspect revision data flags and applies transforms defined by
-registered flag processors.
+"""deprecated entry point to access flag processors"""
+if raw:
+return text, self._processflagsraw(text, flags)
+elif operation == 'read':
+return self._processflagsread(text, flags)
+else: # write operation
+return self._processflagswrite(text, flags)
+
+def _processflagsread(self, text, flags):
+"""Inspect revision data flags and applies read transformations defined
+by registered flag processors.
 
 ``text`` - the revision data to process
 ``flags`` - the revision flags
-``operation`` - the operation being performed (read or write)
 ``raw`` - an optional argument describing if the raw transform should 
be
 applied.
 
@@ -107,10 +115,46 @@
 Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
 processed text and ``validatehash`` is a bool indicating whether the
 returned text should be checked for hash integrity.
+"""
+return self._processflagsfunc(text, flags, 'read')
 
-Note: If the ``raw`` argument is set, it has precedence over the
-operation and will only update the value of ``validatehash``.
+def _processflagswrite(self, text, flags):
+"""Inspect revision data flags and applies write transformations 
defined
+by registered flag processors.
+
+``text`` - the revision data to process
+``flags`` - the revision flags
+
+This method processes the flags in the order (or reverse order if
+``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
+flag processors registered for present flags. The order of flags 
defined
+in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
+
+Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
+processed text and ``validatehash`` is a bool indicating whether the
+returned text should be checked for hash integrity.
 """
+return self._processflagsfunc(text, flags, 'write')
+
+def _processflagsraw(self, text, flags):
+"""Inspect revision data flags to check is the content hash should be
+validated.
+
+``text`` - the revision data to process
+``flags`` - the revision flags
+
+This method processes the flags in the order (or reverse order if
+``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
+flag processors registered for present flags. The order of flags 
defined
+in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
+
+Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
+processed text and ``validatehash`` is a bool indicating whether the
+returned text should be checked for hash integrity.
+"""
+return self._processflagsfunc(text, flags, 'read', raw=True)[1]
+
+def _processflagsfunc(self, text, flags, operation, raw=False):
 # fast path: no flag processors will run
 if flags == 0:
 return text, True



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


D6799: flagutil: use it in simplestorerepo

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This remove the other code duplication of the `_processflags` code.
  
  To be honest, this code looks very dead since it is not run by either 
developer
  nor buildbot. However, we update the code to make the task of reviving this 
less
  daunting.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/simplestorerepo.py

CHANGE DETAILS

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -91,7 +91,7 @@
 node = attr.ib(default=None)
 
 @interfaceutil.implementer(repository.ifilestorage)
-class filestorage(object):
+class filestorage(flagutil.flagprocessorsmixin):
 """Implements storage for a tracked path.
 
 Data is stored in the VFS in a directory corresponding to the tracked
@@ -102,6 +102,8 @@
 Fulltext data is stored in files having names of the node.
 """
 
+_flagserrorclass = simplestoreerror
+
 def __init__(self, svfs, path):
 self._svfs = svfs
 self._path = path
@@ -119,6 +121,8 @@
 self._index = []
 self._refreshindex()
 
+self._flagprocessors = dict(flagutil.flagprocessors)
+
 def _refreshindex(self):
 self._indexbynode.clear()
 self._indexbyrev.clear()
@@ -263,45 +267,6 @@
 
 return True
 
-def _processflags(self, text, flags, operation, raw=False):
-if flags == 0:
-return text, True
-
-if flags & ~flagutil.REVIDX_KNOWN_FLAGS:
-raise simplestoreerror(_("incompatible revision flag '%#x'") %
-   (flags & ~flagutil.REVIDX_KNOWN_FLAGS))
-
-validatehash = True
-# Depending on the operation (read or write), the order might be
-# reversed due to non-commutative transforms.
-orderedflags = revlog.REVIDX_FLAGS_ORDER
-if operation == 'write':
-orderedflags = reversed(orderedflags)
-
-for flag in orderedflags:
-# If a flagprocessor has been registered for a known flag, apply 
the
-# related operation transform and update result tuple.
-if flag & flags:
-vhash = True
-
-if flag not in revlog._flagprocessors:
-message = _("missing processor for flag '%#x'") % (flag)
-raise simplestoreerror(message)
-
-processor = revlog._flagprocessors[flag]
-if processor is not None:
-readtransform, writetransform, rawtransform = processor
-
-if raw:
-vhash = rawtransform(self, text)
-elif operation == 'read':
-text, vhash = readtransform(self, text)
-else:  # write operation
-text, vhash = writetransform(self, text)
-validatehash = validatehash and vhash
-
-return text, validatehash
-
 def checkhash(self, text, node, p1=None, p2=None, rev=None):
 if p1 is None and p2 is None:
 p1, p2 = self.parents(node)



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


D6796: flagutil: introduce a flagprocessorsmixin class

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  To avoid code duplication, we will provide a simple "ready to use" mixin that
  carry the appropriate logic. First we use it in standard revlog, we'll remove
  code duplication in later changesets.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlog.py
  mercurial/revlogutils/flagutil.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -78,3 +78,74 @@
 msg = _("cannot register multiple processors on flag '%#x'.") % (flag)
 raise error.Abort(msg)
 flagprocessors[flag] = processor
+
+class flagprocessorsmixin(object):
+"""basic mixin to support revlog flag processing
+
+Make sure the `_flagprocessors` attribute is set at ``__init__`` time.
+
+See the documentation of the ``_processflags`` method for details.
+"""
+
+def _processflags(self, text, flags, operation, raw=False):
+"""Inspect revision data flags and applies transforms defined by
+registered flag processors.
+
+``text`` - the revision data to process
+``flags`` - the revision flags
+``operation`` - the operation being performed (read or write)
+``raw`` - an optional argument describing if the raw transform should 
be
+applied.
+
+This method processes the flags in the order (or reverse order if
+``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
+flag processors registered for present flags. The order of flags 
defined
+in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
+
+Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
+processed text and ``validatehash`` is a bool indicating whether the
+returned text should be checked for hash integrity.
+
+Note: If the ``raw`` argument is set, it has precedence over the
+operation and will only update the value of ``validatehash``.
+"""
+# fast path: no flag processors will run
+if flags == 0:
+return text, True
+if not operation in ('read', 'write'):
+raise error.ProgrammingError(_("invalid '%s' operation") %
+ operation)
+# Check all flags are known.
+if flags & ~REVIDX_KNOWN_FLAGS:
+raise error.RevlogError(_("incompatible revision flag '%#x'") %
+(flags & ~REVIDX_KNOWN_FLAGS))
+validatehash = True
+# Depending on the operation (read or write), the order might be
+# reversed due to non-commutative transforms.
+orderedflags = REVIDX_FLAGS_ORDER
+if operation == 'write':
+orderedflags = reversed(orderedflags)
+
+for flag in orderedflags:
+# If a flagprocessor has been registered for a known flag, apply 
the
+# related operation transform and update result tuple.
+if flag & flags:
+vhash = True
+
+if flag not in self._flagprocessors:
+message = _("missing processor for flag '%#x'") % (flag)
+raise error.RevlogError(message)
+
+processor = self._flagprocessors[flag]
+if processor is not None:
+readtransform, writetransform, rawtransform = processor
+
+if raw:
+vhash = rawtransform(self, text)
+elif operation == 'read':
+text, vhash = readtransform(self, text)
+else: # write operation
+text, vhash = writetransform(self, text)
+validatehash = validatehash and vhash
+
+return text, validatehash
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -261,7 +261,7 @@
 p = versionformat_pack(version) + p[4:]
 return p
 
-class revlog(object):
+class revlog(flagutil.flagprocessorsmixin):
 """
 the underlying revision storage object
 
@@ -1711,69 +1711,6 @@
 """
 return storageutil.hashrevisionsha1(text, p1, p2)
 
-def _processflags(self, text, flags, operation, raw=False):
-"""Inspect revision data flags and applies transforms defined by
-registered flag processors.
-
-``text`` - the revision data to process
-``flags`` - the revision flags
-``operation`` - the operation being performed (read or write)
-``raw`` - an optional argument describing if the raw transform should 
be
-applied.
-
-This method 

D6798: flagutil: make the error class used by the mixin configurable

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  One of the code duplication use a different error class. So let's make it
  possible to do so.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlogutils/flagutil.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -87,6 +87,8 @@
 See the documentation of the ``_processflags`` method for details.
 """
 
+_flagserrorclass = error.RevlogError
+
 def _processflags(self, text, flags, operation, raw=False):
 """Inspect revision data flags and applies transforms defined by
 registered flag processors.
@@ -117,8 +119,8 @@
  operation)
 # Check all flags are known.
 if flags & ~REVIDX_KNOWN_FLAGS:
-raise error.RevlogError(_("incompatible revision flag '%#x'") %
-(flags & ~REVIDX_KNOWN_FLAGS))
+raise self._flagserrorclass(_("incompatible revision flag '%#x'") %
+(flags & ~REVIDX_KNOWN_FLAGS))
 validatehash = True
 # Depending on the operation (read or write), the order might be
 # reversed due to non-commutative transforms.
@@ -134,7 +136,7 @@
 
 if flag not in self._flagprocessors:
 message = _("missing processor for flag '%#x'") % (flag)
-raise error.RevlogError(message)
+raise self._flagserrorclass(message)
 
 processor = self._flagprocessors[flag]
 if processor is not None:



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


D6797: flagutil: use the new mixin use in remotefilelog

2019-09-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This remove one of the code duplication. Hooray \o/.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py

CHANGE DETAILS

diff --git a/hgext/remotefilelog/remotefilelog.py 
b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -25,6 +25,8 @@
 )
 from mercurial.utils import storageutil
 
+from mercurial.revlogutils import flagutil
+
 from . import (
 constants,
 fileserverclient,
@@ -45,7 +47,7 @@
 raise KeyError(node)
 return node
 
-class remotefilelog(object):
+class remotefilelog(flagutil.flagprocessorsmixin):
 
 _generaldelta = True
 
@@ -57,6 +59,8 @@
 
 self.version = 1
 
+self._flagprocessors = dict(flagutil.flagprocessors)
+
 def read(self, node):
 """returns the file contents at this node"""
 t = self.revision(node)
@@ -327,28 +331,6 @@
 def rawdata(self, node):
 return self.revision(node, raw=False)
 
-def _processflags(self, text, flags, operation, raw=False):
-# mostly copied from hg/mercurial/revlog.py
-validatehash = True
-orderedflags = revlog.REVIDX_FLAGS_ORDER
-if operation == 'write':
-orderedflags = reversed(orderedflags)
-for flag in orderedflags:
-if flag & flags:
-vhash = True
-if flag not in revlog._flagprocessors:
-message = _("missing processor for flag '%#x'") % (flag)
-raise revlog.RevlogError(message)
-readfunc, writefunc, rawfunc = revlog._flagprocessors[flag]
-if raw:
-vhash = rawfunc(self, text)
-elif operation == 'read':
-text, vhash = readfunc(self, text)
-elif operation == 'write':
-text, vhash = writefunc(self, text)
-validatehash = validatehash and vhash
-return text, validatehash
-
 def _read(self, id):
 """reads the raw file blob from disk, cache, or server"""
 fileservice = self.repo.fileservice



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


D6795: strip: fix bug with treemanifests and unordered linkrevs

2019-09-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is the treemanifest version of f45f7390c1c5 
 
(strip: calculate
  list of extra nodes to save and pass it to changegroupsubset,
  2008-01-19).

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/repair.py
  tests/test-strip-cross.t

CHANGE DETAILS

diff --git a/tests/test-strip-cross.t b/tests/test-strip-cross.t
--- a/tests/test-strip-cross.t
+++ b/tests/test-strip-cross.t
@@ -203,14 +203,9 @@
   checking changesets
   checking manifests
   checking directory manifests
-   dir/@0: parent-directory manifest refers to unknown revision 1c556153fe54
-   dir/@1: parent-directory manifest refers to unknown revision 1f76dba919fd
   crosschecking files in changesets and manifests
   checking files
-   dir/other@1: 5d9299349fc0 not in manifests
   checked 3 changesets with 4 changes to 3 files
-  3 integrity errors encountered!
-  (first damaged changeset appears to be 0)
   
   % Trying to strip revision 3
   saved backup bundle to 
$TESTTMP/treemanifests/3/.hg/strip-backup/e4e3de5c3cb2-f4c70376-backup.hg
diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -81,14 +81,12 @@
 _, brokenset = revlog.getstrippoint(striprev)
 return [revlog.linkrev(r) for r in brokenset]
 
-def _collectmanifest(repo, striprev):
-return _collectrevlog(repo.manifestlog.getstorage(b''), striprev)
-
 def _collectbrokencsets(repo, files, striprev):
 """return the changesets which will be broken by the truncation"""
 s = set()
 
-s.update(_collectmanifest(repo, striprev))
+for revlog in manifestrevlogs(repo):
+s.update(_collectrevlog(revlog, striprev))
 for fname in files:
 s.update(_collectrevlog(repo.file(fname), striprev))
 



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


D6793: tests: show broken strip with treemanifests and unordered linkrevs

2019-09-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is the treemanifest version of issue764.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-strip-cross.t

CHANGE DETAILS

diff --git a/tests/test-strip-cross.t b/tests/test-strip-cross.t
--- a/tests/test-strip-cross.t
+++ b/tests/test-strip-cross.t
@@ -8,6 +8,7 @@
   > count=1
   > for i in "$@"; do
   > for f in $i; do
+  > mkdir -p `dirname $f`
   > echo $count > $f
   > done
   > count=`expr $count + 1`
@@ -160,3 +161,65 @@
   checked 3 changesets with 3 changes to 2 files
   
   $ cd ..
+
+Now a similar test for a non-root manifest revlog
+  $ cat >> $HGRCPATH < [experimental]
+  > treemanifests = yes
+  > EOF
+  $ mkdir treemanifests
+  $ cd treemanifests
+  $ 
+  $ hg --config experimental.treemanifest=True init orig
+  $ cd orig
+  $ commit 'dir/file'
+  $ commit 'dir/other'
+  $ commit '' 'dir/other'
+  $ HGUSER=yet-another-user; export HGUSER
+  $ commit 'otherdir dir/file'
+  $ commit 'otherdir dir/other' 'otherdir dir/file'
+  $ cd ..
+  $ hg --config experimental.treemanifest=True clone -q -U -r 1 -r 2 -r 3 -r 4 
orig crossed
+  $ cd crossed
+  $ hg debugindex --dir dir
+ rev linkrev nodeid   p1   p2
+   0   2 6bbc6fee55c2  
+   1   0 1c556153fe54  
+   2   1 1f76dba919fd  
+   3   3 bbee06ad59d5  
+
+  $ cd ..
+  $ for i in 2 3; do
+  > hg --config experimental.treemanifest=True clone -q -U --pull crossed 
$i
+  > echo "% Trying to strip revision $i"
+  > hg --cwd $i strip $i
+  > echo "% Verifying"
+  > hg --cwd $i verify
+  > echo
+  > done
+  % Trying to strip revision 2
+  saved backup bundle to 
$TESTTMP/treemanifests/2/.hg/strip-backup/145f5c75f9ac-a105cfbe-backup.hg
+  % Verifying
+  checking changesets
+  checking manifests
+  checking directory manifests
+   dir/@0: parent-directory manifest refers to unknown revision 1c556153fe54
+   dir/@1: parent-directory manifest refers to unknown revision 1f76dba919fd
+  crosschecking files in changesets and manifests
+  checking files
+   dir/other@1: 5d9299349fc0 not in manifests
+  checked 3 changesets with 4 changes to 3 files
+  3 integrity errors encountered!
+  (first damaged changeset appears to be 0)
+  
+  % Trying to strip revision 3
+  saved backup bundle to 
$TESTTMP/treemanifests/3/.hg/strip-backup/e4e3de5c3cb2-f4c70376-backup.hg
+  % Verifying
+  checking changesets
+  checking manifests
+  checking directory manifests
+  crosschecking files in changesets and manifests
+  checking files
+  checked 3 changesets with 4 changes to 3 files
+  
+  $ cd ..



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


D6794: repair: extract a helper for generating all manifest revlogs

2019-09-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We'll need to walk the manifest revlogs also to figure out which
  manifests have linkrevs out of order (for fixing the bug shown in the
  previous patch).
  
  By the way, perhaps it would be more efficient in many cases to find
  only the relevant directory manifest revlogs based on the files
  instead of walking the entire store, but that can be changed later.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/repair.py

CHANGE DETAILS

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -364,11 +364,11 @@
 callback.addnodes(nodelist)
 
 def stripmanifest(repo, striprev, tr, files):
-revlog = repo.manifestlog.getstorage(b'')
-revlog.strip(striprev, tr)
-striptrees(repo, tr, striprev, files)
+for revlog in manifestrevlogs(repo):
+revlog.strip(striprev, tr)
 
-def striptrees(repo, tr, striprev, files):
+def manifestrevlogs(repo):
+yield repo.manifestlog.getstorage(b'')
 if 'treemanifest' in repo.requirements:
 # This logic is safe if treemanifest isn't enabled, but also
 # pointless, so we skip it if treemanifest isn't enabled.
@@ -376,7 +376,7 @@
 if (unencoded.startswith('meta/') and
 unencoded.endswith('00manifest.i')):
 dir = unencoded[5:-12]
-repo.manifestlog.getstorage(dir).strip(striprev, tr)
+yield repo.manifestlog.getstorage(dir)
 
 def rebuildfncache(ui, repo):
 """Rebuilds the fncache file from repo history.



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


D6792: tests: split out manifest case from test-strip-cross.t

2019-09-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The manifest case was added on after the other cases, in d67cfe0d4714 

  (test-strip-cross: test handling of linkrev crosses in the manifest,
  2008-01-20). I think it's easier to read and modify if it's separated.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-strip-cross.t

CHANGE DETAILS

diff --git a/tests/test-strip-cross.t b/tests/test-strip-cross.t
--- a/tests/test-strip-cross.t
+++ b/tests/test-strip-cross.t
@@ -2,8 +2,6 @@
 
   $ echo '[extensions]' >> $HGRCPATH
   $ echo 'strip =' >> $HGRCPATH
-  $ hg init orig
-  $ cd orig
   $ commit()
   > {
   > hg up -qC null
@@ -19,27 +17,20 @@
 
 2 1 0 2 0 1 2
 
+  $ mkdir files
+  $ cd files
+  $ hg init orig
+  $ cd orig
   $ commit '201 210'
   $ commit '102 120' '210'
   $ commit '021'
   $ commit '201' '021 120'
   $ commit '012 021' '102 201' '120 210'
-  $ commit 'manifest-file'
   $ commit '102 120' '012 210' '021 201'
   $ commit '201 210' '021 120' '012 102'
-  $ HGUSER=another-user; export HGUSER
-  $ commit 'manifest-file'
-  $ commit '012' 'manifest-file'
   $ cd ..
-  $ hg clone -q -U -r 4 -r 6 -r 7 -r 8 -r 9 orig crossed
+  $ hg clone -q -U -r 4 -r 5 -r 6 orig crossed
   $ cd crossed
-  $ hg debugindex --manifest
- rev linkrev nodeid   p1   p2
-   0   0 6f105cbb914d  
-   1   3 1b55917b3699  
-   2   1 8f3d04e263e5  
-   3   2 f0ef8726ac4f  
-   4   4 0b76e38b4070  
 
   $ for i in 012 021 102 120 201 210; do
   > echo $i
@@ -83,7 +74,7 @@
2   0 2661d26c6496  
   
   $ cd ..
-  $ for i in 0 1 2 3 4; do
+  $ for i in 0 1 2; do
   > hg clone -q -U --pull crossed $i
   > echo "% Trying to strip revision $i"
   > hg --cwd $i strip $i
@@ -92,47 +83,80 @@
   > echo
   > done
   % Trying to strip revision 0
-  saved backup bundle to $TESTTMP/0/.hg/strip-backup/*-backup.hg (glob)
+  saved backup bundle to 
$TESTTMP/files/0/.hg/strip-backup/cbb8c2f0a2e3-239800b9-backup.hg
   % Verifying
   checking changesets
   checking manifests
   crosschecking files in changesets and manifests
   checking files
-  checked 4 changesets with 15 changes to 7 files
+  checked 2 changesets with 12 changes to 6 files
   
   % Trying to strip revision 1
-  saved backup bundle to $TESTTMP/1/.hg/strip-backup/*-backup.hg (glob)
+  saved backup bundle to 
$TESTTMP/files/1/.hg/strip-backup/124ecc0cbec9-6104543f-backup.hg
+  % Verifying
+  checking changesets
+  checking manifests
+  crosschecking files in changesets and manifests
+  checking files
+  checked 2 changesets with 12 changes to 6 files
+  
+  % Trying to strip revision 2
+  saved backup bundle to 
$TESTTMP/files/2/.hg/strip-backup/f6439b304a1a-c6505a5f-backup.hg
   % Verifying
   checking changesets
   checking manifests
   crosschecking files in changesets and manifests
   checking files
-  checked 4 changesets with 14 changes to 7 files
+  checked 2 changesets with 12 changes to 6 files
   
+  $ cd ..
+
+Do a similar test where the manifest revlog has unordered linkrevs
+  $ mkdir manifests
+  $ cd manifests
+  $ hg init orig
+  $ cd orig
+  $ commit 'file'
+  $ commit 'other'
+  $ commit '' 'other'
+  $ HGUSER=another-user; export HGUSER
+  $ commit 'file'
+  $ commit 'other' 'file'
+  $ cd ..
+  $ hg clone -q -U -r 1 -r 2 -r 3 -r 4 orig crossed
+  $ cd crossed
+  $ hg debugindex --manifest
+ rev linkrev nodeid   p1   p2
+   0   2 6bbc6fee55c2  
+   1   0 1c556153fe54  
+   2   1 1f76dba919fd  
+   3   3 bbee06ad59d5  
+
+  $ cd ..
+  $ for i in 2 3; do
+  > hg clone -q -U --pull crossed $i
+  > echo "% Trying to strip revision $i"
+  > hg --cwd $i strip $i
+  > echo "% Verifying"
+  > hg --cwd $i verify
+  > echo
+  > done
   % Trying to strip revision 2
-  saved backup bundle to $TESTTMP/2/.hg/strip-backup/*-backup.hg (glob)
+  saved backup bundle to 
$TESTTMP/manifests/2/.hg/strip-backup/f3015ad03c03-4d98bdc2-backup.hg
   % Verifying
   checking changesets
   checking manifests
   crosschecking files in changesets and manifests
   checking files
-  checked 4 changesets with 14 changes to 7 files
+  checked 3 changesets with 3 changes to 2 files
   
   % Trying to strip revision 3
-  saved backup bundle to $TESTTMP/3/.hg/strip-backup/*-backup.hg (glob)
+  saved backup bundle to 
$TESTTMP/manifests/3/.hg/strip-backup/9632aa303aa4-69192e3f-backup.hg
   % Verifying
   checking changesets
   checking manifests
   crosschecking files in 

D6791: tests: don't log manifest-file in test-strip-cross.t

2019-09-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I'm confident that the file is there only to help produce a certain
  manifest log; there is nothing special about the file's filelog
  itself. (And there already is a `hg debugindex --manifest` call higher
  up in the file that shows the crossed linkrevs.)

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-strip-cross.t

CHANGE DETAILS

diff --git a/tests/test-strip-cross.t b/tests/test-strip-cross.t
--- a/tests/test-strip-cross.t
+++ b/tests/test-strip-cross.t
@@ -41,7 +41,7 @@
3   2 f0ef8726ac4f  
4   4 0b76e38b4070  
 
-  $ for i in 012 021 102 120 201 210 manifest-file; do
+  $ for i in 012 021 102 120 201 210; do
   > echo $i
   > hg debugindex $i
   > echo
@@ -82,11 +82,6 @@
1   1 5d9299349fc0  
2   0 2661d26c6496  
   
-  manifest-file
- rev linkrev nodeid   p1   p2
-   0   3 b8e02f643373  
-   1   4 5d9299349fc0  
-  
   $ cd ..
   $ for i in 0 1 2 3 4; do
   > hg clone -q -U --pull crossed $i



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


D6790: tests: use positive revision numbers in test-strip-cross.t

2019-09-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It took me a long time to realize that '-r -1' was pulling revision -1
  because I didn't even notice the minus sign until I tried changing the
  revision number. The order of arguments doesn't matter, so I changed
  from decreasing order to increasing while at it.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-strip-cross.t

CHANGE DETAILS

diff --git a/tests/test-strip-cross.t b/tests/test-strip-cross.t
--- a/tests/test-strip-cross.t
+++ b/tests/test-strip-cross.t
@@ -31,7 +31,7 @@
   $ commit 'manifest-file'
   $ commit '012' 'manifest-file'
   $ cd ..
-  $ hg clone -q -U -r -1 -r -2 -r -3 -r -4 -r -6 orig crossed
+  $ hg clone -q -U -r 4 -r 6 -r 7 -r 8 -r 9 orig crossed
   $ cd crossed
   $ hg debugindex --manifest
  rev linkrev nodeid   p1   p2



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


D6789: check-code: allow command substitution with $(command)

2019-09-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Both `command` and $(command) are specified by POSIX. The latter nests
  better. I don't see why we shouldn't allow both (or only the latter).

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/check-code.py

CHANGE DETAILS

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -116,7 +116,6 @@
 (r'\bls\b.*-\w*R', "don't use 'ls -R', use 'find'"),
 (r'printf.*[^\\]\\([1-9]|0\d)', r"don't use 'printf \NNN', use Python"),
 (r'printf.*[^\\]\\x', "don't use printf \\x, use Python"),
-(r'\$\(.*\)', "don't use $(expr), use `expr`"),
 (r'rm -rf \*', "don't use naked rm -rf, target a directory"),
 (r'\[[^\]]+==', '[ foo == bar ] is a bashism, use [ foo = bar ] instead'),
 (r'(^|\|\s*)grep (-\w\s+)*[^|]*[(|]\w',



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