D6693: fix: ignore fixer tool configurations that are missing patterns

2019-07-24 Thread hooper (Danny Hooper)
hooper created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is to prevent a crash under the same circumstances.
  
  This is also to avoid data loss due to accidental application of a fixer tool
  to all files, if the matching logic somehow changed to that effect. Affecting
  all files until otherwise configured would be dangerous, and not very useful.
  
  We shouldn't abort because there may be other fixers, and it may still be
  useful to run them without having to adjust configuration. A user might not
  feel confident in changing configs, for example.

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS

diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -1264,3 +1264,23 @@
 
   $ cd ..
 
+Tools configured without a pattern are ignored. It would be too dangerous to
+run them on all files, because this might happen while testing a configuration
+that also deletes all of the file content. There is no reasonable subset of the
+files to use as a default. Users should be explicit about what files are
+affected by a tool. This test also confirms that we don't crash when the
+pattern config is missing, and that we only warn about it once.
+
+  $ hg init nopatternconfigured
+  $ cd nopatternconfigured
+
+  $ printf "foo" > foo
+  $ printf "bar" > bar
+  $ hg add -q
+  $ hg fix --debug --working-dir --config "fix.nopattern:command=echo fixed"
+  fixer tool has no pattern configuration: nopattern
+  $ cat foo bar
+  foobar (no-eol)
+
+  $ cd ..
+
diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -710,6 +710,14 @@
 setattr(fixers[name], pycompat.sysstr('_' + key),
 attrs.get(key, default))
 fixers[name]._priority = int(fixers[name]._priority)
+# Don't use a fixer if it has no pattern configured. It would be
+# dangerous to let it affect all files. It would be pointless to let it
+# affect no files. There is no reasonable subset of files to use as the
+# default.
+if fixers[name]._pattern is None:
+ui.warn(
+_('fixer tool has no pattern configuration: %s\n') % (name,))
+del fixers[name]
 return collections.OrderedDict(
 sorted(fixers.items(), key=lambda item: item[1]._priority,
reverse=True))
@@ -727,7 +735,8 @@
 
 def affects(self, opts, fixctx, path):
 """Should this fixer run on the file at the given path and context?"""
-return scmutil.match(fixctx, [self._pattern], opts)(path)
+return (self._pattern is not None and
+scmutil.match(fixctx, [self._pattern], opts)(path))
 
 def shouldoutputmetadata(self):
 """Should the stdout of this fixer start with JSON and a null byte?"""



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


D6692: fix: add a test case around the effect of cwd on pattern matching

2019-07-24 Thread hooper (Danny Hooper)
hooper created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This was not covered by previous tests. It is related to a regression
  encountered at Google due to misconfiguration of [fix].

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-fix.t

CHANGE DETAILS

diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -1284,3 +1284,28 @@
 
   $ cd ..
 
+Test that we can configure a fixer to affect all files regardless of the cwd.
+The way we invoke matching must not prohibit this.
+
+  $ hg init affectallfiles
+  $ cd affectallfiles
+
+  $ mkdir foo bar
+  $ printf "foo" > foo/file
+  $ printf "bar" > bar/file
+  $ printf "baz" > baz_file
+  $ hg add -q
+
+  $ cd bar
+  $ hg fix --working-dir --config "fix.cooltool:command=echo fixed" \
+  >  --config "fix.cooltool:pattern=rootglob:**"
+  $ cd ..
+
+  $ cat foo/file
+  fixed
+  $ cat bar/file
+  fixed
+  $ cat baz_file
+  fixed
+
+  $ cd ..



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


D6691: fix: remove support for :fileset sub-config in favor of :pattern

2019-07-24 Thread hooper (Danny Hooper)
hooper 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/D6691

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

CHANGE DETAILS

diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -1161,28 +1161,6 @@
 
   $ cd ..
 
-The :fileset subconfig was a misnomer, so we renamed it to :pattern. We will
-still accept :fileset by itself as if it were :pattern, but this will issue a
-warning.
-
-  $ hg init filesetispattern
-  $ cd filesetispattern
-
-  $ printf "foo\n" > foo.whole
-  $ printf "first\nsecond\n" > bar.txt
-  $ hg add -q
-  $ hg fix -w --config fix.sometool:fileset=bar.txt \
-  >   --config fix.sometool:command="sort -r"
-  the fix.tool:fileset config name is deprecated; please rename it to 
fix.tool:pattern
-
-  $ cat foo.whole
-  FOO
-  $ cat bar.txt
-  second
-  first
-
-  $ cd ..
-
 The execution order of tools can be controlled. This example doesn't work if
 you sort after truncating, but the config defines the correct order while the
 definitions are out of order (which might imply the incorrect order given the
diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -152,7 +152,6 @@
 FIXER_ATTRS = {
 'command': None,
 'linerange': None,
-'fileset': None,
 'pattern': None,
 'priority': 0,
 'metadata': False,
@@ -702,10 +701,6 @@
 for name in fixernames(ui):
 fixers[name] = Fixer()
 attrs = ui.configsuboptions('fix', name)[1]
-if 'fileset' in attrs and 'pattern' not in attrs:
-ui.warn(_('the fix.tool:fileset config name is deprecated; '
-  'please rename it to fix.tool:pattern\n'))
-attrs['pattern'] = attrs['fileset']
 for key, default in FIXER_ATTRS.items():
 setattr(fixers[name], pycompat.sysstr('_' + key),
 attrs.get(key, default))



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


mercurial@42644: new changeset (1 on stable)

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

https://www.mercurial-scm.org/repo/hg/rev/0795bbe8ed19
changeset:   42644:0795bbe8ed19
branch:  stable
bookmark:@
tag: tip
user:Navaneeth Suresh 
date:Tue Jul 23 12:03:24 2019 +0530
summary: unshelve: add help text on --interactive in verbose mode

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


D6685: unshelve: changes how date is set on interactive mode

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 16059.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6685?vs=16039&id=16059

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

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

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
@@ -828,7 +828,7 @@
 snode = repo.commit(text=shelvectx.description(),
 extra=shelvectx.extra(),
 user=shelvectx.user(),
-date=shelvectx.date())
+date=dateutil.makedate())
 m = scmutil.matchfiles(repo, repo[snode].files())
 if snode:
 _shelvecreatedcommit(repo, snode, basename, m)



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


D6684: unshelve: modify --continue on interactive unshelve

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh edited the summary of this revision.
navaneeth.suresh updated this revision to Diff 16058.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6684?vs=16056&id=16058

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

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

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
@@ -698,11 +698,12 @@
 if shfile.exists():
 shfile.movetobackup()
 cleanupoldbackups(repo)
-def unshelvecontinue(ui, repo, state, opts, basename=None):
+def unshelvecontinue(ui, repo, state, opts):
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
 # parent, second is the temporary "fake" commit we're unshelving.
 interactive = state.interactive
+basename = state.name
 with repo.lock():
 checkparents(repo, state)
 ms = merge.mergestate.read(repo)
@@ -933,7 +934,7 @@
 if opts.get("name"):
 shelved.append(opts["name"])
 
-if abortf or continuef and not interactive:
+if abortf or continuef:
 if abortf and continuef:
 raise error.Abort(_('cannot use both abort and continue'))
 if shelved:
@@ -955,11 +956,8 @@
 raise error.Abort(_('no shelved changes to apply!'))
 basename = util.split(shelved[0][1])[1]
 ui.status(_("unshelving change '%s'\n") % basename)
-elif shelved:
+else:
 basename = shelved[0]
-if continuef and interactive:
-state = _loadshelvedstate(ui, repo, opts)
-return unshelvecontinue(ui, repo, state, opts, basename)
 
 if not shelvedfile(repo, basename, patchextension).exists():
 raise error.Abort(_("shelved change '%s' not found") % basename)



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


D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 16057.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6679?vs=16055&id=16057

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

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

AFFECTED FILES
  mercurial/shelve.py
  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
@@ -1351,13 +1351,12 @@
   A
   B
   C
-  $ hg unshelve --continue -i < y
   > y
   > y
   > y
   > EOF
-  unshelving change 'default-01'
   diff --git a/bar1 b/bar1
   1 hunks, 1 lines changed
   examine changes to 'bar1'?
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -177,6 +177,7 @@
 _nokeep = 'nokeep'
 # colon is essential to differentiate from a real bookmark name
 _noactivebook = ':no-active-bookmark'
+_interactive = 'interactive'
 
 @classmethod
 def _verifyandtransform(cls, d):
@@ -247,6 +248,7 @@
 obj.activebookmark = ''
 if d.get('activebook', '') != cls._noactivebook:
 obj.activebookmark = d.get('activebook', '')
+obj.interactive = d.get('interactive') == cls._interactive
 except (error.RepoLookupError, KeyError) as err:
 raise error.CorruptedState(pycompat.bytestr(err))
 
@@ -254,7 +256,7 @@
 
 @classmethod
 def save(cls, repo, name, originalwctx, pendingctx, nodestoremove,
- branchtorestore, keep=False, activebook=''):
+ branchtorestore, keep=False, activebook='', interactive=False):
 info = {
 "name": name,
 "originalwctx": nodemod.hex(originalwctx.node()),
@@ -267,6 +269,8 @@
 "keep": cls._keep if keep else cls._nokeep,
 "activebook": activebook or cls._noactivebook
 }
+if interactive:
+info['interactive'] = cls._interactive
 scmutil.simplekeyvaluefile(
 repo.vfs, cls._filename).write(info,
firstline=("%d" % cls._version))
@@ -698,7 +702,7 @@
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
 # parent, second is the temporary "fake" commit we're unshelving.
-interactive = opts.get('interactive')
+interactive = state.interactive
 with repo.lock():
 checkparents(repo, state)
 ms = merge.mergestate.read(repo)
@@ -854,7 +858,8 @@
 nodestoremove = [repo.changelog.node(rev)
  for rev in pycompat.xrange(oldtiprev, len(repo))]
 shelvedstate.save(repo, basename, pctx, tmpwctx, nodestoremove,
-  branchtorestore, opts.get('keep'), 
activebookmark)
+  branchtorestore, opts.get('keep'), 
activebookmark,
+  interactive)
 raise error.InterventionRequired(
 _("unresolved conflicts (see 'hg resolve', then "
   "'hg unshelve --continue')"))



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


D6688: unshelve: make basename as a mandatory argument for unshelvecontinue()

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh added a comment.


  In D6688#97859 , @pulkit wrote:
  
  > Can you explain in commit description as why this is done?
  
  This patch will become obsolete after D6684 
. Should I abandon this?

REPOSITORY
  rHG Mercurial

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

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

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


D6684: unshelve: modify --continue on interactive unshelve

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh edited the summary of this revision.
navaneeth.suresh updated this revision to Diff 16056.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6684?vs=16037&id=16056

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

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

AFFECTED FILES
  mercurial/shelve.py
  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
@@ -1351,13 +1351,12 @@
   A
   B
   C
-  $ hg unshelve --continue -i < y
   > y
   > y
   > y
   > EOF
-  unshelving change 'default-01'
   diff --git a/bar1 b/bar1
   1 hunks, 1 lines changed
   examine changes to 'bar1'?
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -698,11 +698,12 @@
 if shfile.exists():
 shfile.movetobackup()
 cleanupoldbackups(repo)
-def unshelvecontinue(ui, repo, state, opts, basename=None):
+def unshelvecontinue(ui, repo, state, opts):
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
 # parent, second is the temporary "fake" commit we're unshelving.
 interactive = state.interactive
+basename = state.name
 with repo.lock():
 checkparents(repo, state)
 ms = merge.mergestate.read(repo)
@@ -933,10 +934,10 @@
 if opts.get("name"):
 shelved.append(opts["name"])
 
-if abortf or continuef and not interactive:
+if abortf or continuef:
 if abortf and continuef:
 raise error.Abort(_('cannot use both abort and continue'))
-if shelved:
+if opts.get("name"):
 raise error.Abort(_('cannot combine abort/continue with '
'naming a shelved change'))
 if abortf and opts.get('tool', False):
@@ -947,19 +948,17 @@
 return unshelveabort(ui, repo, state)
 elif continuef:
 return unshelvecontinue(ui, repo, state, opts)
-elif len(shelved) > 1:
+if len(shelved) > 1:
 raise error.Abort(_('can only unshelve one change at a time'))
 elif not shelved:
 shelved = listshelves(repo)
 if not shelved:
 raise error.Abort(_('no shelved changes to apply!'))
 basename = util.split(shelved[0][1])[1]
-ui.status(_("unshelving change '%s'\n") % basename)
-elif shelved:
+if not (abortf or continuef):
+ui.status(_("unshelving change '%s'\n") % basename)
+else:
 basename = shelved[0]
-if continuef and interactive:
-state = _loadshelvedstate(ui, repo, opts)
-return unshelvecontinue(ui, repo, state, opts, basename)
 
 if not shelvedfile(repo, basename, patchextension).exists():
 raise error.Abort(_("shelved change '%s' not found") % basename)



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


D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh marked an inline comment as done.
navaneeth.suresh updated this revision to Diff 16055.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6679?vs=16054&id=16055

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

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

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
@@ -177,6 +177,7 @@
 _nokeep = 'nokeep'
 # colon is essential to differentiate from a real bookmark name
 _noactivebook = ':no-active-bookmark'
+_interactive = 'interactive'
 
 @classmethod
 def _verifyandtransform(cls, d):
@@ -247,6 +248,7 @@
 obj.activebookmark = ''
 if d.get('activebook', '') != cls._noactivebook:
 obj.activebookmark = d.get('activebook', '')
+obj.interactive = d.get('interactive') == cls._interactive
 except (error.RepoLookupError, KeyError) as err:
 raise error.CorruptedState(pycompat.bytestr(err))
 
@@ -254,7 +256,7 @@
 
 @classmethod
 def save(cls, repo, name, originalwctx, pendingctx, nodestoremove,
- branchtorestore, keep=False, activebook=''):
+ branchtorestore, keep=False, activebook='', interactive=False):
 info = {
 "name": name,
 "originalwctx": nodemod.hex(originalwctx.node()),
@@ -267,6 +269,8 @@
 "keep": cls._keep if keep else cls._nokeep,
 "activebook": activebook or cls._noactivebook
 }
+if interactive:
+info['interactive'] = cls._interactive
 scmutil.simplekeyvaluefile(
 repo.vfs, cls._filename).write(info,
firstline=("%d" % cls._version))
@@ -698,7 +702,7 @@
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
 # parent, second is the temporary "fake" commit we're unshelving.
-interactive = opts.get('interactive')
+interactive = state.interactive
 with repo.lock():
 checkparents(repo, state)
 ms = merge.mergestate.read(repo)
@@ -854,7 +858,8 @@
 nodestoremove = [repo.changelog.node(rev)
  for rev in pycompat.xrange(oldtiprev, len(repo))]
 shelvedstate.save(repo, basename, pctx, tmpwctx, nodestoremove,
-  branchtorestore, opts.get('keep'), 
activebookmark)
+  branchtorestore, opts.get('keep'), 
activebookmark,
+  interactive)
 raise error.InterventionRequired(
 _("unresolved conflicts (see 'hg resolve', then "
   "'hg unshelve --continue')"))



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


D6684: unshelve: modify --continue on interactive unshelve

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh added inline comments.

INLINE COMMENTS

> pulkit wrote in shelve.py:950
> Now I understand how this and the parent patches are arranged.
> 
> Why don't be have all the logic related to interactive in `unshelvecontinue`, 
> including getting the name of the shelve we are processing.
> 
> Right now, we are getting name of top most shelve, however we should read the 
> shelvedstate and get the name from there.

Doing that right away!

REPOSITORY
  rHG Mercurial

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

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

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


D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh added inline comments.
navaneeth.suresh marked an inline comment as done.

INLINE COMMENTS

> pulkit wrote in shelve.py:181
> The above comment is not done.
> 
> I meant, we don't need _noninteractive.

Done.

REPOSITORY
  rHG Mercurial

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

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

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


D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh marked an inline comment as done.
navaneeth.suresh updated this revision to Diff 16054.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6679?vs=16036&id=16054

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

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

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
@@ -177,6 +177,7 @@
 _nokeep = 'nokeep'
 # colon is essential to differentiate from a real bookmark name
 _noactivebook = ':no-active-bookmark'
+_interactive = 'interactive'
 
 @classmethod
 def _verifyandtransform(cls, d):
@@ -247,6 +248,7 @@
 obj.activebookmark = ''
 if d.get('activebook', '') != cls._noactivebook:
 obj.activebookmark = d.get('activebook', '')
+obj.interactive = d.get('interactive') == cls._interactive
 except (error.RepoLookupError, KeyError) as err:
 raise error.CorruptedState(pycompat.bytestr(err))
 
@@ -254,7 +256,7 @@
 
 @classmethod
 def save(cls, repo, name, originalwctx, pendingctx, nodestoremove,
- branchtorestore, keep=False, activebook=''):
+ branchtorestore, keep=False, activebook='', interactive=False):
 info = {
 "name": name,
 "originalwctx": nodemod.hex(originalwctx.node()),
@@ -265,8 +267,10 @@
   for n in nodestoremove]),
 "branchtorestore": branchtorestore,
 "keep": cls._keep if keep else cls._nokeep,
-"activebook": activebook or cls._noactivebook
+"activebook": activebook or cls._noactivebook,
 }
+if interactive:
+info['interactive'] = cls._interactive
 scmutil.simplekeyvaluefile(
 repo.vfs, cls._filename).write(info,
firstline=("%d" % cls._version))
@@ -698,7 +702,7 @@
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
 # parent, second is the temporary "fake" commit we're unshelving.
-interactive = opts.get('interactive')
+interactive = state.interactive
 with repo.lock():
 checkparents(repo, state)
 ms = merge.mergestate.read(repo)
@@ -854,7 +858,8 @@
 nodestoremove = [repo.changelog.node(rev)
  for rev in pycompat.xrange(oldtiprev, len(repo))]
 shelvedstate.save(repo, basename, pctx, tmpwctx, nodestoremove,
-  branchtorestore, opts.get('keep'), 
activebookmark)
+  branchtorestore, opts.get('keep'), 
activebookmark,
+  interactive)
 raise error.InterventionRequired(
 _("unresolved conflicts (see 'hg resolve', then "
   "'hg unshelve --continue')"))



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


D6631: rust-cpython: add macro for sharing references

2019-07-24 Thread Raphaël Gomès
Alphare added a comment.


  @kevincox I've renamed the file since it no longer just contains macros.
  
  I've moved whatever I could move to separate structs and used `Cell` instead 
of `RefCell` on those scalar types. I'm not so keen on using `UnsafeCell`, 
espacially since the target `py_class!`-resulting struct could be using 
`RefCell`-specific APIs.
  
  I'm not too sure on the terminology, so tell me if you have better ideas than 
mine.
  
  Later down the line, I could see a `trait` to help define the interface for 
shared structs.

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
Cc: gracinet, durin42, kevincox, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6634: rust-dirstate: call rust dirstatemap from Python

2019-07-24 Thread Raphaël Gomès
Alphare updated this revision to Diff 16053.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6634?vs=15894&id=16053

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

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

AFFECTED FILES
  hgext/largefiles/overrides.py
  mercurial/dirstate.py

CHANGE DETAILS

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -27,14 +27,14 @@
 util,
 )
 
-orig_parsers = policy.importmod(r'parsers')
-parsers = policy.importrust(r'parsers', default=orig_parsers)
+parsers = policy.importmod(r'parsers')
+rustmod = policy.importrust(r'dirstate')
 
 propertycache = util.propertycache
 filecache = scmutil.filecache
 _rangemask = 0x7fff
 
-dirstatetuple = orig_parsers.dirstatetuple
+dirstatetuple = parsers.dirstatetuple
 
 class repocache(filecache):
 """filecache for files in .hg/"""
@@ -652,7 +652,8 @@
 delaywrite = self._ui.configint('debug', 'dirstate.delaywrite')
 if delaywrite > 0:
 # do we have any files to delay for?
-for f, e in self._map.iteritems():
+items = self._map.iteritems()
+for f, e in items:
 if e[0] == 'n' and e[3] == now:
 import time # to avoid useless import
 # rather than sleep n seconds, sleep until the next
@@ -663,6 +664,12 @@
 time.sleep(end - clock)
 now = end # trust our estimate that the end is near now
 break
+# since the iterator is potentially not depleted,
+# delete the iterator to release the reference for the Rust
+# implementation.
+# TODO make the Rust implementation behave like Python
+# since this would not work with a non ref-counting GC.
+del items
 
 self._map.write(st, now)
 self._lastnormaltime = 0
@@ -1516,3 +1523,187 @@
 for name in self._dirs:
 f[normcase(name)] = name
 return f
+
+
+if rustmod is not None:
+class dirstatemap(object):
+def __init__(self, ui, opener, root):
+self._ui = ui
+self._opener = opener
+self._root = root
+self._filename = 'dirstate'
+self._parents = None
+self._dirtyparents = False
+
+# for consistent view between _pl() and _read() invocations
+self._pendingmode = None
+
+
+def addfile(self, *args, **kwargs):
+return self._rustmap.addfile(*args, **kwargs)
+
+def removefile(self, *args, **kwargs):
+return self._rustmap.removefile(*args, **kwargs)
+
+def dropfile(self, *args, **kwargs):
+return self._rustmap.dropfile(*args, **kwargs)
+
+def clearambiguoustimes(self, *args, **kwargs):
+return self._rustmap.clearambiguoustimes(*args, **kwargs)
+
+def nonnormalentries(self):
+return self._rustmap.nonnormalentries()
+
+def get(self, *args, **kwargs):
+return self._rustmap.get(*args, **kwargs)
+
+@propertycache
+def _rustmap(self):
+self._rustmap = rustmod.DirstateMap(self._root)
+self.read()
+return self._rustmap
+
+@property
+def copymap(self):
+return self._rustmap.copymap()
+
+def preload(self):
+self._rustmap
+
+def clear(self):
+self._rustmap.clear()
+self.setparents(nullid, nullid)
+util.clearcachedproperty(self, "_dirs")
+util.clearcachedproperty(self, "_alldirs")
+util.clearcachedproperty(self, "dirfoldmap")
+
+def items(self):
+return self._rustmap.items()
+
+def keys(self):
+return iter(self._rustmap)
+
+def __contains__(self, key):
+return key in self._rustmap
+
+def __getitem__(self, item):
+return self._rustmap[item]
+
+def __len__(self):
+return len(self._rustmap)
+
+def __iter__(self):
+return iter(self._rustmap)
+
+# forward for python2,3 compat
+iteritems = items
+
+def _opendirstatefile(self):
+fp, mode = txnutil.trypending(self._root, self._opener,
+  self._filename)
+if self._pendingmode is not None and self._pendingmode != mode:
+fp.close()
+raise error.Abort(_('working directory state may be '
+'changed parallelly'))
+self._pendingmode = mode
+return fp
+
+def setparents(self, p1, p2):
+self._rustmap.setparents(p1, p2)
+self._parents = (p1, p2)
+self._dirtyparents = True
+
+def parents(self):
+if not self._parents:
+  

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

2019-07-24 Thread Raphaël Gomès
Alphare updated this revision to Diff 16052.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6633?vs=15851&id=16052

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

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

AFFECTED FILES
  rust/hg-cpython/src/dirstate.rs
  rust/hg-cpython/src/dirstate/copymap.rs
  rust/hg-cpython/src/dirstate/dirstate_map.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/dirstate/dirstate_map.rs 
b/rust/hg-cpython/src/dirstate/dirstate_map.rs
new file mode 100644
--- /dev/null
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs
@@ -0,0 +1,508 @@
+// dirstate_map.rs
+//
+// Copyright 2019 Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+//! Bindings for the `hg::dirstate::dirstate_map` file provided by the
+//! `hg-core` package.
+
+use std::cell::RefCell;
+use std::convert::TryInto;
+use std::time::Duration;
+
+use cpython::{
+exc, ObjectProtocol, PyBool, PyBytes, PyClone, PyDict, PyErr, PyObject,
+PyResult, PyTuple, Python, PythonObject, ToPyObject,
+};
+use libc::c_char;
+
+use crate::{
+dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator},
+dirstate::{decapsule_make_dirstate_tuple, dirs_multiset::Dirs},
+ref_sharing::PySharedState,
+};
+use hg::{
+utils::copy_into_array, DirsIterable, DirsMultiset, DirstateEntry,
+DirstateMap as RustDirstateMap, DirstateParents, DirstateParseError,
+EntryState,
+};
+
+// TODO
+// This object needs to share references to multiple members of its Rust
+// inner struct, namely `copy_map`, `dirs` and `all_dirs`.
+// Right now `CopyMap` is done, but it needs to have an explicit reference
+// to `RustDirstateMap` which itself needs to have an encapsulation for
+// every method in `CopyMap` (copymapcopy, etc.).
+// This is ugly and hard to maintain.
+// The same logic applies to `dirs` and `all_dirs`, however the `Dirs`
+// `py_class!` is already implemented and does not mention
+// `RustDirstateMap`, rightfully so.
+// All attributes also have to have a separate refcount data attribute for
+// leaks, with all methods that go along for reference sharing.
+py_class!(pub class DirstateMap |py| {
+data inner: RefCell;
+data py_shared_state: PySharedState;
+
+def __new__(_cls, _root: PyObject) -> PyResult {
+let inner = RustDirstateMap::default();
+Self::create_instance(
+py,
+RefCell::new(inner),
+PySharedState::default()
+)
+}
+
+def clear(&self) -> PyResult {
+self.borrow_mut(py)?.clear();
+Ok(py.None())
+}
+
+def get(
+&self,
+key: PyObject,
+default: Option = None
+) -> PyResult> {
+let key = key.extract::(py)?;
+match self.inner(py).borrow().get(key.data(py)) {
+Some(entry) => {
+// Explicitly go through u8 first, then cast to
+// platform-specific `c_char`.
+let state: u8 = entry.state.into();
+Ok(Some(decapsule_make_dirstate_tuple(py)?(
+state as c_char,
+entry.mode,
+entry.size,
+entry.mtime,
+)))
+},
+None => Ok(default)
+}
+}
+
+def addfile(
+&self,
+f: PyObject,
+oldstate: PyObject,
+state: PyObject,
+mode: PyObject,
+size: PyObject,
+mtime: PyObject
+) -> PyResult {
+self.borrow_mut(py)?.add_file(
+f.extract::(py)?.data(py),
+oldstate.extract::(py)?.data(py)[0]
+.try_into()
+.map_err(|e: DirstateParseError| {
+PyErr::new::(py, e.to_string())
+})?,
+DirstateEntry {
+state: state.extract::(py)?.data(py)[0]
+.try_into()
+.map_err(|e: DirstateParseError| {
+PyErr::new::(py, e.to_string())
+})?,
+mode: mode.extract(py)?,
+size: size.extract(py)?,
+mtime: mtime.extract(py)?,
+},
+);
+Ok(py.None())
+}
+
+def removefile(
+&self,
+f: PyObject,
+oldstate: PyObject,
+size: PyObject
+) -> PyResult {
+self.borrow_mut(py)?
+.remove_file(
+f.extract::(py)?.data(py),
+oldstate.extract::(py)?.data(py)[0]
+.try_into()
+.map_err(|e: DirstateParseError| {
+PyErr::new::(py, e.to_string())
+})?,
+size.extract(py)?,
+)
+.or_else(|_| {
+Err(PyErr::

D6632: rust-dirstate: rust implementation of dirstatemap

2019-07-24 Thread Raphaël Gomès
Alphare updated this revision to Diff 16051.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6632?vs=15850&id=16051

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

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

AFFECTED FILES
  rust/hg-core/src/dirstate.rs
  rust/hg-core/src/dirstate/dirstate_map.rs
  rust/hg-core/src/lib.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs
--- a/rust/hg-core/src/lib.rs
+++ b/rust/hg-core/src/lib.rs
@@ -10,6 +10,7 @@
 pub mod testing; // unconditionally built, for use from integration tests
 pub use dirstate::{
 dirs_multiset::DirsMultiset,
+dirstate_map::DirstateMap,
 parsers::{pack_dirstate, parse_dirstate, PARENT_SIZE},
 CopyMap, DirsIterable, DirstateEntry, DirstateParents, EntryState,
 StateMap,
diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs 
b/rust/hg-core/src/dirstate/dirstate_map.rs
new file mode 100644
--- /dev/null
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs
@@ -0,0 +1,433 @@
+// dirstate_map.rs
+//
+// Copyright 2019 Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+use crate::{
+dirstate::{parsers::PARENT_SIZE, EntryState},
+pack_dirstate, parse_dirstate,
+utils::copy_into_array,
+CopyMap, DirsIterable, DirsMultiset, DirstateEntry, DirstateError,
+DirstateMapError, DirstateParents, DirstateParseError, StateMap,
+};
+use core::borrow::Borrow;
+use std::collections::{HashMap, HashSet};
+use std::iter::FromIterator;
+use std::ops::Deref;
+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 MTIME_UNSET: i32 = -1;
+const SIZE_DIRTY: i32 = -2;
+
+#[derive(Default)]
+pub struct DirstateMap {
+state_map: StateMap,
+pub copy_map: CopyMap,
+file_fold_map: Option,
+pub dirs: Option,
+pub all_dirs: Option,
+non_normal_set: HashSet>,
+other_parent_set: HashSet>,
+parents: Option,
+dirty_parents: bool,
+}
+
+/// Should only really be used in python interface code, for clarity
+impl Deref for DirstateMap {
+type Target = StateMap;
+
+fn deref(&self) -> &Self::Target {
+&self.state_map
+}
+}
+
+impl FromIterator<(Vec, DirstateEntry)> for DirstateMap {
+fn from_iter, DirstateEntry)>>(
+iter: I,
+) -> Self {
+Self {
+state_map: iter.into_iter().collect(),
+..Self::default()
+}
+}
+}
+
+impl DirstateMap {
+pub fn new() -> Self {
+Self::default()
+}
+
+pub fn clear(&mut self) {
+self.state_map.clear();
+self.copy_map.clear();
+self.file_fold_map = None;
+self.non_normal_set.clear();
+self.other_parent_set.clear();
+self.set_parents(DirstateParents {
+p1: NULL_REVISION,
+p2: NULL_REVISION,
+})
+}
+
+/// Add a tracked file to the dirstate
+pub fn add_file(
+&mut self,
+filename: &[u8],
+old_state: EntryState,
+entry: DirstateEntry,
+) {
+if old_state == EntryState::Unknown || old_state == EntryState::Removed
+{
+if let Some(ref mut dirs) = self.dirs {
+dirs.add_path(filename)
+}
+}
+if old_state == EntryState::Unknown {
+if let Some(ref mut all_dirs) = self.all_dirs {
+all_dirs.add_path(filename)
+}
+}
+self.state_map.insert(filename.to_owned(), entry.to_owned());
+
+if entry.state != EntryState::Normal || entry.mtime == MTIME_UNSET {
+self.non_normal_set.insert(filename.to_owned());
+}
+
+if entry.size == SIZE_DIRTY {
+self.other_parent_set.insert(filename.to_owned());
+}
+}
+
+/// Mark a file as removed in the dirstate.
+///
+/// The `size` parameter is used to store sentinel values that indicate
+/// the file's previous state.  In the future, we should refactor this
+/// to be more explicit about what that state is.
+pub fn remove_file(
+&mut self,
+filename: &[u8],
+old_state: EntryState,
+size: i32,
+) -> Result<(), DirstateMapError> {
+if old_state != EntryState::Unknown && old_state != EntryState::Removed
+{
+if let Some(ref mut dirs) = self.dirs {
+dirs.delete_path(filename)?;
+}
+}
+if old_state == EntryState::Unknown {
+if let Some(ref mut all_dirs) = self.all_dirs {
+all_dirs.add_path(filename);
+}
+}
+
+if let Some(ref mut file_fold_map) = self.file_fold_map {
+

D6628: rust-parsers: switch to parse/pack_dirstate to mutate-on-loop

2019-07-24 Thread Raphaël Gomès
Alphare updated this revision to Diff 16046.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6628?vs=15897&id=16046

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

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

AFFECTED FILES
  rust/hg-core/src/dirstate.rs
  rust/hg-core/src/dirstate/dirs_multiset.rs
  rust/hg-core/src/dirstate/parsers.rs
  rust/hg-core/src/lib.rs
  rust/hg-core/src/utils.rs
  rust/hg-cpython/src/dirstate.rs
  rust/hg-cpython/src/dirstate/dirs_multiset.rs
  rust/hg-cpython/src/parsers.rs

CHANGE DETAILS

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,17 +12,18 @@
 //!
 use cpython::{
 exc, PyBytes, PyDict, PyErr, PyInt, PyModule, PyResult, PyTuple, Python,
-PythonObject, ToPyObject,
+ToPyObject,
 };
 use hg::{
-pack_dirstate, parse_dirstate, CopyVecEntry, DirstateEntry,
-DirstatePackError, DirstateParents, DirstateParseError,
+pack_dirstate, parse_dirstate, utils::copy_into_array, DirstateEntry,
+DirstatePackError, DirstateParents, DirstateParseError, PARENT_SIZE,
 };
 use std::collections::HashMap;
 
 use libc::c_char;
 
-use crate::dirstate::{decapsule_make_dirstate_tuple, extract_dirstate_vec};
+use crate::dirstate::{decapsule_make_dirstate_tuple, extract_dirstate};
+use std::time::Duration;
 
 fn parse_dirstate_wrapper(
 py: Python,
@@ -30,12 +31,15 @@
 copymap: PyDict,
 st: PyBytes,
 ) -> PyResult {
-match parse_dirstate(st.data(py)) {
-Ok((parents, dirstate_vec, copies)) => {
-for (filename, entry) in dirstate_vec {
+let mut dirstate_map = HashMap::new();
+let mut copies = HashMap::new();
+
+match parse_dirstate(&mut dirstate_map, &mut copies, st.data(py)) {
+Ok(parents) => {
+for (filename, entry) in dirstate_map {
 dmap.set_item(
 py,
-PyBytes::new(py, &filename[..]),
+PyBytes::new(py, &filename),
 decapsule_make_dirstate_tuple(py)?(
 entry.state as c_char,
 entry.mode,
@@ -44,15 +48,17 @@
 ),
 )?;
 }
-for CopyVecEntry { path, copy_path } in copies {
+for (path, copy_path) in copies {
 copymap.set_item(
 py,
-PyBytes::new(py, path),
-PyBytes::new(py, copy_path),
+PyBytes::new(py, &path),
+PyBytes::new(py, ©_path),
 )?;
 }
-Ok((PyBytes::new(py, parents.p1), PyBytes::new(py, parents.p2))
-.to_py_object(py))
+Ok(
+(PyBytes::new(py, &parents.p1), PyBytes::new(py, &parents.p2))
+.to_py_object(py),
+)
 }
 Err(e) => Err(PyErr::new::(
 py,
@@ -64,6 +70,9 @@
 "overflow in dirstate".to_string()
 }
 DirstateParseError::CorruptedEntry(e) => e,
+DirstateParseError::Damaged => {
+"dirstate appears to be damaged".to_string()
+}
 },
 )),
 }
@@ -81,7 +90,7 @@
 let p2 = pl.get_item(py, 1).extract::(py)?;
 let p2: &[u8] = p2.data(py);
 
-let dirstate_vec = extract_dirstate_vec(py, &dmap)?;
+let mut dirstate_map = extract_dirstate(py, &dmap)?;
 
 let copies: Result, Vec>, PyErr> = copymap
 .items(py)
@@ -94,13 +103,23 @@
 })
 .collect();
 
+if p1.len() != PARENT_SIZE || p2.len() != PARENT_SIZE {
+return Err(PyErr::new::(
+py,
+"expected a 20-byte hash".to_string(),
+));
+}
+
 match pack_dirstate(
-&dirstate_vec,
+&mut dirstate_map,
 &copies?,
-DirstateParents { p1, p2 },
-now.as_object().extract::(py)?,
+DirstateParents {
+p1: copy_into_array(&p1),
+p2: copy_into_array(&p2),
+},
+Duration::from_secs(now.value(py) as u64),
 ) {
-Ok((packed, new_dirstate_vec)) => {
+Ok(packed) => {
 for (
 filename,
 DirstateEntry {
@@ -109,7 +128,7 @@
 size,
 mtime,
 },
-) in new_dirstate_vec
+) in dirstate_map
 {
 dmap.set_item(
 py,
diff --git a/rust/hg-cpython/src/dirstate/dirs_multiset.rs 
b/rust/hg-cpython/src/dirstate/dirs_multiset.rs
--- a/rust/hg-cpython/src/dirstate/dirs_multiset.rs
+++ b/rust/hg-cpython/src/dirstate/dirs_multiset.rs
@@ -15,7 +15,7 @@
 ToPyObject,
 };
 
-use crate::dirstate::extract_dirstate_vec;
+use crate::dirstate::extract_dirstate;
 use hg::{DirsIte

D6631: rust-cpython: add macro for sharing references

2019-07-24 Thread Raphaël Gomès
Alphare edited the summary of this revision.
Alphare updated this revision to Diff 16050.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6631?vs=15844&id=16050

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

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

AFFECTED FILES
  rust/hg-cpython/src/dirstate/dirs_multiset.rs
  rust/hg-cpython/src/exceptions.rs
  rust/hg-cpython/src/lib.rs
  rust/hg-cpython/src/ref_sharing.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/ref_sharing.rs 
b/rust/hg-cpython/src/ref_sharing.rs
new file mode 100644
--- /dev/null
+++ b/rust/hg-cpython/src/ref_sharing.rs
@@ -0,0 +1,375 @@
+// macros.rs
+//
+// Copyright 2019 Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+//! Macros for use in the `hg-cpython` bridge library.
+
+use crate::exceptions::AlreadyBorrowed;
+use cpython::{PyResult, Python};
+use std::cell::{Cell, RefCell, RefMut};
+
+/// Manages the shared state between Python and Rust
+#[derive(Default)]
+pub struct PySharedState {
+leak_count: Cell,
+mutably_borrowed: Cell,
+}
+
+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(
+&self,
+py: Python,
+data: &RefCell,
+) -> 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) }
+}
+
+pub fn decrease_leak_count(&self, _py: Python, mutable: bool) {
+self.leak_count
+.replace(self.leak_count.get().saturating_sub(1));
+if mutable {
+self.mutably_borrowed.replace(false);
+}
+}
+}
+
+/// Holds a mutable reference to data shared between Python and Rust.
+pub struct PyRefMut<'a, T> {
+inner: RefMut<'a, T>,
+py_shared_state: &'a PySharedState,
+}
+
+impl<'a, T> PyRefMut<'a, T> {
+fn new(
+_py: Python<'a>,
+inner: RefMut<'a, T>,
+py_shared_state: &'a PySharedState,
+) -> Self {
+Self {
+inner,
+py_shared_state,
+}
+}
+}
+
+impl<'a, T> std::ops::Deref for PyRefMut<'a, T> {
+type Target = RefMut<'a, T>;
+
+fn deref(&self) -> &Self::Target {
+&self.inner
+}
+}
+impl<'a, T> std::ops::DerefMut for PyRefMut<'a, T> {
+fn deref_mut(&mut self) -> &mut Self::Target {
+&mut self.inner
+}
+}
+
+impl<'a, T> Drop for PyRefMut<'a, T> {
+fn drop(&mut self) {
+let gil = Python::acquire_gil();
+let py = gil.python();
+self.py_shared_state.decrease_leak_count(py, true);
+}
+}
+
+/// Allows a `py_class!` generated struct to share references to one of its
+/// data members with Python.
+///
+/// # Warning
+///
+/// The targeted `py_class!` needs to have the
+/// `data py_shared_state: PySharedState;` data attribute to compile.
+/// A better, more complicated macro is needed to automatically insert it,
+/// but this one is not yet really battle tested (what happens when
+/// multiple references are needed?). See the example below.
+///
+/// TODO allow

D6629: rust-dirstate: use EntryState enum instead of literals

2019-07-24 Thread Raphaël Gomès
Alphare updated this revision to Diff 16047.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6629?vs=15898&id=16047

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

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

AFFECTED FILES
  rust/hg-core/src/dirstate.rs
  rust/hg-core/src/dirstate/dirs_multiset.rs
  rust/hg-core/src/dirstate/parsers.rs
  rust/hg-core/src/lib.rs
  rust/hg-cpython/src/dirstate.rs
  rust/hg-cpython/src/dirstate/dirs_multiset.rs
  rust/hg-cpython/src/parsers.rs

CHANGE DETAILS

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
@@ -37,11 +37,17 @@
 match parse_dirstate(&mut dirstate_map, &mut copies, st.data(py)) {
 Ok(parents) => {
 for (filename, entry) in dirstate_map {
+// Explicitly go through u8 first, then cast to
+// platform-specific `c_char` because Into has a specific
+// implementation while `as c_char` would just do a naive enum
+// cast.
+let state: u8 = entry.state.into();
+
 dmap.set_item(
 py,
 PyBytes::new(py, &filename),
 decapsule_make_dirstate_tuple(py)?(
-entry.state as c_char,
+state as c_char,
 entry.mode,
 entry.size,
 entry.mtime,
@@ -130,6 +136,11 @@
 },
 ) in dirstate_map
 {
+// Explicitly go through u8 first, then cast to
+// platform-specific `c_char` because Into has a specific
+// implementation while `as c_char` would just do a naive enum
+// cast.
+let state: u8 = state.into();
 dmap.set_item(
 py,
 PyBytes::new(py, &filename[..]),
diff --git a/rust/hg-cpython/src/dirstate/dirs_multiset.rs 
b/rust/hg-cpython/src/dirstate/dirs_multiset.rs
--- a/rust/hg-cpython/src/dirstate/dirs_multiset.rs
+++ b/rust/hg-cpython/src/dirstate/dirs_multiset.rs
@@ -16,7 +16,11 @@
 };
 
 use crate::dirstate::extract_dirstate;
-use hg::{DirsIterable, DirsMultiset, DirstateMapError};
+use hg::{
+DirsIterable, DirsMultiset, DirstateMapError, DirstateParseError,
+EntryState,
+};
+use std::convert::TryInto;
 
 py_class!(pub class Dirs |py| {
 data dirs_map: RefCell;
@@ -28,9 +32,15 @@
 map: PyObject,
 skip: Option = None
 ) -> PyResult {
-let mut skip_state: Option = None;
+let mut skip_state: Option = None;
 if let Some(skip) = skip {
-skip_state = Some(skip.extract::(py)?.data(py)[0] as i8);
+skip_state = Some(
+skip.extract::(py)?.data(py)[0]
+.try_into()
+.map_err(|e: DirstateParseError| {
+PyErr::new::(py, e.to_string())
+})?,
+);
 }
 let inner = if let Ok(map) = map.cast_as::(py) {
 let dirstate = extract_dirstate(py, &map)?;
diff --git a/rust/hg-cpython/src/dirstate.rs b/rust/hg-cpython/src/dirstate.rs
--- a/rust/hg-cpython/src/dirstate.rs
+++ b/rust/hg-cpython/src/dirstate.rs
@@ -12,14 +12,16 @@
 mod dirs_multiset;
 use crate::dirstate::dirs_multiset::Dirs;
 use cpython::{
-PyBytes, PyDict, PyErr, PyModule, PyObject, PyResult, PySequence, Python,
+exc, PyBytes, PyDict, PyErr, PyModule, PyObject, PyResult, PySequence,
+Python,
 };
-use hg::{DirstateEntry, StateMap};
+use hg::{DirstateEntry, DirstateParseError, EntryState, StateMap};
 use libc::{c_char, c_int};
 #[cfg(feature = "python27")]
 use python27_sys::PyCapsule_Import;
 #[cfg(feature = "python3")]
 use python3_sys::PyCapsule_Import;
+use std::convert::TryFrom;
 use std::ffi::CStr;
 use std::mem::transmute;
 
@@ -60,7 +62,11 @@
 .map(|(filename, stats)| {
 let stats = stats.extract::(py)?;
 let state = stats.get_item(py, 0)?.extract::(py)?;
-let state = state.data(py)[0] as i8;
+let state = EntryState::try_from(state.data(py)[0]).map_err(
+|e: DirstateParseError| {
+PyErr::new::(py, e.to_string())
+},
+)?;
 let mode = stats.get_item(py, 1)?.extract(py)?;
 let size = stats.get_item(py, 2)?.extract(py)?;
 let mtime = stats.get_item(py, 3)?.extract(py)?;
diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs
--- a/rust/hg-core/src/lib.rs
+++ b/rust/hg-core/src/lib.rs
@@ -11,7 +11,8 @@
 pub use dirstate::{
 dirs_multiset::DirsMultiset,
 parsers::{pack_dirstate, parse_dirstate, PARENT_SIZE},
-CopyMap, DirsIterable, DirstateEntry, DirstateParents, StateMap,
+CopyMap, DirsIterable, Dirst

D6630: rust-docstrings: add missing module docstrings

2019-07-24 Thread Raphaël Gomès
Alphare updated this revision to Diff 16049.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6630?vs=15893&id=16049

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

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

AFFECTED FILES
  rust/hg-core/src/filepatterns.rs
  rust/hg-core/src/utils.rs
  rust/hg-core/src/utils/files.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/utils/files.rs b/rust/hg-core/src/utils/files.rs
--- a/rust/hg-core/src/utils/files.rs
+++ b/rust/hg-core/src/utils/files.rs
@@ -1,3 +1,14 @@
+// files.rs
+//
+// Copyright 2019
+// Raphaël Gomès ,
+// Yuya Nishihara 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+//! Functions for fiddling with files.
+
 use std::iter::FusedIterator;
 use std::path::Path;
 
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
@@ -1,3 +1,12 @@
+// utils module
+//
+// Copyright 2019 Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+//! Contains useful functions, traits, structs, etc. for use in core.
+
 pub mod files;
 
 use std::convert::AsMut;
diff --git a/rust/hg-core/src/filepatterns.rs b/rust/hg-core/src/filepatterns.rs
--- a/rust/hg-core/src/filepatterns.rs
+++ b/rust/hg-core/src/filepatterns.rs
@@ -1,3 +1,12 @@
+// filepatterns.rs
+//
+// Copyright 2019 Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+//! Handling of Mercurial-specific patterns.
+
 use crate::{
 utils::{files::get_path_from_bytes, SliceExt},
 LineNumber, PatternError, PatternFileError,



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


D6690: rust-dirstate: improve API of `DirsMultiset`

2019-07-24 Thread Raphaël Gomès
Alphare created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  - Use opaque `Iterator` type instead of implementation-specific one from 
`HashMap`
  - Make `DirsMultiset` behave like a set both in Rust and from Python

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  rust/hg-core/src/dirstate/dirs_multiset.rs
  rust/hg-cpython/src/dirstate/dirs_multiset.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/dirstate/dirs_multiset.rs 
b/rust/hg-cpython/src/dirstate/dirs_multiset.rs
--- a/rust/hg-cpython/src/dirstate/dirs_multiset.rs
+++ b/rust/hg-cpython/src/dirstate/dirs_multiset.rs
@@ -12,7 +12,7 @@
 
 use cpython::{
 exc, ObjectProtocol, PyBytes, PyDict, PyErr, PyObject, PyResult,
-ToPyObject,
+PythonObject, ToPyObject,
 };
 
 use crate::dirstate::extract_dirstate;
@@ -93,26 +93,21 @@
 // of having it work to continue working on the rest of the module
 // hopefully bypassing Python entirely pretty soon.
 def __iter__(&self) -> PyResult {
-let dict = PyDict::new(py);
-
-for (key, value) in self.dirs_map(py).borrow().iter() {
-dict.set_item(
-py,
-PyBytes::new(py, &key[..]),
-value.to_py_object(py),
-)?;
-}
-
-let locals = PyDict::new(py);
-locals.set_item(py, "obj", dict)?;
-
-py.eval("iter(obj)", None, Some(&locals))
+let dirs = self.dirs_map(py).borrow();
+let dirs: Vec<_> = dirs
+.iter()
+.map(|d| PyBytes::new(py, d))
+.collect();
+dirs.to_py_object(py)
+.into_object()
+.iter(py)
+.map(|o| o.into_object())
 }
 
 def __contains__(&self, item: PyObject) -> PyResult {
 Ok(self
 .dirs_map(py)
 .borrow()
-.contains_key(item.extract::(py)?.data(py).as_ref()))
+.contains(item.extract::(py)?.data(py).as_ref()))
 }
 });
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
@@ -12,7 +12,7 @@
 dirstate::EntryState, utils::files, DirsIterable, DirstateEntry,
 DirstateMapError,
 };
-use std::collections::hash_map::{Entry, Iter};
+use std::collections::hash_map::Entry;
 use std::collections::HashMap;
 
 #[derive(PartialEq, Debug)]
@@ -98,12 +98,12 @@
 Ok(())
 }
 
-pub fn contains_key(&self, key: &[u8]) -> bool {
+pub fn contains(&self, key: &[u8]) -> bool {
 self.inner.contains_key(key)
 }
 
-pub fn iter(&self) -> Iter, u32> {
-self.inner.iter()
+pub fn iter(&self) -> impl Iterator> {
+self.inner.keys()
 }
 
 pub fn len(&self) -> usize {



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


D6627: rust-parsers: move parser bindings to their own file and Python module

2019-07-24 Thread Raphaël Gomès
Alphare updated this revision to Diff 16045.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6627?vs=15840&id=16045

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

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

AFFECTED FILES
  mercurial/dirstate.py
  rust/hg-cpython/src/dirstate.rs
  rust/hg-cpython/src/lib.rs
  rust/hg-cpython/src/parsers.rs
  tests/fakedirstatewritetime.py

CHANGE DETAILS

diff --git a/tests/fakedirstatewritetime.py b/tests/fakedirstatewritetime.py
--- a/tests/fakedirstatewritetime.py
+++ b/tests/fakedirstatewritetime.py
@@ -30,6 +30,7 @@
 )
 
 parsers = policy.importmod(r'parsers')
+rustmod = policy.importrust(r'parsers')
 
 def pack_dirstate(fakenow, orig, dmap, copymap, pl, now):
 # execute what original parsers.pack_dirstate should do actually
@@ -57,16 +58,21 @@
 # 'fakenow' value and 'touch -t mmddHHMM' argument easy
 fakenow = dateutil.parsedate(fakenow, [b'%Y%m%d%H%M'])[0]
 
-if rustext is not None:
-orig_module = rustext.dirstate
-orig_pack_dirstate = rustext.dirstate.pack_dirstate
-else:
-orig_module = parsers
-orig_pack_dirstate = parsers.pack_dirstate
+if rustmod is not None:
+# The Rust implementation does not use public parse/pack dirstate
+# to prevent conversion round-trips
+orig_dirstatemap_write = dirstate.dirstatemap.write
+wrapper = lambda self, st, now: orig_dirstatemap_write(self,
+   st,
+   fakenow)
+dirstate.dirstatemap.write = wrapper
 
 orig_dirstate_getfsnow = dirstate._getfsnow
 wrapper = lambda *args: pack_dirstate(fakenow, orig_pack_dirstate, *args)
 
+orig_module = parsers
+orig_pack_dirstate = parsers.pack_dirstate
+
 orig_module.pack_dirstate = wrapper
 dirstate._getfsnow = lambda *args: fakenow
 try:
@@ -74,6 +80,8 @@
 finally:
 orig_module.pack_dirstate = orig_pack_dirstate
 dirstate._getfsnow = orig_dirstate_getfsnow
+if rustmod is not None:
+dirstate.dirstatemap.write = orig_dirstatemap_write
 
 def _poststatusfixup(orig, workingctx, status, fixup):
 ui = workingctx.repo().ui
diff --git a/rust/hg-cpython/src/parsers.rs b/rust/hg-cpython/src/parsers.rs
new file mode 100644
--- /dev/null
+++ b/rust/hg-cpython/src/parsers.rs
@@ -0,0 +1,177 @@
+// parsers.rs
+//
+// Copyright 2019 Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+//! Bindings for the `hg::dirstate::parsers` module provided by the
+//! `hg-core` package.
+//!
+//! From Python, this will be seen as `mercurial.rustext.parsers`
+//!
+use cpython::{
+exc, PyBytes, PyDict, PyErr, PyInt, PyModule, PyResult, PyTuple, Python,
+PythonObject, ToPyObject,
+};
+use hg::{
+pack_dirstate, parse_dirstate, CopyVecEntry, DirstateEntry,
+DirstatePackError, DirstateParents, DirstateParseError,
+};
+use std::collections::HashMap;
+
+use libc::c_char;
+
+use crate::dirstate::{decapsule_make_dirstate_tuple, extract_dirstate_vec};
+
+fn parse_dirstate_wrapper(
+py: Python,
+dmap: PyDict,
+copymap: PyDict,
+st: PyBytes,
+) -> PyResult {
+match parse_dirstate(st.data(py)) {
+Ok((parents, dirstate_vec, copies)) => {
+for (filename, entry) in dirstate_vec {
+dmap.set_item(
+py,
+PyBytes::new(py, &filename[..]),
+decapsule_make_dirstate_tuple(py)?(
+entry.state as c_char,
+entry.mode,
+entry.size,
+entry.mtime,
+),
+)?;
+}
+for CopyVecEntry { path, copy_path } in copies {
+copymap.set_item(
+py,
+PyBytes::new(py, path),
+PyBytes::new(py, copy_path),
+)?;
+}
+Ok((PyBytes::new(py, parents.p1), PyBytes::new(py, parents.p2))
+.to_py_object(py))
+}
+Err(e) => Err(PyErr::new::(
+py,
+match e {
+DirstateParseError::TooLittleData => {
+"too little data for parents".to_string()
+}
+DirstateParseError::Overflow => {
+"overflow in dirstate".to_string()
+}
+DirstateParseError::CorruptedEntry(e) => e,
+},
+)),
+}
+}
+
+fn pack_dirstate_wrapper(
+py: Python,
+dmap: PyDict,
+copymap: PyDict,
+pl: PyTuple,
+now: PyInt,
+) -> PyResult {
+let p1 = pl.get_item(py, 0).extract::(py)?;
+let p1: &[u8] = p1.data(py);
+let p2 = pl.get_item(py, 1).e

D6626: rust-dirstate: create dirstate submodule in hg-cpython

2019-07-24 Thread Raphaël Gomès
Alphare updated this revision to Diff 16044.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6626?vs=15839&id=16044

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

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

AFFECTED FILES
  rust/hg-cpython/src/dirstate.rs
  rust/hg-cpython/src/dirstate/dirs_multiset.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/dirstate/dirs_multiset.rs 
b/rust/hg-cpython/src/dirstate/dirs_multiset.rs
new file mode 100644
--- /dev/null
+++ b/rust/hg-cpython/src/dirstate/dirs_multiset.rs
@@ -0,0 +1,110 @@
+// dirs_multiset.rs
+//
+// Copyright 2019 Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+//! Bindings for the `hg::dirstate::dirs_multiset` file provided by the
+//! `hg-core` package.
+
+use std::cell::RefCell;
+
+use cpython::{
+exc, ObjectProtocol, PyBytes, PyDict, PyErr, PyObject, PyResult,
+ToPyObject,
+};
+
+use crate::dirstate::extract_dirstate_vec;
+use hg::{DirsIterable, DirsMultiset, DirstateMapError};
+
+py_class!(pub class Dirs |py| {
+data dirs_map: RefCell;
+
+// `map` is either a `dict` or a flat iterator (usually a `set`, sometimes
+// a `list`)
+def __new__(
+_cls,
+map: PyObject,
+skip: Option = None
+) -> PyResult {
+let mut skip_state: Option = None;
+if let Some(skip) = skip {
+skip_state = Some(skip.extract::(py)?.data(py)[0] as i8);
+}
+let dirs_map;
+
+if let Ok(map) = map.cast_as::(py) {
+let dirstate_vec = extract_dirstate_vec(py, &map)?;
+dirs_map = DirsMultiset::new(
+DirsIterable::Dirstate(dirstate_vec),
+skip_state,
+)
+} else {
+let map: Result>, PyErr> = map
+.iter(py)?
+.map(|o| Ok(o?.extract::(py)?.data(py).to_owned()))
+.collect();
+dirs_map = DirsMultiset::new(
+DirsIterable::Manifest(map?),
+skip_state,
+)
+}
+
+Self::create_instance(py, RefCell::new(dirs_map))
+}
+
+def addpath(&self, path: PyObject) -> PyResult {
+self.dirs_map(py).borrow_mut().add_path(
+path.extract::(py)?.data(py),
+);
+Ok(py.None())
+}
+
+def delpath(&self, path: PyObject) -> PyResult {
+self.dirs_map(py).borrow_mut().delete_path(
+path.extract::(py)?.data(py),
+)
+.and(Ok(py.None()))
+.or_else(|e| {
+match e {
+DirstateMapError::PathNotFound(_p) => {
+Err(PyErr::new::(
+py,
+"expected a value, found none".to_string(),
+))
+}
+DirstateMapError::EmptyPath => {
+Ok(py.None())
+}
+}
+})
+}
+
+// This is really inefficient on top of being ugly, but it's an easy way
+// of having it work to continue working on the rest of the module
+// hopefully bypassing Python entirely pretty soon.
+def __iter__(&self) -> PyResult {
+let dict = PyDict::new(py);
+
+for (key, value) in self.dirs_map(py).borrow().iter() {
+dict.set_item(
+py,
+PyBytes::new(py, &key[..]),
+value.to_py_object(py),
+)?;
+}
+
+let locals = PyDict::new(py);
+locals.set_item(py, "obj", dict)?;
+
+py.eval("iter(obj)", None, Some(&locals))
+}
+
+def __contains__(&self, item: PyObject) -> PyResult {
+Ok(self
+.dirs_map(py)
+.borrow()
+.contains_key(item.extract::(py)?.data(py).as_ref()))
+}
+});
diff --git a/rust/hg-cpython/src/dirstate.rs b/rust/hg-cpython/src/dirstate.rs
--- a/rust/hg-cpython/src/dirstate.rs
+++ b/rust/hg-cpython/src/dirstate.rs
@@ -9,22 +9,21 @@
 //! `hg-core` package.
 //!
 //! From Python, this will be seen as `mercurial.rustext.dirstate`
-
+mod dirs_multiset;
+use crate::dirstate::dirs_multiset::Dirs;
 use cpython::{
-exc, ObjectProtocol, PyBytes, PyDict, PyErr, PyInt, PyModule, PyObject,
-PyResult, PySequence, PyTuple, Python, PythonObject, ToPyObject,
+exc, PyBytes, PyDict, PyErr, PyInt, PyModule, PyObject, PyResult,
+PySequence, PyTuple, Python, PythonObject, ToPyObject,
 };
 use hg::{
-pack_dirstate, parse_dirstate, CopyVecEntry, DirsIterable, DirsMultiset,
-DirstateEntry, DirstateMapError, DirstatePackError, DirstateParents,
-DirstateParseError, DirstateVec,
+pack_dirstate, parse_dirstate, CopyVecEntry, DirstateEntry,
+DirstatePackError, DirstateParents, DirstateParseError, DirstateVec,
 };
 use libc::{c_char, c_int};
 #

D6626: rust-dirstate: create dirstate submodule in hg-cpython

2019-07-24 Thread Raphaël Gomès
Alphare added a comment.
Alphare marked an inline comment as done.


  Most of those will be taken care of in a follow-up patch, since they're 
cosmetic, plus this change just moves code around.

REPOSITORY
  rHG Mercurial

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

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

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


D6684: unshelve: modify --continue on interactive unshelve

2019-07-24 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> shelve.py:950
>  elif continuef:
> -return unshelvecontinue(ui, repo, state, opts)
> -elif len(shelved) > 1:

Now I understand how this and the parent patches are arranged.

Why don't be have all the logic related to interactive in `unshelvecontinue`, 
including getting the name of the shelve we are processing.

Right now, we are getting name of top most shelve, however we should read the 
shelvedstate and get the name from there.

REPOSITORY
  rHG Mercurial

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

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

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


D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-24 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> pulkit wrote in shelve.py:181
> We are already in shelve code, so no need to prepend shelved to the name.
> 
> Also, we can only had `interactive` stored in the shelved state. If it's not 
> present in the state file, we can assume we were not running interactive 
> unshelve.

The above comment is not done.

I meant, we don't need _noninteractive.

REPOSITORY
  rHG Mercurial

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

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

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


D6688: unshelve: make basename as a mandatory argument for unshelvecontinue()

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


  Can you explain in commit description as why this is done?

REPOSITORY
  rHG Mercurial

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

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

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


D6686: unshelve: handle stripping changesets on interactive mode

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


  Can you add tests for this? There is no test which passes or fails because of 
this change.

REPOSITORY
  rHG Mercurial

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

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

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


D6685: unshelve: changes how date is set on interactive mode

2019-07-24 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> shelve.py:832
>  user=shelvectx.user(),
> -date=shelvectx.date())
> +date=opts.get('date'))
>  m = scmutil.matchfiles(repo, repo[snode].files())

IIUC `opts.get('date')` will be `None` here always.

REPOSITORY
  rHG Mercurial

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

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

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


D6684: unshelve: modify --continue on interactive unshelve

2019-07-24 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> test-shelve.t:1354
>C
> -  $ hg unshelve --continue -i <> y

This test change should be in the parent differential.

REPOSITORY
  rHG Mercurial

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

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

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


D6689: continue: added support for transplant

2019-07-24 Thread taapas1128 (Taapas Agrawal)
taapas1128 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This creates a seperate function `continuetransplant()`
  containing logic for resuming transplant from interrupted
  state.
  `continuetransplant()` is then registered as `continuefunc`
  for state detection API.
  
  Results are shown in tests.

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS

diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -1,8 +1,16 @@
+#testcases commandmode continueflag
   $ cat <> $HGRCPATH
   > [extensions]
   > transplant=
   > EOF
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = transplant --continue
+  > EOF
+#endif
+
   $ hg init t
   $ cd t
   $ hg transplant
@@ -424,8 +432,9 @@
   updated to "e8643552fde5: foobar"
   1 other heads for branch "default"
   $ rm added
-  $ hg transplant --continue
-  abort: no transplant to continue
+  $ hg continue
+  abort: no transplant to continue (continueflag !)
+  abort: no operation in progress (no-continueflag !)
   [255]
   $ hg transplant 1
   applying 46ae92138f3c
@@ -492,7 +501,7 @@
   # To abort:   hg update
   
   $ echo fixed > baz
-  $ hg transplant --continue
+  $ hg continue
   9d6d6b5a8275 transplanted as d80c49962290
   applying 1dab759070cf
   1dab759070cf transplanted to aa0ffe6bd5ae
@@ -881,7 +890,7 @@
   [255]
   $ hg status
   ? b.rej
-  $ hg transplant --continue
+  $ hg continue
   645035761929 skipped due to empty diff
 
   $ cd ..
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -734,6 +734,15 @@
 if cleanupfn:
 cleanupfn()
 
+def continuetransplant(ui, repo):
+"""logic to resume an interrupted transplant using
+'hg continue'"""
+with repo.wlock():
+opts = {}
+tp = transplanter(ui, repo, opts)
+tp.resume(repo, repo, opts)
+return
+
 revsetpredicate = registrar.revsetpredicate()
 
 @revsetpredicate('transplanted([set])')
@@ -760,6 +769,7 @@
 def extsetup(ui):
 statemod.addunfinished (
 'transplant', fname='transplant/journal', clearable=True,
+continuefunc=continuetransplant,
 statushint=_('To continue:hg transplant --continue\n'
  'To abort:   hg update'),
 cmdhint=_("use 'hg transplant --continue' or 'hg update' to abort")



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


D6683: unshelve: unify logic around creating an unshelve changeset

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh added a comment.


  In D6683#97731 , @pulkit wrote:
  
  > This patch does following things:
  >
  > 1. unify logic around creating unshelvectx
  > 2. changes how date is set in iteractive mode
  > 3. handles stripping in interavtive mode
  > 4. compute a matcher only if it's required
  > 5. and a change around making basename madatory argument
  >
  > Can we have them in separate patches?
  
  Done.

REPOSITORY
  rHG Mercurial

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

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

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


D6688: unshelve: make basename as a mandatory argument for unshelvecontinue()

2019-07-24 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/D6688

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
@@ -699,7 +699,7 @@
 if shfile.exists():
 shfile.movetobackup()
 cleanupoldbackups(repo)
-def unshelvecontinue(ui, repo, state, opts, basename=None):
+def unshelvecontinue(ui, repo, state, opts, basename):
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
 # parent, second is the temporary "fake" commit we're unshelving.



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


D6687: unshelve: create a matcher only if required on creating unshelve ctx

2019-07-24 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/D6687

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
@@ -830,8 +830,8 @@
 extra=shelvectx.extra(),
 user=shelvectx.user(),
 date=opts.get('date'))
-m = scmutil.matchfiles(repo, repo[snode].files())
 if snode:
+m = scmutil.matchfiles(repo, repo[snode].files())
 _shelvecreatedcommit(repo, snode, basename, m)
 
 return newnode, bool(snode)



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


D6686: unshelve: handle stripping changesets on interactive mode

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

REVISION SUMMARY
  On interactive mode, changesets on `nodestoremove` should be
  stripped regardless of the shelve is partial or not. This patch
  modifies `unshelvecontinue()` to do that.

REPOSITORY
  rHG Mercurial

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

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
@@ -747,10 +747,10 @@
 mergefiles(ui, repo, state.wctx, shelvectx)
 restorebranch(ui, repo, state.branchtorestore)
 
+if not phases.supportinternal(repo):
+repair.strip(ui, repo, state.nodestoremove, backup=False,
+ topic='shelve')
 if not ispartialunshelve:
-if not phases.supportinternal(repo):
-repair.strip(ui, repo, state.nodestoremove, backup=False,
-topic='shelve')
 shelvedstate.clear(repo)
 unshelvecleanup(ui, repo, state.name, opts)
 _restoreactivebookmark(repo, state.activebookmark)



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


D6685: unshelve: changes how date is set on interactive mode

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

REVISION SUMMARY
  On an interactive unshelve, the remaining changes are shelved again
  for later. This patch modifies the date of remaining shelved change
  to the time of interactive shelve.

REPOSITORY
  rHG Mercurial

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

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
@@ -829,7 +829,7 @@
 snode = repo.commit(text=shelvectx.description(),
 extra=shelvectx.extra(),
 user=shelvectx.user(),
-date=shelvectx.date())
+date=opts.get('date'))
 m = scmutil.matchfiles(repo, repo[snode].files())
 if snode:
 _shelvecreatedcommit(repo, snode, basename, m)



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


D6683: unshelve: unify logic around creating an unshelve changeset

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh edited the summary of this revision.
navaneeth.suresh retitled this revision from "unshelve: fixes on interactive 
mode" to "unshelve: unify logic around creating an unshelve changeset".
navaneeth.suresh updated this revision to Diff 16038.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6683?vs=16025&id=16038

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

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

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
@@ -726,15 +726,8 @@
 with repo.ui.configoverride(overrides, 'unshelve'):
 with repo.dirstate.parentchange():
 repo.setparents(state.parents[0], nodemod.nullid)
-if not interactive:
-ispartialunshelve = False
-newnode = repo.commit(text=shelvectx.description(),
-extra=shelvectx.extra(),
-user=shelvectx.user(),
-date=shelvectx.date())
-else:
-newnode, ispartialunshelve = _dounshelveinteractive(ui,
-repo, shelvectx, basename, opts)
+newnode, ispartialunshelve = _createunshelvectx(ui,
+repo, shelvectx, basename, interactive, opts)
 
 if newnode is None:
 # If it ended up being a no-op commit, then the normal
@@ -809,14 +802,25 @@
 
 return repo, shelvectx
 
-def _dounshelveinteractive(ui, repo, shelvectx, basename, opts):
-"""The user might want to unshelve certain changes only from the stored
-shelve. So, we would create two commits. One with requested changes to
-unshelve at that time and the latter is shelved for future.
+def _createunshelvectx(ui, repo, shelvectx, basename, interactive, opts):
+"""Creates a commit ctx to unshelve interactively or non-interactively.
+The user might want to unshelve certain changes only from the stored
+shelve in interactive. So, we would create two commits. One with requested
+changes to unshelve at that time and the latter is shelved for future.
+
+Here, we return both the newnode which is created interactively and a
+bool to know whether the shelve is partly done or completely done.
 """
 opts['message'] = shelvectx.description()
 opts['interactive-unshelve'] = True
 pats = []
+if not interactive:
+newnode = repo.commit(text=shelvectx.description(),
+  extra=shelvectx.extra(),
+  user=shelvectx.user(),
+  date=shelvectx.date())
+return newnode, False
+
 commitfunc = getcommitfunc(shelvectx.extra(), interactive=True,
editor=True)
 newnode = cmdutil.dorecord(ui, repo, commitfunc, None, False,
@@ -867,15 +871,8 @@
 
 with repo.dirstate.parentchange():
 repo.setparents(tmpwctx.node(), nodemod.nullid)
-if not interactive:
-ispartialunshelve = False
-newnode = repo.commit(text=shelvectx.description(),
-  extra=shelvectx.extra(),
-  user=shelvectx.user(),
-  date=shelvectx.date())
-else:
-newnode, ispartialunshelve = _dounshelveinteractive(ui, repo,
-shelvectx, basename, opts)
+newnode, ispartialunshelve = _createunshelvectx(ui, repo,
+shelvectx, basename, interactive, 
opts)
 
 if newnode is None:
 # If it ended up being a no-op commit, then the normal



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


[Bug 6175] New: `obslog --patch` shows incorrect spacing when `diff.word-diff=True` is set

2019-07-24 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=6175

Bug ID: 6175
   Summary: `obslog --patch` shows incorrect spacing when
`diff.word-diff=True` is set
   Product: Mercurial
   Version: default branch
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: feature
  Priority: wish
 Component: evolution
  Assignee: bugzi...@mercurial-scm.org
  Reporter: 7895pul...@gmail.com
CC: mercurial-devel@mercurial-scm.org,
pierre-yves.da...@ens-lyon.org

The related part of code is
https://www.mercurial-scm.org/repo/evolve/file/tip/hgext3rd/evolve/obshistory.py#l612.

That `fm.plain('')` call is to align each line of diff output. However in
case of worddiff, chunks can be part of lines and not complete lines which
leads to addition of 4 spaces in between of lines.

For ex:

```
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6213,9 +6213,11 @@ def unshelve(ui, repo, *shelved, **opts)

Selected changes can be unshelved with ``--interactive`` flag.
The working directory is updated with the selected changes, and
-   only the unselected changes remain shelved. Note that the
user will
-   get into conflicts whenever the
shelved change has conflicts with
-   the working directory regardless of the
changes requested by the user.
+   only the unselected changes remain shelved.
+   Note: The whole shelve is  
  applied to working directory first before
+   running interactively. So, this will bring up all the conflicts
between
+   working directory and the shelve, irrespective of which
changes will be
+   unshelved.
 """
 with repo.wlock():
 return shelvemod.dounshelve(ui, repo, *shelved, **opts)
```

Works fine when running with `--config diff.word-diff=0`

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


D6684: unshelve: modify --continue on interactive unshelve

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

REVISION SUMMARY
  `shelvedstate` should store info about interactive mode after D6679 
.
  This patch modifies the test and behavior of `hg unshelve --continue`
  after an unshelve on interactive mode.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/shelve.py
  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
@@ -1351,13 +1351,12 @@
   A
   B
   C
-  $ hg unshelve --continue -i < y
   > y
   > y
   > y
   > EOF
-  unshelving change 'default-01'
   diff --git a/bar1 b/bar1
   1 hunks, 1 lines changed
   examine changes to 'bar1'?
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -934,10 +934,21 @@
 if opts.get("name"):
 shelved.append(opts["name"])
 
-if abortf or continuef and not interactive:
+if len(shelved) > 1:
+raise error.Abort(_('can only unshelve one change at a time'))
+elif not shelved:
+shelved = listshelves(repo)
+if not shelved:
+raise error.Abort(_('no shelved changes to apply!'))
+basename = util.split(shelved[0][1])[1]
+if not (abortf or continuef):
+ui.status(_("unshelving change '%s'\n") % basename)
+elif shelved:
+basename = shelved[0]
+if abortf or continuef:
 if abortf and continuef:
 raise error.Abort(_('cannot use both abort and continue'))
-if shelved:
+if opts.get("name"):
 raise error.Abort(_('cannot combine abort/continue with '
'naming a shelved change'))
 if abortf and opts.get('tool', False):
@@ -947,20 +958,7 @@
 if abortf:
 return unshelveabort(ui, repo, state)
 elif continuef:
-return unshelvecontinue(ui, repo, state, opts)
-elif len(shelved) > 1:
-raise error.Abort(_('can only unshelve one change at a time'))
-elif not shelved:
-shelved = listshelves(repo)
-if not shelved:
-raise error.Abort(_('no shelved changes to apply!'))
-basename = util.split(shelved[0][1])[1]
-ui.status(_("unshelving change '%s'\n") % basename)
-elif shelved:
-basename = shelved[0]
-if continuef and interactive:
-state = _loadshelvedstate(ui, repo, opts)
-return unshelvecontinue(ui, repo, state, opts, basename)
+return unshelvecontinue(ui, repo, state, opts, basename)
 
 if not shelvedfile(repo, basename, patchextension).exists():
 raise error.Abort(_("shelved change '%s' not found") % basename)



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


D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh added inline comments.
navaneeth.suresh marked 3 inline comments as done.

INLINE COMMENTS

> pulkit wrote in shelve.py:938
> This change is unrelated to storing info about interactive in shelvedstate. 
> Can you decouple this into a separate patch?

Doing that right away!

REPOSITORY
  rHG Mercurial

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

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

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


D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 16036.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6679?vs=16021&id=16036

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

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

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
@@ -177,6 +177,8 @@
 _nokeep = 'nokeep'
 # colon is essential to differentiate from a real bookmark name
 _noactivebook = ':no-active-bookmark'
+_interactive = 'interactive'
+_noninteractive = 'noninteractive'
 
 @classmethod
 def _verifyandtransform(cls, d):
@@ -247,6 +249,7 @@
 obj.activebookmark = ''
 if d.get('activebook', '') != cls._noactivebook:
 obj.activebookmark = d.get('activebook', '')
+obj.interactive = d.get('interactive') == cls._interactive
 except (error.RepoLookupError, KeyError) as err:
 raise error.CorruptedState(pycompat.bytestr(err))
 
@@ -254,7 +257,7 @@
 
 @classmethod
 def save(cls, repo, name, originalwctx, pendingctx, nodestoremove,
- branchtorestore, keep=False, activebook=''):
+ branchtorestore, keep=False, activebook='', interactive=False):
 info = {
 "name": name,
 "originalwctx": nodemod.hex(originalwctx.node()),
@@ -265,7 +268,9 @@
   for n in nodestoremove]),
 "branchtorestore": branchtorestore,
 "keep": cls._keep if keep else cls._nokeep,
-"activebook": activebook or cls._noactivebook
+"activebook": activebook or cls._noactivebook,
+"interactive": (cls._interactive
+if interactive else cls._noninteractive)
 }
 scmutil.simplekeyvaluefile(
 repo.vfs, cls._filename).write(info,
@@ -698,7 +703,7 @@
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
 # parent, second is the temporary "fake" commit we're unshelving.
-interactive = opts.get('interactive')
+interactive = state.interactive
 with repo.lock():
 checkparents(repo, state)
 ms = merge.mergestate.read(repo)
@@ -854,7 +859,8 @@
 nodestoremove = [repo.changelog.node(rev)
  for rev in pycompat.xrange(oldtiprev, len(repo))]
 shelvedstate.save(repo, basename, pctx, tmpwctx, nodestoremove,
-  branchtorestore, opts.get('keep'), 
activebookmark)
+  branchtorestore, opts.get('keep'), 
activebookmark,
+  interactive)
 raise error.InterventionRequired(
 _("unresolved conflicts (see 'hg resolve', then "
   "'hg unshelve --continue')"))



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


D6676: unshelve: add help text on --interactive in verbose mode

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


  In D6676#97793 , @mharbison72 
wrote:
  
  > Maybe I’m looking at something wrong, but it looks like a couple references 
to “the shelve” snuck in after the last edit in diff 16017.
  
  Ah, forgot to mention, I edited the `Note:` part in flight a bit.
  
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6213,9 +6213,11 @@ def unshelve(ui, repo, *shelved, **opts)
 
Selected changes can be unshelved with ``--interactive`` flag.
The working directory is updated with the selected changes, and
-   only the unselected changes remain shelved. Note that the 
user will
-   get into conflicts  whenever the  shelved change has conflicts 
with
-   the working directory regardless of the changes requested by 
the user.
+   only the unselected changes remain shelved.
+Note: The whole shelve is applied to working directory first 
before
+   running interactively. So, this will bring up all the conflicts 
between
+   working directory and the shelve, irrespective of which changes 
will be
+   unshelved.
 """
 with repo.wlock():
 return shelvemod.dounshelve(ui, repo, *shelved, **opts)

REPOSITORY
  rHG Mercurial

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

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

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


D6676: unshelve: add help text on --interactive in verbose mode

2019-07-24 Thread mharbison72 (Matt Harbison)
mharbison72 added a comment.


  Maybe I’m looking at something wrong, but it looks like a couple references 
to “the shelve” snuck in after the last edit in diff 16017.

REPOSITORY
  rHG Mercurial

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

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

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


D6681: debugcommands: add support for extensions adding their own debug info

2019-07-24 Thread durin42 (Augie Fackler)
Closed by commit rHG0c0478b71595: debugcommands: add support for extensions 
adding their own debug info (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/D6681?vs=16023&id=16034

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

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

AFFECTED FILES
  mercurial/debugcommands.py

CHANGE DETAILS

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1383,6 +1383,11 @@
 fm.condwrite(err, 'usernameerror', _("checking username...\n %s\n"
 " (specify a username in your configuration file)\n"), err)
 
+for name, mod in extensions.extensions():
+handler = getattr(mod, 'debuginstall', None)
+if handler is not None:
+problems += handler(ui, fm)
+
 fm.condwrite(not problems, '',
  _("no problems detected\n"))
 if not problems:



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


D6682: fsmonitor: add support for extra `hg debuginstall` data

2019-07-24 Thread durin42 (Augie Fackler)
Closed by commit rHG3358dc6e7c04: fsmonitor: add support for extra `hg 
debuginstall` data (authored by durin42).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6682?vs=16024&id=16035#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6682?vs=16024&id=16035

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

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

AFFECTED FILES
  hgext/fsmonitor/__init__.py
  tests/test-install.t

CHANGE DETAILS

diff --git a/tests/test-install.t b/tests/test-install.t
--- a/tests/test-install.t
+++ b/tests/test-install.t
@@ -153,6 +153,16 @@
   1 problems detected, please check your install!
   [1]
 
+debuginstall extension support
+  $ hg debuginstall --config extensions.fsmonitor= --config 
fsmonitor.watchman_exe=false | grep atchman
+  fsmonitor checking for watchman binary... (false)
+   watchman binary missing or broken: warning: Watchman unavailable: watchman 
exited with code 1
+Verify the json works too:
+  $ hg debuginstall --config extensions.fsmonitor= --config 
fsmonitor.watchman_exe=false -Tjson | grep atchman
+"fsmonitor-watchman": "false",
+"fsmonitor-watchman-error": "warning: Watchman unavailable: watchman 
exited with code 1",
+
+
 #if test-repo
   $ . "$TESTDIR/helpers-testrepo.sh"
 
diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py
--- a/hgext/fsmonitor/__init__.py
+++ b/hgext/fsmonitor/__init__.py
@@ -112,6 +112,7 @@
 import os
 import stat
 import sys
+import tempfile
 import weakref
 
 from mercurial.i18n import _
@@ -175,6 +176,23 @@
 # and will disable itself when encountering one of these:
 _blacklist = ['largefiles', 'eol']
 
+def debuginstall(ui, fm):
+fm.write("fsmonitor-watchman",
+ _("fsmonitor checking for watchman binary... (%s)\n"),
+   ui.configpath("fsmonitor", "watchman_exe"))
+root = tempfile.mkdtemp()
+c = watchmanclient.client(ui, root)
+err = None
+try:
+v = c.command("version")
+fm.write("fsmonitor-watchman-version",
+ _(" watchman binary version %s\n"), v["version"])
+except watchmanclient.Unavailable as e:
+err = str(e)
+fm.condwrite(err, "fsmonitor-watchman-error",
+ _(" watchman binary missing or broken: %s\n"), err)
+return 1 if err else 0
+
 def _handleunavailable(ui, state, ex):
 """Exception handler for Watchman interaction exceptions"""
 if isinstance(ex, watchmanclient.Unavailable):



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


D6680: fsmonitor: refactor watchmanclient.client to accept ui and repo path

2019-07-24 Thread durin42 (Augie Fackler)
Closed by commit rHGf3c594ddecb7: fsmonitor: refactor watchmanclient.client to 
accept ui and repo path (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/D6680?vs=16022&id=16033

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

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

AFFECTED FILES
  hgext/fsmonitor/__init__.py
  hgext/fsmonitor/watchmanclient.py

CHANGE DETAILS

diff --git a/hgext/fsmonitor/watchmanclient.py 
b/hgext/fsmonitor/watchmanclient.py
--- a/hgext/fsmonitor/watchmanclient.py
+++ b/hgext/fsmonitor/watchmanclient.py
@@ -33,12 +33,12 @@
 super(WatchmanNoRoot, self).__init__(msg)
 
 class client(object):
-def __init__(self, repo, timeout=1.0):
+def __init__(self, ui, root, timeout=1.0):
 err = None
 if not self._user:
 err = "couldn't get user"
 warn = True
-if self._user in repo.ui.configlist('fsmonitor', 'blacklistusers'):
+if self._user in ui.configlist('fsmonitor', 'blacklistusers'):
 err = 'user %s in blacklist' % self._user
 warn = False
 
@@ -47,8 +47,8 @@
 
 self._timeout = timeout
 self._watchmanclient = None
-self._root = repo.root
-self._ui = repo.ui
+self._root = root
+self._ui = ui
 self._firsttime = True
 
 def settimeout(self, timeout):
diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py
--- a/hgext/fsmonitor/__init__.py
+++ b/hgext/fsmonitor/__init__.py
@@ -780,7 +780,7 @@
 return
 
 try:
-client = watchmanclient.client(repo)
+client = watchmanclient.client(repo.ui, repo._root)
 except Exception as ex:
 _handleunavailable(ui, fsmonitorstate, ex)
 return



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


D6670: relnotes: empty to prepare for next release

2019-07-24 Thread martinvonz (Martin von Zweigbergk)
Closed by commit rHGa562df8a3e98: relnotes: empty to prepare for next release 
(authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6670?vs=16000&id=16032

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

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

AFFECTED FILES
  relnotes/next

CHANGE DETAILS

diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -1,90 +1,14 @@
 == New Features ==
 
- * New config `commands.commit.post-status` shows status after successful
- commit.
-
- * `hg root` now has templating support, including support for showing
-   where a repo share's source is. See `hg help -v root` for details.
-
- * New `--force-close-branch` flag for `hg commit` to forcibly close
-   branch from a non-head changeset.
-
- * The curses-based interface for commands like `hg commit -i` now supports
-   a range-select mechanism. Select the first line using space like before,
-   navigate to the last line, and press X (capital x) to set all items in
-   the range at once. Lowercase x has been added as a synonym for space to
-   help reinforce the mechanism, and pressing enter/return continues to be a
-   synonym for "toggle the current line and move down to the next item in
-   this section."
 
 == New Experimental Features ==
 
- * New config `experimental.log.topo` makes `hg log -G` use
-   topological sorting. This is especially useful for aliases since it
-   lets the alias accept an `-r` option while still using topological
-   sorting with or without the `-r` (unlike if you use the `sort(...,
-   topo)` revset).
-
 
 == Bug Fixes  ==
 
- * issue4292: "hg log and {files} {file_adds} {file_mods} {file_dels}
-   in template show wrong files on merged revision". See details in
-   "Backwards Compatibility Changes".
-
 
 == Backwards Compatibility Changes ==
 
- * Removed (experimental) support for log graph lines mixing
-   parent/grandparent styles. Setting
-   e.g. `experimental.graphstyle.parent = !` and
-   `experimental.graphstyle.grandparent = 3.` would use `!` for the
-   first three lines of the graph and then `.`. This is no longer
-   supported.
-
- * If `ui.origbackuppath` had been (incorrectly) configured to point
-   to a file, we will now replace that file by a directory and put
-   backups in that directory. This is similar to how we would
-   previously replace files *in* the configured directory by
-   subdirectories.
-
-* Template keyword `{file_mods}`, `{file_adds}`, and `{file_dels}`
-   have changed behavior on merge commits. They used to be relative to
-   the first parent, but they now consider both parents. `{file_adds}`
-   shows files that exists in the commit but did not exist in either
-   parent. `{file_dels}` shows files that do not exist in the commit
-   but existed in either parent. `{file_mods}` show the remaining
-   files from `{files}` that were not in the other two
-   sets.
-
 
 == Internal API Changes ==
 
- * Matchers are no longer iterable. Use `match.files()` instead.
-
- * `match.visitdir()` and `match.visitchildrenset()` now expect the
-   empty string instead of '.' to indicate the root directory.
-
- * `util.dirs()` and `util.finddirs()` now include an entry for the
-   root directory (empty string).
-
- * shelve is no longer an extension now. it will be turned on by default.
-
- * New API to manage unfinished operations: Earlier there were distinct APIs
-   which dealt with unfinished states and separate lists maintaining them
-   that are `cmdutil.afterresolvestates`, `cmdutil.unfinishedstates` and
-   `cmdutil.STATES`. Now these have been unified to a single
-   API which handles the various states and their utilities. This API
-   has been added to `state.py`. Now instead of adding to these 3 lists
-   independently a state for a new operation can be registered using
-   `addunfinished()` in `state` module.
-
- * `cmdutil.checkunfinished()` now includes detection for merge too.
-
- * merge abort has been disallowed in case an operation of higher
-   precedence is in progress to avoid cases of partial abort of
-   operations.
-
- * We used to automatically attempt to make extensions compatible with
-   Python 3 (by translating their source code while loading it). We no
-   longer do that.



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


D6676: unshelve: add help text on --interactive in verbose mode

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
Closed by commit rHG0795bbe8ed19: unshelve: add help text on --interactive in 
verbose mode (authored by navaneeth.suresh).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6676?vs=16017&id=16026#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6676?vs=16017&id=16026

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

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6210,6 +6210,14 @@
Timestamp in seconds is used to decide order of backups. More
than ``maxbackups`` backups are kept, if same timestamp
prevents from deciding exact order of them, for safety.
+
+   Selected changes can be unshelved with ``--interactive`` flag.
+   The working directory is updated with the selected changes, and
+   only the unselected changes remain shelved.
+   Note: The whole shelve is applied to working directory first before
+   running interactively. So, this will bring up all the conflicts between
+   working directory and the shelve, irrespective of which changes will be
+   unshelved.
 """
 with repo.wlock():
 return shelvemod.dounshelve(ui, repo, *shelved, **opts)



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


D6673: automation: make Windows base image name configurable

2019-07-24 Thread indygreg (Gregory Szorc)
Closed by commit rHGd80edcb0b30c: automation: make Windows base image name 
configurable (authored by indygreg).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6673?vs=16005&id=16030

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

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

AFFECTED FILES
  contrib/automation/hgautomation/aws.py
  contrib/automation/hgautomation/cli.py

CHANGE DETAILS

diff --git a/contrib/automation/hgautomation/cli.py 
b/contrib/automation/hgautomation/cli.py
--- a/contrib/automation/hgautomation/cli.py
+++ b/contrib/automation/hgautomation/cli.py
@@ -52,15 +52,16 @@
 aws.ensure_linux_dev_ami(c, distro=distro)
 
 
-def bootstrap_windows_dev(hga: HGAutomation, aws_region):
+def bootstrap_windows_dev(hga: HGAutomation, aws_region, base_image_name):
 c = hga.aws_connection(aws_region)
-image = aws.ensure_windows_dev_ami(c)
+image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
 print('Windows development AMI available as %s' % image.id)
 
 
-def build_inno(hga: HGAutomation, aws_region, arch, revision, version):
+def build_inno(hga: HGAutomation, aws_region, arch, revision, version,
+   base_image_name):
 c = hga.aws_connection(aws_region)
-image = aws.ensure_windows_dev_ami(c)
+image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
 DIST_PATH.mkdir(exist_ok=True)
 
 with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts:
@@ -74,9 +75,10 @@
  version=version)
 
 
-def build_wix(hga: HGAutomation, aws_region, arch, revision, version):
+def build_wix(hga: HGAutomation, aws_region, arch, revision, version,
+  base_image_name):
 c = hga.aws_connection(aws_region)
-image = aws.ensure_windows_dev_ami(c)
+image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
 DIST_PATH.mkdir(exist_ok=True)
 
 with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts:
@@ -89,9 +91,10 @@
 DIST_PATH, version=version)
 
 
-def build_windows_wheel(hga: HGAutomation, aws_region, arch, revision):
+def build_windows_wheel(hga: HGAutomation, aws_region, arch, revision,
+base_image_name):
 c = hga.aws_connection(aws_region)
-image = aws.ensure_windows_dev_ami(c)
+image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
 DIST_PATH.mkdir(exist_ok=True)
 
 with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts:
@@ -104,9 +107,9 @@
 
 
 def build_all_windows_packages(hga: HGAutomation, aws_region, revision,
-   version):
+   version, base_image_name):
 c = hga.aws_connection(aws_region)
-image = aws.ensure_windows_dev_ami(c)
+image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
 DIST_PATH.mkdir(exist_ok=True)
 
 with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts:
@@ -169,9 +172,9 @@
 
 
 def run_tests_windows(hga: HGAutomation, aws_region, instance_type,
-  python_version, arch, test_flags):
+  python_version, arch, test_flags, base_image_name):
 c = hga.aws_connection(aws_region)
-image = aws.ensure_windows_dev_ami(c)
+image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
 
 with aws.temporary_windows_dev_instances(c, image, instance_type,
  disable_antivirus=True) as insts:
@@ -217,6 +220,11 @@
 'bootstrap-windows-dev',
 help='Bootstrap the Windows development environment',
 )
+sp.add_argument(
+'--base-image-name',
+help='AMI name of base image',
+default=aws.WINDOWS_BASE_IMAGE_NAME,
+)
 sp.set_defaults(func=bootstrap_windows_dev)
 
 sp = subparsers.add_parser(
@@ -232,6 +240,11 @@
 '--version',
 help='Mercurial version string to use',
 )
+sp.add_argument(
+'--base-image-name',
+help='AMI name of base image',
+default=aws.WINDOWS_BASE_IMAGE_NAME,
+)
 sp.set_defaults(func=build_all_windows_packages)
 
 sp = subparsers.add_parser(
@@ -254,6 +267,11 @@
 '--version',
 help='Mercurial version string to use in installer',
 )
+sp.add_argument(
+'--base-image-name',
+help='AMI name of base image',
+default=aws.WINDOWS_BASE_IMAGE_NAME,
+)
 sp.set_defaults(func=build_inno)
 
 sp = subparsers.add_parser(
@@ -272,6 +290,11 @@
 help='Mercurial revision to build',
 default='.',
 )
+sp.add_argument(
+'--base-image-name',
+help='AMI name of base image',
+default=aws.WINDOWS_BASE_IMAGE_NAME,
+)
 sp.set_defau

D6674: contrib: install Python 3.8b2 instead of 3.8a2

2019-07-24 Thread indygreg (Gregory Szorc)
Closed by commit rHG7fae3b0bd893: contrib: install Python 3.8b2 instead of 
3.8a2 (authored by indygreg).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6674?vs=16006&id=16031

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

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

AFFECTED FILES
  contrib/install-windows-dependencies.ps1

CHANGE DETAILS

diff --git a/contrib/install-windows-dependencies.ps1 
b/contrib/install-windows-dependencies.ps1
--- a/contrib/install-windows-dependencies.ps1
+++ b/contrib/install-windows-dependencies.ps1
@@ -42,10 +42,10 @@
 $PYTHON37_x64_URL = 
"https://www.python.org/ftp/python/3.7.2/python-3.7.2-amd64.exe";
 $PYTHON37_x64_SHA256 = 
"0FE2A696F5A3E481FED795EF6896ED99157BCEF273EF3C4A96F2905CBDB3AA13"
 
-$PYTHON38_x86_URL = 
"https://www.python.org/ftp/python/3.8.0/python-3.8.0a2.exe";
-$PYTHON38_x86_SHA256 = 
"013A7DDD317679FE51223DE627688CFCB2F0F1128FD25A987F846AEB476D3FEF"
-$PYTHON38_x64_URL = 
"https://www.python.org/ftp/python/3.8.0/python-3.8.0a2-amd64.exe";
-$PYTHON38_X64_SHA256 = 
"560BC6D1A76BCD6D544AC650709F3892956890753CDCF9CE67E3D7302D76FB41"
+$PYTHON38_x86_URL = 
"https://www.python.org/ftp/python/3.8.0/python-3.8.0b2.exe";
+$PYTHON38_x86_SHA256 = 
"efa37ff7a239332bd5cf8b6e6ff15e3f183da942fd8c8d3e4b6bd11fa5e07e23"
+$PYTHON38_x64_URL = 
"https://www.python.org/ftp/python/3.8.0/python-3.8.0b2-amd64.exe";
+$PYTHON38_x64_SHA256 = 
"4e151f7dfa3605e6f400a3b01acfc2517468d71afb1e20f9299149356b79d8e9"
 
 # PIP 19.0.3.
 $PIP_URL = 
"https://github.com/pypa/get-pip/raw/fee32c376da1ff6496a798986d7939cd51e1644f/get-pip.py";



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


D6672: automation: extract strings to constants

2019-07-24 Thread indygreg (Gregory Szorc)
Closed by commit rHG8804aa6c07a0: automation: extract strings to constants 
(authored by indygreg).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6672?vs=16004&id=16029

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

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

AFFECTED FILES
  contrib/automation/hgautomation/aws.py

CHANGE DETAILS

diff --git a/contrib/automation/hgautomation/aws.py 
b/contrib/automation/hgautomation/aws.py
--- a/contrib/automation/hgautomation/aws.py
+++ b/contrib/automation/hgautomation/aws.py
@@ -52,10 +52,14 @@
 }
 
 
+AMAZON_ACCOUNT_ID = '801119661308'
 DEBIAN_ACCOUNT_ID = '379101102735'
 UBUNTU_ACCOUNT_ID = '099720109477'
 
 
+WINDOWS_BASE_IMAGE_NAME = 'Windows_Server-2019-English-Full-Base-2019.07.12'
+
+
 KEY_PAIRS = {
 'automation',
 }
@@ -1046,9 +1050,7 @@
 
 name = '%s%s' % (prefix, 'windows-dev')
 
-image = find_image(ec2resource,
-   '801119661308',
-   'Windows_Server-2019-English-Full-Base-2019.07.12')
+image = find_image(ec2resource, AMAZON_ACCOUNT_ID, WINDOWS_BASE_IMAGE_NAME)
 
 config = {
 'BlockDeviceMappings': [



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


D6675: copies: fix crash on in changeset-centric tracing from commit to itself

2019-07-24 Thread martinvonz (Martin von Zweigbergk)
Closed by commit rHG8c5a36805d5d: copies: fix crash on in changeset-centric 
tracing from commit to itself (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6675?vs=16007&id=16027

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

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

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

CHANGE DETAILS

diff --git a/tests/test-copies.t b/tests/test-copies.t
--- a/tests/test-copies.t
+++ b/tests/test-copies.t
@@ -58,6 +58,17 @@
   x -> y
   $ hg debugpathcopies 1 0 y
 
+Copies not including commit changes
+  $ newrepo
+  $ echo x > x
+  $ hg ci -Aqm 'add x'
+  $ hg mv x y
+  $ hg debugpathcopies . .
+  $ hg debugpathcopies . 'wdir()'
+  x -> y
+  $ hg debugpathcopies 'wdir()' .
+  y -> x
+
 Copy a file onto another file
   $ newrepo
   $ echo x > x
diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -246,7 +246,7 @@
 return cm
 
 def _changesetforwardcopies(a, b, match):
-if a.rev() == node.nullrev:
+if a.rev() in (node.nullrev, b.rev()):
 return {}
 
 repo = a.repo()



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


D6671: automation: use newer Windows base image

2019-07-24 Thread indygreg (Gregory Szorc)
Closed by commit rHG92a99822e731: automation: use newer Windows base image 
(authored by indygreg).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6671?vs=16003&id=16028

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

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

AFFECTED FILES
  contrib/automation/hgautomation/aws.py

CHANGE DETAILS

diff --git a/contrib/automation/hgautomation/aws.py 
b/contrib/automation/hgautomation/aws.py
--- a/contrib/automation/hgautomation/aws.py
+++ b/contrib/automation/hgautomation/aws.py
@@ -1048,7 +1048,7 @@
 
 image = find_image(ec2resource,
'801119661308',
-   'Windows_Server-2019-English-Full-Base-2019.02.13')
+   'Windows_Server-2019-English-Full-Base-2019.07.12')
 
 config = {
 'BlockDeviceMappings': [



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


D6682: fsmonitor: add support for extra `hg debuginstall` data

2019-07-24 Thread pulkit (Pulkit Goyal)
This revision is now accepted and ready to land.
pulkit added inline comments.
pulkit accepted this revision.

INLINE COMMENTS

> __init__.py:182
> +   ui.configpath("fsmonitor", "watchman_exe"))
> +import tempfile
> +root = tempfile.mkdtemp()

Moved this import to top level in flight.

> __init__.py:191
> +except watchmanclient.Unavailable as e:
> +err = str(e)
> +fm.condwrite(err, "fsmonitor-watchman-error",

This might make py3 unhappy.

REPOSITORY
  rHG Mercurial

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

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

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


D6681: debugcommands: add support for extensions adding their own debug info

2019-07-24 Thread pulkit (Pulkit Goyal)
This revision is now accepted and ready to land.
pulkit added a comment.
pulkit accepted this revision.


  Maybe worth to add about this in relnotes for 5.2

REPOSITORY
  rHG Mercurial

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

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

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


D6676: unshelve: add help text on --interactive in verbose mode

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


  Since, we already has `--interactive` pushed for the upcoming release, 
queuing this on stable branch.

REPOSITORY
  rHG Mercurial

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

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

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


D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-24 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> shelve.py:181
> +_shelvedinteractively = 'shelvedinteractively'
> +_notshelvedinteractively = 'notshelvedinteractively'
>  

We are already in shelve code, so no need to prepend shelved to the name.

Also, we can only had `interactive` stored in the shelved state. If it's not 
present in the state file, we can assume we were not running interactive 
unshelve.

> shelve.py:842
>  # we'll be merging with, rebase it to be on top.
> -interactive = opts.get('interactive')
> +interactive = opts.get('interactive', False)
>  if tmpwctx.node() == shelvectx.p1().node() and not interactive:

unrequired change.

> shelve.py:938
>  
> -if abortf or continuef and not interactive:
> +if len(shelved) > 1:
> +raise error.Abort(_('can only unshelve one change at a time'))

This change is unrelated to storing info about interactive in shelvedstate. Can 
you decouple this into a separate patch?

REPOSITORY
  rHG Mercurial

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

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

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


D6683: unshelve: fixes on interactive mode

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


  This patch does following things:
  
  1. unify logic around creating unshelvectx
  2. changes how date is set in iteractive mode
  3. handles stripping in interavtive mode
  4. compute a matcher only if it's required
  5. and a change around making basename madatory argument
  
  Can we have them in separate patches?

REPOSITORY
  rHG Mercurial

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

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

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