Re: [PATCH 01 of 15] rawdata: update caller in revlog

2019-08-17 Thread Yuya Nishihara
On Thu, 15 Aug 2019 12:39:59 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David 
> # Date 1565201306 -7200
> #  Wed Aug 07 20:08:26 2019 +0200
> # Node ID 66af150744d04f984d0300fb71ff93ceb2dc28a9
> # Parent  bbe71b5afd02c764639780bfe763348d5e5d7a6b
> # EXP-Topic rawdata
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> 66af150744d0
> rawdata: update caller in revlog

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


Re: [PATCH 02 of 10] rawdata: introduce a `rawdata` method on revlog

2019-08-17 Thread Yuya Nishihara
On Wed, 07 Aug 2019 23:30:31 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David 
> # Date 1565207669 -7200
> #  Wed Aug 07 21:54:29 2019 +0200
> # Node ID fe5517914e9f519855d5f8c0ef89098e039d68c6
> # Parent  3b49bb04851ea501f005e7a58403fee3b1c52958
> # EXP-Topic rawdata
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> fe5517914e9f
> rawdata: introduce a `rawdata` method on revlog
> 
> This method aims at replacing `revision(..., raw=True)` call. The purpose of
> data returned without and without raw are different enough that having two
> different method would make sense.
> 
> This split is motivated by other work aiming at storing data on the side of 
> the
> main revision of a revlog. Having a cleaner API makes it simpler to add this
> work.
> 
> The series following this first changesets is organised as follow:
> 1) add `rawdata` method everywhere it is useful
> 2) update all caller
> 3) implement all `rawdata` method without using `revision`
> 4) deprecate the `rawdata` parameter of `revision`
> 
> diff --git a/mercurial/revlog.py b/mercurial/revlog.py
> --- a/mercurial/revlog.py
> +++ b/mercurial/revlog.py
> @@ -1720,6 +1720,13 @@ class revlog(object):
>  
>  return text
>  
> +def rawdata(self, nodeorrev, _df=None, raw=False):
> +"""return an uncompressed raw data of a given node or revision 
> number.
> +
> +_df - an existing file handle to read from. (internal-only)
> +"""
> +return self._revisiondata(nodeorrev, _df, raw=True)

Just curious. What does rawdata(raw=False|True) mean?
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6741: interfaces: create a new folder for interfaces and move repository.py in it

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

REVISION SUMMARY
  I was trying to understand current interfaces and write new ones and I 
realized
  we need to improve how current interfaces are organised. This creates a
  dedicated folder for defining interfaces and move `repository.py` which 
defines
  all the current interfaces inside it.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/import-checker.py
  hgext/lfs/__init__.py
  hgext/lfs/wrapper.py
  hgext/narrow/__init__.py
  hgext/narrow/narrowbundle2.py
  hgext/narrow/narrowcommands.py
  hgext/sqlitestore.py
  mercurial/changegroup.py
  mercurial/exchange.py
  mercurial/exchangev2.py
  mercurial/filelog.py
  mercurial/hg.py
  mercurial/httppeer.py
  mercurial/interfaces/__init__.py
  mercurial/interfaces/repository.py
  mercurial/localrepo.py
  mercurial/manifest.py
  mercurial/narrowspec.py
  mercurial/repository.py
  mercurial/revlog.py
  mercurial/revlogutils/constants.py
  mercurial/streamclone.py
  mercurial/testing/storage.py
  mercurial/utils/storageutil.py
  mercurial/wireprotov1peer.py
  setup.py
  tests/notcapable
  tests/pullext.py
  tests/simplestorerepo.py
  tests/test-check-interfaces.py
  tests/wireprotosimplecache.py

CHANGE DETAILS

diff --git a/tests/wireprotosimplecache.py b/tests/wireprotosimplecache.py
--- a/tests/wireprotosimplecache.py
+++ b/tests/wireprotosimplecache.py
@@ -10,12 +10,14 @@
 from mercurial import (
 extensions,
 registrar,
-repository,
 util,
 wireprotoserver,
 wireprototypes,
 wireprotov2server,
 )
+from mercurial.interfaces import (
+repository,
+)
 from mercurial.utils import (
 interfaceutil,
 stringutil,
diff --git a/tests/test-check-interfaces.py b/tests/test-check-interfaces.py
--- a/tests/test-check-interfaces.py
+++ b/tests/test-check-interfaces.py
@@ -14,6 +14,9 @@
 'test-repo']):
 sys.exit(80)
 
+from mercurial.interfaces import (
+repository,
+)
 from mercurial.thirdparty.zope import (
 interface as zi,
 )
@@ -27,7 +30,6 @@
 localrepo,
 manifest,
 pycompat,
-repository,
 revlog,
 sshpeer,
 statichttprepo,
diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -32,11 +32,13 @@
 localrepo,
 mdiff,
 pycompat,
-repository,
 revlog,
 store,
 verify,
 )
+from mercurial.interfaces import (
+repository,
+)
 from mercurial.utils import (
 cborutil,
 interfaceutil,
diff --git a/tests/pullext.py b/tests/pullext.py
--- a/tests/pullext.py
+++ b/tests/pullext.py
@@ -13,6 +13,8 @@
 error,
 extensions,
 localrepo,
+)
+from mercurial.interfaces import (
 repository,
 )
 
diff --git a/tests/notcapable b/tests/notcapable
--- a/tests/notcapable
+++ b/tests/notcapable
@@ -6,7 +6,8 @@
 fi
 
 cat > notcapable-$CAP.py << EOF
-from mercurial import extensions, localrepo, repository
+from mercurial import extensions, localrepo
+from mercurial.interfaces import repository
 def extsetup(ui):
 extensions.wrapfunction(repository.peer, 'capable', wrapcapable)
 extensions.wrapfunction(localrepo.localrepository, 'peer', wrappeer)
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -1067,6 +1067,7 @@
 'mercurial.cext',
 'mercurial.cffi',
 'mercurial.hgweb',
+'mercurial.interfaces',
 'mercurial.pure',
 'mercurial.thirdparty',
 'mercurial.thirdparty.attr',
diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py
--- a/mercurial/wireprotov1peer.py
+++ b/mercurial/wireprotov1peer.py
@@ -22,10 +22,12 @@
 error,
 pushkey as pushkeymod,
 pycompat,
-repository,
 util,
 wireprototypes,
 )
+from .interfaces import (
+repository,
+)
 from .utils import (
 interfaceutil,
 )
diff --git a/mercurial/utils/storageutil.py b/mercurial/utils/storageutil.py
--- a/mercurial/utils/storageutil.py
+++ b/mercurial/utils/storageutil.py
@@ -22,8 +22,8 @@
 error,
 mdiff,
 pycompat,
-repository,
 )
+from ..interfaces import repository
 
 _nullhash = hashlib.sha1(nullid)
 
diff --git a/mercurial/testing/storage.py b/mercurial/testing/storage.py
--- a/mercurial/testing/storage.py
+++ b/mercurial/testing/storage.py
@@ -17,6 +17,8 @@
 from .. import (
 error,
 mdiff,
+)
+from ..interfaces import (
 repository,
 )
 from ..utils import (
diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -12,13 +12,15 @@
 import struct
 
 from .i18n import _
+from .interfaces import (
+repository,
+)
 from . import (
 cacheutil,
 error,
 narrowspec,

D6742: interfaceutil: move to interfaces/

2019-08-17 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Now that we have a dedicated folder for interfaces, let's move interfaceutil
  there.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/sqlitestore.py
  mercurial/filelog.py
  mercurial/httppeer.py
  mercurial/interfaces/repository.py
  mercurial/interfaces/util.py
  mercurial/localrepo.py
  mercurial/manifest.py
  mercurial/revlog.py
  mercurial/utils/interfaceutil.py
  mercurial/wireprotoserver.py
  mercurial/wireprototypes.py
  mercurial/wireprotov1peer.py
  mercurial/wireprotov2server.py
  tests/simplestorerepo.py
  tests/wireprotosimplecache.py

CHANGE DETAILS

diff --git a/tests/wireprotosimplecache.py b/tests/wireprotosimplecache.py
--- a/tests/wireprotosimplecache.py
+++ b/tests/wireprotosimplecache.py
@@ -17,9 +17,9 @@
 )
 from mercurial.interfaces import (
 repository,
+util as interfaceutil,
 )
 from mercurial.utils import (
-interfaceutil,
 stringutil,
 )
 
diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -38,10 +38,10 @@
 )
 from mercurial.interfaces import (
 repository,
+util as interfaceutil,
 )
 from mercurial.utils import (
 cborutil,
-interfaceutil,
 storageutil,
 )
 from mercurial.revlogutils import (
diff --git a/mercurial/wireprotov2server.py b/mercurial/wireprotov2server.py
--- a/mercurial/wireprotov2server.py
+++ b/mercurial/wireprotov2server.py
@@ -28,9 +28,11 @@
 wireprotoframing,
 wireprototypes,
 )
+from .interfaces import (
+util as interfaceutil,
+)
 from .utils import (
 cborutil,
-interfaceutil,
 stringutil,
 )
 
diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py
--- a/mercurial/wireprotov1peer.py
+++ b/mercurial/wireprotov1peer.py
@@ -27,9 +27,7 @@
 )
 from .interfaces import (
 repository,
-)
-from .utils import (
-interfaceutil,
+util as interfaceutil,
 )
 
 urlreq = util.urlreq
diff --git a/mercurial/wireprototypes.py b/mercurial/wireprototypes.py
--- a/mercurial/wireprototypes.py
+++ b/mercurial/wireprototypes.py
@@ -17,9 +17,11 @@
 error,
 util,
 )
+from .interfaces import (
+util as interfaceutil,
+)
 from .utils import (
 compression,
-interfaceutil,
 )
 
 # Names of the SSH protocol implementations.
diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -21,10 +21,12 @@
 wireprotov1server,
 wireprotov2server,
 )
+from .interfaces import (
+util as interfaceutil,
+)
 from .utils import (
 cborutil,
 compression,
-interfaceutil,
 )
 
 stringio = util.stringio
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -70,13 +70,13 @@
 )
 from .interfaces import (
 repository,
+util as interfaceutil,
 )
 from .revlogutils import (
 deltas as deltautil,
 flagutil,
 )
 from .utils import (
-interfaceutil,
 storageutil,
 stringutil,
 )
diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -29,9 +29,7 @@
 )
 from .interfaces import (
 repository,
-)
-from .utils import (
-interfaceutil,
+util as interfaceutil,
 )
 
 parsers = policy.importmod(r'parsers')
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -68,10 +68,10 @@
 
 from .interfaces import (
 repository,
+util as interfaceutil,
 )
 
 from .utils import (
-interfaceutil,
 procutil,
 stringutil,
 )
diff --git a/mercurial/utils/interfaceutil.py b/mercurial/interfaces/util.py
rename from mercurial/utils/interfaceutil.py
rename to mercurial/interfaces/util.py
--- a/mercurial/utils/interfaceutil.py
+++ b/mercurial/interfaces/util.py
@@ -1,4 +1,4 @@
-# interfaceutil.py - Utilities for declaring interfaces.
+# util.py - Utilities for declaring interfaces.
 #
 # Copyright 2018 Gregory Szorc 
 #
diff --git a/mercurial/interfaces/repository.py 
b/mercurial/interfaces/repository.py
--- a/mercurial/interfaces/repository.py
+++ b/mercurial/interfaces/repository.py
@@ -11,8 +11,8 @@
 from .. import (
 error,
 )
