[Bug 6056] New: commit fails on non-generaldelta repositories

2019-01-21 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=6056

Bug ID: 6056
   Summary: commit fails on non-generaldelta repositories
   Product: Mercurial
   Version: stable branch
  Hardware: PC
OS: Windows
Status: UNCONFIRMED
  Severity: feature
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: mathias.dem...@gmail.com
CC: mercurial-devel@mercurial-scm.org

It appears we still have some non-generaldelta repositories, and I just bumped
into an issue with one of them. This occurs on 4.9rc0+11-13c23396c7fe:

env HGRCPATH= HGPLAIN= hg commit -u foo -m "foo"
transaction abort!
rollback completed
** unknown exception encountered, please report by visiting
** https://mercurial-scm.org/wiki/BugTracker
** Python 2.7.5 (default, Jul 13 2018, 13:06:57) [GCC 4.8.5 20150623 (Red Hat
4.8.5-28)]
** Mercurial Distributed SCM (version 4.9rc0+11-13c23396c7fe)
** Extensions loaded: 
Traceback (most recent call last):
  File "/bin/hg", line 43, in 
dispatch.run()
  File "/usr/lib64/python2.7/site-packages/mercurial/dispatch.py", line 99, in
run
status = dispatch(req)
  File "/usr/lib64/python2.7/site-packages/mercurial/dispatch.py", line 225, in
dispatch
ret = _runcatch(req) or 0
  File "/usr/lib64/python2.7/site-packages/mercurial/dispatch.py", line 376, in
_runcatch
return _callcatch(ui, _runcatchfunc)
  File "/usr/lib64/python2.7/site-packages/mercurial/dispatch.py", line 384, in
_callcatch
return scmutil.callcatch(ui, func)
  File "/usr/lib64/python2.7/site-packages/mercurial/scmutil.py", line 165, in
callcatch
return func()
  File "/usr/lib64/python2.7/site-packages/mercurial/dispatch.py", line 367, in
_runcatchfunc
return _dispatch(req)
  File "/usr/lib64/python2.7/site-packages/mercurial/dispatch.py", line 1021,
in _dispatch
cmdpats, cmdoptions)
  File "/usr/lib64/python2.7/site-packages/mercurial/dispatch.py", line 756, in
runcommand
ret = _runcommand(ui, options, cmd, d)
  File "/usr/lib64/python2.7/site-packages/mercurial/dispatch.py", line 1030,
in _runcommand
return cmdfunc()
  File "/usr/lib64/python2.7/site-packages/mercurial/dispatch.py", line 1018,
in 
d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
  File "/usr/lib64/python2.7/site-packages/mercurial/util.py", line 1670, in
check
return func(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/mercurial/commands.py", line 1644,
in commit
return _docommit(ui, repo, *pats, **opts)
  File "/usr/lib64/python2.7/site-packages/mercurial/commands.py", line 1719,
in _docommit
node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
  File "/usr/lib64/python2.7/site-packages/mercurial/cmdutil.py", line 2397, in
commit
return commitfunc(ui, repo, message, matcher, opts)
  File "/usr/lib64/python2.7/site-packages/mercurial/commands.py", line 1717,
in commitfunc
extra=extra)
  File "/usr/lib64/python2.7/site-packages/mercurial/localrepo.py", line 158,
in wrapper
return orig(repo.unfiltered(), *args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/mercurial/localrepo.py", line 2477,
in commit
ret = self.commitctx(cctx, True)
  File "/usr/lib64/python2.7/site-packages/mercurial/localrepo.py", line 158,
in wrapper
return orig(repo.unfiltered(), *args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/mercurial/localrepo.py", line 2587,
in commitctx
added, drop, match=self.narrowmatch())
  File "/usr/lib64/python2.7/site-packages/mercurial/manifest.py", line 1749,
in write
p1, p2, added, removed, match=match)
  File "/usr/lib64/python2.7/site-packages/mercurial/manifest.py", line 1493,
in add
cachedelta)
  File "/usr/lib64/python2.7/site-packages/mercurial/revlog.py", line 1885, in
addrevision
deltacomputer=deltacomputer)
  File "/usr/lib64/python2.7/site-packages/mercurial/revlog.py", line 1900, in
addrawrevision
deltacomputer=deltacomputer)
  File "/usr/lib64/python2.7/site-packages/mercurial/revlog.py", line 2028, in
_addrevision
deltainfo = deltacomputer.finddeltainfo(revinfo, fh)
  File "/usr/lib64/python2.7/site-packages/mercurial/revlogutils/deltas.py",
line 995, in finddeltainfo
candidaterevs = next(groups)
  File "/usr/lib64/python2.7/site-packages/mercurial/revlogutils/deltas.py",
line 643, in _candidategroups
temptative = candidates.send(good)
  File "/usr/lib64/python2.7/site-packages/mercurial/revlogutils/deltas.py",
line 717, in _refinedgroups
for candidates in _rawgroups(revlog, p1, p2, cachedelta, snapshots):
  File "/usr/lib64/python2.7/site-packages/mercurial/revlogutils/deltas.py",
line 778, in _rawgroups
if sparse and parents:
UnboundLocalError: local variable 'parents' referenced before assignment

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
Mercurial-devel mailing list

mercurial@41297: 5 new changesets (5 on stable)

2019-01-21 Thread Mercurial Commits
5 new changesets (5 on stable) in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/86f6b441adea
changeset:   41293:86f6b441adea
branch:  stable
user:Matt Harbison 
date:Fri Jan 18 23:13:04 2019 -0500
summary: help: modernize the example for command registration

https://www.mercurial-scm.org/repo/hg/rev/b5d7413e4009
changeset:   41294:b5d7413e4009
branch:  stable
user:Matt Harbison 
date:Fri Jan 18 23:22:56 2019 -0500
summary: help: document the minimumhgversion variable for extensions

https://www.mercurial-scm.org/repo/hg/rev/bf4a078b3f88
changeset:   41295:bf4a078b3f88
branch:  stable
user:Boris Feld 
date:Fri Jan 18 16:02:26 2019 +0100
summary: mmap: backed out changeset 74a9f428227e

https://www.mercurial-scm.org/repo/hg/rev/d82dd55024e7
changeset:   41296:d82dd55024e7
branch:  stable
user:Boris Feld 
date:Fri Jan 18 16:03:37 2019 +0100
summary: mmap: backed out changeset 875d2af8cb4e

https://www.mercurial-scm.org/repo/hg/rev/b1ea90613af3
changeset:   41297:b1ea90613af3
branch:  stable
bookmark:@
tag: tip
user:Boris Feld 
date:Fri Jan 18 14:21:47 2019 +0100
summary: revset: introduce an internal `_rev` predicate for '%d' usage

-- 
Repository URL: https://www.mercurial-scm.org/repo/hg
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 3 of 3 STABLE] rust: add comment about lack of wdirrev handling

2019-01-21 Thread Yuya Nishihara
On Mon, 21 Jan 2019 17:00:38 +0100, Georges Racinet wrote:
> Le 20 janvier 2019 04:11:11 GMT+01:00, Yuya Nishihara  a écrit 
> :
> ># HG changeset patch
> ># User Yuya Nishihara 
> ># Date 1547953056 -32400
> >#  Sun Jan 20 11:57:36 2019 +0900
> ># Branch stable
> ># Node ID 13c23396c7fe1633a2336b29e3a32b9b76274f28
> ># Parent  66102f6fa10aa533a658532b198cd6879a538406
> >rust: add comment about lack of wdirrev handling
> >
> >If hg is compiled with rust support, 'only(wdir())' crashed as
> >"rustext.GraphError: ('ParentOutOfRange', 2147483647)", which should
> >instead
> >say "abort: working directory revision cannot be specified."
> 
> I can fix that easily if you like, and it seems possible to me that rust-core 
> could get awareness of wdirrev and that rust-cpython would raise the proper 
> exception.
> 
> If that's too much for the stable branch, a simple try/except as is already 
> done in the C case would be enough.

Thanks. I think it's better to translate wdirrev to error in Rust part.
try-catch won't be viable solution as Rust core gets more laziness and
object APIs.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5639: context: delete mistaken comment about return value of renamed()

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

REVISION SUMMARY
  The comment seems to think that the return value of renamed() is a
  tuple of source pathsx in the parents, but it's actually a pair of
  (rename source path, file nodeid).

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -2178,8 +2178,6 @@
 """
 def getfilectx(repo, memctx, path):
 fctx = ctx[path]
-# this is weird but apparently we only keep track of one parent
-# (why not only store that instead of a tuple?)
 copied = fctx.renamed()
 if copied:
 copied = copied[0]



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


D5290: branchmap: rename partial -> bcache

2019-01-21 Thread mjpieters (Martijn Pieters)
mjpieters added a comment.


  @yuja: you wanted separate commits, you got separate commits. :-)
  
  (and apologies for taking so long)

REPOSITORY
  rHG Mercurial

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

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


D5292: branchmap: make it easier for extensions not to break branchcache

2019-01-21 Thread mjpieters (Martijn Pieters)
mjpieters abandoned this revision.
mjpieters added a comment.


  This would need more thought then; the evolve/topic/topicmap codebase wraps 
the whole branchmap.branchcache class and mucks about with a context manager to 
re-instate the right name in the branchmap globals so super() doesn't break, 
which is what led to this patch.

REPOSITORY
  rHG Mercurial

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

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


D5638: branchmap: encapsulate cache updating in the map itself

2019-01-21 Thread mjpieters (Martijn Pieters)
mjpieters created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Rather than have a repository update the cache, move handling of cache updates
  into the branchmap module, in the form of a custom mapping class.
  
  This makes later performance improvements easier to handle too.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/perf.py
  mercurial/branchmap.py
  mercurial/localrepo.py
  mercurial/statichttprepo.py
  mercurial/streamclone.py

CHANGE DETAILS

diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -174,7 +174,7 @@
 repo._writerequirements()
 
 if rbranchmap:
-branchmap.replacecache(repo, rbranchmap)
+repo._branchcaches.replace(repo, rbranchmap)
 
 repo.invalidate()
 
diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py
+++ b/mercurial/statichttprepo.py
@@ -13,6 +13,7 @@
 
 from .i18n import _
 from . import (
+branchmap,
 changelog,
 error,
 localrepo,
@@ -192,7 +193,7 @@
 self.changelog = changelog.changelog(self.svfs)
 self._tags = None
 self.nodetagscache = None
-self._branchcaches = {}
+self._branchcaches = branchmap.BranchMapCache()
 self._revbranchcache = None
 self.encodepats = None
 self.decodepats = None
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -991,7 +991,7 @@
 
 self._dirstatevalidatewarned = False
 
-self._branchcaches = {}
+self._branchcaches = branchmap.BranchMapCache()
 self._revbranchcache = None
 self._filterpats = {}
 self._datafilters = {}
@@ -1519,8 +1519,7 @@
 def branchmap(self):
 '''returns a dictionary {branch: [branchheads]} with branchheads
 ordered by increasing revision number'''
-branchmap.updatecache(self)
-return self._branchcaches[self.filtername]
+return self._branchcaches[self]
 
 @unfilteredmethod
 def revbranchcache(self):
@@ -2073,9 +2072,9 @@
 return
 
 if tr is None or tr.changes['origrepolen'] < len(self):
-# updating the unfiltered branchmap should refresh all the others,
+# accessing the 'ser ved' branchmap should refresh all the others,
 self.ui.debug('updating the branch cache\n')
-branchmap.updatecache(self.filtered('served'))
+self.filtered('served').branchmap()
 
 if full:
 rbc = self.revbranchcache()
@@ -2093,7 +2092,7 @@
 # can't use delattr on proxy
 del self.__dict__[r'_tagscache']
 
-self.unfiltered()._branchcaches.clear()
+self._branchcaches.clear()
 self.invalidatevolatilesets()
 self._sparsesignaturecache.clear()
 
diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -43,75 +43,89 @@
'served': 'immutable',
'immutable': 'base'}
 
-def updatecache(repo):
-"""Update the cache for the given filtered view on a repository"""
-# This can trigger updates for the caches for subsets of the filtered
-# view, e.g. when there is no cache for this filtered view or the cache
-# is stale.
+
+class BranchMapCache(object):
+"""Cache mapping"""
+def __init__(self):
+self._per_filter = {}
 
-cl = repo.changelog
-filtername = repo.filtername
-bcache = repo._branchcaches.get(filtername)
-if bcache is None or not bcache.validfor(repo):
-# cache object missing or cache object stale? Read from disk
-bcache = branchcache.fromfile(repo)
+def __getitem__(self, repo):
+self.updatecache(repo)
+return self._per_filter[repo.filtername]
+
+def updatecache(self, repo):
+"""Update the cache for the given filtered view on a repository"""
+# This can trigger updates for the caches for subsets of the filtered
+# view, e.g. when there is no cache for this filtered view or the cache
+# is stale.
 
-revs = []
-if bcache is None:
-# no (fresh) cache available anymore, perhaps we can re-use
-# the cache for a subset, then extend that to add info on missing
-# revisions.
-subsetname = subsettable.get(filtername)
-if subsetname is not None:
-subset = repo.filtered(subsetname)
-bcache = subset.branchmap().copy()
-extrarevs = subset.changelog.filteredrevs - cl.filteredrevs
-revs.extend(r for r in extrarevs if r <= bcache.tiprev)
-else:
-# nothing to fall back on, start empty.
-bcache = branchcache()
+cl = repo.changelog
+   

D5637: branchmap: add some clarifications and clean up flow

2019-01-21 Thread mjpieters (Martijn Pieters)
mjpieters created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  - Remove indentation where it is not needed.
  
  - Swap the subset test branches to follow along logically and put the 'empty' 
case last.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/branchmap.py

CHANGE DETAILS

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -44,22 +44,33 @@
'immutable': 'base'}
 
 def updatecache(repo):
+"""Update the cache for the given filtered view on a repository"""
+# This can trigger updates for the caches for subsets of the filtered
+# view, e.g. when there is no cache for this filtered view or the cache
+# is stale.
+
 cl = repo.changelog
 filtername = repo.filtername
 bcache = repo._branchcaches.get(filtername)
+if bcache is None or not bcache.validfor(repo):
+# cache object missing or cache object stale? Read from disk
+bcache = branchcache.fromfile(repo)
 
 revs = []
-if bcache is None or not bcache.validfor(repo):
-bcache = branchcache.fromfile(repo)
-if bcache is None:
-subsetname = subsettable.get(filtername)
-if subsetname is None:
-bcache = branchcache()
-else:
-subset = repo.filtered(subsetname)
-bcache = subset.branchmap().copy()
-extrarevs = subset.changelog.filteredrevs - cl.filteredrevs
-revs.extend(r for  r in extrarevs if r <= bcache.tiprev)
+if bcache is None:
+# no (fresh) cache available anymore, perhaps we can re-use
+# the cache for a subset, then extend that to add info on missing
+# revisions.
+subsetname = subsettable.get(filtername)
+if subsetname is not None:
+subset = repo.filtered(subsetname)
+bcache = subset.branchmap().copy()
+extrarevs = subset.changelog.filteredrevs - cl.filteredrevs
+revs.extend(r for r in extrarevs if r <= bcache.tiprev)
+else:
+# nothing to fall back on, start empty.
+bcache = branchcache()
+
 revs.extend(cl.revs(start=bcache.tiprev + 1))
 if revs:
 bcache.update(repo, revs)



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


D5635: branchmap: make branchcache responsible for reading

2019-01-21 Thread mjpieters (Martijn Pieters)
mjpieters created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Encapsulate reading in a classmethod, to make it clear what kind of object is
  being handled.
  
  This is part of a stack of refactoring changes to help performance 
improvements
  down the line.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/perf.py
  mercurial/branchmap.py

CHANGE DETAILS

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -30,63 +30,6 @@
 pack_into = struct.pack_into
 unpack_from = struct.unpack_from
 
-def _filename(repo):
-"""name of a branchcache file for a given repo or repoview"""
-filename = "branch2"
-if repo.filtername:
-filename = '%s-%s' % (filename, repo.filtername)
-return filename
-
-def read(repo):
-f = None
-try:
-f = repo.cachevfs(_filename(repo))
-lineiter = iter(f)
-cachekey = next(lineiter).rstrip('\n').split(" ", 2)
-last, lrev = cachekey[:2]
-last, lrev = bin(last), int(lrev)
-filteredhash = None
-if len(cachekey) > 2:
-filteredhash = bin(cachekey[2])
-bcache = branchcache(tipnode=last, tiprev=lrev,
-  filteredhash=filteredhash)
-if not bcache.validfor(repo):
-# invalidate the cache
-raise ValueError(r'tip differs')
-cl = repo.changelog
-for l in lineiter:
-l = l.rstrip('\n')
-if not l:
-continue
-node, state, label = l.split(" ", 2)
-if state not in 'oc':
-raise ValueError(r'invalid branch state')
-label = encoding.tolocal(label.strip())
-node = bin(node)
-if not cl.hasnode(node):
-raise ValueError(
-r'node %s does not exist' % pycompat.sysstr(hex(node)))
-bcache.setdefault(label, []).append(node)
-if state == 'c':
-bcache._closednodes.add(node)
-
-except (IOError, OSError):
-return None
-
-except Exception as inst:
-if repo.ui.debugflag:
-msg = 'invalid branchheads cache'
-if repo.filtername is not None:
-msg += ' (%s)' % repo.filtername
-msg += ': %s\n'
-repo.ui.debug(msg % pycompat.bytestr(inst))
-bcache = None
-
-finally:
-if f:
-f.close()
-
-return bcache
 
 ### Nearest subset relation
 # Nearest subset of filter X is a filter Y so that:
@@ -107,7 +50,7 @@
 
 revs = []
 if bcache is None or not bcache.validfor(repo):
-bcache = read(repo)
+bcache = branchcache.fromfile(repo)
 if bcache is None:
 subsetname = subsettable.get(filtername)
 if subsetname is None:
@@ -181,6 +124,64 @@
 This field can be used to avoid changelog reads when determining if a
 branch head closes a branch or not.
 """
+@classmethod
+def fromfile(cls, repo):
+f = None
+try:
+f = repo.cachevfs(cls._filename(repo))
+lineiter = iter(f)
+cachekey = next(lineiter).rstrip('\n').split(" ", 2)
+last, lrev = cachekey[:2]
+last, lrev = bin(last), int(lrev)
+filteredhash = None
+if len(cachekey) > 2:
+filteredhash = bin(cachekey[2])
+bcache = cls(tipnode=last, tiprev=lrev, filteredhash=filteredhash)
+if not bcache.validfor(repo):
+# invalidate the cache
+raise ValueError(r'tip differs')
+cl = repo.changelog
+for line in lineiter:
+line = line.rstrip('\n')
+if not line:
+continue
+node, state, label = line.split(" ", 2)
+if state not in 'oc':
+raise ValueError(r'invalid branch state')
+label = encoding.tolocal(label.strip())
+node = bin(node)
+if not cl.hasnode(node):
+raise ValueError(
+r'node %s does not exist' % pycompat.sysstr(hex(node)))
+bcache.setdefault(label, []).append(node)
+if state == 'c':
+bcache._closednodes.add(node)
+
+except (IOError, OSError):
+return None
+
+except Exception as inst:
+if repo.ui.debugflag:
+msg = 'invalid branchheads cache'
+if repo.filtername is not None:
+msg += ' (%s)' % repo.filtername
+msg += ': %s\n'
+repo.ui.debug(msg % pycompat.bytestr(inst))
+bcache = None
+
+finally:
+if f:
+f.close()
+
+return bcache
+
+

D5636: branchmap: updating triggers a write

2019-01-21 Thread mjpieters (Martijn Pieters)
mjpieters created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Rather than separate updating and writing, create a subclass that doesn't 
write
  on update. This minimises chances we forget to write out updates somewhere.
  
  This also makes refactoring and improving the branchmap functionality easier.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/branchmap.py
  mercurial/discovery.py

CHANGE DETAILS

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -238,7 +238,7 @@
 
 # D. Update newmap with outgoing changes.
 # This will possibly add new heads and remove existing ones.
-newmap = branchmap.branchcache((branch, heads[1])
+newmap = branchmap.remotebranchcache((branch, heads[1])
  for branch, heads in headssum.iteritems()
  if heads[0] is not None)
 newmap.update(repo, (ctx.rev() for ctx in missingctx))
diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -63,7 +63,6 @@
 revs.extend(cl.revs(start=bcache.tiprev + 1))
 if revs:
 bcache.update(repo, revs)
-bcache.write(repo)
 
 assert bcache.validfor(repo), filtername
 repo._branchcaches[repo.filtername] = bcache
@@ -242,8 +241,9 @@
 
 def copy(self):
 """return an deep copy of the branchcache object"""
-return branchcache(self, self.tipnode, self.tiprev, self.filteredhash,
-   self._closednodes)
+return type(self)(
+self, self.tipnode, self.tiprev, self.filteredhash,
+self._closednodes)
 
 def write(self, repo):
 try:
@@ -332,6 +332,15 @@
 repo.ui.log('branchcache', 'updated %s branch cache in %.4f seconds\n',
 repo.filtername, duration)
 
+self.write(repo)
+
+
+class remotebranchcache(branchcache):
+"""Branchmap info for a remote connection, should not write locally"""
+def write(self, repo):
+pass
+
+
 # Revision branch info cache
 
 _rbcversion = '-v1'



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


D5290: branchmap: rename partial -> bcache

2019-01-21 Thread mjpieters (Martijn Pieters)
mjpieters updated this revision to Diff 13329.
mjpieters edited the summary of this revision.
mjpieters retitled this revision from "branchmap: refactor for better 
encapsulation" to "branchmap: rename partial -> bcache".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5290?vs=12573=13329

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

AFFECTED FILES
  mercurial/branchmap.py

CHANGE DETAILS

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -48,9 +48,9 @@
 filteredhash = None
 if len(cachekey) > 2:
 filteredhash = bin(cachekey[2])
-partial = branchcache(tipnode=last, tiprev=lrev,
+bcache = branchcache(tipnode=last, tiprev=lrev,
   filteredhash=filteredhash)
-if not partial.validfor(repo):
+if not bcache.validfor(repo):
 # invalidate the cache
 raise ValueError(r'tip differs')
 cl = repo.changelog
@@ -66,9 +66,9 @@
 if not cl.hasnode(node):
 raise ValueError(
 r'node %s does not exist' % pycompat.sysstr(hex(node)))
-partial.setdefault(label, []).append(node)
+bcache.setdefault(label, []).append(node)
 if state == 'c':
-partial._closednodes.add(node)
+bcache._closednodes.add(node)
 
 except (IOError, OSError):
 return None
@@ -80,13 +80,13 @@
 msg += ' (%s)' % repo.filtername
 msg += ': %s\n'
 repo.ui.debug(msg % pycompat.bytestr(inst))
-partial = None
+bcache = None
 
 finally:
 if f:
 f.close()
 
-return partial
+return bcache
 
 ### Nearest subset relation
 # Nearest subset of filter X is a filter Y so that:
@@ -103,27 +103,27 @@
 def updatecache(repo):
 cl = repo.changelog
 filtername = repo.filtername
-partial = repo._branchcaches.get(filtername)
+bcache = repo._branchcaches.get(filtername)
 
 revs = []
-if partial is None or not partial.validfor(repo):
-partial = read(repo)
-if partial is None:
+if bcache is None or not bcache.validfor(repo):
+bcache = read(repo)
+if bcache is None:
 subsetname = subsettable.get(filtername)
 if subsetname is None:
-partial = branchcache()
+bcache = branchcache()
 else:
 subset = repo.filtered(subsetname)
-partial = subset.branchmap().copy()
+bcache = subset.branchmap().copy()
 extrarevs = subset.changelog.filteredrevs - cl.filteredrevs
-revs.extend(r for  r in extrarevs if r <= partial.tiprev)
-revs.extend(cl.revs(start=partial.tiprev + 1))
+revs.extend(r for  r in extrarevs if r <= bcache.tiprev)
+revs.extend(cl.revs(start=bcache.tiprev + 1))
 if revs:
-partial.update(repo, revs)
-partial.write(repo)
+bcache.update(repo, revs)
+bcache.write(repo)
 
-assert partial.validfor(repo), filtername
-repo._branchcaches[repo.filtername] = partial
+assert bcache.validfor(repo), filtername
+repo._branchcaches[repo.filtername] = bcache
 
 def replacecache(repo, bm):
 """Replace the branchmap cache for a repo with a branch mapping.



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


Re: [PATCH 3 of 3 STABLE] rust: add comment about lack of wdirrev handling

2019-01-21 Thread Georges Racinet


Le 20 janvier 2019 04:11:11 GMT+01:00, Yuya Nishihara  a écrit :
># HG changeset patch
># User Yuya Nishihara 
># Date 1547953056 -32400
>#  Sun Jan 20 11:57:36 2019 +0900
># Branch stable
># Node ID 13c23396c7fe1633a2336b29e3a32b9b76274f28
># Parent  66102f6fa10aa533a658532b198cd6879a538406
>rust: add comment about lack of wdirrev handling
>
>If hg is compiled with rust support, 'only(wdir())' crashed as
>"rustext.GraphError: ('ParentOutOfRange', 2147483647)", which should
>instead
>say "abort: working directory revision cannot be specified."

I can fix that easily if you like, and it seems possible to me that rust-core 
could get awareness of wdirrev and that rust-cpython would raise the proper 
exception.

If that's too much for the stable branch, a simple try/except as is already 
done in the C case would be enough.


>
>diff --git a/mercurial/revlog.py b/mercurial/revlog.py
>--- a/mercurial/revlog.py
>+++ b/mercurial/revlog.py
>@@ -896,6 +896,8 @@ class revlog(object):
> common = [nullrev]
> 
> if rustext is not None:
>+# TODO: WdirUnsupported should be raised instead of
>GraphError
>+# if common includes wdirrev
>   return rustext.ancestor.MissingAncestors(self.index, common)
>   return ancestor.incrementalmissingancestors(self.parentrevs, common)
> 
>___
>Mercurial-devel mailing list
>Mercurial-devel@mercurial-scm.org
>https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma 
brièveté.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH STABLE] revlog: fix resolution of revlog version 0

2019-01-21 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1548076469 -32400
#  Mon Jan 21 22:14:29 2019 +0900
# Branch stable
# Node ID 498a5d7f8e19d6b430f300ff6687a92270022f81
# Parent  13c23396c7fe1633a2336b29e3a32b9b76274f28
revlog: fix resolution of revlog version 0

This partially backs out cecf3f8bccd3, "revlog: always process opener options."

My understanding is that if there's no "revlog1" nor "revlog2" in .hg/requires,
the repository should stick to the v0 format. The reasoning is briefly
described in 31a5973fcf96, "revlog: get rid of defversion."

Maybe we can drop support for missing opener options, but I didn't do that
in this patch.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -396,6 +396,11 @@ class revlog(object):
 newversionflags = REVLOGV1 | FLAG_INLINE_DATA
 if 'generaldelta' in opts:
 newversionflags |= FLAG_GENERALDELTA
+elif getattr(self.opener, 'options', None) is not None:
+# If options provided but no 'revlog*' found, the repository
+# would have no 'requires' file in it, which means we have to
+# stick to the old format.
+newversionflags = REVLOGV0
 else:
 newversionflags = REVLOG_DEFAULT_VERSION
 
diff --git a/tests/test-clone.t b/tests/test-clone.t
--- a/tests/test-clone.t
+++ b/tests/test-clone.t
@@ -717,6 +717,9 @@ Test clone from the repository in (emula
   $ hg -R src commit -m '#0'
   $ hg -R src log -q
   0:e1bab28bca43
+  $ hg -R src debugrevlog -c | egrep 'format|flags'
+  format : 0
+  flags  : (none)
   $ hg clone -U -q src dst
   $ hg -R dst log -q
   0:e1bab28bca43
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel