D6683: unshelve: fixes on interactive mode

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

REVISION SUMMARY
  This is a follow-up patch to 5162753c4c14 
 on 
addressing reviews
  on the commit. This includes fixes on interactive mode.

REPOSITORY
  rHG Mercurial

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
@@ -700,7 +700,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.
@@ -727,15 +727,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
@@ -755,10 +748,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)
@@ -810,14 +803,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,
@@ -826,9 +830,9 @@
 snode = repo.commit(text=shelvectx.description(),
 extra=shelvectx.extra(),
 user=shelvectx.user(),
-date=shelvectx.date())
-m = scmutil.matchfiles(repo, repo[snode].files())
+date=opts.get('date'))
 if snode:
+m = scmutil.matchfiles(repo, repo[snode].files())
 _shelvecreatedcommit(repo, snode, basename, m)
 
 return newnode, bool(snode)
@@ -868,15 +872,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(),
-  

Mercurial mini-sprint in Leipzig

2019-07-23 Thread Manuel Jacob

Hi,

In addition to the sprints that are hosted about every two minor 
releases, the Mercurial community organizes so called "mini-sprints" in 
irregular intervals.


I attended the mini-sprint in April in Paris and I liked the experience, 
so I offered to organize one in Leipzig.  This email is to gather 
information about potential participants and their time preferences.


So what's the goal of the mini-sprint?  It's an opportunity for existing 
developers to collaborate in person.  But even more important, it's a 
chance for mere users to become contributors.  So no matter whether you 
are a long-term contributor or someone wanting to start hacking on 
Mercurial, you will be welcome.


The sprint will be 2-4 days long, depending on demand.  For us, some 
time in August would be ideal.


The location will be an office in Leipzig, which is easily reachable by 
train.  For example, from Paris it's about 8h for about 60€ – 120€.  
From Frankfurt airport it's about 3h for about 20€ – 50€.  It provides 
space for around 10 people (more on weekends).


Lunch will be provided for a contribution towards expenses.  At least 2 
sleeping facilities can be provided free of charge.


I've created a poll for finding a date: 
https://framadate.org/jIs6Idj4r8tldJKZ


Please spread the word by forwarding the mail or the link to the poll.

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


mercurial@42643: 2 new changesets (2 on stable)

2019-07-23 Thread Mercurial Commits
2 new changesets (2 on stable) in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/464aa857c717
changeset:   42642:464aa857c717
branch:  stable
user:Valentin Gatien-Baron 
date:Mon Jul 22 06:33:00 2019 -0400
summary: amend: add a test for a simplified version of issue6157

https://www.mercurial-scm.org/repo/hg/rev/ce52377102db
changeset:   42643:ce52377102db
branch:  stable
bookmark:@
tag: tip
user:Valentin Gatien-Baron 
date:Mon Jul 22 06:33:11 2019 -0400
summary: amend: stop committing unrequested file reverts (issue6157)

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


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

2019-07-23 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We've had a couple of cases where it'd be handy at Google to add data
  to `hg debuginstall`'s output. We've kludged around that at various
  times, but it seems reasonable to let extensions add their own data
  here so extension maintainers can get useful extra data.

REPOSITORY
  rHG Mercurial

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
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-23 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added subscribers: mercurial-devel, mjpieters.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This might make some things easier to debug, and for default bug
  report templates it'll help collect more data from users all at
  once. I don't actually need fsmonitor in our bug reports (we don't use
  it), but this demonstrates the utility of the preceding patches
  without having to add new things to core.

REPOSITORY
  rHG Mercurial

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
@@ -175,6 +175,24 @@
 # 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"))
+import tempfile
+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
Cc: 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-23 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added subscribers: mercurial-devel, mjpieters.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This will make my next patch simpler.

REPOSITORY
  rHG Mercurial

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
Cc: mjpieters, 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-23 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is a follow-up patch to 5162753c4c14 
. 
This makes `unshelve`
  stores the information about interactive mode on conflicts.

REPOSITORY
  rHG Mercurial

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,8 @@
 _nokeep = 'nokeep'
 # colon is essential to differentiate from a real bookmark name
 _noactivebook = ':no-active-bookmark'
+_shelvedinteractively = 'shelvedinteractively'
+_notshelvedinteractively = 'notshelvedinteractively'
 
 @classmethod
 def _verifyandtransform(cls, d):
@@ -247,6 +249,8 @@
 obj.activebookmark = ''
 if d.get('activebook', '') != cls._noactivebook:
 obj.activebookmark = d.get('activebook', '')
+obj.shelvedinteractively = (d.get('shelvedinteractively')
+ == cls._shelvedinteractively)
 except (error.RepoLookupError, KeyError) as err:
 raise error.CorruptedState(pycompat.bytestr(err))
 
@@ -254,7 +258,7 @@
 
 @classmethod
 def save(cls, repo, name, originalwctx, pendingctx, nodestoremove,
- branchtorestore, keep=False, activebook=''):
+ branchtorestore, keep=False, activebook='', 
shelvedinteractively=False):
 info = {
 "name": name,
 "originalwctx": nodemod.hex(originalwctx.node()),
@@ -265,7 +269,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,
+"shelvedinteractively": (cls._shelvedinteractively
+if shelvedinteractively else cls._notshelvedinteractively)
 }
 scmutil.simplekeyvaluefile(
 repo.vfs, cls._filename).write(info,
@@ -698,7 +704,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.shelvedinteractively
 with repo.lock():
 checkparents(repo, state)
 ms = merge.mergestate.read(repo)
@@ -833,7 +839,7 @@
 """Rebase restored commit from its original location to a destination"""
 # If the shelve is not immediately on top of the commit
 # 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:
 # We won't skip on interactive mode because, the user might want to
 # unshelve certain changes only.
@@ -854,7 +860,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,
+  shelvedinteractively=interactive)
 raise error.InterventionRequired(
 _("unresolved conflicts (see 'hg resolve', then "
   "'hg unshelve --continue')"))
@@ -928,10 +935,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 

D6678: continue: added support for histedit

2019-07-23 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 16019.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6678?vs=16018=16019

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

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

AFFECTED FILES
  hgext/histedit.py
  tests/test-histedit-arguments.t

CHANGE DETAILS

diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
--- a/tests/test-histedit-arguments.t
+++ b/tests/test-histedit-arguments.t
@@ -1,4 +1,4 @@
-#testcases abortcommand abortflag
+#testcases commandmode abortflag continueflag
 
 #if abortflag
   $ cat >> $HGRCPATH < EOF
 #endif
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = histedit --continue
+  > EOF
+#endif
+
 Test argument handling and various data parsing
 ==
 
@@ -53,12 +60,13 @@
 histedit --continue/--abort with no existing state
 --
 
-  $ hg histedit --continue
-  abort: no histedit in progress
+  $ hg continue
+  abort: no histedit in progress (continueflag !)
+  abort: no operation in progress (no-continueflag !)
   [255]
   $ hg abort
   abort: no histedit in progress (abortflag !)
-  abort: no operation in progress (abortcommand !)
+  abort: no operation in progress (no-abortflag !)
   [255]
 
 Run a dummy edit to make sure we get tip^^ correctly via revsingle.
@@ -163,7 +171,7 @@
   $ echo alpha >> alpha
   $ mv .hg/histedit-state.back .hg/histedit-state
 
-  $ hg histedit --continue
+  $ hg continue
   saved backup bundle to 
$TESTTMP/foo/.hg/strip-backup/08d98a8350f3-02594089-histedit.hg
   $ hg log -G -T '{rev} {shortest(node)} {desc}\n' -r 2::
   @  4 f5ed five
@@ -493,7 +501,7 @@
   $ hg resolve -m --all
   (no more unresolved files)
   continue: hg histedit --continue
-  $ hg histedit --cont
+  $ hg continue
   merging foo
   warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
   Editing (6f2f0241f119), you may commit or record as needed now.
@@ -516,7 +524,7 @@
   > evolution.allowunstable=True
   > EOF
   $ hg commit --amend -m 'allow this fold'
-  $ hg histedit --continue
+  $ hg continue
 
   $ cd ..
 
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1839,6 +1839,20 @@
 
 state.write()
 
+def hgcontinuehistedit(ui, repo):
+state = histeditstate(repo)
+with repo.wlock() as wlock, repo.lock() as lock:
+state.wlock = wlock
+state.lock = lock
+opts = {'keep' : state.keep}
+fm = ui.formatter('histedit', opts)
+fm.startitem()
+state.read()
+state = bootstrapcontinue(ui, state, opts)
+_continuehistedit(ui, repo, state)
+_finishhistedit(ui, repo, state, fm)
+fm.end()
+
 def _finishhistedit(ui, repo, state, fm):
 """This action runs when histedit is finishing its session"""
 hg.updaterepo(repo, state.parentctxnode, overwrite=False)
@@ -2322,5 +2336,6 @@
 def extsetup(ui):
 cmdutil.summaryhooks.add('histedit', summaryhook)
 statemod.addunfinished('histedit', fname='histedit-state', 
allowcommit=True,
-continueflag=True, abortfunc=hgaborthistedit)
-
+continueflag=True, abortfunc=hgaborthistedit,
+continuefunc=hgcontinuehistedit)
+



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


D6678: continue: added support for histedit

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

REVISION SUMMARY
  This patch adds the support for histedit in `hg continue` plan.
  
  As seperate `hgcontinuehistedit()` function is created to handle
  independent calls for resuming histedit. This function is
  then registered as continuefunc for state detection API.
  
  Results are shown as tests.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/histedit.py
  tests/test-histedit-arguments.t

CHANGE DETAILS

diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
--- a/tests/test-histedit-arguments.t
+++ b/tests/test-histedit-arguments.t
@@ -1,4 +1,4 @@
-#testcases abortcommand abortflag
+#testcases commandmode abortflag continueflag
 
 #if abortflag
   $ cat >> $HGRCPATH < EOF
 #endif
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = histedit --continue
+  > EOF
+#endif
+
 Test argument handling and various data parsing
 ==
 
@@ -53,12 +60,13 @@
 histedit --continue/--abort with no existing state
 --
 
-  $ hg histedit --continue
-  abort: no histedit in progress
+  $ hg continue
+  abort: no histedit in progress (continueflag !)
+  abort: no operation in progress (no-continueflag !)
   [255]
   $ hg abort
   abort: no histedit in progress (abortflag !)
-  abort: no operation in progress (abortcommand !)
+  abort: no operation in progress (no-abortflag !)
   [255]
 
 Run a dummy edit to make sure we get tip^^ correctly via revsingle.
@@ -163,7 +171,7 @@
   $ echo alpha >> alpha
   $ mv .hg/histedit-state.back .hg/histedit-state
 
-  $ hg histedit --continue
+  $ hg continue
   saved backup bundle to 
$TESTTMP/foo/.hg/strip-backup/08d98a8350f3-02594089-histedit.hg
   $ hg log -G -T '{rev} {shortest(node)} {desc}\n' -r 2::
   @  4 f5ed five
@@ -493,7 +501,7 @@
   $ hg resolve -m --all
   (no more unresolved files)
   continue: hg histedit --continue
-  $ hg histedit --cont
+  $ hg continue
   merging foo
   warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
   Editing (6f2f0241f119), you may commit or record as needed now.
@@ -516,7 +524,7 @@
   > evolution.allowunstable=True
   > EOF
   $ hg commit --amend -m 'allow this fold'
-  $ hg histedit --continue
+  $ hg continue
 
   $ cd ..
 
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1839,6 +1839,20 @@
 
 state.write()
 
+def hgcontinuehistedit(ui, repo):
+state = histeditstate(repo)
+with repo.wlock() as wlock, repo.lock() as lock:
+state.wlock = wlock
+state.lock = lock
+opts = {'keep':state.keep}
+fm = ui.formatter('histedit', opts)
+fm.startitem()
+state.read()
+state = bootstrapcontinue(ui, state, opts)
+_continuehistedit(ui, repo, state)
+_finishhistedit(ui, repo, state, fm)
+fm.end()
+
 def _finishhistedit(ui, repo, state, fm):
 """This action runs when histedit is finishing its session"""
 hg.updaterepo(repo, state.parentctxnode, overwrite=False)
@@ -2322,5 +2336,6 @@
 def extsetup(ui):
 cmdutil.summaryhooks.add('histedit', summaryhook)
 statemod.addunfinished('histedit', fname='histedit-state', 
allowcommit=True,
-continueflag=True, abortfunc=hgaborthistedit)
-
+continueflag=True, abortfunc=hgaborthistedit,
+continuefunc=hgcontinuehistedit)
+



To: taapas1128, durin42, #hg-reviewers
Cc: 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-23 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh added inline comments.
navaneeth.suresh marked 2 inline comments as done.

INLINE COMMENTS

> mharbison72 wrote in commands.py:6215-6218
> "Shelve" is an action, so "stored shelve" and "whole shelve" read awkwardly.  
> Maybe stick to the phrase "shelved change" from above?
> 
> Minor bikeshedding, but it might also be better to say something like "The 
> working directory is updated with the selected changes, and only the 
> unselected changes remain shelved", rather than saying the shelved store is 
> modified with remaining changes (since they were already there).

Thanks for the review. Updated the description accordingly.

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: 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-23 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 16017.

REPOSITORY
  rHG Mercurial

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

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,12 @@
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 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.
 """
 with repo.wlock():
 return shelvemod.dounshelve(ui, repo, *shelved, **opts)



To: navaneeth.suresh, #hg-reviewers
Cc: 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-23 Thread mharbison72 (Matt Harbison)
mharbison72 added inline comments.

INLINE COMMENTS

> commands.py:6214
> +
> +   Selected changes can be unshelved with ``--interactive`` flag. The 
> repo
> +   is updated with the requested changes by the user and the stored 
> shelve

s/repo/working directory/

> commands.py:6215-6218
> +   is updated with the requested changes by the user and the stored 
> shelve
> +   is modified with the remaining changes. Note that the user will get 
> into
> +   conflicts whenever the whole shelve has conflicts with the repo
> +   regardless of the changes they have requested.

"Shelve" is an action, so "stored shelve" and "whole shelve" read awkwardly.  
Maybe stick to the phrase "shelved change" from above?

Minor bikeshedding, but it might also be better to say something like "The 
working directory is updated with the selected changes, and only the unselected 
changes remain shelved", rather than saying the shelved store is modified with 
remaining changes (since they were already there).

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


D6596: unshelve: add interactive mode

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


  For record: I left more comments about this patch. Mistakenly I did them on 
the phabricator commit instead of this review. 
https://phab.mercurial-scm.org/rHG5162753c4c14c143e6be011b89d6567b5ef50d66#51172

REPOSITORY
  rHG Mercurial

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

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

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-23 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 16016.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6676?vs=16008=16016

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,12 @@
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 repo
+   is updated with the requested changes by the user and the stored shelve
+   is modified with the remaining changes. Note that the user will get into
+   conflicts whenever the whole shelve has conflicts with the repo
+   regardless of the changes they have requested.
 """
 with repo.wlock():
 return shelvemod.dounshelve(ui, repo, *shelved, **opts)



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


D6427: discovery: new devel.discovery.randomize option

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6427?vs=15937=16015

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

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/setdiscovery.py
  tests/test-setdiscovery.t

CHANGE DETAILS

diff --git a/tests/test-setdiscovery.t b/tests/test-setdiscovery.t
--- a/tests/test-setdiscovery.t
+++ b/tests/test-setdiscovery.t
@@ -968,7 +968,7 @@
   updating to branch b
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
-  $ hg -R a debugdiscovery b --debug --verbose --config progress.debug=true
+  $ hg -R a debugdiscovery b --debug --verbose --config progress.debug=true 
--config devel.discovery.randomize=false
   comparing with b
   query 1; heads
   searching for changes
@@ -980,11 +980,14 @@
   query 3; still undecided: 980, sample size is: 200
   sampling from both directions
   searching: 4 queries
-  query 4; still undecided: 435, sample size is: 210
+  query 4; still undecided: 497, sample size is: 210
   sampling from both directions
   searching: 5 queries
-  query 5; still undecided: 185, sample size is: 185
-  5 total queries in *.s (glob)
+  query 5; still undecided: 285, sample size is: 220
+  sampling from both directions
+  searching: 6 queries
+  query 6; still undecided: 63, sample size is: 63
+  6 total queries in *.s (glob)
   elapsed time:  * seconds (glob)
   heads summary:
 total common heads:  1
@@ -1093,16 +1096,9 @@
 give 'all remote heads known locally' without checking the remaining heads -
 fixed in 86c35b7ae300:
 
-  $ cat >> $TESTTMP/unrandomsample.py << EOF
-  > import random
-  > def sample(population, k):
-  > return sorted(population)[:k]
-  > random.sample = sample
-  > EOF
-
   $ cat >> r1/.hg/hgrc << EOF
-  > [extensions]
-  > unrandomsample = $TESTTMP/unrandomsample.py
+  > [devel]
+  > discovery.randomize = False
   > EOF
 
   $ hg -R r1 outgoing r2 -T'{rev} ' --config extensions.blackbox= \
diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -390,7 +390,9 @@
 
 # full blown discovery
 
-disco = partialdiscovery(local, ownheads, remote.limitedarguments)
+randomize = ui.configbool('devel', 'discovery.randomize')
+disco = partialdiscovery(local, ownheads, remote.limitedarguments,
+ randomize=randomize)
 # treat remote heads (and maybe own heads) as a first implicit sample
 # response
 disco.addcommons(knownsrvheads)
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -415,6 +415,9 @@
 coreconfigitem('devel', 'debug.peer-request',
 default=False,
 )
+coreconfigitem('devel', 'discovery.randomize',
+default=True,
+)
 _registerdiffopts(section='diff')
 coreconfigitem('email', 'bcc',
 default=None,



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


D6426: rust-discovery: optionally don't randomize at all, for tests

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6426?vs=15936=16014

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

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

AFFECTED FILES
  mercurial/setdiscovery.py
  rust/hg-core/src/discovery.rs
  rust/hg-cpython/src/discovery.rs
  tests/test-rust-discovery.py

CHANGE DETAILS

diff --git a/tests/test-rust-discovery.py b/tests/test-rust-discovery.py
--- a/tests/test-rust-discovery.py
+++ b/tests/test-rust-discovery.py
@@ -103,6 +103,9 @@
 self.assertTrue(disco.iscomplete())
 self.assertEqual(disco.commonheads(), {1})
 
+def testinitnorandom(self):
+PartialDiscovery(self.repo(), [3], True, randomize=False)
+
 if __name__ == '__main__':
 import silenttestrunner
 silenttestrunner.main(__name__)
diff --git a/rust/hg-cpython/src/discovery.rs b/rust/hg-cpython/src/discovery.rs
--- a/rust/hg-cpython/src/discovery.rs
+++ b/rust/hg-cpython/src/discovery.rs
@@ -36,7 +36,8 @@
 _cls,
 repo: PyObject,
 targetheads: PyObject,
-respectsize: bool
+respectsize: bool,
+randomize: bool = true
 ) -> PyResult {
 let index = repo.getattr(py, "changelog")?.getattr(py, "index")?;
 Self::create_instance(
@@ -44,7 +45,8 @@
 RefCell::new(Box::new(CorePartialDiscovery::new(
 Index::new(py, index)?,
 rev_pyiter_collect(py, )?,
-respectsize
+respectsize,
+randomize,
 )))
 )
 }
diff --git a/rust/hg-core/src/discovery.rs b/rust/hg-core/src/discovery.rs
--- a/rust/hg-core/src/discovery.rs
+++ b/rust/hg-core/src/discovery.rs
@@ -31,6 +31,7 @@
 missing: HashSet,
 rng: Rng,
 respect_size: bool,
+randomize: bool,
 }
 
 pub struct DiscoveryStats {
@@ -151,14 +152,26 @@
 /// will interpret the size argument requested by the caller. If it's
 /// `false`, they are allowed to produce a sample whose size is more
 /// appropriate to the situation (typically bigger).
+///
+/// The `randomize` boolean affects sampling, and specifically how
+/// limiting or last-minute expanding is been done:
+///
+/// If `true`, both will perform random picking from `self.undecided`.
+/// This is currently the best for actual discoveries.
+///
+/// If `false`, a reproductible picking strategy is performed. This is
+/// useful for integration tests.
 pub fn new(
 graph: G,
 target_heads: Vec,
 respect_size: bool,
+randomize: bool,
 ) -> Self {
 let mut seed: [u8; 16] = [0; 16];
-thread_rng().fill_bytes( seed);
-Self::new_with_seed(graph, target_heads, seed, respect_size)
+if randomize {
+thread_rng().fill_bytes( seed);
+}
+Self::new_with_seed(graph, target_heads, seed, respect_size, randomize)
 }
 
 pub fn new_with_seed(
@@ -166,6 +179,7 @@
 target_heads: Vec,
 seed: [u8; 16],
 respect_size: bool,
+randomize: bool,
 ) -> Self {
 PartialDiscovery {
 undecided: None,
@@ -176,6 +190,7 @@
 missing: HashSet::new(),
 rng: Rng::from_seed(seed),
 respect_size: respect_size,
+randomize: randomize,
 }
 }
 
@@ -186,6 +201,11 @@
 mut sample: Vec,
 size: usize,
 ) -> Vec {
+if !self.randomize {
+sample.sort();
+sample.truncate(size);
+return sample;
+}
 let sample_len = sample.len();
 if sample_len <= size {
 return sample;
@@ -436,13 +456,15 @@
 
 /// A PartialDiscovery as for pushing all the heads of `SampleGraph`
 ///
-/// To avoid actual randomness in tests, we give it a fixed random seed.
+/// To avoid actual randomness in these tests, we give it a fixed
+/// random seed, but by default we'll test the random version.
 fn full_disco() -> PartialDiscovery {
 PartialDiscovery::new_with_seed(
 SampleGraph,
 vec![10, 11, 12, 13],
 [0; 16],
 true,
+true,
 )
 }
 
@@ -450,7 +472,13 @@
 ///
 /// To avoid actual randomness in tests, we give it a fixed random seed.
 fn disco12() -> PartialDiscovery {
-PartialDiscovery::new_with_seed(SampleGraph, vec![12], [0; 16], true)
+PartialDiscovery::new_with_seed(
+SampleGraph,
+vec![12],
+[0; 16],
+true,
+true,
+)
 }
 
 fn sorted_undecided(
@@ -535,6 +563,16 @@
 }
 
 #[test]
+fn test_limit_sample_no_random() {
+let mut disco = full_disco();
+disco.randomize = false;
+assert_eq!(
+disco.limit_sample(vec![1, 8, 13, 5, 7, 3], 4),
+

D6424: rust-discovery: takefullsample() core implementation

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6424?vs=15934=16012

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

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

AFFECTED FILES
  rust/hg-core/src/discovery.rs
  rust/hg-cpython/src/discovery.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/discovery.rs b/rust/hg-cpython/src/discovery.rs
--- a/rust/hg-cpython/src/discovery.rs
+++ b/rust/hg-cpython/src/discovery.rs
@@ -36,7 +36,7 @@
 _cls,
 repo: PyObject,
 targetheads: PyObject,
-_respectsize: bool
+respectsize: bool
 ) -> PyResult {
 let index = repo.getattr(py, "changelog")?.getattr(py, "index")?;
 Self::create_instance(
@@ -44,6 +44,7 @@
 RefCell::new(Box::new(CorePartialDiscovery::new(
 Index::new(py, index)?,
 rev_pyiter_collect(py, )?,
+respectsize
 )))
 )
 }
diff --git a/rust/hg-core/src/discovery.rs b/rust/hg-core/src/discovery.rs
--- a/rust/hg-core/src/discovery.rs
+++ b/rust/hg-core/src/discovery.rs
@@ -17,6 +17,7 @@
 use super::{Graph, GraphError, Revision, NULL_REVISION};
 use crate::ancestors::MissingAncestors;
 use crate::dagops;
+use std::cmp::{max, min};
 use std::collections::{HashMap, HashSet, VecDeque};
 
 type Rng = self::rand_pcg::Pcg32;
@@ -26,8 +27,10 @@
 graph: G, // plays the role of self._repo
 common: MissingAncestors,
 undecided: Option>,
+children_cache: Option>>,
 missing: HashSet,
 rng: Rng,
+respect_size: bool,
 }
 
 pub struct DiscoveryStats {
@@ -49,13 +52,16 @@
 /// - `sample`: a sample to update
 /// - `parentfn`: a callable to resolve parents for a revision
 /// - `quicksamplesize`: optional target size of the sample
-fn update_sample(
+fn update_sample(
 revs: Option<>,
 heads: impl IntoIterator,
 sample:  HashSet,
-parentsfn: impl Fn(Revision) -> Result<[Revision; 2], GraphError>,
+parentsfn: impl Fn(Revision) -> Result,
 quicksamplesize: Option,
-) -> Result<(), GraphError> {
+) -> Result<(), GraphError>
+where
+I: Iterator,
+{
 let mut distances: HashMap = HashMap::new();
 let mut visit: VecDeque = heads.into_iter().collect();
 let mut factor: u32 = 1;
@@ -83,10 +89,7 @@
 }
 }
 }
-for  in (current)? {
-if p == NULL_REVISION {
-continue;
-}
+for p in parentsfn(current)? {
 if let Some(revs) = revs {
 if !revs.contains() {
 continue;
@@ -99,6 +102,39 @@
 Ok(())
 }
 
+struct ParentsIterator {
+parents: [Revision; 2],
+cur: usize,
+}
+
+impl ParentsIterator {
+fn graph_parents(
+graph:  Graph,
+r: Revision,
+) -> Result {
+Ok(ParentsIterator {
+parents: graph.parents(r)?,
+cur: 0,
+})
+}
+}
+
+impl Iterator for ParentsIterator {
+type Item = Revision;
+
+fn next( self) -> Option {
+if self.cur > 1 {
+return None;
+}
+let rev = self.parents[self.cur];
+self.cur += 1;
+if rev == NULL_REVISION {
+return self.next();
+}
+Some(rev)
+}
+}
+
 impl PartialDiscovery {
 /// Create a PartialDiscovery object, with the intent
 /// of comparing our `::` revset to the contents of another
@@ -110,24 +146,36 @@
 /// If we want to make the signature more flexible,
 /// we'll have to make it a type argument of `PartialDiscovery` or a trait
 /// object since we'll keep it in the meanwhile
-pub fn new(graph: G, target_heads: Vec) -> Self {
+///
+/// The `respect_size` boolean controls how the sampling methods
+/// will interpret the size argument requested by the caller. If it's
+/// `false`, they are allowed to produce a sample whose size is more
+/// appropriate to the situation (typically bigger).
+pub fn new(
+graph: G,
+target_heads: Vec,
+respect_size: bool,
+) -> Self {
 let mut seed: [u8; 16] = [0; 16];
 thread_rng().fill_bytes( seed);
-Self::new_with_seed(graph, target_heads, seed)
+Self::new_with_seed(graph, target_heads, seed, respect_size)
 }
 
 pub fn new_with_seed(
 graph: G,
 target_heads: Vec,
 seed: [u8; 16],
+respect_size: bool,
 ) -> Self {
 PartialDiscovery {
 undecided: None,
+children_cache: None,
 target_heads: Some(target_heads),
 graph: graph.clone(),
 common: MissingAncestors::new(graph, vec![]),
 missing: HashSet::new(),
 rng: Rng::from_seed(seed),
+respect_size: respect_size,
 }
 }
 
@@ -228,6 +276,22 @@
 Ok(())
 }
 
+fn ensure_children_cache( self) 

D6425: rust-discovery: exposing sampling to python

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6425?vs=15935=16013

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

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

AFFECTED FILES
  rust/hg-cpython/src/discovery.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/discovery.rs b/rust/hg-cpython/src/discovery.rs
--- a/rust/hg-cpython/src/discovery.rs
+++ b/rust/hg-cpython/src/discovery.rs
@@ -18,7 +18,7 @@
 exceptions::GraphError,
 };
 use cpython::{
-ObjectProtocol, PyDict, PyModule, PyObject, PyResult, Python,
+ObjectProtocol, PyDict, PyModule, PyObject, PyResult, PyTuple, Python,
 PythonObject, ToPyObject,
 };
 use hg::discovery::PartialDiscovery as CorePartialDiscovery;
@@ -111,6 +111,32 @@
 .map_err(|e| GraphError::pynew(py, e))?
 )
 }
+
+def takefullsample(, _headrevs: PyObject,
+   size: usize) -> PyResult {
+let mut inner = self.inner(py).borrow_mut();
+let sample = inner.take_full_sample(size)
+.map_err(|e| GraphError::pynew(py, e))?;
+let as_vec: Vec = sample
+.iter()
+.map(|rev| rev.to_py_object(py).into_object())
+.collect();
+Ok(PyTuple::new(py, as_vec.as_slice()).into_object())
+}
+
+def takequicksample(, headrevs: PyObject,
+size: usize) -> PyResult {
+let mut inner = self.inner(py).borrow_mut();
+let revsvec: Vec = rev_pyiter_collect(py, )?;
+let sample = inner.take_quick_sample(revsvec, size)
+.map_err(|e| GraphError::pynew(py, e))?;
+let as_vec: Vec = sample
+.iter()
+.map(|rev| rev.to_py_object(py).into_object())
+.collect();
+Ok(PyTuple::new(py, as_vec.as_slice()).into_object())
+}
+
 });
 
 /// Create the module, with __package__ given from parent



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


D6517: rust-discovery: read the index from a repo passed at init

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6517?vs=15932=16011

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

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

AFFECTED FILES
  rust/hg-cpython/src/discovery.rs
  tests/test-rust-discovery.py

CHANGE DETAILS

diff --git a/tests/test-rust-discovery.py b/tests/test-rust-discovery.py
--- a/tests/test-rust-discovery.py
+++ b/tests/test-rust-discovery.py
@@ -31,6 +31,11 @@
 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00'
 )
 
+class fakerepo(object):
+def __init__(self, idx):
+"""Just make so that self.changelog.index is the given idx."""
+self.index = idx
+self.changelog = self
 
 @unittest.skipIf(PartialDiscovery is None or cparsers is None,
  "rustext or the C Extension parsers module "
@@ -50,6 +55,9 @@
 def parseindex(self):
 return cparsers.parse_index2(data_non_inlined, False)[0]
 
+def repo(self):
+return fakerepo(self.parseindex())
+
 def testindex(self):
 idx = self.parseindex()
 # checking our assumptions about the index binary data:
@@ -60,8 +68,7 @@
   3: (2, -1)})
 
 def testaddcommonsmissings(self):
-idx = self.parseindex()
-disco = PartialDiscovery(idx, [3], True)
+disco = PartialDiscovery(self.repo(), [3], True)
 self.assertFalse(disco.hasinfo())
 self.assertFalse(disco.iscomplete())
 
@@ -76,24 +83,21 @@
 self.assertEqual(disco.commonheads(), {1})
 
 def testaddmissingsstats(self):
-idx = self.parseindex()
-disco = PartialDiscovery(idx, [3], True)
+disco = PartialDiscovery(self.repo(), [3], True)
 self.assertIsNone(disco.stats()['undecided'], None)
 
 disco.addmissings([2])
 self.assertEqual(disco.stats()['undecided'], 2)
 
 def testaddinfocommonfirst(self):
-idx = self.parseindex()
-disco = PartialDiscovery(idx, [3], True)
+disco = PartialDiscovery(self.repo(), [3], True)
 disco.addinfo([(1, True), (2, False)])
 self.assertTrue(disco.hasinfo())
 self.assertTrue(disco.iscomplete())
 self.assertEqual(disco.commonheads(), {1})
 
 def testaddinfomissingfirst(self):
-idx = self.parseindex()
-disco = PartialDiscovery(idx, [3], True)
+disco = PartialDiscovery(self.repo(), [3], True)
 disco.addinfo([(2, False), (1, True)])
 self.assertTrue(disco.hasinfo())
 self.assertTrue(disco.iscomplete())
diff --git a/rust/hg-cpython/src/discovery.rs b/rust/hg-cpython/src/discovery.rs
--- a/rust/hg-cpython/src/discovery.rs
+++ b/rust/hg-cpython/src/discovery.rs
@@ -34,10 +34,11 @@
 // implemented.
 def __new__(
 _cls,
-index: PyObject,
+repo: PyObject,
 targetheads: PyObject,
 _respectsize: bool
 ) -> PyResult {
+let index = repo.getattr(py, "changelog")?.getattr(py, "index")?;
 Self::create_instance(
 py,
 RefCell::new(Box::new(CorePartialDiscovery::new(



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


D6516: rust-discovery: accept the new 'respectsize' init arg

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6516?vs=15931=16010

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

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

AFFECTED FILES
  rust/hg-cpython/src/discovery.rs
  tests/test-rust-discovery.py

CHANGE DETAILS

diff --git a/tests/test-rust-discovery.py b/tests/test-rust-discovery.py
--- a/tests/test-rust-discovery.py
+++ b/tests/test-rust-discovery.py
@@ -61,7 +61,7 @@
 
 def testaddcommonsmissings(self):
 idx = self.parseindex()
-disco = PartialDiscovery(idx, [3])
+disco = PartialDiscovery(idx, [3], True)
 self.assertFalse(disco.hasinfo())
 self.assertFalse(disco.iscomplete())
 
@@ -77,7 +77,7 @@
 
 def testaddmissingsstats(self):
 idx = self.parseindex()
-disco = PartialDiscovery(idx, [3])
+disco = PartialDiscovery(idx, [3], True)
 self.assertIsNone(disco.stats()['undecided'], None)
 
 disco.addmissings([2])
@@ -85,7 +85,7 @@
 
 def testaddinfocommonfirst(self):
 idx = self.parseindex()
-disco = PartialDiscovery(idx, [3])
+disco = PartialDiscovery(idx, [3], True)
 disco.addinfo([(1, True), (2, False)])
 self.assertTrue(disco.hasinfo())
 self.assertTrue(disco.iscomplete())
@@ -93,7 +93,7 @@
 
 def testaddinfomissingfirst(self):
 idx = self.parseindex()
-disco = PartialDiscovery(idx, [3])
+disco = PartialDiscovery(idx, [3], True)
 disco.addinfo([(2, False), (1, True)])
 self.assertTrue(disco.hasinfo())
 self.assertTrue(disco.iscomplete())
diff --git a/rust/hg-cpython/src/discovery.rs b/rust/hg-cpython/src/discovery.rs
--- a/rust/hg-cpython/src/discovery.rs
+++ b/rust/hg-cpython/src/discovery.rs
@@ -29,10 +29,14 @@
 py_class!(pub class PartialDiscovery |py| {
 data inner: RefCell>>;
 
+// `_respectsize` is currently only here to replicate the Python API and
+// will be used in future patches inside methods that are yet to be
+// implemented.
 def __new__(
 _cls,
 index: PyObject,
-targetheads: PyObject
+targetheads: PyObject,
+_respectsize: bool
 ) -> PyResult {
 Self::create_instance(
 py,



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


D6677: module-policy: update rust extension import to use the new module policy

2019-07-23 Thread Raphaël Gomès
Alphare 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/D6677

AFFECTED FILES
  tests/test-rust-discovery.py

CHANGE DETAILS

diff --git a/tests/test-rust-discovery.py b/tests/test-rust-discovery.py
--- a/tests/test-rust-discovery.py
+++ b/tests/test-rust-discovery.py
@@ -1,16 +1,9 @@
 from __future__ import absolute_import
 import unittest
 
-try:
-from mercurial import rustext
-rustext.__name__  # trigger immediate actual import
-except ImportError:
-rustext = None
-else:
-# this would fail already without appropriate ancestor.__package__
-from mercurial.rustext.discovery import (
-PartialDiscovery,
-)
+from mercurial import policy
+
+PartialDiscovery = policy.importrust('discovery', member='PartialDiscovery')
 
 try:
 from mercurial.cext import parsers as cparsers
@@ -39,7 +32,7 @@
 )
 
 
-@unittest.skipIf(rustext is None or cparsers is None,
+@unittest.skipIf(PartialDiscovery is None or cparsers is None,
  "rustext or the C Extension parsers module "
  "discovery relies on is not available")
 class rustdiscoverytest(unittest.TestCase):



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


D6516: rust-discovery: accept the new 'respectsize' init arg

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


  In D6516#97578 , @kevincox wrote:
  
  > It seems weird to add this argument without using it. I would much rather 
it was added as the implementation was added.
  
  I think it makes sense considering this is supposed to be a drop-in 
replacement for the Python implementation, though I would prefer if there were 
a comment about it.
  I'll update with the comment as well as the new import syntax.

REPOSITORY
  rHG Mercurial

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

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

To: gracinet, #hg-reviewers, kevincox
Cc: Alphare, durin42, kevincox, 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-23 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is a follow-up patch to rHG9eace8d6d537 
. 
This modifies the
  help text of unshelve in verbose mode to mention the details
  about `--interactive` flag.

REPOSITORY
  rHG Mercurial

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
@@ -6188,6 +6188,10 @@
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 repo
+   is updated with the requested changes by the user and the stored shelve
+   is modified with the remaining changes.
 """
 with repo.wlock():
 return shelvemod.dounshelve(ui, repo, *shelved, **opts)



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