-from ..utils import (
-interfaceutil,
+from . import (
+util as interfaceutil,
 )
 
 # When narrowing is finalized and no longer subject to format changes,
diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -16,9 +16,6 @@
 import weakref
 
 from .i18n import _
-from .interfaces import (
-repository,
-)
 from . import (
 bundle2,
 error,
@@ -33,9 +30,12 @@
 wireprotov2peer,
 wireprotov2server,
 )
+from .interfaces import (
+repository,
+util as 

D6731: exchange: abort on pushing bookmarks pointing to secret changesets (issue6159)

2019-08-17 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh added a comment.


  In D6731#98871 , @pulkit wrote:
  
  > In such cases, I like the idea of having fix as two patches, first which 
demonstrates the bug and the second which fixes the bug. What do you think?
  
  Yeah, sounds good to me. The stack has been updated.

REPOSITORY
  rHG Mercurial

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

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

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


D6731: exchange: abort on pushing bookmarks pointing to secret changesets (issue6159)

2019-08-17 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 16258.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6731?vs=16225=16258

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

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

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

CHANGE DETAILS

diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -1343,9 +1343,6 @@
 Move the bookmark "foo" to point at a secret changeset
   $ hg commit -qAm_
   $ hg phase -s -f
-  $ hg log -r . --template '{node}'
-  cf489fd8a374cab73c2dc19e899bde6fe3a43f8f (no-eol)
-
 
 Pushing the bookmark "foo" now fails as it contains a secret changeset
 #if b2-pushkey
@@ -1353,60 +1350,14 @@
   pushing to $TESTTMP/issue6159remote
   searching for changes
   no changes found (ignored 1 secret changesets)
-  abort: updating bookmark foo failed!
+  abort: bookmark foo points to a secret changeset
   [255]
 #endif
-
 #if b2-binary
   $ hg push -r foo
   pushing to $TESTTMP/issue6159remote
   searching for changes
   no changes found (ignored 1 secret changesets)
-  updating bookmark foo
-  [1]
+  abort: bookmark foo points to a secret changeset
+  [255]
 #endif
-
-Now the "remote" repo contains a bookmark pointing to a nonexistent revision
-#if b2-pushkey
-  $ cd ../a
-  $ hg bookmark
- @ 1:0d2164f0ce0d
- @12:9b140be10808
-   * X 1:0d2164f0ce0d
- X@1   2:9b140be10808
- Y 5:c922c0139ca0
- Z 1:0d2164f0ce0d
- foo   -1:
- foobar2:9b140be10808
-  $ cat .hg/bookmarks
-  0d2164f0ce0d8f1d6f94351eba04b794909be66c @
-  9b140be1080824d768c5a4691a564088eede71f9 @1
-  0d2164f0ce0d8f1d6f94351eba04b794909be66c X
-  9b140be1080824d768c5a4691a564088eede71f9 X@1
-  c922c0139ca03858f655e4a2af4dd02796a63969 Y
-  0d2164f0ce0d8f1d6f94351eba04b794909be66c Z
-   foo
-  9b140be1080824d768c5a4691a564088eede71f9 foobar
-#endif
-
-#if b2-binary
-  $ cd ../a
-  $ hg bookmark
- @ 1:0d2164f0ce0d
- @12:9b140be10808
-   * X 1:0d2164f0ce0d
- X@1   2:9b140be10808
- Y 5:c922c0139ca0
- Z 1:0d2164f0ce0d
- foo   -1:
- foobar2:9b140be10808
-  $ cat .hg/bookmarks
-  0d2164f0ce0d8f1d6f94351eba04b794909be66c @
-  9b140be1080824d768c5a4691a564088eede71f9 @1
-  0d2164f0ce0d8f1d6f94351eba04b794909be66c X
-  9b140be1080824d768c5a4691a564088eede71f9 X@1
-  c922c0139ca03858f655e4a2af4dd02796a63969 Y
-  0d2164f0ce0d8f1d6f94351eba04b794909be66c Z
-   foo
-  9b140be1080824d768c5a4691a564088eede71f9 foobar
-#endif
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1034,6 +1034,15 @@
 return 'delete'
 return 'update'
 
+def _abortonsecretctx(pushop, node, b):
+"""abort if a given bookmark points to a secret changeset"""
+if not node:
+return False
+ctx = pushop.repo[node]
+if ctx.phase() == phases.secret:
+raise error.Abort(_('bookmark %s points to a secret changeset') % b)
+return False
+
 def _pushb2bookmarkspart(pushop, bundler):
 pushop.stepsdone.add('bookmarks')
 if not pushop.outbookmarks:
@@ -1042,6 +1051,7 @@
 allactions = []
 data = []
 for book, old, new in pushop.outbookmarks:
+_abortonsecretctx(pushop, new, book)
 new = bin(new)
 data.append((book, new))
 allactions.append((book, _bmaction(old, new)))
@@ -1070,6 +1080,7 @@
 assert False
 
 for book, old, new in pushop.outbookmarks:
+_abortonsecretctx(pushop, new, book)
 part = bundler.newpart('pushkey')
 part.addparam('namespace', enc('bookmarks'))
 part.addparam('key', enc(book))



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


D6740: tests: add test to demonstrate issue6159

2019-08-17 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh 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/D6740

AFFECTED FILES
  tests/test-bookmarks-pushpull.t

CHANGE DETAILS

diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -1322,3 +1322,91 @@
   abort: push failed on remote
   [255]
 #endif
+
+-- test for stop pushing bookmarks pointing to secret changesets
+
+Set up a "remote" repo
+  $ hg init issue6159remote
+  $ cd issue6159remote
+  $ echo a > a
+  $ hg add a
+  $ hg commit -m_
+  $ hg bookmark foo
+  $ cd ..
+
+Clone a local repo
+  $ hg clone -q issue6159remote issue6159local
+  $ cd issue6159local
+  $ hg up -qr foo
+  $ echo b > b
+
+Move the bookmark "foo" to point at a secret changeset
+  $ hg commit -qAm_
+  $ hg phase -s -f
+  $ hg log -r . --template '{node}'
+  cf489fd8a374cab73c2dc19e899bde6fe3a43f8f (no-eol)
+
+
+Pushing the bookmark "foo" now fails as it contains a secret changeset
+#if b2-pushkey
+  $ hg push -r foo
+  pushing to $TESTTMP/issue6159remote
+  searching for changes
+  no changes found (ignored 1 secret changesets)
+  abort: updating bookmark foo failed!
+  [255]
+#endif
+
+#if b2-binary
+  $ hg push -r foo
+  pushing to $TESTTMP/issue6159remote
+  searching for changes
+  no changes found (ignored 1 secret changesets)
+  updating bookmark foo
+  [1]
+#endif
+
+Now the "remote" repo contains a bookmark pointing to a nonexistent revision
+#if b2-pushkey
+  $ cd ../a
+  $ hg bookmark
+ @ 1:0d2164f0ce0d
+ @12:9b140be10808
+   * X 1:0d2164f0ce0d
+ X@1   2:9b140be10808
+ Y 5:c922c0139ca0
+ Z 1:0d2164f0ce0d
+ foo   -1:
+ foobar2:9b140be10808
+  $ cat .hg/bookmarks
+  0d2164f0ce0d8f1d6f94351eba04b794909be66c @
+  9b140be1080824d768c5a4691a564088eede71f9 @1
+  0d2164f0ce0d8f1d6f94351eba04b794909be66c X
+  9b140be1080824d768c5a4691a564088eede71f9 X@1
+  c922c0139ca03858f655e4a2af4dd02796a63969 Y
+  0d2164f0ce0d8f1d6f94351eba04b794909be66c Z
+   foo
+  9b140be1080824d768c5a4691a564088eede71f9 foobar
+#endif
+
+#if b2-binary
+  $ cd ../a
+  $ hg bookmark
+ @ 1:0d2164f0ce0d
+ @12:9b140be10808
+   * X 1:0d2164f0ce0d
+ X@1   2:9b140be10808
+ Y 5:c922c0139ca0
+ Z 1:0d2164f0ce0d
+ foo   -1:
+ foobar2:9b140be10808
+  $ cat .hg/bookmarks
+  0d2164f0ce0d8f1d6f94351eba04b794909be66c @
+  9b140be1080824d768c5a4691a564088eede71f9 @1
+  0d2164f0ce0d8f1d6f94351eba04b794909be66c X
+  9b140be1080824d768c5a4691a564088eede71f9 X@1
+  c922c0139ca03858f655e4a2af4dd02796a63969 Y
+  0d2164f0ce0d8f1d6f94351eba04b794909be66c Z
+   foo
+  9b140be1080824d768c5a4691a564088eede71f9 foobar
+#endif



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


D6733: setup: fix a sorting issue I noticed in package names

2019-08-17 Thread durin42 (Augie Fackler)
Closed by commit rHGf299555785c5: setup: fix a sorting issue I noticed in 
package names (authored by durin42).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6733?vs=16227=16256

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

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

AFFECTED FILES
  setup.py

CHANGE DETAILS

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -1078,8 +1078,8 @@
 'hgext', 'hgext.convert', 'hgext.fsmonitor',
 'hgext.fastannotate',
 'hgext.fsmonitor.pywatchman',
+'hgext.highlight',
 'hgext.infinitepush',
-'hgext.highlight',
 'hgext.largefiles', 'hgext.lfs', 'hgext.narrow',
 'hgext.remotefilelog',
 'hgext.zeroconf', 'hgext3rd',



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


[Bug 6187] New: .orig files that are committed as largefiles cannot be pulled

2019-08-17 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=6187

Bug ID: 6187
   Summary: .orig files that are committed as largefiles cannot be
pulled
   Product: Mercurial
   Version: 5.0.2
  Hardware: PC
OS: Windows
Status: UNCONFIRMED
  Severity: bug
  Priority: wish
 Component: largefiles
  Assignee: bugzi...@mercurial-scm.org
  Reporter: m...@simplyv4.com
CC: mercurial-devel@mercurial-scm.org, nato...@gmail.com

OK, first of all, apologies for taking so long to file this. I hopped on to IRC
on the 9th of June late at night to get help with .orig files never being
pulled from a remote server and it would cause headaches (as I recall I could
never merge with the affected changelist because the .orig file would be
already marked as missing from the repo before I could complete the merge and
Mercurial wouldn't allow a merge with uncommitted changes).

With a lot of help from someone on IRC (apologies I don't have logs, it was at
~3am central european time in case there are logs stored somewhere) we were
able to track down the bug to the following conditional in lfcommands.py:

https://www.mercurial-scm.org/repo/hg/file/760a7851e9ba/hgext/largefiles/lfcommands.py#l473

It is unlinking the orig file, even though it is a tracked file.

The fix I have locally (thank goodness, someone just committed a .orig
largefile again, breaking our workflows) has the following check to the
conditional at the end (extra check between !!):

wvfs.exists(lfile)!! and standinorig not in repo.dirstate)!!:

This allows the .orig to be successfully pulled down and the world can keep
spinning (meaning: remove the .orig on the very next commit!)

I'm unsure if I should file this as a bug, or just send a patch, but I figure
if I file the bug then the information will exist beyond IRC logs and my hard
drive.

Matt

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


D6739: unshelve: add abort on using --interactive and --unresolved together

2019-08-17 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It seems not to be a good idea to partially unshelve a mergestate. So,
  let us abort on using `--interactive` and `--unresolved` together.`

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS

diff --git a/tests/test-shelve-unresolved.t b/tests/test-shelve-unresolved.t
--- a/tests/test-shelve-unresolved.t
+++ b/tests/test-shelve-unresolved.t
@@ -220,6 +220,11 @@
   A
   C
 
+-- abort on using both --interactive and --unresolved
+  $ hg unshelve --unresolved --interactive
+  abort: cannot use both interactive and unresolved
+  [255]
+
 -- flag --unshelve is not passed. but, the last shelve is unresolved
   $ hg unshelve
   unshelving change 'default'
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -1008,6 +1008,8 @@
 
 if interactive and opts.get('keep'):
 raise error.Abort(_('--keep on --interactive is not yet supported'))
+if interactive and unresolved:
+raise error.Abort(_('cannot use both interactive and unresolved'))
 if abortf or continuef:
 if abortf and continuef:
 raise error.Abort(_('cannot use both abort and continue'))



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


D6738: unshelve: add --unresolved flag to unshelve mergestate with unresolved files

2019-08-17 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  `hg unshelve --unresolved` will get the user back to the old unresolved merge 
by
  the following steps:
  
  Step 1: If the user has committed new changesets after shelving the changes,
  they must update the working directory to one of the merge parents.
  
  Step 2: Change parents of dirstate to `p1` and `p2`.
  
  Step 3: In order to restore our partially resolved state, we will write from
  data stored in changeset extras.
  
  Step 4: We now have a state in which files marked as resolved might have
  conflicts. But, we will apply the changes in shelve on the top of this so 
that we
  can get our old unresolved merge again by the usual unshelve mechanism.
  
  The usual rebase step is avoided on unresolved shelve changesets.
  
  `$ hg unshelve --unresolved` will abort when:
  
  1. The working directory is dirty.
  2. If there is an ongoing merge.
  3. If the working directory is not at either p1 or p2.
  
  (`p1`, `p2` are the parents of the unresolved shelve changeset)

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/shelve.py
  tests/test-completion.t
  tests/test-shelve-unresolved.t

CHANGE DETAILS

diff --git a/tests/test-shelve-unresolved.t b/tests/test-shelve-unresolved.t
--- a/tests/test-shelve-unresolved.t
+++ b/tests/test-shelve-unresolved.t
@@ -171,3 +171,290 @@
   +===
   +B
   +>>> merge rev:fd9a4049234b - test: B
+
+-- now, fix an urgent bug
+  $ echo fixed >> bug
+  $ ls
+  bar
+  bug
+  file1
+  file1.orig
+  file2
+  file2.orig
+  $ hg add bug
+  $ hg ci -m "fix bug"
+  $ hg log -G
+  @  changeset:   3:a53a9a7475b3
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: fix bug
+  |
+  o  changeset:   2:69004294ad57
+  |  parent:  0:c32ef6121744
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: C
+  |
+  | o  changeset:   1:fd9a4049234b
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: B
+  |
+  o  changeset:   0:c32ef6121744
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: A
+  
+-- let's get back to the old mergestate
+-- we need to update to one of the merge parents. otherwise, abort.
+  $ hg unshelve --unresolved
+  unshelving change 'default'
+  abort: dirstate is not on either of the merge parents.
+  use hg update to one of the merge parents.
+  [255]
+
+  $ hg up 2
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ cat file2
+  A
+  C
+
+-- flag --unshelve is not passed. but, the last shelve is unresolved
+  $ hg unshelve
+  unshelving change 'default'
+  abort: default is an unresolved shelve, use --unresolved to unshelve it
+  [255]
+
+  $ hg unshelve --unresolved
+  unshelving change 'default'
+
+  $ hg log -G
+  o  changeset:   3:a53a9a7475b3
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: fix bug
+  |
+  @  changeset:   2:69004294ad57
+  |  parent:  0:c32ef6121744
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: C
+  |
+  | @  changeset:   1:fd9a4049234b
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: B
+  |
+  o  changeset:   0:c32ef6121744
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: A
+  
+  $ cat file1
+  A
+  B
+  C
+  $ hg diff
+  diff -r 69004294ad57 file1
+  --- a/file1  Thu Jan 01 00:00:00 1970 +
+  +++ b/file1  Thu Jan 01 00:00:00 1970 +
+  @@ -1,2 +1,3 @@
+   A
+  +B
+   C
+  diff -r 69004294ad57 file2
+  --- a/file2  Thu Jan 01 00:00:00 1970 +
+  +++ b/file2  Thu Jan 01 00:00:00 1970 +
+  @@ -1,2 +1,6 @@
+   A
+  +<<< working copy: 69004294ad57 - test: C
+   C
+  +===
+  +B
+  +>>> merge rev:fd9a4049234b - test: B
+  $ cat file2
+  A
+  <<< working copy: 69004294ad57 - test: C
+  C
+  ===
+  B
+  >>> merge rev:fd9a4049234b - test: B
+  $ hg resolve -l
+  R file1
+  U file2
+
+-- flag --unresolved is passed but the top most shelve is not unresolved
+  $ hg shelve --unresolved
+  shelved as default
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+  $ echo garbage >> bug
+  $ hg st
+  ? bar
+  ? bug
+  ? file1.orig
+  ? file2.orig
+  $ hg add bug
+  $ hg shelve
+  shelved as default-01
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg unshelve --unresolved
+  unshelving change 'default-01'
+  abort: default-01 is not an unresolved shelve
+  
+  [255]
+
+-- now, unshelve default
+  $ hg unshelve -n default --unresolved
+
+-- commit the merge after completing conflict resolution
+  $ cat >> 

D6737: shelve: add --unresolved flag to shelve mergestate with unresolved files

2019-08-17 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Until now, `shelve` used to abort on trying to `shelve` a mergestate.
  This patch adds an `--unresolved` flag to `shelve` and use the changeset
  extras to store the mergestate.
  
  After shelving, and the working directory is updated to `p1()`.
  
  `hg shelve` will abort when:
  
  1. No merge is active on calling with `--unresolved`.
  2. No unresolved files found in active merge on calling with `--unresolved`.
  3. Merge is active on calling without `--unresolved`.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/shelve.py
  tests/test-completion.t
  tests/test-shelve-unresolved.t
  tests/test-shelve.t

CHANGE DETAILS

diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -83,6 +83,7 @@
   --statoutput diffstat-style summary of changes (provide
 the names of the shelved changes as positional
 arguments)
+  --unresolved  shelve mergestate with unresolved files
-I --include PATTERN [+] include names matching the given patterns
-X --exclude PATTERN [+] exclude names matching the given patterns
   --mq  operate on patch repository
diff --git a/tests/test-shelve-unresolved.t b/tests/test-shelve-unresolved.t
new file mode 100644
--- /dev/null
+++ b/tests/test-shelve-unresolved.t
@@ -0,0 +1,173 @@
+  $ addunresolvedmerge() {
+  >   echo A >> $1
+  >   echo A >> $2
+  >   hg ci -m A
+  >   echo B >> $1
+  >   echo B >> $2
+  >   hg ci -m B
+  >   hg up $3
+  >   echo C >> $1
+  >   echo C >> $2
+  >   hg ci -m C
+  >   hg merge -r $(($3+1))
+  > }
+
+Test shelve with unresolved mergestate
+
+  $ cat >> $HGRCPATH < [extensions]
+  > shelve =
+  > EOF
+
+  $ hg init shelve-unresolved
+  $ cd shelve-unresolved
+  $ echo A >> file1
+  $ echo A >> file2
+  $ hg ci -Am A
+  adding file1
+  adding file2
+  $ echo foo >> bar
+  $ hg add bar
+
+-- should abort on absence of mergestate
+  $ hg shelve --unresolved
+  abort: no active mergestate found
+  [255]
+
+  $ hg forget bar
+  $ echo B >> file1
+  $ echo B >> file2
+  $ hg ci -m B
+  $ hg up 0
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo C >> file1
+  $ echo C >> file2
+  $ hg ci -m C
+  created new head
+  $ hg merge
+  merging file1
+  merging file2
+  warning: conflicts while merging file1! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging file2! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 2 files unresolved
+  use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to 
abandon
+  [1]
+
+-- let's partially solve the conflicts
+  $ cat > file1 < A
+  > B
+  > C
+  > EOF
+  $ hg resolve -m file1
+
+-- mark file2 as resolved to check abort
+  $ hg resolve -m file2
+  (no more unresolved files)
+  $ hg log -G
+  @  changeset:   2:69004294ad57
+  |  tag: tip
+  |  parent:  0:c32ef6121744
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: C
+  |
+  | @  changeset:   1:fd9a4049234b
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: B
+  |
+  o  changeset:   0:c32ef6121744
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: A
+  
+  $ cat file1
+  A
+  B
+  C
+  $ hg diff
+  diff -r 69004294ad57 file1
+  --- a/file1  Thu Jan 01 00:00:00 1970 +
+  +++ b/file1  Thu Jan 01 00:00:00 1970 +
+  @@ -1,2 +1,3 @@
+   A
+  +B
+   C
+  diff -r 69004294ad57 file2
+  --- a/file2  Thu Jan 01 00:00:00 1970 +
+  +++ b/file2  Thu Jan 01 00:00:00 1970 +
+  @@ -1,2 +1,6 @@
+   A
+  +<<< working copy: 69004294ad57 - test: C
+   C
+  +===
+  +B
+  +>>> merge rev:fd9a4049234b - test: B
+
+-- should abort on absence of conflicts
+  $ hg shelve
+  abort: mergestate found
+  try with --unresolved to shelve conflicts
+  [255]
+  $ hg shelve --unresolved
+  abort: no unresolved files found in the mergestate
+  [255]
+  $ hg resolve -u file2
+  $ hg resolve -l
+  R file1
+  U file2
+
+-- should suggest --unresolved on shelving with mergestate
+  $ hg shelve
+  abort: mergestate found
+  try with --unresolved to shelve conflicts
+  [255]
+
+  $ hg shelve --unresolved
+  shelved as default
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+  $ cat file1
+  A
+  C
+  $ hg log -G
+  @  changeset:   2:69004294ad57
+  |  tag: tip
+  |  parent:  0:c32ef6121744
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: C
+  |
+  | o  changeset:   1:fd9a4049234b
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |

D6736: shelve: add method for storing mergestate in changeset extras

2019-08-17 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We store mergestate records in `.hg/merge`. This patch adds a method
  of storage in changeset extras. This will help in the exchange of
  mergestate records to other repos. Also, this can be used by
  `shelve --unresolved` to store the mergestate records.
  
  It uses the storage format supported for hg versions 3.7 or later. For the
  time being, I have omitted the storage of the content of the local version
  of unresolved files.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/shelve.py

CHANGE DETAILS

diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -413,6 +413,36 @@
 cmdutil.exportfile(repo, [node], fp, opts=mdiff.diffopts(git=True),
match=match)
 
+def _encodemergerecords(records):
+"""Encode mergestate records to store in changeset extras.
+Takes list of tuples as input and returns str.
+"""
+items = [
+'%s\033%s' % (rtype, record)
+for rtype, record in sorted(records)
+]
+return "\n".join(items)
+
+def _decodemergerecords(data):
+"""Decode mergestate record from changeset extras to return
+a list of tuples.
+"""
+records = []
+for l in data.split('\n'):
+rtype, record = l.split('\033')
+records.append((rtype, record))
+return records
+
+def _storeunresolvedmerge(ui, repo, name=None, extra=None):
+"""Store the mergestate information in changeset extra
+
+This will clear the mergestate and also stores the mergestate
+information for later restoration.
+"""
+ms = merge.mergestate.read(repo)
+extra['mergerecords'] = _encodemergerecords(ms._readrecords())
+ms.reset()
+
 def _includeunknownfiles(repo, pats, opts, extra):
 s = repo.status(match=scmutil.match(repo[None], pats, opts),
 unknown=True)



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


D6479: shelve: first prototype of storing/restoring unresolved changes

2019-08-17 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  In D6479#98757 , 
@navaneeth.suresh wrote:
  
  > In D6479#98737 , @durin42 wrote:
  >
  >> The only thing I'm curious about really is why we have extrastorage and 
usualstorge. Can we get away with only one of those choices instead of having 
more options?
  >
  > The ultimate goal is to store the mergestate info in the changeset extras 
only. But, now , it has no support to store the local version of the files 
which are stored in the mergestate. This lacks info when the user gets 
conflicts other than a usual `hg merge`.
  
  Hm, sorry for missing this earlier. If we start the merge with a clean 
working directory, we don't need to store the local version of file then.

REPOSITORY
  rHG Mercurial

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

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

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


D6735: update: added support for --abort flag(issue4404)

2019-08-17 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> test-merge-tools.t:2092
> +
> +Test for 'hg update --abort'
> +

I suggest taking `update --abort` tests in a new file as we will need to 
extensively test that.

> test-merge-tools.t:2129
> +  merging file
> +  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
> +  update aborted

we need to hide this, maybe use more low level APIs. I haven't look at code in 
details, will try to look soon.

REPOSITORY
  rHG Mercurial

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

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

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


D6731: exchange: abort on pushing bookmarks pointing to secret changesets (issue6159)

2019-08-17 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  In such cases, I like the idea of having fix as two patches, first which 
demonstrates the bug and the second which fixes the bug. What do you think?

REPOSITORY
  rHG Mercurial

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

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

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


D6728: config: add experimental argument to the config registrar

2019-08-17 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> perf.py:244
>  default=mercurial.configitems.dynamicdefault,
> +experimental=True,
>  )

This breaks `contrib/perf.py` with older versions of mercurial. Can you send a 
compatibility fix as followup?

REPOSITORY
  rHG Mercurial

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

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

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


D6735: update: added support for --abort flag(issue4404)

2019-08-17 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 16251.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6735?vs=16250=16251

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

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/hg.py
  tests/test-merge-tools.t

CHANGE DETAILS

diff --git a/tests/test-merge-tools.t b/tests/test-merge-tools.t
--- a/tests/test-merge-tools.t
+++ b/tests/test-merge-tools.t
@@ -4,6 +4,8 @@
   $ cat >> $HGRCPATH << EOF
   > [ui]
   > merge=
+  > [extensions]
+  > graphlog=
   > EOF
   $ hg init repo
   $ cd repo
@@ -2086,3 +2088,63 @@
   f = false
 
   $ cd ..
+
+Test for 'hg update --abort'
+
+  $ hg init test
+  $ cd test
+  $ echo before > file
+  $ hg add file
+  $ hg commit -mbefore
+  $ echo after > file
+  $ hg commit -mafter
+  $ echo edited > file
+
+Pre-update log and file content
+  $ hg glog
+  @  changeset:   1:47d1da7c1f80
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: after
+  |
+  o  changeset:   0:dd67ebc4de84
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: before
+  
+
+  $ cat file
+  edited
+  $ hg update 0
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  [1]
+
+  $ hg update --abort
+  aborting the update, updating back to 47d1da7c1f80
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  update aborted
+  working directory is now at 47d1da7c1f80
+
+Post-update log and file content
+  $ hg glog
+  @  changeset:   1:47d1da7c1f80
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: after
+  |
+  o  changeset:   0:dd67ebc4de84
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: before
+  
+
+  $ cat file
+  edited
+
+  $ cd ..
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -984,6 +984,34 @@
 _showstats(repo, stats)
 return stats.unresolvedcount > 0
 
+def _unmarkandresolvelocal(ui, repo , ms):
+"""Helper for abortupdate(). This unmarks partially resolved files and then
+resolves the update generated conflicts."""
+wctx = repo[None]
+for f in ms:
+ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED_PATH)
+ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED)
+try:
+overrides = {('ui', 'forcemerge'): ':local'}
+with ui.configoverride(overrides, 'resolve'):
+ms.preresolve(f, wctx)
+ms.resolve(f, wctx)
+finally:
+ms.commit()
+
+def abortupdate(ui, repo):
+"""logic to abort an conflicted update"""
+ms = mergemod.mergestate.read(repo)
+node = ms.localctx.hex()
+_unmarkandresolvelocal(ui, repo, ms)
+repo.ui.status(_("aborting the update, updating back to"
+ " %s\n") % node[:12])
+mergemod.update(repo, node, branchmerge=False, force=False)
+ms2 = mergemod.mergestate.read(repo)
+_unmarkandresolvelocal(ui, repo, ms2)
+ui.status(_("update aborted\n"))
+ui.status(_("working directory is now at %s\n") % node[:12])
+
 def _incoming(displaychlist, subreporecurse, ui, repo, source,
 opts, buffered=False):
 """
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6154,6 +6154,7 @@
 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
 ('c', 'check', None, _('require clean working directory')),
 ('m', 'merge', None, _('merge uncommitted changes')),
+('', 'abort', False, _('abort interrupted update')),
 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
 ('r', 'rev', '', _('revision'), _('REV'))
  ] + mergetoolopts,
@@ -6220,6 +6221,7 @@
 clean = opts.get(r'clean')
 check = opts.get(r'check')
 merge = opts.get(r'merge')
+abort = opts.get(r'abort')
 if rev and node:
 raise error.Abort(_("please specify just one revision"))
 
@@ -6245,6 +6247,8 @@
 updatecheck = 'none'
 
 with repo.wlock():
+if abort:
+return hg.abortupdate(ui, repo)
 cmdutil.clearunfinished(repo)
 if date:
 rev = cmdutil.finddate(ui, repo, date)



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


D6735: update: added support for --abort flag(issue4404)

2019-08-17 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 16250.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6735?vs=16249=16250

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

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/hg.py
  tests/test-merge-tools.t

CHANGE DETAILS

diff --git a/tests/test-merge-tools.t b/tests/test-merge-tools.t
--- a/tests/test-merge-tools.t
+++ b/tests/test-merge-tools.t
@@ -4,6 +4,8 @@
   $ cat >> $HGRCPATH << EOF
   > [ui]
   > merge=
+  > [extensions]
+  > graphlog=
   > EOF
   $ hg init repo
   $ cd repo
@@ -2086,3 +2088,63 @@
   f = false
 
   $ cd ..
+
+Test for 'hg update --abort'
+
+  $ hg init test
+  $ cd test
+  $ echo before > file
+  $ hg add file
+  $ hg commit -mbefore
+  $ echo after > file
+  $ hg commit -mafter
+  $ echo edited > file
+
+Pre-update log and file content
+  $ hg glog
+  @  changeset:   1:47d1da7c1f80
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: after
+  |
+  o  changeset:   0:dd67ebc4de84
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: before
+  
+
+  $ cat file
+  edited
+  $ hg update 0
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  [1]
+
+  $ hg update --abort
+  aborting the update, updating back to 47d1da7c1f80
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  update aborted
+  working directory is now at 47d1da7c1f80
+
+Post-update log and file content
+  $ hg glog
+  @  changeset:   1:47d1da7c1f80
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: after
+  |
+  o  changeset:   0:dd67ebc4de84
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: before
+  
+
+  $ cat file
+  edited
+
+  $ cd ..
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -984,6 +984,34 @@
 _showstats(repo, stats)
 return stats.unresolvedcount > 0
 
+def _unmarkandresolvelocal(ui, repo , ms):
+"""Helper for abortupdate(). This unmarks partially resolved files and then
+resolves the update generated conflicts."""
+wctx = repo[None]
+for f in ms:
+ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED_PATH)
+ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED)
+try:
+overrides = {('ui', 'forcemerge'): ':local'}
+with ui.configoverride(overrides, 'resolve'):
+ms.preresolve(f, wctx)
+ms.resolve(f, wctx)
+finally:
+ms.commit()
+
+def abortupdate(ui, repo):
+"""logic to abort an conflicted update"""
+ms = mergemod.mergestate.read(repo)
+node = ms.localctx.hex()
+_unmarkandresolvelocal(ui, repo, ms)
+repo.ui.status(_("aborting the update, updating back to"
+ " %s\n") % node[:12])
+mergemod.update(repo, node, branchmerge=False, force=False)
+ms2 = mergemod.mergestate.read(repo)
+_unmarkandresolvelocal(ui, repo, ms)(ui, repo, ms2)
+ui.status(_("update aborted\n"))
+ui.status(_("working directory is now at %s\n") % node[:12])
+
 def _incoming(displaychlist, subreporecurse, ui, repo, source,
 opts, buffered=False):
 """
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6154,6 +6154,7 @@
 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
 ('c', 'check', None, _('require clean working directory')),
 ('m', 'merge', None, _('merge uncommitted changes')),
+('', 'abort', False, _('abort interrupted update')),
 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
 ('r', 'rev', '', _('revision'), _('REV'))
  ] + mergetoolopts,
@@ -6220,6 +6221,7 @@
 clean = opts.get(r'clean')
 check = opts.get(r'check')
 merge = opts.get(r'merge')
+abort = opts.get(r'abort')
 if rev and node:
 raise error.Abort(_("please specify just one revision"))
 
@@ -6245,6 +6247,8 @@
 updatecheck = 'none'
 
 with repo.wlock():
+if abort:
+return hg.abortupdate(ui, repo)
 cmdutil.clearunfinished(repo)
 if date:
 rev = cmdutil.finddate(ui, repo, date)



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


D6735: update: added support for --abort flag(issue4404)

2019-08-17 Thread taapas1128 (Taapas Agrawal)
taapas1128 created this revision.
Herald added subscribers: mercurial-devel, mjpieters.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch adds functionality to abort a conflicted
  update. A new function `hg.abortupdate()` is added for
  the purpose which has a helper function
  `hg._unmarkandresolvelocal()` which deals with the
  conflicts occured.
  
  Results are shown in tests.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/transplant.py
  mercurial/commands.py
  mercurial/hg.py
  tests/test-merge-tools.t

CHANGE DETAILS

diff --git a/tests/test-merge-tools.t b/tests/test-merge-tools.t
--- a/tests/test-merge-tools.t
+++ b/tests/test-merge-tools.t
@@ -4,6 +4,8 @@
   $ cat >> $HGRCPATH << EOF
   > [ui]
   > merge=
+  > [extensions]
+  > graphlog=
   > EOF
   $ hg init repo
   $ cd repo
@@ -2086,3 +2088,63 @@
   f = false
 
   $ cd ..
+
+Test for 'hg update --abort'
+
+  $ hg init test
+  $ cd test
+  $ echo before > file
+  $ hg add file
+  $ hg commit -mbefore
+  $ echo after > file
+  $ hg commit -mafter
+  $ echo edited > file
+
+Pre-update log and file content
+  $ hg glog
+  @  changeset:   1:47d1da7c1f80
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: after
+  |
+  o  changeset:   0:dd67ebc4de84
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: before
+  
+
+  $ cat file
+  edited
+  $ hg update 0
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  [1]
+
+  $ hg update --abort
+  aborting the update, updating back to 47d1da7c1f80
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  update aborted
+  working directory is now at 47d1da7c1f80
+
+Post-update log and file content
+  $ hg glog
+  @  changeset:   1:47d1da7c1f80
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: after
+  |
+  o  changeset:   0:dd67ebc4de84
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: before
+  
+
+  $ cat file
+  edited
+
+  $ cd ..
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -984,6 +984,34 @@
 _showstats(repo, stats)
 return stats.unresolvedcount > 0
 
+def _unmarkandresolvelocal(ui, repo , ms):
+"""Helper for abortupdate(). This unmarks partially resolved files and then
+resolves the update generated conflicts."""
+wctx = repo[None]
+for f in ms:
+ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED_PATH)
+ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED)
+try:
+overrides = {('ui', 'forcemerge'): ':local'}
+with ui.configoverride(overrides, 'resolve'):
+ms.preresolve(f, wctx)
+ms.resolve(f, wctx)
+finally:
+ms.commit()
+
+def abortupdate(ui, repo):
+"""logic to abort an conflicted update"""
+ms = mergemod.mergestate.read(repo)
+node = ms.localctx.hex()
+_unmarkandresolvelocal(ui, repo, ms)
+repo.ui.status(_("aborting the update, updating back to"
+ " %s\n") % node[:12])
+mergemod.update(repo, node, branchmerge=False, force=False)
+ms2 = mergemod.mergestate.read(repo)
+_unmarkandresolvelocal(ui, repo, ms)(ui, repo, ms2)
+ui.status(_("update aborted\n"))
+ui.status(_("working directory is now at %s\n") % node[:12])
+
 def _incoming(displaychlist, subreporecurse, ui, repo, source,
 opts, buffered=False):
 """
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6154,6 +6154,7 @@
 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
 ('c', 'check', None, _('require clean working directory')),
 ('m', 'merge', None, _('merge uncommitted changes')),
+('', 'abort', False, _('abort interrupted update')),
 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
 ('r', 'rev', '', _('revision'), _('REV'))
  ] + mergetoolopts,
@@ -6220,6 +6221,7 @@
 clean = opts.get(r'clean')
 check = opts.get(r'check')
 merge = opts.get(r'merge')
+abort = opts.get(r'abort')
 if rev and node:
 raise error.Abort(_("please specify just one revision"))
 
@@ -6245,6 +6247,8 @@
 updatecheck = 'none'
 
 with repo.wlock():
+if abort:
+return hg.abortupdate(ui, repo)
 cmdutil.clearunfinished(repo)
 if date:
 rev = cmdutil.finddate(ui, repo, date)
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -786,13 +786,27 @@
 return n and nodemod.hex(n) or ''
 
 

D6709: config: add --registered flag to show all known configs

2019-08-17 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 16248.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6709?vs=16247=16248

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

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/ui.py
  tests/test-basic.t
  tests/test-commandserver.t
  tests/test-completion.t
  tests/test-config.t
  tests/test-hgrc.t

CHANGE DETAILS

diff --git a/tests/test-hgrc.t b/tests/test-hgrc.t
--- a/tests/test-hgrc.t
+++ b/tests/test-hgrc.t
@@ -80,9 +80,9 @@
 
   $ hg showconfig --config ui.verbose=True --quiet
   bundle.mainreporoot=$TESTTMP
-  ui.verbose=False
-  ui.debug=False
-  ui.quiet=True
+  ui.verbose=no
+  ui.debug=no
+  ui.quiet=yes
 
   $ touch foobar/untracked
   $ cat >> foobar/.hg/hgrc < done
   $ HGRCPATH=configs hg config section.key
   99
+
+test --registered flag
+
+  $ hg showconfig --registered
+  annotate.git=no
+  annotate.ignoreblanklines=no
+  annotate.ignorews=no
+  annotate.ignorewsamount=no
+  annotate.ignorewseol=no
+  annotate.nobinary=no
+  annotate.nodates=no
+  annotate.noprefix=no
+  annotate.showfunc=no
+  annotate.unified=None
+  annotate.word-diff=no
+  auth.cookiefile=None
+  bookmarks.pushing=
+  bundle.mainreporoot=$TESTTMP (default: )
+  chgserver.idletimeout=3600
+  chgserver.skiphash=no
+  cmdserver.log=None
+  cmdserver.max-log-files=7
+  cmdserver.max-log-size=1 MB
+  cmdserver.track-log=chgserver cmdserver repocache
+  color.mode=auto
+  commands.commit.interactive.git=no
+  commands.commit.interactive.ignoreblanklines=no
+  commands.commit.interactive.ignorews=no
+  commands.commit.interactive.ignorewsamount=no
+  commands.commit.interactive.ignorewseol=no
+  commands.commit.interactive.nobinary=no
+  commands.commit.interactive.nodates=no
+  commands.commit.interactive.noprefix=no
+  commands.commit.interactive.showfunc=no
+  commands.commit.interactive.unified=None
+  commands.commit.interactive.word-diff=no
+  commands.commit.post-status=no
+  commands.rebase.requiredest=no
+  commands.resolve.confirm=no
+  commands.resolve.explicit-re-merge=no
+  commands.resolve.mark-check=none
+  commands.revert.interactive.git=no
+  commands.revert.interactive.ignoreblanklines=no
+  commands.revert.interactive.ignorews=no
+  commands.revert.interactive.ignorewsamount=no
+  commands.revert.interactive.ignorewseol=no
+  commands.revert.interactive.nobinary=no
+  commands.revert.interactive.nodates=no
+  commands.revert.interactive.noprefix=no
+  commands.revert.interactive.showfunc=no
+  commands.revert.interactive.unified=None
+  commands.revert.interactive.word-diff=no
+  commands.show.aliasprefix=
+  commands.status.relative=no
+  commands.status.terse=
+  commands.status.verbose=no
+  commands.update.check=None
+  commands.update.requiredest=no
+  convert.bzr.saverev=yes
+  convert.cvsps.cache=yes
+  convert.cvsps.fuzz=60
+  convert.cvsps.logencoding=None
+  convert.cvsps.mergefrom=None
+  convert.cvsps.mergeto=None
+  convert.git.committeractions=messagedifferent
+  convert.git.extrakeys=
+  convert.git.findcopiesharder=no
+  convert.git.remoteprefix=remote
+  convert.git.renamelimit=400
+  convert.git.saverev=yes
+  convert.git.similarity=50
+  convert.git.skipsubmodules=no
+  convert.hg.clonebranches=no
+  convert.hg.ignoreerrors=no
+  convert.hg.preserve-hash=no
+  convert.hg.revs=None
+  convert.hg.saverev=no
+  convert.hg.sourcename=None
+  convert.hg.startrev=None
+  convert.hg.tagsbranch=default
+  convert.hg.usebranchnames=yes
+  convert.localtimezone=no
+  convert.p4.startrev=0
+  convert.skiptags=no
+  convert.svn.branches=None
+  convert.svn.debugsvnlog=yes
+  convert.svn.startrev=0
+  convert.svn.tags=None
+  convert.svn.trunk=None
+  diff.git=no
+  diff.ignoreblanklines=no
+  diff.ignorews=no
+  diff.ignorewsamount=no
+  diff.ignorewseol=no
+  diff.nobinary=no
+  diff.nodates=no
+  diff.noprefix=no
+  diff.showfunc=no
+  diff.unified=None
+  diff.word-diff=no
+  email.bcc=None
+  email.cc=None
+  email.charsets=
+  email.from=None
+  email.method=smtp
+  email.reply-to=None
+  email.to=None
+  format.bookmarks-in-store=no
+  format.dotencode=yes
+  format.obsstore-version=None
+  format.revlog-compression=$BUNDLE2_COMPRESSIONS$
+  format.sparse-revlog=yes
+  format.usefncache=yes
+  format.usegeneraldelta=yes
+  format.usestore=yes
+  fsmonitor.warn_update_file_count=5
+  fsmonitor.warn_when_unused=yes
+  hostsecurity.ciphers=None
+  hostsecurity.disabletls10warning=no
+  http.timeout=None
+  http_proxy.always=no
+  http_proxy.host=None
+  http_proxy.no=
+  http_proxy.passwd=None
+  http_proxy.user=None
+  logtoprocess.command=None
+  logtoprocess.commandexception=None
+  logtoprocess.commandfinish=None
+  logtoprocess.develwarn=None
+  logtoprocess.uiblocked=None
+  merge.checkignored=abort
+  merge.checkunknown=abort
+  merge.followcopies=yes
+  merge.on-failure=continue
+  merge.strict-capability-check=no
+  

D6730: config: handle default values of type list

2019-08-17 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh added a comment.
navaneeth.suresh abandoned this revision.


  In D6730#98852 , @av6 wrote:
  
  > The changes in tests that this patch causes are actually already present in 
the D6709 , so let's fold this patch into 
it as well.
  
  Okay. Folded and updated D6709 . 
Abandoning this.

REPOSITORY
  rHG Mercurial

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

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

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


D6709: config: add --registered flag to show all known configs

2019-08-17 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 16247.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6709?vs=16229=16247

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

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/ui.py
  tests/test-basic.t
  tests/test-commandserver.t
  tests/test-completion.t
  tests/test-config.t
  tests/test-hgrc.t

CHANGE DETAILS

diff --git a/tests/test-hgrc.t b/tests/test-hgrc.t
--- a/tests/test-hgrc.t
+++ b/tests/test-hgrc.t
@@ -80,9 +80,9 @@
 
   $ hg showconfig --config ui.verbose=True --quiet
   bundle.mainreporoot=$TESTTMP
-  ui.verbose=False
-  ui.debug=False
-  ui.quiet=True
+  ui.verbose=no
+  ui.debug=no
+  ui.quiet=yes
 
   $ touch foobar/untracked
   $ cat >> foobar/.hg/hgrc < done
   $ HGRCPATH=configs hg config section.key
   99
+
+test --registered flag
+
+  $ hg showconfig --registered
+  annotate.git=no
+  annotate.ignoreblanklines=no
+  annotate.ignorews=no
+  annotate.ignorewsamount=no
+  annotate.ignorewseol=no
+  annotate.nobinary=no
+  annotate.nodates=no
+  annotate.noprefix=no
+  annotate.showfunc=no
+  annotate.unified=None
+  annotate.word-diff=no
+  auth.cookiefile=None
+  bookmarks.pushing=
+  bundle.mainreporoot=$TESTTMP (default: )
+  chgserver.idletimeout=3600
+  chgserver.skiphash=no
+  cmdserver.log=None
+  cmdserver.max-log-files=7
+  cmdserver.max-log-size=1 MB
+  cmdserver.track-log=chgserver cmdserver repocache
+  color.mode=auto
+  commands.commit.interactive.git=no
+  commands.commit.interactive.ignoreblanklines=no
+  commands.commit.interactive.ignorews=no
+  commands.commit.interactive.ignorewsamount=no
+  commands.commit.interactive.ignorewseol=no
+  commands.commit.interactive.nobinary=no
+  commands.commit.interactive.nodates=no
+  commands.commit.interactive.noprefix=no
+  commands.commit.interactive.showfunc=no
+  commands.commit.interactive.unified=None
+  commands.commit.interactive.word-diff=no
+  commands.commit.post-status=no
+  commands.rebase.requiredest=no
+  commands.resolve.confirm=no
+  commands.resolve.explicit-re-merge=no
+  commands.resolve.mark-check=none
+  commands.revert.interactive.git=no
+  commands.revert.interactive.ignoreblanklines=no
+  commands.revert.interactive.ignorews=no
+  commands.revert.interactive.ignorewsamount=no
+  commands.revert.interactive.ignorewseol=no
+  commands.revert.interactive.nobinary=no
+  commands.revert.interactive.nodates=no
+  commands.revert.interactive.noprefix=no
+  commands.revert.interactive.showfunc=no
+  commands.revert.interactive.unified=None
+  commands.revert.interactive.word-diff=no
+  commands.show.aliasprefix=
+  commands.status.relative=no
+  commands.status.terse=
+  commands.status.verbose=no
+  commands.update.check=None
+  commands.update.requiredest=no
+  convert.bzr.saverev=yes
+  convert.cvsps.cache=yes
+  convert.cvsps.fuzz=60
+  convert.cvsps.logencoding=None
+  convert.cvsps.mergefrom=None
+  convert.cvsps.mergeto=None
+  convert.git.committeractions=messagedifferent
+  convert.git.extrakeys=
+  convert.git.findcopiesharder=no
+  convert.git.remoteprefix=remote
+  convert.git.renamelimit=400
+  convert.git.saverev=yes
+  convert.git.similarity=50
+  convert.git.skipsubmodules=no
+  convert.hg.clonebranches=no
+  convert.hg.ignoreerrors=no
+  convert.hg.preserve-hash=no
+  convert.hg.revs=None
+  convert.hg.saverev=no
+  convert.hg.sourcename=None
+  convert.hg.startrev=None
+  convert.hg.tagsbranch=default
+  convert.hg.usebranchnames=yes
+  convert.localtimezone=no
+  convert.p4.startrev=0
+  convert.skiptags=no
+  convert.svn.branches=None
+  convert.svn.debugsvnlog=yes
+  convert.svn.startrev=0
+  convert.svn.tags=None
+  convert.svn.trunk=None
+  diff.git=no
+  diff.ignoreblanklines=no
+  diff.ignorews=no
+  diff.ignorewsamount=no
+  diff.ignorewseol=no
+  diff.nobinary=no
+  diff.nodates=no
+  diff.noprefix=no
+  diff.showfunc=no
+  diff.unified=None
+  diff.word-diff=no
+  email.bcc=None
+  email.cc=None
+  email.charsets=
+  email.from=None
+  email.method=smtp
+  email.reply-to=None
+  email.to=None
+  format.bookmarks-in-store=no
+  format.dotencode=yes
+  format.obsstore-version=None
+  format.revlog-compression=$BUNDLE2_COMPRESSIONS$
+  format.sparse-revlog=yes
+  format.usefncache=yes
+  format.usegeneraldelta=yes
+  format.usestore=yes
+  fsmonitor.warn_update_file_count=5
+  fsmonitor.warn_when_unused=yes
+  hostsecurity.ciphers=None
+  hostsecurity.disabletls10warning=no
+  http.timeout=None
+  http_proxy.always=no
+  http_proxy.host=None
+  http_proxy.no=
+  http_proxy.passwd=None
+  http_proxy.user=None
+  logtoprocess.command=None
+  logtoprocess.commandexception=None
+  logtoprocess.commandfinish=None
+  logtoprocess.develwarn=None
+  logtoprocess.uiblocked=None
+  merge.checkignored=abort
+  merge.checkunknown=abort
+  merge.followcopies=yes
+  merge.on-failure=continue
+  merge.strict-capability-check=no
+  

Re: [PATCH] py3: do not convert rust module/attribute names to bytes

2019-08-17 Thread Pulkit Goyal
On Sat, Aug 17, 2019 at 3:09 PM Yuya Nishihara  wrote:
>
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1566005104 -32400
> #  Sat Aug 17 10:25:04 2019 +0900
> # Node ID 302e4706ab25b4d29d858f93ca2678a609e95570
> # Parent  a3c360094c93509ee013ed7f4b7807c74b2d60a4
> py3: do not convert rust module/attribute names to bytes
>
> policy.import*() functions expect system strings.

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


Re: [PATCH] transplant: unnest --stop case

2019-08-17 Thread Pulkit Goyal
On Sat, Aug 17, 2019 at 3:06 PM Yuya Nishihara  wrote:
>
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1566024221 -32400
> #  Sat Aug 17 15:43:41 2019 +0900
> # Node ID a3c360094c93509ee013ed7f4b7807c74b2d60a4
> # Parent  88d6a6f7e83716146fc725f20166509a520bc164
> transplant: unnest --stop case
>
> It should be aligned with --continue.

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


D6730: config: handle default values of type list

2019-08-17 Thread av6 (Anton Shestakov)
This revision now requires changes to proceed.
av6 added a comment.
av6 requested changes to this revision.


  The changes in tests that this patch causes are actually already present in 
the D6709 , so let's fold this patch into 
it as well.

REPOSITORY
  rHG Mercurial

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

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

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


D6709: config: add --registered flag to show all known configs

2019-08-17 Thread av6 (Anton Shestakov)
av6 added inline comments.

INLINE COMMENTS

> ui.py:832
> +# Omit config items with dynamicdefault, devel,
> +# experimental and generic config opts.
> +continue

Nit: originally I was fine with two different `if ...: continue` blocks here, 
and I still think it would be better. Not only the condition here is fairly 
complex and spans multiple lines (so not easy to read), but this comment is not 
quite correct. We always omit items with dynamic defaults and generic items, 
but experimental (& etc) items are only omitted unless --verbose is given. Two 
comments in two if-blocks with two separate conditions here would be more 
readable.

REPOSITORY
  rHG Mercurial

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

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

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


[PATCH 11 of 11] rust-dirstate: remove test case for DirsMultiset::new(Manifest, Some)

2019-08-17 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1566034135 -32400
#  Sat Aug 17 18:28:55 2019 +0900
# Node ID 24f0204173d07b53cdd34b75122b46cd74df3756
# Parent  c0660c41e5b27173f73b8c88da1728b69425aeba
rust-dirstate: remove test case for DirsMultiset::new(Manifest, Some)

It's no longer possible.

diff --git a/rust/hg-core/src/dirstate/dirs_multiset.rs 
b/rust/hg-core/src/dirstate/dirs_multiset.rs
--- a/rust/hg-core/src/dirstate/dirs_multiset.rs
+++ b/rust/hg-core/src/dirstate/dirs_multiset.rs
@@ -283,24 +283,6 @@ mod tests {
 
 #[test]
 fn test_dirsmultiset_new_skip() {
-let input_vec = ["a/", "b/", "a/c", "a/d/"]
-.iter()
-.map(|e| e.as_bytes().to_vec())
-.collect();
-let expected_inner = [("", 2), ("a", 3), ("b", 1), ("a/d", 1)]
-.iter()
-.map(|(k, v)| (k.as_bytes().to_vec(), *v))
-.collect();
-
-// this was
-// DirsMultiset::new(Manifest(_vec), Some(EntryState::Normal))
-let new = DirsMultiset::from_manifest(_vec);
-let expected = DirsMultiset {
-inner: expected_inner,
-};
-// Skip does not affect a manifest
-assert_eq!(expected, new);
-
 let input_map = [
 ("a/", EntryState::Normal),
 ("a/b/", EntryState::Normal),
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 10 of 11] rust-dirstate: split DirsMultiset constructor per input type

2019-08-17 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1566033929 -32400
#  Sat Aug 17 18:25:29 2019 +0900
# Node ID c0660c41e5b27173f73b8c88da1728b69425aeba
# Parent  d4c0130723d92bd545e7df45aceead8bd7562156
rust-dirstate: split DirsMultiset constructor per input type

Since skip_state only applies to dirstate, it doesn't make sense to unify
these constructors and dispatch by enum.

diff --git a/rust/hg-core/src/dirstate.rs b/rust/hg-core/src/dirstate.rs
--- a/rust/hg-core/src/dirstate.rs
+++ b/rust/hg-core/src/dirstate.rs
@@ -33,13 +33,6 @@ pub struct DirstateEntry {
 pub type StateMap = HashMap, DirstateEntry>;
 pub type CopyMap = HashMap, Vec>;
 
-/// The Python implementation passes either a mapping (dirstate) or a flat
-/// iterable (manifest)
-pub enum DirsIterable<'a> {
-Dirstate(&'a HashMap, DirstateEntry>),
-Manifest(&'a Vec>),
-}
-
 #[derive(Copy, Clone, Debug, Eq, PartialEq)]
 pub enum EntryState {
 Normal,
diff --git a/rust/hg-core/src/dirstate/dirs_multiset.rs 
b/rust/hg-core/src/dirstate/dirs_multiset.rs
--- a/rust/hg-core/src/dirstate/dirs_multiset.rs
+++ b/rust/hg-core/src/dirstate/dirs_multiset.rs
@@ -9,8 +9,7 @@
 //!
 //! Used to counts the references to directories in a manifest or dirstate.
 use crate::{
-dirstate::EntryState, utils::files, DirsIterable, DirstateEntry,
-DirstateMapError,
+dirstate::EntryState, utils::files, DirstateEntry, DirstateMapError,
 };
 use std::collections::hash_map::Entry;
 use std::collections::HashMap;
@@ -21,40 +20,44 @@ pub struct DirsMultiset {
 }
 
 impl DirsMultiset {
-/// Initializes the multiset from a dirstate or a manifest.
+/// Initializes the multiset from a dirstate.
 ///
 /// If `skip_state` is provided, skips dirstate entries with equal state.
-pub fn new(
-iterable: DirsIterable,
+pub fn from_dirstate(
+vec: , DirstateEntry>,
 skip_state: Option,
 ) -> Self {
 let mut multiset = DirsMultiset {
 inner: HashMap::new(),
 };
 
-match iterable {
-DirsIterable::Dirstate(vec) => {
-for (filename, DirstateEntry { state, .. }) in vec {
-// This `if` is optimized out of the loop
-if let Some(skip) = skip_state {
-if skip != *state {
-multiset.add_path(filename);
-}
-} else {
-multiset.add_path(filename);
-}
-}
-}
-DirsIterable::Manifest(vec) => {
-for filename in vec {
+for (filename, DirstateEntry { state, .. }) in vec {
+// This `if` is optimized out of the loop
+if let Some(skip) = skip_state {
+if skip != *state {
 multiset.add_path(filename);
 }
+} else {
+multiset.add_path(filename);
 }
 }
 
 multiset
 }
 
+/// Initializes the multiset from a manifest.
+pub fn from_manifest(vec: >) -> Self {
+let mut multiset = DirsMultiset {
+inner: HashMap::new(),
+};
+
+for filename in vec {
+multiset.add_path(filename);
+}
+
+multiset
+}
+
 /// Increases the count of deepest directory contained in the path.
 ///
 /// If the directory is not yet in the map, adds its parents.
@@ -118,7 +121,7 @@ mod tests {
 
 #[test]
 fn test_delete_path_path_not_found() {
-let mut map = DirsMultiset::new(DirsIterable::Manifest(![]), None);
+let mut map = DirsMultiset::from_manifest(![]);
 let path = b"doesnotexist/";
 assert_eq!(
 Err(DirstateMapError::PathNotFound(path.to_vec())),
@@ -128,8 +131,7 @@ mod tests {
 
 #[test]
 fn test_delete_path_empty_path() {
-let mut map =
-DirsMultiset::new(DirsIterable::Manifest(![vec![]]), None);
+let mut map = DirsMultiset::from_manifest(![vec![]]);
 let path = b"";
 assert_eq!(Ok(()), map.delete_path(path));
 assert_eq!(
@@ -169,7 +171,7 @@ mod tests {
 
 #[test]
 fn test_add_path_empty_path() {
-let mut map = DirsMultiset::new(DirsIterable::Manifest(![]), None);
+let mut map = DirsMultiset::from_manifest(![]);
 let path = b"";
 map.add_path(path);
 
@@ -178,7 +180,7 @@ mod tests {
 
 #[test]
 fn test_add_path_successful() {
-let mut map = DirsMultiset::new(DirsIterable::Manifest(![]), None);
+let mut map = DirsMultiset::from_manifest(![]);
 
 map.add_path(b"a/");
 assert_eq!(1, *map.inner.get("a".to_vec()).unwrap());
@@ -223,15 +225,13 @@ mod tests {
 
 #[test]
 fn test_dirsmultiset_new_empty() {
-use DirsIterable::{Dirstate, Manifest};
-
-let new = DirsMultiset::new(Manifest(![]), None);
+let new = 

[PATCH 09 of 11] rust-dirstate: remove excessive clone() of parameter and return value

2019-08-17 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1566027185 -32400
#  Sat Aug 17 16:33:05 2019 +0900
# Node ID d4c0130723d92bd545e7df45aceead8bd7562156
# Parent  5f76ca22fb8fb29ec0a60ec0af88cb328f7a0c9e
rust-dirstate: remove excessive clone() of parameter and return value

I think pass-by-ref is preferred in general.

diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs 
b/rust/hg-core/src/dirstate/dirstate_map.rs
--- a/rust/hg-core/src/dirstate/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs
@@ -68,7 +68,7 @@ impl DirstateMap {
 self.file_fold_map = None;
 self.non_normal_set.clear();
 self.other_parent_set.clear();
-self.set_parents(DirstateParents {
+self.set_parents( {
 p1: NULL_ID,
 p2: NULL_ID,
 })
@@ -253,9 +253,9 @@ impl DirstateMap {
 pub fn parents(
  self,
 file_contents: &[u8],
-) -> Result {
+) -> Result<, DirstateError> {
 if let Some(ref parents) = self.parents {
-return Ok(parents.clone());
+return Ok(parents);
 }
 let parents;
 if file_contents.len() == PARENT_SIZE * 2 {
@@ -274,11 +274,11 @@ impl DirstateMap {
 return Err(DirstateError::Parse(DirstateParseError::Damaged));
 }
 
-self.parents = Some(parents.to_owned());
-Ok(parents.clone())
+self.parents = Some(parents);
+Ok(self.parents.as_ref().unwrap())
 }
 
-pub fn set_parents( self, parents: DirstateParents) {
+pub fn set_parents( self, parents: ) {
 self.parents = Some(parents.clone());
 self.dirty_parents = true;
 }
@@ -298,7 +298,7 @@ impl DirstateMap {
 )?;
 
 if !self.dirty_parents {
-self.set_parents(parents.to_owned());
+self.set_parents();
 }
 
 Ok(Some(parents))
@@ -320,9 +320,9 @@ impl DirstateMap {
 Ok(packed)
 }
 
-pub fn build_file_fold_map( self) -> FileFoldMap {
+pub fn build_file_fold_map( self) ->  {
 if let Some(ref file_fold_map) = self.file_fold_map {
-return file_fold_map.to_owned();
+return file_fold_map;
 }
 let mut new_file_fold_map = FileFoldMap::new();
 for (filename, DirstateEntry { state, .. }) in self.state_map.borrow()
@@ -335,7 +335,7 @@ impl DirstateMap {
 }
 }
 self.file_fold_map = Some(new_file_fold_map);
-self.file_fold_map.to_owned().unwrap()
+self.file_fold_map.as_ref().unwrap()
 }
 }
 
diff --git a/rust/hg-cpython/src/dirstate/dirstate_map.rs 
b/rust/hg-cpython/src/dirstate/dirstate_map.rs
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs
@@ -243,7 +243,7 @@ py_class!(pub class DirstateMap |py| {
 
 self.inner(py)
 .borrow_mut()
-.set_parents(DirstateParents { p1, p2 });
+.set_parents( { p1, p2 });
 Ok(py.None())
 }
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 08 of 11] rust-dirstate: handle invalid length of p1/p2 parameters

2019-08-17 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1566032768 -32400
#  Sat Aug 17 18:06:08 2019 +0900
# Node ID 5f76ca22fb8fb29ec0a60ec0af88cb328f7a0c9e
# Parent  d496a0a5d5f8ff45afde5a0a90b0917e507c
rust-dirstate: handle invalid length of p1/p2 parameters

It uses match syntax since map_err() failed to deduce the argument type.

diff --git a/rust/hg-cpython/src/dirstate/dirstate_map.rs 
b/rust/hg-cpython/src/dirstate/dirstate_map.rs
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs
@@ -24,9 +24,8 @@ use crate::{
 ref_sharing::PySharedState,
 };
 use hg::{
-DirsIterable, DirsMultiset, DirstateEntry,
-DirstateMap as RustDirstateMap, DirstateParents, DirstateParseError,
-EntryState,
+DirsIterable, DirsMultiset, DirstateEntry, DirstateMap as RustDirstateMap,
+DirstateParents, DirstateParseError, EntryState, PARENT_SIZE,
 };
 
 // TODO
@@ -239,9 +238,8 @@ py_class!(pub class DirstateMap |py| {
 }
 
 def setparents(, p1: PyObject, p2: PyObject) -> PyResult {
-// TODO: don't panic; raise Python exception instead.
-let p1 = p1.extract::(py)?.data(py).try_into().unwrap();
-let p2 = p2.extract::(py)?.data(py).try_into().unwrap();
+let p1 = extract_node_id(py, )?;
+let p2 = extract_node_id(py, )?;
 
 self.inner(py)
 .borrow_mut()
@@ -275,9 +273,8 @@ py_class!(pub class DirstateMap |py| {
 ) -> PyResult {
 let now = Duration::new(now.extract(py)?, 0);
 let parents = DirstateParents {
-// TODO: don't panic; raise Python exception instead.
-p1: p1.extract::(py)?.data(py).try_into().unwrap(),
-p2: p2.extract::(py)?.data(py).try_into().unwrap(),
+p1: extract_node_id(py, )?,
+p2: extract_node_id(py, )?,
 };
 
 match self.borrow_mut(py)?.pack(parents, now) {
@@ -508,3 +505,11 @@ py_shared_mapping_iterator!(
 DirstateMap::translate_key_value,
 Option<(PyBytes, PyObject)>
 );
+
+fn extract_node_id(py: Python, obj: ) -> PyResult<[u8; PARENT_SIZE]> {
+let bytes = obj.extract::(py)?;
+match bytes.data(py).try_into() {
+Ok(s) => Ok(s),
+Err(e) => Err(PyErr::new::(py, e.to_string())),
+}
+}
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 07 of 11] rust: simply use TryInto to convert slice to array

2019-08-17 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1566009462 -32400
#  Sat Aug 17 11:37:42 2019 +0900
# Node ID d496a0a5d5f8ff45afde5a0a90b0917e507c
# Parent  a57c56ff9cec59f12780c83f5dc2ab679d2523e6
rust: simply use TryInto to convert slice to array

Since our rust module depends on TryInto, there's no point to avoid using it.

While rewriting copy_into_array(), I noticed CPython interface doesn't check
the length of the p1/p2 values, which is marked as TODO.

diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs 
b/rust/hg-core/src/dirstate/dirstate_map.rs
--- a/rust/hg-core/src/dirstate/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs
@@ -7,13 +7,13 @@
 
 use crate::{
 dirstate::{parsers::PARENT_SIZE, EntryState},
-pack_dirstate, parse_dirstate,
-utils::copy_into_array,
-CopyMap, DirsIterable, DirsMultiset, DirstateEntry, DirstateError,
-DirstateMapError, DirstateParents, DirstateParseError, StateMap,
+pack_dirstate, parse_dirstate, CopyMap, DirsIterable, DirsMultiset,
+DirstateEntry, DirstateError, DirstateMapError, DirstateParents,
+DirstateParseError, StateMap,
 };
 use core::borrow::Borrow;
 use std::collections::{HashMap, HashSet};
+use std::convert::TryInto;
 use std::iter::FromIterator;
 use std::ops::Deref;
 use std::time::Duration;
@@ -260,10 +260,10 @@ impl DirstateMap {
 let parents;
 if file_contents.len() == PARENT_SIZE * 2 {
 parents = DirstateParents {
-p1: copy_into_array(_contents[..PARENT_SIZE]),
-p2: copy_into_array(
-_contents[PARENT_SIZE..PARENT_SIZE * 2],
-),
+p1: file_contents[..PARENT_SIZE].try_into().unwrap(),
+p2: file_contents[PARENT_SIZE..PARENT_SIZE * 2]
+.try_into()
+.unwrap(),
 };
 } else if file_contents.is_empty() {
 parents = DirstateParents {
diff --git a/rust/hg-core/src/dirstate/parsers.rs 
b/rust/hg-core/src/dirstate/parsers.rs
--- a/rust/hg-core/src/dirstate/parsers.rs
+++ b/rust/hg-core/src/dirstate/parsers.rs
@@ -5,7 +5,6 @@
 
 use crate::{
 dirstate::{CopyMap, EntryState, StateMap},
-utils::copy_into_array,
 DirstateEntry, DirstatePackError, DirstateParents, DirstateParseError,
 };
 use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
@@ -31,8 +30,8 @@ pub fn parse_dirstate(
 
 let mut curr_pos = PARENT_SIZE * 2;
 let parents = DirstateParents {
-p1: copy_into_array([..PARENT_SIZE]),
-p2: copy_into_array([PARENT_SIZE..curr_pos]),
+p1: contents[..PARENT_SIZE].try_into().unwrap(),
+p2: contents[PARENT_SIZE..curr_pos].try_into().unwrap(),
 };
 
 while curr_pos < contents.len() {
diff --git a/rust/hg-core/src/utils.rs b/rust/hg-core/src/utils.rs
--- a/rust/hg-core/src/utils.rs
+++ b/rust/hg-core/src/utils.rs
@@ -9,23 +9,6 @@
 
 pub mod files;
 
-use std::convert::AsMut;
-
-/// Takes a slice and copies it into an array.
-///
-/// # Panics
-///
-/// Will panic if the slice and target array don't have the same length.
-pub fn copy_into_array(slice: &[T]) -> A
-where
-A: Sized + Default + AsMut<[T]>,
-T: Copy,
-{
-let mut a = Default::default();
->::as_mut( a).copy_from_slice(slice);
-a
-}
-
 /// Replaces the `from` slice with the `to` slice inside the `buf` slice.
 ///
 /// # Examples
diff --git a/rust/hg-cpython/src/dirstate/dirstate_map.rs 
b/rust/hg-cpython/src/dirstate/dirstate_map.rs
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs
@@ -24,7 +24,7 @@ use crate::{
 ref_sharing::PySharedState,
 };
 use hg::{
-utils::copy_into_array, DirsIterable, DirsMultiset, DirstateEntry,
+DirsIterable, DirsMultiset, DirstateEntry,
 DirstateMap as RustDirstateMap, DirstateParents, DirstateParseError,
 EntryState,
 };
@@ -239,8 +239,9 @@ py_class!(pub class DirstateMap |py| {
 }
 
 def setparents(, p1: PyObject, p2: PyObject) -> PyResult {
-let p1 = copy_into_array(p1.extract::(py)?.data(py));
-let p2 = copy_into_array(p2.extract::(py)?.data(py));
+// TODO: don't panic; raise Python exception instead.
+let p1 = p1.extract::(py)?.data(py).try_into().unwrap();
+let p2 = p2.extract::(py)?.data(py).try_into().unwrap();
 
 self.inner(py)
 .borrow_mut()
@@ -274,8 +275,9 @@ py_class!(pub class DirstateMap |py| {
 ) -> PyResult {
 let now = Duration::new(now.extract(py)?, 0);
 let parents = DirstateParents {
-p1: copy_into_array(p1.extract::(py)?.data(py)),
-p2: copy_into_array(p2.extract::(py)?.data(py)),
+// TODO: don't panic; raise Python exception instead.
+p1: p1.extract::(py)?.data(py).try_into().unwrap(),
+p2: p2.extract::(py)?.data(py).try_into().unwrap(),
 };
 
 match self.borrow_mut(py)?.pack(parents, now) {

[PATCH 06 of 11] rust-dirstate: use PARENT_SIZE constant where appropriate

2019-08-17 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1566017705 -32400
#  Sat Aug 17 13:55:05 2019 +0900
# Node ID a57c56ff9cec59f12780c83f5dc2ab679d2523e6
# Parent  f61ecf74968aae152d1cdbe946d3f418b0fa1381
rust-dirstate: use PARENT_SIZE constant where appropriate

diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs 
b/rust/hg-core/src/dirstate/dirstate_map.rs
--- a/rust/hg-core/src/dirstate/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs
@@ -258,7 +258,7 @@ impl DirstateMap {
 return Ok(parents.clone());
 }
 let parents;
-if file_contents.len() == 40 {
+if file_contents.len() == PARENT_SIZE * 2 {
 parents = DirstateParents {
 p1: copy_into_array(_contents[..PARENT_SIZE]),
 p2: copy_into_array(
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 05 of 11] rust-dirstate: rename NULL_REVISION to NULL_ID which isn't a revision number

2019-08-17 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1566016031 -32400
#  Sat Aug 17 13:27:11 2019 +0900
# Node ID f61ecf74968aae152d1cdbe946d3f418b0fa1381
# Parent  af8265f67d45cfff198c26e639b57e98c0c56287
rust-dirstate: rename NULL_REVISION to NULL_ID which isn't a revision number

diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs 
b/rust/hg-core/src/dirstate/dirstate_map.rs
--- a/rust/hg-core/src/dirstate/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs
@@ -20,7 +20,7 @@ use std::time::Duration;
 
 pub type FileFoldMap = HashMap, Vec>;
 
-const NULL_REVISION: [u8; 20] = [0; 20];
+const NULL_ID: [u8; 20] = [0; 20];
 const MTIME_UNSET: i32 = -1;
 const SIZE_DIRTY: i32 = -2;
 
@@ -69,8 +69,8 @@ impl DirstateMap {
 self.non_normal_set.clear();
 self.other_parent_set.clear();
 self.set_parents(DirstateParents {
-p1: NULL_REVISION,
-p2: NULL_REVISION,
+p1: NULL_ID,
+p2: NULL_ID,
 })
 }
 
@@ -267,8 +267,8 @@ impl DirstateMap {
 };
 } else if file_contents.is_empty() {
 parents = DirstateParents {
-p1: NULL_REVISION,
-p2: NULL_REVISION,
+p1: NULL_ID,
+p2: NULL_ID,
 };
 } else {
 return Err(DirstateError::Parse(DirstateParseError::Damaged));
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 04 of 11] rust-dirstate: remove repetition in array literal

2019-08-17 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1566015964 -32400
#  Sat Aug 17 13:26:04 2019 +0900
# Node ID af8265f67d45cfff198c26e639b57e98c0c56287
# Parent  8f7737800ff279e6886250b8e2a21e67d7492937
rust-dirstate: remove repetition in array literal

diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs 
b/rust/hg-core/src/dirstate/dirstate_map.rs
--- a/rust/hg-core/src/dirstate/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs
@@ -20,10 +20,7 @@ use std::time::Duration;
 
 pub type FileFoldMap = HashMap, Vec>;
 
-const NULL_REVISION: [u8; 20] = [
-b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0',
-b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0',
-];
+const NULL_REVISION: [u8; 20] = [0; 20];
 const MTIME_UNSET: i32 = -1;
 const SIZE_DIRTY: i32 = -2;
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 03 of 11] rust-dirstate: remove too abstracted way of getting &[u8]

2019-08-17 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1566016950 -32400
#  Sat Aug 17 13:42:30 2019 +0900
# Node ID 8f7737800ff279e6886250b8e2a21e67d7492937
# Parent  e04eef69a482c886117a6aaa604d8dce6e3e1d3a
rust-dirstate: remove too abstracted way of getting &[u8]

diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs 
b/rust/hg-core/src/dirstate/dirstate_map.rs
--- a/rust/hg-core/src/dirstate/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs
@@ -130,8 +130,7 @@ impl DirstateMap {
 }
 
 if let Some(ref mut file_fold_map) = self.file_fold_map {
-file_fold_map
-.remove::>(filename.to_ascii_uppercase().as_ref());
+file_fold_map.remove(_ascii_uppercase());
 }
 self.state_map.insert(
 filename.to_owned(),
@@ -153,10 +152,7 @@ impl DirstateMap {
 filename: &[u8],
 old_state: EntryState,
 ) -> Result {
-let exists = self
-.state_map
-.remove::>(filename.to_owned().as_ref())
-.is_some();
+let exists = self.state_map.remove(filename).is_some();
 
 if exists {
 if old_state != EntryState::Removed {
@@ -169,11 +165,9 @@ impl DirstateMap {
 }
 }
 if let Some(ref mut file_fold_map) = self.file_fold_map {
-file_fold_map
-.remove::>(filename.to_ascii_uppercase().as_ref());
+file_fold_map.remove(_ascii_uppercase());
 }
-self.non_normal_set
-.remove::>(filename.to_owned().as_ref());
+self.non_normal_set.remove(filename);
 
 Ok(exists)
 }
@@ -251,12 +245,12 @@ impl DirstateMap {
 
 pub fn has_tracked_dir( self, directory: &[u8]) -> bool {
 self.set_dirs();
-self.dirs.as_ref().unwrap().contains(directory.as_ref())
+self.dirs.as_ref().unwrap().contains(directory)
 }
 
 pub fn has_dir( self, directory: &[u8]) -> bool {
 self.set_all_dirs();
-self.all_dirs.as_ref().unwrap().contains(directory.as_ref())
+self.all_dirs.as_ref().unwrap().contains(directory)
 }
 
 pub fn parents(
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 02 of 11] rust-dirstate: remove unneeded "ref"

2019-08-17 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1566009785 -32400
#  Sat Aug 17 11:43:05 2019 +0900
# Node ID e04eef69a482c886117a6aaa604d8dce6e3e1d3a
# Parent  809ab6f869baaa800f15fd6ab4003c480bd0871f
rust-dirstate: remove unneeded "ref"

At 7cae6bc29ff9, .to_owned() was rewritten as .to_owned().to_vec(), which
is no longer needed since the filename is a single reference.

diff --git a/rust/hg-core/src/dirstate/parsers.rs 
b/rust/hg-core/src/dirstate/parsers.rs
--- a/rust/hg-core/src/dirstate/parsers.rs
+++ b/rust/hg-core/src/dirstate/parsers.rs
@@ -92,7 +92,7 @@ pub fn pack_dirstate(
 .iter()
 .map(|(filename, _)| {
 let mut length = MIN_ENTRY_SIZE + filename.len();
-if let Some(ref copy) = copy_map.get(filename) {
+if let Some(copy) = copy_map.get(filename) {
 length += copy.len() + 1;
 }
 length
@@ -106,8 +106,8 @@ pub fn pack_dirstate(
 packed.extend();
 packed.extend();
 
-for (ref filename, entry) in state_map.iter() {
-let mut new_filename: Vec = filename.to_vec();
+for (filename, entry) in state_map.iter() {
+let mut new_filename: Vec = filename.to_owned();
 let mut new_mtime: i32 = entry.mtime;
 if entry.state == EntryState::Normal && entry.mtime == now {
 // The file was last modified "simultaneously" with the current
@@ -121,7 +121,7 @@ pub fn pack_dirstate(
 // mistakenly treating such files as clean.
 new_mtime = -1;
 new_state_map.push((
-filename.to_owned().to_vec(),
+filename.to_owned(),
 DirstateEntry {
 mtime: new_mtime,
 ..*entry
@@ -129,7 +129,7 @@ pub fn pack_dirstate(
 ));
 }
 
-if let Some(copy) = copy_map.get(*filename) {
+if let Some(copy) = copy_map.get(filename) {
 new_filename.push('\0' as u8);
 new_filename.extend(copy);
 }
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 01 of 11] rust-parsers: fix unboxing of PyInt on Python 3

2019-08-17 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1566011866 -32400
#  Sat Aug 17 12:17:46 2019 +0900
# Node ID 809ab6f869baaa800f15fd6ab4003c480bd0871f
# Parent  302e4706ab25b4d29d858f93ca2678a609e95570
rust-parsers: fix unboxing of PyInt on Python 3

Broken at 7cae6bc29ff9.

diff --git a/rust/hg-cpython/src/parsers.rs b/rust/hg-cpython/src/parsers.rs
--- a/rust/hg-cpython/src/parsers.rs
+++ b/rust/hg-cpython/src/parsers.rs
@@ -12,7 +12,7 @@
 //!
 use cpython::{
 exc, PyBytes, PyDict, PyErr, PyInt, PyModule, PyResult, PyTuple, Python,
-ToPyObject,
+PythonObject, ToPyObject,
 };
 use hg::{
 pack_dirstate, parse_dirstate, utils::copy_into_array, DirstateEntry,
@@ -123,7 +123,7 @@ fn pack_dirstate_wrapper(
 p1: copy_into_array(),
 p2: copy_into_array(),
 },
-Duration::from_secs(now.value(py) as u64),
+Duration::from_secs(now.as_object().extract::(py)?),
 ) {
 Ok(packed) => {
 for (
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH] py3: do not convert rust module/attribute names to bytes

2019-08-17 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1566005104 -32400
#  Sat Aug 17 10:25:04 2019 +0900
# Node ID 302e4706ab25b4d29d858f93ca2678a609e95570
# Parent  a3c360094c93509ee013ed7f4b7807c74b2d60a4
py3: do not convert rust module/attribute names to bytes

policy.import*() functions expect system strings.

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -25,7 +25,7 @@ from .utils import (
 stringutil,
 )
 
-rustmod = policy.importrust('filepatterns')
+rustmod = policy.importrust(r'filepatterns')
 
 allpatternkinds = ('re', 'glob', 'path', 'relglob', 'relpath', 'relre',
'rootglob',
diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -270,8 +270,8 @@ class partialdiscovery(object):
 sample.update(takefrom[:more])
 return sample
 
-partialdiscovery = policy.importrust('discovery',
- member='PartialDiscovery',
+partialdiscovery = policy.importrust(r'discovery',
+ member=r'PartialDiscovery',
  default=partialdiscovery)
 
 def findcommonheads(ui, local, remote,
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -53,7 +53,7 @@ from .utils import (
 stringutil,
 )
 
-rustdirs = policy.importrust('dirstate', 'Dirs')
+rustdirs = policy.importrust(r'dirstate', r'Dirs')
 
 base85 = policy.importmod(r'base85')
 osutil = policy.importmod(r'osutil')
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH] transplant: unnest --stop case

2019-08-17 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1566024221 -32400
#  Sat Aug 17 15:43:41 2019 +0900
# Node ID a3c360094c93509ee013ed7f4b7807c74b2d60a4
# Parent  88d6a6f7e83716146fc725f20166509a520bc164
transplant: unnest --stop case

It should be aligned with --continue.

diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -692,11 +692,11 @@ def _dotransplant(ui, repo, *revs, **opt
 if opts.get('continue'):
 if not tp.canresume():
 raise error.Abort(_('no transplant to continue'))
+elif opts.get('stop'):
+if not tp.canresume():
+raise error.Abort(_('no interrupted transplant found'))
+return tp.stop(ui, repo)
 else:
-if opts.get('stop'):
-if not tp.canresume():
-raise error.Abort(_('no interrupted transplant found'))
-return tp.stop(ui, repo)
 cmdutil.checkunfinished(repo)
 cmdutil.bailifchanged(repo)
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6678: continue: added support for histedit

2019-08-17 Thread taapas1128 (Taapas Agrawal)
taapas1128 added a comment.


  @pulkit This one is ready too.

REPOSITORY
  rHG Mercurial

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

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

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


D6631: rust-cpython: add macro for sharing references

2019-08-17 Thread yuja (Yuya Nishihara)
yuja added a comment.


  > +impl PySharedState {
  > +pub fn borrow_mut<'a, T>(
  > +&'a self,
  > +py: Python<'a>,
  > +pyrefmut: RefMut<'a, T>,
  > +) -> PyResult> {
  > +if self.mutably_borrowed.get() {
  > +return Err(AlreadyBorrowed::new(
  > +py,
  > +"Cannot borrow mutably while there exists another \
  > + mutable reference in a Python object",
  > +));
  > +}
  > +match self.leak_count.get() {
  > +0 => {
  > +self.mutably_borrowed.replace(true);
  > +Ok(PyRefMut::new(py, pyrefmut, self))
  > +}
  > +// TODO
  > +// For now, this works differently than Python references
  > +// in the case of iterators.
  > +// Python does not complain when the data an iterator
  > +// points to is modified if the iterator is never used
  > +// afterwards.
  > +// Here, we are stricter than this by refusing to give a
  > +// mutable reference if it is already borrowed.
  > +// While the additional safety might be argued for, it
  > +// breaks valid programming patterns in Python and we need
  > +// to fix this issue down the line.
  > +_ => Err(AlreadyBorrowed::new(
  > +py,
  > +"Cannot borrow mutably while there are \
  > + immutable references in Python objects",
  > +)),
  > +}
  > +}
  > +
  > +/// Return a reference to the wrapped data with an artificial static
  > +/// lifetime.
  > +/// We need to be protected by the GIL for thread-safety.
  > +pub fn leak_immutable(
  > +,
  > +py: Python,
  > +data: ,
  > +) -> PyResult<&'static T> {
  > +if self.mutably_borrowed.get() {
  > +return Err(AlreadyBorrowed::new(
  > +py,
  > +"Cannot borrow immutably while there is a \
  > + mutable reference in Python objects",
  > +));
  > +}
  > +let ptr = data.as_ptr();
  > +self.leak_count.replace(self.leak_count.get() + 1);
  > +unsafe { Ok(&*ptr) }
  > +}
  
  This leak_immutable() looks potentially unsafe since it can extend the
  lifetime of an arbitrary object, data.
  
  > +macro_rules! py_shared_ref {
  > +(
  > +$name: ident,
  > +$inner_struct: ident,
  > +$data_member: ident,
  > +$leaked: ident,
  > +) => {
  > +impl $name {
  > +fn borrow_mut<'a>(
  > +&'a self,
  > +py: Python<'a>,
  > +) -> PyResult>
  > +{
  > +self.py_shared_state(py)
  > +.borrow_mut(py, self.$data_member(py).borrow_mut())
  > +}
  > +
  > +fn leak_immutable<'a>(
  > +&'a self,
  > +py: Python<'a>,
  > +) -> PyResult<&'static $inner_struct> {
  > +self.py_shared_state(py)
  > +.leak_immutable(py, self.$data_member(py))
  > +}
  > +}
  
  Is it okay to directly borrow/borrow_mut() the inner object?
  
  For example, we can still do `self.inner(py).borrow_mut()` (in place of
  `self.borrow_mut(py)`) while the inner object is leaked, which I think is
  unsafe.
  
  If I understand the py-shared logic correctly, PySharedState needs to own
  the inner object to guarantee that any public operations are safe.

REPOSITORY
  rHG Mercurial

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

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

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


Re: D6631: rust-cpython: add macro for sharing references

2019-08-17 Thread Yuya Nishihara
> +impl PySharedState {
> +pub fn borrow_mut<'a, T>(
> +&'a self,
> +py: Python<'a>,
> +pyrefmut: RefMut<'a, T>,
> +) -> PyResult> {
> +if self.mutably_borrowed.get() {
> +return Err(AlreadyBorrowed::new(
> +py,
> +"Cannot borrow mutably while there exists another \
> + mutable reference in a Python object",
> +));
> +}
> +match self.leak_count.get() {
> +0 => {
> +self.mutably_borrowed.replace(true);
> +Ok(PyRefMut::new(py, pyrefmut, self))
> +}
> +// TODO
> +// For now, this works differently than Python references
> +// in the case of iterators.
> +// Python does not complain when the data an iterator
> +// points to is modified if the iterator is never used
> +// afterwards.
> +// Here, we are stricter than this by refusing to give a
> +// mutable reference if it is already borrowed.
> +// While the additional safety might be argued for, it
> +// breaks valid programming patterns in Python and we need
> +// to fix this issue down the line.
> +_ => Err(AlreadyBorrowed::new(
> +py,
> +"Cannot borrow mutably while there are \
> + immutable references in Python objects",
> +)),
> +}
> +}
> +
> +/// Return a reference to the wrapped data with an artificial static
> +/// lifetime.
> +/// We need to be protected by the GIL for thread-safety.
> +pub fn leak_immutable(
> +,
> +py: Python,
> +data: ,
> +) -> PyResult<&'static T> {
> +if self.mutably_borrowed.get() {
> +return Err(AlreadyBorrowed::new(
> +py,
> +"Cannot borrow immutably while there is a \
> + mutable reference in Python objects",
> +));
> +}
> +let ptr = data.as_ptr();
> +self.leak_count.replace(self.leak_count.get() + 1);
> +unsafe { Ok(&*ptr) }
> +}

This leak_immutable() looks potentially unsafe since it can extend the
lifetime of an arbitrary object, data.

> +macro_rules! py_shared_ref {
> +(
> +$name: ident,
> +$inner_struct: ident,
> +$data_member: ident,
> +$leaked: ident,
> +) => {
> +impl $name {
> +fn borrow_mut<'a>(
> +&'a self,
> +py: Python<'a>,
> +) -> PyResult>
> +{
> +self.py_shared_state(py)
> +.borrow_mut(py, self.$data_member(py).borrow_mut())
> +}
> +
> +fn leak_immutable<'a>(
> +&'a self,
> +py: Python<'a>,
> +) -> PyResult<&'static $inner_struct> {
> +self.py_shared_state(py)
> +.leak_immutable(py, self.$data_member(py))
> +}
> +}

Is it okay to directly borrow/borrow_mut() the inner object?

For example, we can still do `self.inner(py).borrow_mut()` (in place of
`self.borrow_mut(py)`) while the inner object is leaked, which I think is
unsafe.

If I understand the py-shared logic correctly, PySharedState needs to own
the inner object to guarantee that any public operations are safe.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6632: rust-dirstate: rust implementation of dirstatemap

2019-08-17 Thread yuja (Yuya Nishihara)
yuja added a comment.


  > +if let Some(ref mut file_fold_map) = self.file_fold_map {
  > +file_fold_map
  > +.remove::>(filename.to_ascii_uppercase().as_ref());
  
  Looks incompatible with the dirstate class, which uses util.normcase().

REPOSITORY
  rHG Mercurial

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

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

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


Re: D6632: rust-dirstate: rust implementation of dirstatemap

2019-08-17 Thread Yuya Nishihara
> +if let Some(ref mut file_fold_map) = self.file_fold_map {
> +file_fold_map
> +.remove::>(filename.to_ascii_uppercase().as_ref());

Looks incompatible with the dirstate class, which uses util.normcase().
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


mercurial@42747: 2 new changesets

2019-08-17 Thread Mercurial Commits
2 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/b3518b0baa47
changeset:   42746:b3518b0baa47
user:Raphaël Gomès 
date:Mon Jul 08 18:01:39 2019 +0200
summary: rust-dirstate: create dirstate submodule in hg-cpython

https://www.mercurial-scm.org/repo/hg/rev/760a7851e9ba
changeset:   42747:760a7851e9ba
bookmark:@
tag: tip
user:Raphaël Gomès 
date:Wed Jul 10 10:16:28 2019 +0200
summary: rust-parsers: move parser bindings to their own file and Python 
module

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


D6633: rust-dirstate: rust-cpython bridge for dirstatemap

2019-08-17 Thread yuja (Yuya Nishihara)
yuja added a comment.


  > +def getdirs() -> PyResult {
  > +// TODO don't copy, share the reference
  > +self.inner(py).borrow_mut().set_dirs();
  > +Dirs::from_inner(
  > +py,
  > +DirsMultiset::new(
  > +DirsIterable::Dirstate((py).borrow()),
  > +Some(EntryState::Removed),
  > +),
  > +)
  > +}
  > +def getalldirs() -> PyResult {
  > +// TODO don't copy, share the reference
  > +self.inner(py).borrow_mut().set_all_dirs();
  > +Dirs::from_inner(
  > +py,
  > +DirsMultiset::new(
  > +DirsIterable::Dirstate((py).borrow()),
  > +None,
  > +),
  > +)
  > +}
  
  How do these set_dirs/set_all_dirs work? IIUC, the return value is built
  from state_map.

REPOSITORY
  rHG Mercurial

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

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

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


Re: D6633: rust-dirstate: rust-cpython bridge for dirstatemap

2019-08-17 Thread Yuya Nishihara
> +def getdirs() -> PyResult {
> +// TODO don't copy, share the reference
> +self.inner(py).borrow_mut().set_dirs();
> +Dirs::from_inner(
> +py,
> +DirsMultiset::new(
> +DirsIterable::Dirstate((py).borrow()),
> +Some(EntryState::Removed),
> +),
> +)
> +}
> +def getalldirs() -> PyResult {
> +// TODO don't copy, share the reference
> +self.inner(py).borrow_mut().set_all_dirs();
> +Dirs::from_inner(
> +py,
> +DirsMultiset::new(
> +DirsIterable::Dirstate((py).borrow()),
> +None,
> +),
> +)
> +}

How do these set_dirs/set_all_dirs work? IIUC, the return value is built
from state_map.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel