D6447: py3: fix test-narrow* which started failing because of recent changes

2019-05-25 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGe2e507573c7c: py3: fix test-narrow* which started failing 
because of recent changes (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6447?vs=15260=15267

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

AFFECTED FILES
  hgext/narrow/narrowbundle2.py

CHANGE DETAILS

diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -61,7 +61,7 @@
 oldexclude = sorted(filter(bool, kwargs.get(r'oldexcludepats', [])))
 newinclude = sorted(filter(bool, kwargs.get(r'includepats', [])))
 newexclude = sorted(filter(bool, kwargs.get(r'excludepats', [])))
-known = {bin(n) for n in kwargs.get('known', [])}
+known = {bin(n) for n in kwargs.get(r'known', [])}
 generateellipsesbundle2(bundler, repo, oldinclude, oldexclude, newinclude,
 newexclude, version, common, heads, known,
 kwargs.get(r'depth', None))



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


D6369: templatekw: make {file_*} compare to both merge parents (issue4292)

2019-05-25 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 15266.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6369?vs=15153=15266

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

AFFECTED FILES
  mercurial/templatekw.py
  relnotes/next
  tests/test-template-keywords.t

CHANGE DETAILS

diff --git a/tests/test-template-keywords.t b/tests/test-template-keywords.t
--- a/tests/test-template-keywords.t
+++ b/tests/test-template-keywords.t
@@ -809,9 +809,9 @@
   $ hg log -l1 -T '{files}\n'
   a fourth
   $ hg log -l1 -T '{file_mods}\n'
-  third
+  
   $ hg log -l1 -T '{file_adds}\n'
-  b fifth
+  
   $ hg log -l1 -T '{file_dels}\n'
   a fourth
 
diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -15,6 +15,10 @@
 
 == Bug Fixes  ==
 
+ * issue4292: "hg log and {files} {file_adds} {file_mods} {file_dels}
+   in template show wrong files on merged revision". See details in
+   "Backwards Compatibility Changes".
+
 
 == Backwards Compatibility Changes ==
 
@@ -31,6 +35,16 @@
previously replace files *in* the configured directory by
subdirectories.
 
+* Template keyword `{file_mods}`, `{file_adds}`, and `{file_dels}`
+   have changed behavior on merge commits. They used to be relative to
+   the first parent, but they now consider both parents. `{file_adds}`
+   shows files that exists in the commit but did not exist in either
+   parent. `{file_dels}` shows files that do not exist in the commit
+   but existed in either parent. `{file_mods}` show the remaining
+   files from `{files}` that were not in the other two
+   sets.
+
+
 == Internal API Changes ==
 
  * Matchers are no longer iterable. Use `match.files()` instead.
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -290,11 +290,6 @@
 statmap.update((f, char) for f in files)
 return revcache['filestatusmap']  # {path: statchar}
 
-def _showfilesbystat(context, mapping, name, index):
-stat = _getfilestatus(context, mapping)
-files = stat[index]
-return templateutil.compatfileslist(context, mapping, name, files)
-
 @templatekeyword('file_copies',
  requires={'repo', 'ctx', 'cache', 'revcache'})
 def showfilecopies(context, mapping):
@@ -332,17 +327,23 @@
 @templatekeyword('file_adds', requires={'ctx', 'revcache'})
 def showfileadds(context, mapping):
 """List of strings. Files added by this changeset."""
-return _showfilesbystat(context, mapping, 'file_add', 1)
+ctx = context.resource(mapping, 'ctx')
+return templateutil.compatfileslist(context, mapping, 'file_add',
+ctx.filesadded())
 
 @templatekeyword('file_dels', requires={'ctx', 'revcache'})
 def showfiledels(context, mapping):
 """List of strings. Files removed by this changeset."""
-return _showfilesbystat(context, mapping, 'file_del', 2)
+ctx = context.resource(mapping, 'ctx')
+return templateutil.compatfileslist(context, mapping, 'file_del',
+ctx.filesremoved())
 
 @templatekeyword('file_mods', requires={'ctx', 'revcache'})
 def showfilemods(context, mapping):
 """List of strings. Files modified by this changeset."""
-return _showfilesbystat(context, mapping, 'file_mod', 0)
+ctx = context.resource(mapping, 'ctx')
+return templateutil.compatfileslist(context, mapping, 'file_mod',
+ctx.filesmodified())
 
 @templatekeyword('files', requires={'ctx'})
 def showfiles(context, mapping):



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


Re: [PATCH 2 of 3 STABLE] manifest: avoid corruption by dropping removed files with pure (issue5801)

2019-05-25 Thread Yuya Nishihara
On Fri, 24 May 2019 00:01:39 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison 
> # Date 1558662864 14400
> #  Thu May 23 21:54:24 2019 -0400
> # Branch stable
> # Node ID 4cb54e688c12790fcf3cacff2b2fb3822e9f8e8f
> # Parent  89c0c8edc9d40ccb707acbeccff25891c5456521
> manifest: avoid corruption by dropping removed files with pure (issue5801)

Queued for stable, thanks.

Maybe we'll need some unit tests for this compaction method?

> @@ -298,6 +302,16 @@ class _lazymanifest(object):
>  i += 1
>  if i == len(self.positions) or self.positions[i] < 0:
>  break
> +
> +# A removed file has no positions[] entry, but does have 
> an
> +# overwritten first byte.  Break out and find the end of 
> the
> +# current good entry/entries if there is a removed file
> +# before the next position.
> +if (self.hasremovals
> +and self.data.find('\n\x00', cur,
> +   self.positions[i]) != -1):
> +break

Just curious how slow it would be if we just did "if hasremovals: break".
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6367: context: add ctx.files{modified,added,removed}() methods

2019-05-25 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG65fa61ca20af: context: add 
ctx.files{modified,added,removed}() methods (authored by martinvonz, committed 
by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6367?vs=15151=15264#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6367?vs=15151=15264

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

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -463,6 +463,24 @@
 return self._changeset.date
 def files(self):
 return self._changeset.files
+def filesmodified(self):
+modified = set(self.files())
+modified.difference_update(self.filesadded())
+modified.difference_update(self.filesremoved())
+return sorted(modified)
+def filesadded(self):
+added = []
+for f in self.files():
+if not any(f in p for p in self.parents()):
+added.append(f)
+return added
+def filesremoved(self):
+removed = []
+for f in self.files():
+if f not in self:
+removed.append(f)
+return removed
+
 @propertycache
 def _copies(self):
 source = self._repo.ui.config('experimental', 'copies.read-from')
@@ -1170,6 +1188,10 @@
 return self._status.removed
 def deleted(self):
 return self._status.deleted
+filesmodified = modified
+filesadded = added
+filesremoved = removed
+
 def branch(self):
 return encoding.tolocal(self._extra['branch'])
 def closesbranch(self):



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


D6368: tests: add test for {file_mods}, {file_adds}, {file_dels} on merge commit

2019-05-25 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG7a64ad3f325d: tests: add test for {file_mods}, {file_adds}, 
{file_dels} on merge commit (authored by martinvonz, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6368?vs=15152=15265#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6368?vs=15152=15265

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

AFFECTED FILES
  tests/test-template-keywords.t

CHANGE DETAILS

diff --git a/tests/test-template-keywords.t b/tests/test-template-keywords.t
--- a/tests/test-template-keywords.t
+++ b/tests/test-template-keywords.t
@@ -798,6 +798,23 @@
   fourth
   third
 
+Test files lists on merge commit:
+
+  $ hg co '.^' -q
+  $ touch c
+  $ hg add c
+  $ hg ci -qm 'add file'
+  $ hg merge 10 -q
+  $ hg ci -m 'merge'
+  $ hg log -l1 -T '{files}\n'
+  a fourth
+  $ hg log -l1 -T '{file_mods}\n'
+  third
+  $ hg log -l1 -T '{file_adds}\n'
+  b fifth
+  $ hg log -l1 -T '{file_dels}\n'
+  a fourth
+
 Test file copies dict:
 
   $ hg log -r8 -T '{join(file_copies, " ")}\n'
@@ -818,7 +835,7 @@
 
 Test file attributes:
 
-  $ hg log -l1 -T '{files % "{status} {pad(size, 3, left=True)} {path}\n"}'
+  $ hg log -r10 -T '{files % "{status} {pad(size, 3, left=True)} {path}\n"}'
   R a
   A   0 b
   A   7 fifth
@@ -834,7 +851,7 @@
 
 Test index keyword:
 
-  $ hg log -l 2 -T '{index + 10}{files % " {index}:{file}"}\n'
+  $ hg log -r 10:9 -T '{index + 10}{files % " {index}:{file}"}\n'
   10 0:a 1:b 2:fifth 3:fourth 4:third
   11 0:a
 



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


D6418: copies: split up _chain() in naive chaining and filtering steps

2019-05-25 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGf3d06d37e194: copies: split up _chain() in naive chaining 
and filtering steps (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6418?vs=15216=15263

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -107,8 +107,8 @@
 # This only occurs when a is a descendent of b or visa-versa.
 return min(limit, a, b)
 
-def _chain(src, dst, a, b):
-"""chain two sets of copies 'a' and 'b'"""
+def _chainandfilter(src, dst, a, b):
+"""chain two sets of copies 'a' and 'b' and filter result"""
 
 # When chaining copies in 'a' (from 'src' via some other commit 'mid') with
 # copies in 'b' (from 'mid' to 'dst'), we can get the different cases in 
the
@@ -123,31 +123,37 @@
 #   4   x   y   z   x->z
 #   5   -   x   y-
 #   6   x   x   y   x->y
+#
+# _chain() takes care of chaining the copies in 'a' and 'b', but it
+# cannot tell the difference between cases 1 and 2, between 3 and 4, or
+# between 5 and 6, so it includes all cases in its result.
+# Cases 1, 3, and 5 are then removed by _filter().
 
-# Initialize result ('t') from 'a'. This catches cases 1 & 2. We'll remove
-# case 1 later. We'll also catch cases 3 & 4 here. Case 4 will be
-# overwritten later, and case 3 will be removed later.
+t = _chain(a, b)
+_filter(src, dst, t)
+return t
+
+def _filter(src, dst, t):
+"""filters out invalid copies after chaining"""
+for k, v in list(t.items()):
+# remove copies from files that didn't exist
+if v not in src:
+del t[k]
+# remove criss-crossed copies
+elif k in src and v in dst:
+del t[k]
+# remove copies to files that were then removed
+elif k not in dst:
+del t[k]
+
+def _chain(a, b):
+"""chain two sets of copies 'a' and 'b'"""
 t = a.copy()
 for k, v in b.iteritems():
 if v in t:
-# Found a chain, i.e. cases 3 & 4. We'll remove case 3 later.
 t[k] = t[v]
 else:
-# Renamed only in 'b', i.e. cases 5 & 6. We'll remove case 5 later.
 t[k] = v
-
-for k, v in list(t.items()):
-# remove copies from files that didn't exist, i.e. case 5
-if v not in src:
-del t[k]
-# remove criss-crossed copies, i.e. case 3
-elif k in src and v in dst:
-del t[k]
-# remove copies to files that were then removed, i.e. case 1
-# and file 'y' in cases 3 & 4 (in case of rename)
-elif k not in dst:
-del t[k]
-
 return t
 
 def _tracefile(fctx, am, limit):
@@ -307,7 +313,7 @@
 if not match.always():
 childcopies = {dst: src for dst, src in childcopies.items()
if match(dst)}
-childcopies = _chain(a, childctx, copies, childcopies)
+childcopies = _chainandfilter(a, childctx, copies, childcopies)
 heapq.heappush(work, (c, parent, childcopies))
 assert False
 
@@ -323,7 +329,7 @@
 
 cm = _committedforwardcopies(a, b.p1(), match)
 # combine copies from dirstate if necessary
-return _chain(a, b, cm, _dirstatecopies(b._repo, match))
+return _chainandfilter(a, b, cm, _dirstatecopies(b._repo, match))
 return _committedforwardcopies(a, b, match)
 
 def _backwardrenames(a, b, match):
@@ -367,8 +373,8 @@
 return _backwardrenames(x, y, match=match)
 if debug:
 repo.ui.debug('debug.copies: search mode: combined\n')
-return _chain(x, y, _backwardrenames(x, a, match=match),
-  _forwardcopies(a, y, match=match))
+return _chainandfilter(x, y, _backwardrenames(x, a, match=match),
+   _forwardcopies(a, y, match=match))
 
 def mergecopies(repo, c1, c2, base):
 """



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


D6370: templatekw: move showfileadds() close to showfile{mods, dels}()

2019-05-25 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb47e9712000b: templatekw: move showfileadds() close to 
showfile{mods,dels}() (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6370?vs=15081=15261

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

AFFECTED FILES
  mercurial/templatekw.py

CHANGE DETAILS

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -295,11 +295,6 @@
 files = stat[index]
 return templateutil.compatfileslist(context, mapping, name, files)
 
-@templatekeyword('file_adds', requires={'ctx', 'revcache'})
-def showfileadds(context, mapping):
-"""List of strings. Files added by this changeset."""
-return _showfilesbystat(context, mapping, 'file_add', 1)
-
 @templatekeyword('file_copies',
  requires={'repo', 'ctx', 'cache', 'revcache'})
 def showfilecopies(context, mapping):
@@ -334,6 +329,11 @@
 return templateutil.compatfilecopiesdict(context, mapping, 'file_copy',
  copies)
 
+@templatekeyword('file_adds', requires={'ctx', 'revcache'})
+def showfileadds(context, mapping):
+"""List of strings. Files added by this changeset."""
+return _showfilesbystat(context, mapping, 'file_add', 1)
+
 @templatekeyword('file_dels', requires={'ctx', 'revcache'})
 def showfiledels(context, mapping):
 """List of strings. Files removed by this changeset."""



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


D6446: relnotes: document changed behavior of ui.origbackuppath pointing to file

2019-05-25 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGba6ca4e80607: relnotes: document changed behavior of 
ui.origbackuppath pointing to file (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6446?vs=15256=15262

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

AFFECTED FILES
  relnotes/next

CHANGE DETAILS

diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -25,6 +25,11 @@
first three lines of the graph and then `.`. This is no longer
supported.
 
+ * If `ui.origbackuppath` had been (incorrectly) configured to point
+   to a file, we will now replace that file by a directory and put
+   backups in that directory. This is similar to how we would
+   previously replace files *in* the configured directory by
+   subdirectories.
 
 == Internal API Changes ==
 



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


D6368: tests: add test for {file_mods}, {file_adds}, {file_dels} on merge commit

2019-05-25 Thread martinvonz (Martin von Zweigbergk)
martinvonz added inline comments.

INLINE COMMENTS

> pulkit wrote in context.py:469
> This change should be part of previous patch right? (I can fold that in 
> previous change in flight)

Yes, thanks for noticing and fixing. I fixed it in my repo, but I must have 
forgotten to update it here.

REPOSITORY
  rHG Mercurial

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

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


D6441: help: check if a subtopic exists and raise an error if it doesn't (issue6145)

2019-05-25 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> ngoldbaum wrote in help.py:689-695
> OK, I agree that's clearer. I used `_` to match `header` and `doc` to make 
> the line a bit shorter and to make it a bit clearer for me to read since 
> those aren't being used.

This should work but we have `_` as a function imported from mercurial.i18n.

REPOSITORY
  rHG Mercurial

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

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


D6368: tests: add test for {file_mods}, {file_adds}, {file_dels} on merge commit

2019-05-25 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> context.py:469
> +modified.difference_update(self.filesadded())
> +modified.difference_update(self.filesremoved())
>  return sorted(modified)

This change should be part of previous patch right? (I can fold that in 
previous change in flight)

REPOSITORY
  rHG Mercurial

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

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


D6447: py3: fix test-narrow* which started failing because of recent changes

2019-05-25 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: martinvonz.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  #skip-blame because just r'' prefix

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/narrowbundle2.py

CHANGE DETAILS

diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -61,7 +61,7 @@
 oldexclude = sorted(filter(bool, kwargs.get(r'oldexcludepats', [])))
 newinclude = sorted(filter(bool, kwargs.get(r'includepats', [])))
 newexclude = sorted(filter(bool, kwargs.get(r'excludepats', [])))
-known = {bin(n) for n in kwargs.get('known', [])}
+known = {bin(n) for n in kwargs.get(r'known', [])}
 generateellipsesbundle2(bundler, repo, oldinclude, oldexclude, newinclude,
 newexclude, version, common, heads, known,
 kwargs.get(r'depth', None))



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


D6441: help: check if a subtopic exists and raise an error if it doesn't (issue6145)

2019-05-25 Thread ngoldbaum (Nathan Goldbaum)
ngoldbaum added inline comments.

INLINE COMMENTS

> martinvonz wrote in help.py:689-695
> I avoid for-else for the same reason, but how about this:
> 
>   if not any(subtopic in names for names, header, doc in subtopics[name]):
>   raise error.UnknownCommand(name)

OK, I agree that's clearer. I used `_` to match `header` and `doc` to make the 
line a bit shorter and to make it a bit clearer for me to read since those 
aren't being used.

REPOSITORY
  rHG Mercurial

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

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


D6442: help: include subtopic in error message if passed

2019-05-25 Thread ngoldbaum (Nathan Goldbaum)
ngoldbaum updated this revision to Diff 15259.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6442?vs=15253=15259

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

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

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -1303,6 +1303,13 @@
   *empty chunk* at the end of each *delta group* denotes the boundary to 
the
   next filelog sub-segment.
 
+non-existent subtopics print an error
+
+  $ hg help internals.foo
+  abort: no such help topic: internals.foo
+  (try 'hg help --keyword foo')
+  [255]
+
 test advanced, deprecated and experimental options are hidden in command help
   $ hg help debugoptADV
   hg debugoptADV
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -453,7 +453,7 @@
 addtopichook('config', inserttweakrc)
 
 def help_(ui, commands, name, unknowncmd=False, full=True, subtopic=None,
-  **opts):
+  fullname=None, **opts):
 '''
 Generate the help for 'name' as unformatted restructured text. If
 'name' is None, describe the commands available.
@@ -814,8 +814,16 @@
 if unknowncmd:
 raise error.UnknownCommand(name)
 else:
-msg = _('no such help topic: %s') % name
-hint = _("try 'hg help --keyword %s'") % name
+if fullname:
+formatname = fullname
+else:
+formatname = name
+if subtopic:
+hintname = subtopic
+else:
+hintname = name
+msg = _('no such help topic: %s') % formatname
+hint = _("try 'hg help --keyword %s'") % hintname
 raise error.Abort(msg, hint=hint)
 else:
 # program name
@@ -850,7 +858,7 @@
 termwidth = ui.termwidth() - 2
 if textwidth <= 0 or termwidth < textwidth:
 textwidth = termwidth
-text = help_(ui, commands, name,
+text = help_(ui, commands, name, fullname=fullname,
  subtopic=subtopic, unknowncmd=unknowncmd, full=full, **opts)
 
 blocks, pruned = minirst.parse(text, keep=keep)



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


D6441: help: check if a subtopic exists and raise an error if it doesn't (issue6145)

2019-05-25 Thread ngoldbaum (Nathan Goldbaum)
ngoldbaum updated this revision to Diff 15258.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6441?vs=15246=15258

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

AFFECTED FILES
  mercurial/help.py

CHANGE DETAILS

diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -689,6 +689,8 @@
 for names, header, doc in subtopics[name]:
 if subtopic in names:
 break
+if not any(subtopic in names for names, _, _ in subtopics[name]):
+raise error.UnknownCommand(name)
 
 if not header:
 for topic in helptable:



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


Re: [PATCH evolve-ext] py3: broad pass for python3 compatibility

2019-05-25 Thread Ludovic Chabant
> Does this make any existing tests for evolve pass on py3?

The evolve extension wasn't even loading in py3 before this patch --
mercurial core would reject it for trying to add unicode strings to the
command table.

> Taking other patches first would mean this patch would be hard to
> apply and it would miss any newly added code, so the question is: how
> hard would it be to create this patch again?

It's easy to make this patch again:

1) run mercurial's contrib/bytify_strings.py script with the --
   dictiter argument

2) fix up the few calls to exthelper.addattr to _not_ use byte strings
   (because those strings are passed to python's addattr() builtin, and
   that wants unicode).

That's it!
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel