[PATCH 2 of 3 evolve-ext] stablerangecache: use self instead of repo in stablerangerepo.stablerange()
# HG changeset patch # User Anton Shestakov # Date 1522996596 -28800 # Fri Apr 06 14:36:36 2018 +0800 # Node ID ce9f0f1cfbc2bc7fd305625d9da79953fcd43fe1 # Parent 58ee2c2c7cdf8671c181035c5293bbbc91a3f05f stablerangecache: use self instead of repo in stablerangerepo.stablerange() Referring to repo here was somehow preventing it from being garbage-collected (important in hgweb, where currently every request gets a new repo). diff --git a/hgext3rd/evolve/stablerangecache.py b/hgext3rd/evolve/stablerangecache.py --- a/hgext3rd/evolve/stablerangecache.py +++ b/hgext3rd/evolve/stablerangecache.py @@ -353,8 +353,8 @@ def setupcache(ui, repo): @localrepo.unfilteredpropertycache def stablerange(self): -cache = mergepointsql(repo) -cache.update(repo) +cache = mergepointsql(self) +cache.update(self) return cache @localrepo.unfilteredmethod ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 3 of 3 evolve-ext] safeguard: use self instead of repo in noautopublishrepo.checkpush()
# HG changeset patch # User Anton Shestakov # Date 1522996642 -28800 # Fri Apr 06 14:37:22 2018 +0800 # Node ID 86695bae7a72ae1b64ec6d1fa9370abf473f6544 # Parent ce9f0f1cfbc2bc7fd305625d9da79953fcd43fe1 safeguard: use self instead of repo in noautopublishrepo.checkpush() Referring to repo here was somehow preventing it from being garbage-collected (important in hgweb, where currently every request gets a new repo). diff --git a/hgext3rd/evolve/safeguard.py b/hgext3rd/evolve/safeguard.py --- a/hgext3rd/evolve/safeguard.py +++ b/hgext3rd/evolve/safeguard.py @@ -25,17 +25,17 @@ def setuppublishprevention(ui, repo): def checkpush(self, pushop): super(noautopublishrepo, self).checkpush(pushop) -behavior = repo.ui.config('experimental', 'auto-publish', 'default') +behavior = self.ui.config('experimental', 'auto-publish', 'default') remotephases = pushop.remote.listkeys('phases') publishing = remotephases.get('publishing', False) if behavior in ('warn', 'abort') and publishing: if pushop.revs is None: -published = repo.filtered('served').revs("not public()") +published = self.filtered('served').revs("not public()") else: -published = repo.revs("::%ln - public()", pushop.revs) +published = self.revs("::%ln - public()", pushop.revs) if published: if behavior == 'warn': -repo.ui.warn(_('%i changesets about to be published\n') % len(published)) +self.ui.warn(_('%i changesets about to be published\n') % len(published)) elif behavior == 'abort': msg = _('push would publish 1 changesets') hint = _("behavior controlled by 'experimental.auto-publish' config") ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 1 of 3 evolve-ext] obscache: use self instead of repo in obscacherepo.updatecaches()
# HG changeset patch # User Anton Shestakov # Date 1522995984 -28800 # Fri Apr 06 14:26:24 2018 +0800 # Node ID 58ee2c2c7cdf8671c181035c5293bbbc91a3f05f # Parent 01108d67523ff366e18ba324e64edf527d8df1e5 obscache: use self instead of repo in obscacherepo.updatecaches() Referring to repo here was somehow preventing it from being garbage-collected (important in hgweb, where currently every request gets a new repo). diff --git a/hgext3rd/evolve/obscache.py b/hgext3rd/evolve/obscache.py --- a/hgext3rd/evolve/obscache.py +++ b/hgext3rd/evolve/obscache.py @@ -527,8 +527,8 @@ def setupcache(ui, repo): @localrepo.unfilteredmethod def updatecaches(self, tr=None, **kwargs): super(obscacherepo, self).updatecaches(tr, **kwargs) -self.obsstore.obscache.update(repo) -self.obsstore.obscache.save(repo) +self.obsstore.obscache.update(self) +self.obsstore.obscache.save(self) else: def transaction(self, *args, **kwargs): ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3146: context: move handling of stringified ints to revsymbol (API)
martinvonz planned changes to this revision. martinvonz added a comment. I should decide what to do about the `changeid == repo.dirstate.p1()` case before this patch. Also, I may find more cases that should be fixed when I move out other parts (I just found one case in hgweb), so please hold off reviewing this. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3146 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
D3150: revlog: move parsemeta() and packmeta() from filelog (API)
indygreg updated this revision to Diff 7769. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3150?vs=7764&id=7769 REVISION DETAIL https://phab.mercurial-scm.org/D3150 AFFECTED FILES hgext/censor.py hgext/lfs/wrapper.py mercurial/filelog.py mercurial/revlog.py tests/simplestorerepo.py CHANGE DETAILS diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py --- a/tests/simplestorerepo.py +++ b/tests/simplestorerepo.py @@ -32,7 +32,6 @@ bundlerepo, error, extensions, -filelog, localrepo, mdiff, pycompat, @@ -326,7 +325,7 @@ return False fulltext = self.revision(node) -m = filelog.parsemeta(fulltext)[0] +m = revlog.parsemeta(fulltext)[0] if m and 'copy' in m: return m['copy'], bin(m['copyrev']) @@ -415,7 +414,7 @@ def add(self, text, meta, transaction, linkrev, p1, p2): if meta or text.startswith(b'\1\n'): -text = filelog.packmeta(meta, text) +text = revlog.packmeta(meta, text) return self.addrevision(text, transaction, linkrev, p1, p2) diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -19,6 +19,7 @@ import hashlib import heapq import os +import re import struct import zlib @@ -97,6 +98,25 @@ REVIDX_ISCENSORED: None, } +_mdre = re.compile('\1\n') +def parsemeta(text): +"""return (metadatadict, metadatasize)""" +# text can be buffer, so we can't use .startswith or .index +if text[:2] != '\1\n': +return None, None +s = _mdre.search(text, 2).start() +mtext = text[2:s] +meta = {} +for l in mtext.splitlines(): +k, v = l.split(": ", 1) +meta[k] = v +return meta, (s + 2) + +def packmeta(meta, text): +keys = sorted(meta) +metatext = "".join("%s: %s\n" % (k, meta[k]) for k in keys) +return "\1\n%s\1\n%s" % (metatext, text) + def addflagprocessor(flag, processor): """Register a flag processor on a revision data flag. diff --git a/mercurial/filelog.py b/mercurial/filelog.py --- a/mercurial/filelog.py +++ b/mercurial/filelog.py @@ -7,7 +7,6 @@ from __future__ import absolute_import -import re import struct from .thirdparty.zope import ( @@ -20,27 +19,8 @@ revlog, ) -_mdre = re.compile('\1\n') -def parsemeta(text): -"""return (metadatadict, metadatasize)""" -# text can be buffer, so we can't use .startswith or .index -if text[:2] != '\1\n': -return None, None -s = _mdre.search(text, 2).start() -mtext = text[2:s] -meta = {} -for l in mtext.splitlines(): -k, v = l.split(": ", 1) -meta[k] = v -return meta, (s + 2) - -def packmeta(meta, text): -keys = sorted(meta) -metatext = "".join("%s: %s\n" % (k, meta[k]) for k in keys) -return "\1\n%s\1\n%s" % (metatext, text) - def _censoredtext(text): -m, offs = parsemeta(text) +m, offs = revlog.parsemeta(text) return m and "censored" in m @zi.implementer(repository.ifilestorage) @@ -60,14 +40,14 @@ def add(self, text, meta, transaction, link, p1=None, p2=None): if meta or text.startswith('\1\n'): -text = packmeta(meta, text) +text = revlog.packmeta(meta, text) return self.addrevision(text, transaction, link, p1, p2) def renamed(self, node): if self.parents(node)[0] != revlog.nullid: return False t = self.revision(node) -m = parsemeta(t)[0] +m = revlog.parsemeta(t)[0] if m and "copy" in m: return (m["copy"], revlog.bin(m["copyrev"])) return False diff --git a/hgext/lfs/wrapper.py b/hgext/lfs/wrapper.py --- a/hgext/lfs/wrapper.py +++ b/hgext/lfs/wrapper.py @@ -14,7 +14,6 @@ from mercurial import ( error, -filelog, revlog, util, ) @@ -69,13 +68,13 @@ name = k[len('x-hg-'):] hgmeta[name] = p[k] if hgmeta or text.startswith('\1\n'): -text = filelog.packmeta(hgmeta, text) +text = revlog.packmeta(hgmeta, text) return (text, True) def writetostore(self, text): # hg filelog metadata (includes rename, etc) -hgmeta, offset = filelog.parsemeta(text) +hgmeta, offset = revlog.parsemeta(text) if offset and offset > 0: # lfs blob does not contain hg filelog metadata text = text[offset:] @@ -121,7 +120,7 @@ flags=revlog.REVIDX_DEFAULT_FLAGS, **kwds): textlen = len(text) # exclude hg rename meta from file size -meta, offset = filelog.parsemeta(text) +meta, offset = revlog.parsemeta(text) if offset: textlen -= offset diff --git a/hgext/censor.py b/hgext/censor.py --- a/hgext/censor.py +++ b/hgext/censor.py @@ -32,7 +32,6 @@ from mercurial import ( error, -filelog, lock as lockmod, registrar, revlog, @@ -106,7 +105,7
D3154: filelog: wrap revlog instead of inheriting it (API)
indygreg added a comment. I want to draw attention to this patch for the potential performance concerns. Like I said in the commit message, I'd love to know what the performance impact is. I'm just not sure which revlog/filelog attributes/methods are called in tight loops outside of revlog/filelog itself. If the proxy methods are an issue, it /might/ be faster to use `__new__` to hack up each instance so its `self.__dict__[x]` contained pointers to `revlog` functions bound as methods to the `self._revlog` instance. Super hacky. That's why I'd like evidence that performance is a real concern before implementing it. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3154 To: indygreg, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3147: tests: run some largefiles and lfs tests with simple store
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Now that the simple store handles flags properly, a handful of the largefiles and lfs tests pass! REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3147 AFFECTED FILES tests/test-largefiles-cache.t tests/test-largefiles-misc.t tests/test-largefiles-small-disk.t tests/test-largefiles-wireproto.t tests/test-largefiles.t tests/test-lfconvert.t tests/test-lfs-bundle.t CHANGE DETAILS diff --git a/tests/test-lfs-bundle.t b/tests/test-lfs-bundle.t --- a/tests/test-lfs-bundle.t +++ b/tests/test-lfs-bundle.t @@ -1,5 +1,3 @@ -#require no-reposimplestore - In this test, we want to test LFS bundle application on both LFS and non-LFS repos. diff --git a/tests/test-lfconvert.t b/tests/test-lfconvert.t --- a/tests/test-lfconvert.t +++ b/tests/test-lfconvert.t @@ -1,5 +1,3 @@ -#require no-reposimplestore - $ USERCACHE="$TESTTMP/cache"; export USERCACHE $ mkdir "${USERCACHE}" $ cat >> $HGRCPATH < criple.py
D3151: revlog: move censor logic into main revlog class
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Previously, the revlog class implemented dummy methods for various censor-related functionality. Revision censoring was (and will continue to be) only possible on filelog instances. So filelog implemented these methods to perform something reasonable. A problem with implementing censoring on filelog is that it assumes filelog is a revlog. Upcoming work to formalize the filelog interface will make this not true. Furthermore, the censoring logic is security-sensitive. I think action-at-a-distance with custom implementation of core revlog APIs in derived classes is a bit dangerous. I think at a minimum the censor logic should live in revlog.py. I was tempted to created a "censored revlog" class that basically pulled these methods out of filelog. But, I wasn't a huge fan of overriding core methods in child classes. A reason to do that would be performance. However, the censoring code only comes into play when: - hash verification fails - delta generation - applying deltas from changegroups The new code is conditional on an instance attribute. So the overhead for running the censored code when the revlog isn't censorable is an attribute lookup. All of these operations are at least a magnitude slower than a Python attribute lookup. So there shouldn't be a performance concern. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3151 AFFECTED FILES mercurial/filelog.py mercurial/revlog.py CHANGE DETAILS diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -117,6 +117,10 @@ metatext = "".join("%s: %s\n" % (k, meta[k]) for k in keys) return "\1\n%s\1\n%s" % (metatext, text) +def _censoredtext(text): +m, offs = parsemeta(text) +return m and "censored" in m + def addflagprocessor(flag, processor): """Register a flag processor on a revision data flag. @@ -574,9 +578,11 @@ If mmaplargeindex is True, and an mmapindexthreshold is set, the index will be mmapped rather than read if it is larger than the configured threshold. + +If censorable is True, the revlog can have censored revisions. """ def __init__(self, opener, indexfile, datafile=None, checkambig=False, - mmaplargeindex=False): + mmaplargeindex=False, censorable=False): """ create a revlog object @@ -589,6 +595,7 @@ # When True, indexfile is opened with checkambig=True at writing, to # avoid file stat ambiguity. self._checkambig = checkambig +self._censorable = censorable # 3-tuple of (node, rev, text) for a raw revision. self._cache = None # Maps rev to chain base rev. @@ -1867,14 +1874,19 @@ Available as a function so that subclasses can extend hash mismatch behaviors as needed. """ -if p1 is None and p2 is None: -p1, p2 = self.parents(node) -if node != self.hash(text, p1, p2): -revornode = rev -if revornode is None: -revornode = templatefilters.short(hex(node)) -raise RevlogError(_("integrity check failed on %s:%s") -% (self.indexfile, pycompat.bytestr(revornode))) +try: +if p1 is None and p2 is None: +p1, p2 = self.parents(node) +if node != self.hash(text, p1, p2): +revornode = rev +if revornode is None: +revornode = templatefilters.short(hex(node)) +raise RevlogError(_("integrity check failed on %s:%s") +% (self.indexfile, pycompat.bytestr(revornode))) +except RevlogError: +if self._censorable and _censoredtext(text): +raise error.CensoredNodeError(self.indexfile, node, text) +raise def _enforceinlinesize(self, tr, fp=None): """Check if the revlog is too big for inline and convert if so. @@ -2300,11 +2312,33 @@ def iscensored(self, rev): """Check if a file revision is censored.""" -return False +if not self._censorable: +return False + +return self.flags(rev) & REVIDX_ISCENSORED def _peek_iscensored(self, baserev, delta, flush): """Quickly check if a delta produces a censored revision.""" -return False +if not self._censorable: +return False + +# Fragile heuristic: unless new file meta keys are added alphabetically +# preceding "censored", all censored revisions are prefixed by +# "\1\ncensored:". A delta producing such a censored revision must be a +# full-replacement delta, so we inspect the first and only patch in the +# delta for this prefix. +
D3149: filelog: declare that filelog implements a storage interface
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Now that we have a declared interface, let's declare that filelog implements it. Tests have been added that confirm the object conforms to the interface. The existing interface checks verify there are no extra public attributes outside the declared interface. filelog has several extra attributes. So we added a mechanism to suppress this check. The goal is to modify the filelog class so we can drop this check. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3149 AFFECTED FILES mercurial/filelog.py tests/simplestorerepo.py tests/test-check-interfaces.py CHANGE DETAILS diff --git a/tests/test-check-interfaces.py b/tests/test-check-interfaces.py --- a/tests/test-check-interfaces.py +++ b/tests/test-check-interfaces.py @@ -12,20 +12,22 @@ ) from mercurial import ( bundlerepo, +filelog, httppeer, localrepo, repository, sshpeer, statichttprepo, ui as uimod, unionrepo, +vfs as vfsmod, wireprotoserver, wireprototypes, ) rootdir = os.path.normpath(os.path.join(os.path.dirname(__file__), '..')) -def checkzobject(o): +def checkzobject(o, allowextra=False): """Verify an object with a zope interface.""" ifaces = zi.providedBy(o) if not ifaces: @@ -37,6 +39,9 @@ for iface in ifaces: ziverify.verifyObject(iface, o) +if allowextra: +return + # Now verify that the object provides no extra public attributes that # aren't declared as part of interfaces. allowed = set() @@ -132,4 +137,10 @@ httpv2 = wireprotoserver.httpv2protocolhandler(None, None) checkzobject(httpv2) +ziverify.verifyClass(repository.ifilestorage, filelog.filelog) + +vfs = vfsmod.vfs('.') +fl = filelog.filelog(vfs, 'dummy.i') +checkzobject(fl, allowextra=True) + main() diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py --- a/tests/simplestorerepo.py +++ b/tests/simplestorerepo.py @@ -24,6 +24,9 @@ from mercurial.thirdparty import ( cbor, ) +from mercurial.thirdparty.zope import ( +interface as zi, +) from mercurial import ( ancestor, bundlerepo, @@ -33,6 +36,7 @@ localrepo, mdiff, pycompat, +repository, revlog, store, verify, @@ -57,6 +61,7 @@ if not isinstance(rev, int): raise ValueError('expected int') +@zi.implementer(repository.ifilestorage) class filestorage(object): """Implements storage for a tracked path. diff --git a/mercurial/filelog.py b/mercurial/filelog.py --- a/mercurial/filelog.py +++ b/mercurial/filelog.py @@ -10,9 +10,13 @@ import re import struct +from .thirdparty.zope import ( +interface as zi, +) from . import ( error, mdiff, +repository, revlog, ) @@ -39,6 +43,7 @@ m, offs = parsemeta(text) return m and "censored" in m +@zi.implementer(repository.ifilestorage) class filelog(revlog.revlog): def __init__(self, opener, path): super(filelog, self).__init__(opener, To: indygreg, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3153: tests: call rawsize() directly
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY rawsize() is not reimplemented outside of revlog. I'm not sure why this code was insisting it call a specific implementation. Changing it to call rawsize() on the repo.file(f) result seems to work just fine. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3153 AFFECTED FILES tests/test-lfs.t CHANGE DETAILS diff --git a/tests/test-lfs.t b/tests/test-lfs.t --- a/tests/test-lfs.t +++ b/tests/test-lfs.t @@ -630,7 +630,7 @@ > fl = repo.file(name) > if len(fl) == 0: > continue - > sizes = [revlog.revlog.rawsize(fl, i) for i in fl] + > sizes = [fl.rawsize(i) for i in fl] > texts = [fl.revision(i, raw=True) for i in fl] > flags = [int(fl.flags(i)) for i in fl] > hashes = [hash(t) for t in texts] To: indygreg, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3152: upgrade: sniff for filelog type
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY The upgrade code should never encounter a vanilla revlog instance: only changelog, manifestrevlog, and filelog should be seen. The previous code assumed !changelog & !manifestrevlog meant file data. So this change feels pretty safe. If nothing else, it will help tease out typing issues. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3152 AFFECTED FILES mercurial/upgrade.py CHANGE DETAILS diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py --- a/mercurial/upgrade.py +++ b/mercurial/upgrade.py @@ -480,11 +480,13 @@ mrevcount += len(rl) msrcsize += datasize mrawsize += rawsize -elif isinstance(rl, revlog.revlog): +elif isinstance(rl, filelog.filelog): fcount += 1 frevcount += len(rl) fsrcsize += datasize frawsize += rawsize +else: +error.ProgrammingError('unknown revlog type') if not revcount: return To: indygreg, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3148: repository: define existing interface for file storage
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Now that we have mostly successfully implemented an alternate storage backend for files data, let's start to define the interface for it! This commit takes the mostly-working interface as defined by the simple store repo and codifies it as the file storage interface. The interface has been split into its logical components: - index metadata - fulltext data - mutation - everything else I don't consider the existing interface to be great. But it will help to have it more formally defined so we can start chipping away at refactoring it. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3148 AFFECTED FILES mercurial/repository.py CHANGE DETAILS diff --git a/mercurial/repository.py b/mercurial/repository.py --- a/mercurial/repository.py +++ b/mercurial/repository.py @@ -251,6 +251,334 @@ class legacypeer(peer): """peer but with support for legacy wire protocol commands.""" +class ifilerevisionssequence(zi.Interface): +"""Contains index data for all revisions of a file. + +Types implementing this behave like lists of tuples. The index +in the list corresponds to the revision number. The values contain +index metadata. + +The *null* revision (revision number -1) is always the last item +in the index. +""" + +def __len__(): +"""The total number of revisions.""" + +def __getitem__(rev): +"""Returns the object having a specific revision number. + +Returns an 8-tuple with the following fields: + +offset+flags + Contains the offset and flags for the revision. 64-bit unsigned + integer where first 6 bytes are the offset and the next 2 bytes + are flags. The offset can be 0 if it is not used by the store. +compressed size +Size of the revision data in the store. It can be 0 if it isn't +needed by the store. +uncompressed size +Fulltext size. It can be 0 if it isn't needed by the store. +base revision +Revision number of revision the delta for storage is encoded +against. -1 indicates not encoded against a base revision. +link revision +Revision number of changelog revision this entry is related to. +p1 revision +Revision number of 1st parent. -1 if no 1st parent. +p2 revision +Revision number of 2nd parent. -1 if no 1st parent. +node +Binary node value for this revision number. + +Negative values should index off the end of the sequence. ``-1`` +should return the null revision. ``-2`` should return the most +recent revision. +""" + +def __contains__(rev): +"""Whether a revision number exists.""" + +def insert(self, i, entry): +"""Add an item to the index at specific revision.""" + +class ifileindex(zi.Interface): +"""Storage interface for index data of a single file. + +File storage data is divided into index metadata and data storage. +This interface defines the index portion of the interface. + +The index logically consists of: + +* A mapping between revision numbers and nodes. +* DAG data (storing and querying the relationship between nodes). +* Metadata to facilitate storage. +""" +index = zi.Attribute( +"""An ``ifilerevisionssequence`` instance.""") + +def __len__(): +"""Obtain the number of revisions stored for this file.""" + +def __iter__(): +"""Iterate over revision numbers for this file.""" + +def revs(start=0, stop=None): +"""Iterate over revision numbers for this file, with control.""" + +def parents(node): +"""Returns a 2-tuple of parent nodes for a revision. + +Values will be ``nullid`` if the parent is empty. +""" + +def parentrevs(rev): +"""Like parents() but operates on revision numbers.""" + +def rev(node): +"""Obtain the revision number given a node. + +Raises ``error.LookupError`` if the node is not known. +""" + +def node(rev): +"""Obtain the node value given a revision number. + +Raises ``IndexError`` if the node is not known. +""" + +def lookup(node): +"""Attempt to resolve a value to a node. + +Value can be a binary node, hex node, revision number, or a string +that can be converted to an integer. + +Raises ``error.LookupError`` if a node could not be resolved. +""" + +def linkrev(rev): +"""Obtain the changeset revision number a revision is linked to.""" + +def flags(rev): +"""Obtain flags used to affect storage of a revision.""" + +def iscensored(rev): +"""Return whether a revision's content has been censored.""" + +def
D3150: revlog: move parsemeta() and packmeta() from filelog (API)
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY filelog.parsemeta() and filelog.packmeta() are used to decode and encode metadata for file copies and censor. An upcoming commit will move the core logic for censoring revlogs into revlog.py. This would create a cycle between revlog.py and filelog.py. So we move these metadata functions to revlog.py. .. api:: filelog.parsemeta() and filelog.packmeta() have been moved to the revlog module. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3150 AFFECTED FILES hgext/censor.py hgext/lfs/wrapper.py mercurial/filelog.py mercurial/revlog.py tests/simplestorerepo.py CHANGE DETAILS diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py --- a/tests/simplestorerepo.py +++ b/tests/simplestorerepo.py @@ -326,7 +326,7 @@ return False fulltext = self.revision(node) -m = filelog.parsemeta(fulltext)[0] +m = revlog.parsemeta(fulltext)[0] if m and 'copy' in m: return m['copy'], bin(m['copyrev']) @@ -415,7 +415,7 @@ def add(self, text, meta, transaction, linkrev, p1, p2): if meta or text.startswith(b'\1\n'): -text = filelog.packmeta(meta, text) +text = revlog.packmeta(meta, text) return self.addrevision(text, transaction, linkrev, p1, p2) diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -19,6 +19,7 @@ import hashlib import heapq import os +import re import struct import zlib @@ -97,6 +98,25 @@ REVIDX_ISCENSORED: None, } +_mdre = re.compile('\1\n') +def parsemeta(text): +"""return (metadatadict, metadatasize)""" +# text can be buffer, so we can't use .startswith or .index +if text[:2] != '\1\n': +return None, None +s = _mdre.search(text, 2).start() +mtext = text[2:s] +meta = {} +for l in mtext.splitlines(): +k, v = l.split(": ", 1) +meta[k] = v +return meta, (s + 2) + +def packmeta(meta, text): +keys = sorted(meta) +metatext = "".join("%s: %s\n" % (k, meta[k]) for k in keys) +return "\1\n%s\1\n%s" % (metatext, text) + def addflagprocessor(flag, processor): """Register a flag processor on a revision data flag. diff --git a/mercurial/filelog.py b/mercurial/filelog.py --- a/mercurial/filelog.py +++ b/mercurial/filelog.py @@ -7,7 +7,6 @@ from __future__ import absolute_import -import re import struct from .thirdparty.zope import ( @@ -20,27 +19,8 @@ revlog, ) -_mdre = re.compile('\1\n') -def parsemeta(text): -"""return (metadatadict, metadatasize)""" -# text can be buffer, so we can't use .startswith or .index -if text[:2] != '\1\n': -return None, None -s = _mdre.search(text, 2).start() -mtext = text[2:s] -meta = {} -for l in mtext.splitlines(): -k, v = l.split(": ", 1) -meta[k] = v -return meta, (s + 2) - -def packmeta(meta, text): -keys = sorted(meta) -metatext = "".join("%s: %s\n" % (k, meta[k]) for k in keys) -return "\1\n%s\1\n%s" % (metatext, text) - def _censoredtext(text): -m, offs = parsemeta(text) +m, offs = revlog.parsemeta(text) return m and "censored" in m @zi.implementer(repository.ifilestorage) @@ -60,14 +40,14 @@ def add(self, text, meta, transaction, link, p1=None, p2=None): if meta or text.startswith('\1\n'): -text = packmeta(meta, text) +text = revlog.packmeta(meta, text) return self.addrevision(text, transaction, link, p1, p2) def renamed(self, node): if self.parents(node)[0] != revlog.nullid: return False t = self.revision(node) -m = parsemeta(t)[0] +m = revlog.parsemeta(t)[0] if m and "copy" in m: return (m["copy"], revlog.bin(m["copyrev"])) return False diff --git a/hgext/lfs/wrapper.py b/hgext/lfs/wrapper.py --- a/hgext/lfs/wrapper.py +++ b/hgext/lfs/wrapper.py @@ -14,7 +14,6 @@ from mercurial import ( error, -filelog, revlog, util, ) @@ -69,13 +68,13 @@ name = k[len('x-hg-'):] hgmeta[name] = p[k] if hgmeta or text.startswith('\1\n'): -text = filelog.packmeta(hgmeta, text) +text = revlog.packmeta(hgmeta, text) return (text, True) def writetostore(self, text): # hg filelog metadata (includes rename, etc) -hgmeta, offset = filelog.parsemeta(text) +hgmeta, offset = revlog.parsemeta(text) if offset and offset > 0: # lfs blob does not contain hg filelog metadata text = text[offset:] @@ -121,7 +120,7 @@ flags=revlog.REVIDX_DEFAULT_FLAGS, **kwds): textlen = len(text) # exclude hg rename meta from file size -meta, offset = filelog.parsemeta(text) +meta, o
D3154: filelog: wrap revlog instead of inheriting it (API)
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY The revlog base class exposes a ton of methods. Inheriting the revlog class for filelog will make it difficult to expose a clean interface. There will be abstraction violations. This commit breaks the inheritance of revlog by the filelog class. Filelog instances now contain a reference to a revlog instance. Various properties and methods are now proxied to that instance. There is precedence for doing this: manifestlog does something similar. Although, manifestlog has a cleaner interface than filelog. We'll get there with filelog... The new filelog class exposes a handful of extra properties and methods that aren't part of the declared filelog interface. Every extra item was added in order to get a test to pass. The set of tests that failed without these extra proxies has significant overlap with the set of tests that don't work with the simple store repo. There should be no surprise there. Hopefully the hardest part about this commit to review are the changes to bundlerepo and unionrepo. Both repository types define a custom revlog or revlog-like class and then have a custom filelog that inherits from both filelog and their custom revlog. This code has been changed so the filelog types don't inherit from revlog. Instead, they replace the revlog instance on the created filelog. This is super hacky. I plan to fix this in a future commit by parameterizing filelog.__init__. Because Python function call overhead is a thing, this change could impact performance by introducing a nearly empty proxy function for various methods and properties. I would gladly measure the performance impact of it, but I'm not sure what operations have tight loops over filelog attribute lookups or function calls. I know some of the DAG traversal code can be sensitive about the performance of e.g. parentrevs(). However, many of these functions are implemented on the revlog class and therefore have direct access to self.parentrevs() and aren't going through a proxy. .. api:: filelog.filelog is now a standalone class and doesn't inherit from revlog. Instead, it wraps a revlog instance at self._revlog. This change was made in an attempt to formalize storage APIs and prevent revlog implementation details leaking through to callers. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3154 AFFECTED FILES mercurial/bundlerepo.py mercurial/filelog.py mercurial/unionrepo.py CHANGE DETAILS diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py --- a/mercurial/unionrepo.py +++ b/mercurial/unionrepo.py @@ -163,13 +163,15 @@ def baserevdiff(self, rev1, rev2): return manifest.manifestrevlog.revdiff(self, rev1, rev2) -class unionfilelog(unionrevlog, filelog.filelog): +class unionfilelog(filelog.filelog): def __init__(self, opener, path, opener2, linkmapper, repo): filelog.filelog.__init__(self, opener, path) filelog2 = filelog.filelog(opener2, path) -unionrevlog.__init__(self, opener, self.indexfile, filelog2, - linkmapper) +self._revlog = unionrevlog(opener, self.indexfile, + filelog2._revlog, linkmapper) self._repo = repo +self.repotiprev = self._revlog.repotiprev +self.revlog2 = self._revlog.revlog2 def baserevision(self, nodeorrev): return filelog.filelog.revision(self, nodeorrev) diff --git a/mercurial/filelog.py b/mercurial/filelog.py --- a/mercurial/filelog.py +++ b/mercurial/filelog.py @@ -11,18 +11,112 @@ interface as zi, ) from . import ( +error, repository, revlog, ) @zi.implementer(repository.ifilestorage) -class filelog(revlog.revlog): +class filelog(object): def __init__(self, opener, path): -super(filelog, self).__init__(opener, -"/".join(("data", path + ".i")), - censorable=True) +self._revlog = revlog.revlog(opener, + '/'.join(('data', path + '.i')), + censorable=True) # full name of the user visible file, relative to the repository root self.filename = path +self.index = self._revlog.index +self.version = self._revlog.version +self.storedeltachains = self._revlog.storedeltachains +self._generaldelta = self._revlog._generaldelta + +def __len__(self): +return len(self._revlog) + +def __iter__(self): +return self._revlog.__iter__() + +def revs(self, start=0, stop=None): +return self._revlog.revs(start=start, stop=stop) + +def parents(self, node): +return self._revlog.parents(node) + +def parentrevs(self, rev): +return se
D3119: commands: don't violate storage abstractions in `manifest --all`
indygreg updated this revision to Diff 7760. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3119?vs=7701&id=7760 REVISION DETAIL https://phab.mercurial-scm.org/D3119 AFFECTED FILES mercurial/commands.py tests/test-convert-git.t tests/test-manifest.t CHANGE DETAILS diff --git a/tests/test-manifest.t b/tests/test-manifest.t --- a/tests/test-manifest.t +++ b/tests/test-manifest.t @@ -68,9 +68,9 @@ l $ hg manifest --all - a (no-reposimplestore !) - b/a (no-reposimplestore !) - l (no-reposimplestore !) + a + b/a + l The next two calls are expected to abort: diff --git a/tests/test-convert-git.t b/tests/test-convert-git.t --- a/tests/test-convert-git.t +++ b/tests/test-convert-git.t @@ -881,7 +881,7 @@ $ hg convert -q git-repo6 no-submodules --config convert.git.skipsubmodules=True $ hg -R no-submodules manifest --all - .gitmodules-renamed (no-reposimplestore !) + .gitmodules-renamed convert using a different remote prefix $ git init git-repo7 diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3491,19 +3491,13 @@ if rev or node: raise error.Abort(_("can't specify a revision with --all")) -res = [] -# TODO this is a massive layering violation. It assumes the repo is -# backed by revlogs with a well-defined naming scheme. -prefix = "data/" -suffix = ".i" -plen = len(prefix) -slen = len(suffix) -with repo.lock(): -for fn, b, size in repo.store.datafiles(): -if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix: -res.append(fn[plen:-slen]) +res = set() +for rev in repo: +ctx = repo[rev] +res |= set(ctx.files()) + ui.pager('manifest') -for f in res: +for f in sorted(res): fm.startitem() fm.write("path", '%s\n', f) fm.end() To: indygreg, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
RE: [PATCH 2 of 2] copies: clean up _related logic
> -Original Message- > From: Yuya Nishihara [mailto:you...@gmail.com] On Behalf Of Yuya > Nishihara > Sent: Thursday, April 5, 2018 2:57 PM > To: Gábor STEFANIK > Cc: mercurial-devel@mercurial-scm.org > Subject: Re: [PATCH 2 of 2] copies: clean up _related logic > > On Wed, 04 Apr 2018 15:35:34 +0200, Gábor Stefanik wrote: > > # HG changeset patch > > # User Gábor Stefanik # Date 1522848882 -7200 > > # Wed Apr 04 15:34:42 2018 +0200 > > # Node ID 084ee003f2f3cb4d51129c4f1bb63e1ff4db14d0 > > # Parent d72ca973100a1f1a4451a7d1efdc3e43ebc2912e > > copies: clean up _related logic > > > > The limit parameter was never actually used, since the only way the > > 4th case could be reached was if f1r and f2r converged. The new code > > makes this clear, and additionally reduces the conditional block to just 3 > cases. > > Yeah. I suspect the limit should be tested first, but doing that breaks some > tests. So, perhaps we have to handle the case of f.linkrev() < anc.rev() > anyway. We do need to care for relatedness behind anc.rev(), since anc may well be a revision that doesn't modify f at all. In that case, the file revision contained in anc will have a linkrev before anc (since linkrev points to the changelog revision in which the file revision in question was introduced, not the last one where it's present). The limit logic really doesn't make sense here. > > > diff -r d72ca973100a -r 084ee003f2f3 mercurial/copies.py > > --- a/mercurial/copies.py Wed Apr 04 15:28:09 2018 +0200 > > +++ b/mercurial/copies.py Wed Apr 04 15:34:42 2018 +0200 > > @@ -737,7 +737,7 @@ > > except StopIteration: > > raise > > > > -def _related(f1, f2, limit): > > +def _related(f1, f2): > > There's one more caller of _related(). Right, in heuristicscopytracing. > > > @@ -764,10 +764,8 @@ > > f1, g1 = _loose_next(g1) > > elif f2r > f1r: > > f1, g1 = _loose_next(g1) > > -elif f1 == f2: > > -return f1 # a match > > -elif f1r == f2r or f1r < limit or f2r < limit: > > -return False # copy no longer relevant > > +else: # f1 and f2 point to files in the same linkrev > > +return f1 == f2 # true if they point to the same file This message, including its attachments, is confidential and the property of NNG Llc. For more information please read NNG's email policy here: https://www.nng.com/email-policy/ By responding to this email you accept the email policy. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3141: mq: avoid a silly conversion from binary nodeid to hex
This revision was automatically updated to reflect the committed changes. Closed by commit rHG76823340a899: mq: avoid a silly conversion from binary nodeid to hex (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3141?vs=7746&id=7759 REVISION DETAIL https://phab.mercurial-scm.org/D3141 AFFECTED FILES hgext/mq.py CHANGE DETAILS diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -1664,7 +1664,7 @@ cparents = repo.changelog.parents(top) patchparent = self.qparents(repo, top) -inclsubs = checksubstate(repo, hex(patchparent)) +inclsubs = checksubstate(repo, patchparent) if inclsubs: substatestate = repo.dirstate['.hgsubstate'] To: martinvonz, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3142: narrow: remove unused "cacheprop" stuff
This revision was automatically updated to reflect the committed changes. Closed by commit rHGc3c76194f0c1: narrow: remove unused "cacheprop" stuff (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3142?vs=7753&id=7758 REVISION DETAIL https://phab.mercurial-scm.org/D3142 AFFECTED FILES hgext/narrow/narrowrepo.py CHANGE DETAILS diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py --- a/hgext/narrow/narrowrepo.py +++ b/hgext/narrow/narrowrepo.py @@ -8,10 +8,8 @@ from __future__ import absolute_import from mercurial import ( -bundlerepo, changegroup, hg, -localrepo, narrowspec, scmutil, ) @@ -40,14 +38,6 @@ def wraprepo(repo): """Enables narrow clone functionality on a single local repository.""" -cacheprop = localrepo.storecache -if isinstance(repo, bundlerepo.bundlerepository): -# We have to use a different caching property decorator for -# bundlerepo because storecache blows up in strange ways on a -# bundlerepo. Fortunately, there's no risk of data changing in -# a bundlerepo. -cacheprop = lambda name: localrepo.unfilteredpropertycache - class narrowrepository(repo.__class__): def file(self, f): To: martinvonz, durin42, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3146: context: move handling of stringified ints to revsymbol (API)
martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Now there seem to be no more cases where we pass a stringified int into repo.__getitem__, so now can finally move that out of changectx's constructor and into revsymbol(). REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3146 AFFECTED FILES mercurial/context.py mercurial/scmutil.py CHANGE DETAILS diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -452,7 +452,28 @@ "repo[symbol]?" % (symbol, type(symbol))) raise error.ProgrammingError(msg) try: +# TODO: We ideally should resolve these three here instead of +# delegating to repo.__getitem__ +if symbol in ('.', 'tip', 'null'): +return repo[symbol] + +try: +r = int(symbol) +if '%d' % r != symbol: +raise ValueError +l = len(repo.changelog) +if r < 0: +r += l +if r < 0 or r >= l and r != wdirrev: +raise ValueError +return repo[r] +except error.FilteredIndexError: +raise +except (ValueError, OverflowError, IndexError): +pass + return repo[symbol] + except (error.FilteredIndexError, error.FilteredLookupError, error.FilteredRepoLookupError): raise _filterederror(repo, symbol) diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -24,7 +24,6 @@ short, wdirid, wdirnodes, -wdirrev, ) from . import ( dagop, @@ -415,23 +414,6 @@ except LookupError: pass -try: -r = int(changeid) -if '%d' % r != changeid: -raise ValueError -l = len(repo.changelog) -if r < 0: -r += l -if r < 0 or r >= l and r != wdirrev: -raise ValueError -self._rev = r -self._node = repo.changelog.node(r) -return -except error.FilteredIndexError: -raise -except (ValueError, OverflowError, IndexError): -pass - if len(changeid) == 40: try: self._node = bin(changeid) 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
D3145: context: catch right exceptions from namespace lookup (API)
martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Similar to the previous patch, here we were catching FilteredRepoLookupError and RepoLookupError instead of FilteredLookupError and LookupError. What makes this trickier is that this is calling into namespaces code, and since namespaces are meant to be extensible, we could potentially get a RepoLookupError from the namespace lookup. If we got a RepoLookupError before, we would swallow it and try to interpret the string as a partial nodeid. That means that if the user runs `hg co deadbeef` where "deadbeef" is a valid nodeid prefix and also something that make some namespace raise a RepoLookupError, we would happily check out the requested revision. After this patch, we will instead error out. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3145 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 @@ -449,9 +449,9 @@ return except KeyError: pass -except error.FilteredRepoLookupError: +except error.FilteredLookupError: raise -except error.RepoLookupError: +except error.LookupError: pass self._node = repo.unfiltered().changelog._partialmatch(changeid) 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
D3143: context: move handling of filtering error to revsymbol() (API)
martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY When changectx's constructor runs into various Filtered*Error, it creates an exception with a hint about using --hidden. This only makes sense when the revision was provided by the user (if we get e.g. a FilteredLookupError from repo[p1], then it's instead a programming error). Thus, I'm moving the handling into revsymbol(). Also changed "unfilteredrepo[changeid]" to "revsymbol(unfilteredrepo, changeid)" as part of the move. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3143 AFFECTED FILES mercurial/context.py mercurial/localrepo.py mercurial/scmutil.py CHANGE DETAILS diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -451,7 +451,36 @@ msg = ("symbol (%s of type %s) was not a string, did you mean " "repo[symbol]?" % (symbol, type(symbol))) raise error.ProgrammingError(msg) -return repo[symbol] +try: +return repo[symbol] +except (error.FilteredIndexError, error.FilteredLookupError, +error.FilteredRepoLookupError): +raise _filterederror(repo, symbol) + +def _filterederror(repo, changeid): +"""build an exception to be raised about a filtered changeid + +This is extracted in a function to help extensions (eg: evolve) to +experiment with various message variants.""" +if repo.filtername.startswith('visible'): + +# Check if the changeset is obsolete +unfilteredrepo = repo.unfiltered() +ctx = revsymbol(unfilteredrepo, changeid) + +# If the changeset is obsolete, enrich the message with the reason +# that made this changeset not visible +if ctx.obsolete(): +msg = obsutil._getfilteredreason(repo, changeid, ctx) +else: +msg = _("hidden revision '%s'") % changeid + +hint = _('use --hidden to access hidden revisions') + +return error.FilteredRepoLookupError(msg, hint=hint) +msg = _("filtered revision '%s' (not in '%s' subset)") +msg %= (changeid, repo.filtername) +return error.FilteredRepoLookupError(msg) def revsingle(repo, revspec, default='.', localalias=None): if not revspec and revspec != 0: diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -802,7 +802,8 @@ try: self[changeid] return True -except error.RepoLookupError: +except (error.RepoLookupError, error.FilteredIndexError, +error.FilteredLookupError): return False def __nonzero__(self): diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -33,7 +33,6 @@ fileset, match as matchmod, obsolete as obsmod, -obsutil, patch, pathutil, phases, @@ -378,31 +377,6 @@ return r -def _filterederror(repo, changeid): -"""build an exception to be raised about a filtered changeid - -This is extracted in a function to help extensions (eg: evolve) to -experiment with various message variants.""" -if repo.filtername.startswith('visible'): - -# Check if the changeset is obsolete -unfilteredrepo = repo.unfiltered() -ctx = unfilteredrepo[changeid] - -# If the changeset is obsolete, enrich the message with the reason -# that made this changeset not visible -if ctx.obsolete(): -msg = obsutil._getfilteredreason(repo, changeid, ctx) -else: -msg = _("hidden revision '%s'") % changeid - -hint = _('use --hidden to access hidden revisions') - -return error.FilteredRepoLookupError(msg, hint=hint) -msg = _("filtered revision '%s' (not in '%s' subset)") -msg %= (changeid, repo.filtername) -return error.FilteredRepoLookupError(msg) - class changectx(basectx): """A changecontext object makes access to data related to a particular changeset convenient. It represents a read-only context already present in @@ -501,7 +475,7 @@ pass except (error.FilteredIndexError, error.FilteredLookupError, error.FilteredRepoLookupError): -raise _filterederror(repo, changeid) +raise except IndexError: pass raise error.RepoLookupError( 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
D3144: context: make repo[] match node
martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY If you pass in a binary nodeid of a filtered node to repo.__getitem__, it would run through this code: try: self._node = changeid self._rev = repo.changelog.rev(changeid) return except error.FilteredLookupError: raise except LookupError: pass However, repo.changelog.rev() would raise a FilteredLookupError, not FilteredRepoLookupError. Instead, we would hit the "except LookupError" and continue, trying to interpret the nodeid as a bookmark etc. The end result would be an error like this: abort: unknown revision 'ddadbd7c40ef8b8ad6d0d01a7a842092fc431798'! After this patch, it would instead be: abort: 00changelog.i@ddadbd7c40ef8b8ad6d0d01a7a842092fc431798: filtered node! This only happens when we get a binary nodeid, which means it's not string directly from the user, so it would be a programming error if it happened. It's therefore a little hard to test (I checked test-context.py, but it doesn't use obsmarkers). It looks like this has been wrong ever since https://phab.mercurial-scm.org/rHGdc25ed84bee89700a584c828233be17560075082 (changectx: issue a FilteredRepoLookupError when applicable, 2014-10-15). REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3144 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 @@ -410,7 +410,7 @@ self._node = changeid self._rev = repo.changelog.rev(changeid) return -except error.FilteredRepoLookupError: +except error.FilteredLookupError: raise except LookupError: pass 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
D3142: narrow: remove unused "cacheprop" stuff
martinvonz created this revision. Herald added a reviewer: durin42. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This is unused since https://phab.mercurial-scm.org/D3046. I didn't even notice it then, but tests still pass so I hope it's still handled safely. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3142 AFFECTED FILES hgext/narrow/narrowrepo.py CHANGE DETAILS diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py --- a/hgext/narrow/narrowrepo.py +++ b/hgext/narrow/narrowrepo.py @@ -8,10 +8,8 @@ from __future__ import absolute_import from mercurial import ( -bundlerepo, changegroup, hg, -localrepo, narrowspec, scmutil, ) @@ -40,14 +38,6 @@ def wraprepo(repo): """Enables narrow clone functionality on a single local repository.""" -cacheprop = localrepo.storecache -if isinstance(repo, bundlerepo.bundlerepository): -# We have to use a different caching property decorator for -# bundlerepo because storecache blows up in strange ways on a -# bundlerepo. Fortunately, there's no risk of data changing in -# a bundlerepo. -cacheprop = lambda name: localrepo.unfilteredpropertycache - class narrowrepository(repo.__class__): def file(self, f): To: martinvonz, durin42, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3062: tests: disable infinitepush tests for simple store
This revision was automatically updated to reflect the committed changes. Closed by commit rHG24c7428983c5: tests: disable infinitepush tests for simple store (authored by indygreg, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3062?vs=7605&id=7752 REVISION DETAIL https://phab.mercurial-scm.org/D3062 AFFECTED FILES tests/test-infinitepush-bundlestore.t tests/test-infinitepush-ci.t tests/test-infinitepush.t CHANGE DETAILS diff --git a/tests/test-infinitepush.t b/tests/test-infinitepush.t --- a/tests/test-infinitepush.t +++ b/tests/test-infinitepush.t @@ -1,3 +1,5 @@ +#require no-reposimplestore + Testing infinipush extension and the confi options provided by it Setup diff --git a/tests/test-infinitepush-ci.t b/tests/test-infinitepush-ci.t --- a/tests/test-infinitepush-ci.t +++ b/tests/test-infinitepush-ci.t @@ -1,3 +1,5 @@ +#require no-reposimplestore + Testing the case when there is no infinitepush extension present on the client side and the server routes each push to bundlestore. This case is very much similar to CI use case. diff --git a/tests/test-infinitepush-bundlestore.t b/tests/test-infinitepush-bundlestore.t --- a/tests/test-infinitepush-bundlestore.t +++ b/tests/test-infinitepush-bundlestore.t @@ -1,3 +1,4 @@ +#require no-reposimplestore Create an ondisk bundlestore in .hg/scratchbranches $ . "$TESTDIR/library-infinitepush.sh" To: indygreg, #hg-reviewers, durin42, pulkit Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3125: py3: convert user value to bytes by b'' prefix
pulkit updated this revision to Diff 7751. pulkit edited the summary of this revision. pulkit retitled this revision from "py3: convert user value to bytes using pycompat.fsencode()" to "py3: convert user value to bytes by b'' prefix". REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3125?vs=7708&id=7751 REVISION DETAIL https://phab.mercurial-scm.org/D3125 AFFECTED FILES tests/test-journal-share.t tests/test-journal.t CHANGE DETAILS diff --git a/tests/test-journal.t b/tests/test-journal.t --- a/tests/test-journal.t +++ b/tests/test-journal.t @@ -6,7 +6,7 @@ > from mercurial import util, pycompat > from mercurial.utils import dateutil, procutil > def mockgetuser(): - > return 'foobar' + > return b'foobar' > > def mockmakedate(): > filename = os.path.join(os.environ['TESTTMP'], 'testtime') diff --git a/tests/test-journal-share.t b/tests/test-journal-share.t --- a/tests/test-journal-share.t +++ b/tests/test-journal-share.t @@ -6,7 +6,7 @@ > from mercurial import util > from mercurial.utils import procutil > def mockgetuser(): - > return 'foobar' + > return b'foobar' > > def mockmakedate(): > filename = os.path.join(os.environ['TESTTMP'], 'testtime') To: pulkit, #hg-reviewers, yuja Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3125: py3: convert user value to bytes using pycompat.fsencode()
pulkit added a comment. In https://phab.mercurial-scm.org/D3125#50284, @yuja wrote: > Unicode issue is handled by posix.py. The problem is `mockgetuser()` > returns a unicode string. Thanks, I overlooked that and was unable to find what can cause trouble so just added an extra fsencode() call. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3125 To: pulkit, #hg-reviewers, yuja Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3135: bookmarks: drop always-None argument from calculateupdate()
This revision was automatically updated to reflect the committed changes. Closed by commit rHGa973bb92ab71: bookmarks: drop always-None argument from calculateupdate() (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3135?vs=7732&id=7747 REVISION DETAIL https://phab.mercurial-scm.org/D3135 AFFECTED FILES mercurial/bookmarks.py mercurial/destutil.py CHANGE DETAILS diff --git a/mercurial/destutil.py b/mercurial/destutil.py --- a/mercurial/destutil.py +++ b/mercurial/destutil.py @@ -56,7 +56,7 @@ """decide on an update destination from active bookmark""" # we also move the active bookmark, if any node = None -activemark, movemark = bookmarks.calculateupdate(repo.ui, repo, None) +activemark, movemark = bookmarks.calculateupdate(repo.ui, repo) if activemark is not None: node = repo.lookup(activemark) return node, movemark, activemark diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py --- a/mercurial/bookmarks.py +++ b/mercurial/bookmarks.py @@ -348,17 +348,16 @@ heads.append(n) return heads -def calculateupdate(ui, repo, checkout): +def calculateupdate(ui, repo): '''Return a tuple (activemark, movemarkfrom) indicating the active bookmark and where to move the active bookmark from, if needed.''' -movemarkfrom = None -if checkout is None: -activemark = repo._activebookmark -if isactivewdirparent(repo): -movemarkfrom = repo['.'].node() -elif activemark: -ui.status(_("updating to active bookmark %s\n") % activemark) -checkout = activemark +checkout, movemarkfrom = None, None +activemark = repo._activebookmark +if isactivewdirparent(repo): +movemarkfrom = repo['.'].node() +elif activemark: +ui.status(_("updating to active bookmark %s\n") % activemark) +checkout = activemark return (checkout, movemarkfrom) def update(repo, parents, node): 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
D3139: rebase: convert "oldrev" to revnum earlier
This revision was automatically updated to reflect the committed changes. Closed by commit rHG3dfd7f018c69: rebase: convert "oldrev" to revnum earlier (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3139?vs=7740&id=7749 REVISION DETAIL https://phab.mercurial-scm.org/D3139 AFFECTED FILES hgext/rebase.py CHANGE DETAILS diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -243,20 +243,20 @@ activebookmark = l else: args = l.split(':') -oldrev = args[0] +oldrev = repo[args[0]].rev() newrev = args[1] if newrev in legacystates: continue if len(args) > 2: destrev = repo[args[2]].rev() else: destrev = legacydest -destmap[repo[oldrev].rev()] = destrev +destmap[oldrev] = destrev if newrev in (nullid, revtodostr): -state[repo[oldrev].rev()] = revtodo +state[oldrev] = revtodo # Legacy compat special case else: -state[repo[oldrev].rev()] = repo[newrev].rev() +state[oldrev] = repo[newrev].rev() except IOError as err: if err.errno != errno.ENOENT: To: martinvonz, #hg-reviewers, quark, pulkit Cc: quark, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3140: rebase: remove unnecessary and incorrect handling of nullid
This revision was automatically updated to reflect the committed changes. Closed by commit rHG953db9e00eeb: rebase: remove unnecessary and incorrect handling of nullid (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3140?vs=7742&id=7750 REVISION DETAIL https://phab.mercurial-scm.org/D3140 AFFECTED FILES hgext/rebase.py CHANGE DETAILS diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -21,7 +21,6 @@ from mercurial.i18n import _ from mercurial.node import ( -nullid, nullrev, short, ) @@ -252,7 +251,7 @@ else: destrev = legacydest destmap[oldrev] = destrev -if newrev in (nullid, revtodostr): +if newrev == revtodostr: state[oldrev] = revtodo # Legacy compat special case else: To: martinvonz, #hg-reviewers, quark, pulkit Cc: quark, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3138: rebase: make "destnode" consistently a revnum and rename it to "destrev"
This revision was automatically updated to reflect the committed changes. Closed by commit rHG25940470c7e6: rebase: make "destnode" consistently a revnum and rename it to "destrev" (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3138?vs=7739&id=7748 REVISION DETAIL https://phab.mercurial-scm.org/D3138 AFFECTED FILES hgext/rebase.py CHANGE DETAILS diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -248,10 +248,10 @@ if newrev in legacystates: continue if len(args) > 2: -destnode = args[2] +destrev = repo[args[2]].rev() else: -destnode = legacydest -destmap[repo[oldrev].rev()] = repo[destnode].rev() +destrev = legacydest +destmap[repo[oldrev].rev()] = destrev if newrev in (nullid, revtodostr): state[repo[oldrev].rev()] = revtodo # Legacy compat special case To: martinvonz, #hg-reviewers, quark, pulkit Cc: quark, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3141: mq: avoid a silly conversion from binary nodeid to hex
martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY We generally deal with binary nodeids in code. In this case the hex nodeid was passed to strip.checksubstate() where it was passed to repo.__getitem__, which of course accepts a binary nodeid. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3141 AFFECTED FILES hgext/mq.py CHANGE DETAILS diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -1664,7 +1664,7 @@ cparents = repo.changelog.parents(top) patchparent = self.qparents(repo, top) -inclsubs = checksubstate(repo, hex(patchparent)) +inclsubs = checksubstate(repo, patchparent) if inclsubs: substatestate = repo.dirstate['.hgsubstate'] 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
D2819: hgweb: refactor repository name URL parsing
mharbison72 added a comment. In https://phab.mercurial-scm.org/D2819#49519, @mharbison72 wrote: > I installed the latest default branch with SCM Manager, and it 404s even simple things like `hg id https://...`. I bisected back to this. The paths in the access log looks unchanged: > > With this commit: > > 127.0.0.1 - - [04/Apr/2018:12:44:12 -0400] "GET /hook/hg/?ping=true HTTP/1.1" 204 - > 10.10.1.36 - - [04/Apr/2018:12:44:12 -0400] "GET /hg/eng/devsetup?cmd=capabilities HTTP/1.1" 404 949 > > Parent of this commit: > > 127.0.0.1 - - [04/Apr/2018:12:47:18 -0400] "GET /hook/hg/?ping=true HTTP/1.1" 204 - > 10.10.1.36 - - [04/Apr/2018:12:47:19 -0400] "GET /hg/eng/devsetup?cmd=capabilities HTTP/1.1" 200 422 > 10.10.1.36 - - [04/Apr/2018:12:47:19 -0400] "GET /hg/eng/devsetup?cmd=lookup HTTP/1.1" 200 43 > 10.10.1.36 - - [04/Apr/2018:12:47:20 -0400] "GET /hg/eng/devsetup?cmd=listkeys HTTP/1.1" 200 30 > 10.10.1.36 - - [04/Apr/2018:12:47:20 -0400] "GET /hg/eng/devsetup?cmd=listkeys HTTP/1.1" 200 - > > I'm going to try to add print statements, but if you have any darts you'd like to throw, I'd be happy to try it. Finally figured this out. SCM Manager must be generating this stub hgweb.py (it gets rewritten every time tomcat is restarted): import os from mercurial import demandimport from mercurial.hgweb import hgweb, wsgicgi repositoryPath = os.environ['SCM_REPOSITORY_PATH'] demandimport.enable() application = hgweb(repositoryPath) wsgicgi.launch(application) Note that it's not using hgweb**dir**. (I have no idea why not, but it does let you organize repos into virtual directories under '/hg', and git repos under '/git'.) If we simply set the reponame value in request.parserequestfromenv() from env if it wasn't passed in, then everything works. Not real nice, but I assume that we don't want to break existing hosting packages when upgrading just Mercurial? I'll send a patch if this is acceptable. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2819 To: indygreg, #hg-reviewers, durin42 Cc: mharbison72, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3046: narrow: move manifestlog overrides to core
This revision was automatically updated to reflect the committed changes. Closed by commit rHGac42e39b1b77: narrow: move manifestlog overrides to core (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3046?vs=7577&id=7745 REVISION DETAIL https://phab.mercurial-scm.org/D3046 AFFECTED FILES hgext/narrow/narrowrepo.py hgext/narrow/narrowrevlog.py mercurial/manifest.py CHANGE DETAILS diff --git a/mercurial/manifest.py b/mercurial/manifest.py --- a/mercurial/manifest.py +++ b/mercurial/manifest.py @@ -1303,6 +1303,9 @@ if node in self._dirmancache.get(dir, ()): return self._dirmancache[dir][node] +if not self._narrowmatch.always(): +if not self._narrowmatch.visitdir(dir[:-1] or '.'): +return excludeddirmanifestctx(dir, node) if dir: if self._revlog._treeondisk: if verify: diff --git a/hgext/narrow/narrowrevlog.py b/hgext/narrow/narrowrevlog.py --- a/hgext/narrow/narrowrevlog.py +++ b/hgext/narrow/narrowrevlog.py @@ -8,7 +8,6 @@ from __future__ import absolute_import from mercurial import ( - manifest, revlog, util, ) @@ -30,14 +29,6 @@ # load time. pass -def makenarrowmanifestlog(mfl, repo): -class narrowmanifestlog(mfl.__class__): -def get(self, dir, node, verify=True): -if not repo.narrowmatch().visitdir(dir[:-1] or '.'): -return manifest.excludeddirmanifestctx(dir, node) -return super(narrowmanifestlog, self).get(dir, node, verify=verify) -mfl.__class__ = narrowmanifestlog - def makenarrowfilelog(fl, narrowmatch): class narrowfilelog(fl.__class__): def renamed(self, node): diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py --- a/hgext/narrow/narrowrepo.py +++ b/hgext/narrow/narrowrepo.py @@ -50,12 +50,6 @@ class narrowrepository(repo.__class__): -@cacheprop('00manifest.i') -def manifestlog(self): -mfl = super(narrowrepository, self).manifestlog -narrowrevlog.makenarrowmanifestlog(mfl, self) -return mfl - def file(self, f): fl = super(narrowrepository, self).file(f) narrowrevlog.makenarrowfilelog(fl, self.narrowmatch()) To: martinvonz, durin42, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3044: narrow: move excludeddir and related classes to core
This revision was automatically updated to reflect the committed changes. Closed by commit rHG1b2fa531fd7a: narrow: move excludeddir and related classes to core (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3044?vs=7575&id=7743 REVISION DETAIL https://phab.mercurial-scm.org/D3044 AFFECTED FILES hgext/narrow/narrowrevlog.py mercurial/manifest.py CHANGE DETAILS diff --git a/mercurial/manifest.py b/mercurial/manifest.py --- a/mercurial/manifest.py +++ b/mercurial/manifest.py @@ -1569,3 +1569,80 @@ def find(self, key): return self.read().find(key) + +class excludeddir(treemanifest): +"""Stand-in for a directory that is excluded from the repository. + +With narrowing active on a repository that uses treemanifests, +some of the directory revlogs will be excluded from the resulting +clone. This is a huge storage win for clients, but means we need +some sort of pseudo-manifest to surface to internals so we can +detect a merge conflict outside the narrowspec. That's what this +class is: it stands in for a directory whose node is known, but +whose contents are unknown. +""" +def __init__(self, dir, node): +super(excludeddir, self).__init__(dir) +self._node = node +# Add an empty file, which will be included by iterators and such, +# appearing as the directory itself (i.e. something like "dir/") +self._files[''] = node +self._flags[''] = 't' + +# Manifests outside the narrowspec should never be modified, so avoid +# copying. This makes a noticeable difference when there are very many +# directories outside the narrowspec. Also, it makes sense for the copy to +# be of the same type as the original, which would not happen with the +# super type's copy(). +def copy(self): +return self + +class excludeddirmanifestctx(treemanifestctx): +"""context wrapper for excludeddir - see that docstring for rationale""" +def __init__(self, dir, node): +self._dir = dir +self._node = node + +def read(self): +return excludeddir(self._dir, self._node) + +def write(self, *args): +raise error.ProgrammingError( +'attempt to write manifest from excluded dir %s' % self._dir) + +class excludedmanifestrevlog(manifestrevlog): +"""Stand-in for excluded treemanifest revlogs. + +When narrowing is active on a treemanifest repository, we'll have +references to directories we can't see due to the revlog being +skipped. This class exists to conform to the manifestrevlog +interface for those directories and proactively prevent writes to +outside the narrowspec. +""" + +def __init__(self, dir): +self._dir = dir + +def __len__(self): +raise error.ProgrammingError( +'attempt to get length of excluded dir %s' % self._dir) + +def rev(self, node): +raise error.ProgrammingError( +'attempt to get rev from excluded dir %s' % self._dir) + +def linkrev(self, node): +raise error.ProgrammingError( +'attempt to get linkrev from excluded dir %s' % self._dir) + +def node(self, rev): +raise error.ProgrammingError( +'attempt to get node from excluded dir %s' % self._dir) + +def add(self, *args, **kwargs): +# We should never write entries in dirlogs outside the narrow clone. +# However, the method still gets called from writesubtree() in +# _addtree(), so we need to handle it. We should possibly make that +# avoid calling add() with a clean manifest (_dirty is always False +# in excludeddir instances). +pass diff --git a/hgext/narrow/narrowrevlog.py b/hgext/narrow/narrowrevlog.py --- a/hgext/narrow/narrowrevlog.py +++ b/hgext/narrow/narrowrevlog.py @@ -8,7 +8,6 @@ from __future__ import absolute_import from mercurial import ( - error, manifest, revlog, util, @@ -31,83 +30,6 @@ # load time. pass -class excludeddir(manifest.treemanifest): -"""Stand-in for a directory that is excluded from the repository. - -With narrowing active on a repository that uses treemanifests, -some of the directory revlogs will be excluded from the resulting -clone. This is a huge storage win for clients, but means we need -some sort of pseudo-manifest to surface to internals so we can -detect a merge conflict outside the narrowspec. That's what this -class is: it stands in for a directory whose node is known, but -whose contents are unknown. -""" -def __init__(self, dir, node): -super(excludeddir, self).__init__(dir) -self._node = node -# Add an empty file, which will be included by iterators and such, -# appearing as the directory itself (i.e. something like "dir/") -self._files[''] = node -self._flags[''] = '
D3045: narrow: move manifestrevlog overrides to core
This revision was automatically updated to reflect the committed changes. Closed by commit rHGc50078fc32f3: narrow: move manifestrevlog overrides to core (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3045?vs=7576&id=7744 REVISION DETAIL https://phab.mercurial-scm.org/D3045 AFFECTED FILES hgext/narrow/narrowrepo.py hgext/narrow/narrowrevlog.py mercurial/manifest.py CHANGE DETAILS diff --git a/mercurial/manifest.py b/mercurial/manifest.py --- a/mercurial/manifest.py +++ b/mercurial/manifest.py @@ -1279,6 +1279,7 @@ self._treeinmem = usetreemanifest self._revlog = repo._constructmanifest() +self._narrowmatch = repo.narrowmatch() # A cache of the manifestctx or treemanifestctx for each directory self._dirmancache = {} @@ -1477,6 +1478,10 @@ #self.linkrev = revlog.linkrev(rev) def _revlog(self): +narrowmatch = self._manifestlog._narrowmatch +if not narrowmatch.always(): +if not narrowmatch.visitdir(self._dir[:-1] or '.'): +return excludedmanifestrevlog(self._dir) return self._manifestlog._revlog.dirlog(self._dir) def read(self): diff --git a/hgext/narrow/narrowrevlog.py b/hgext/narrow/narrowrevlog.py --- a/hgext/narrow/narrowrevlog.py +++ b/hgext/narrow/narrowrevlog.py @@ -30,24 +30,6 @@ # load time. pass -def makenarrowmanifestrevlog(mfrevlog, repo): -if util.safehasattr(mfrevlog, '_narrowed'): -return - -class narrowmanifestrevlog(mfrevlog.__class__): -# This function is called via debug{revlog,index,data}, but also during -# at least some push operations. This will be used to wrap/exclude the -# child directories when using treemanifests. -def dirlog(self, d): -if not repo.narrowmatch().visitdir(d[:-1] or '.'): -return manifest.excludedmanifestrevlog(d) -result = super(narrowmanifestrevlog, self).dirlog(d) -makenarrowmanifestrevlog(result, repo) -return result - -mfrevlog.__class__ = narrowmanifestrevlog -mfrevlog._narrowed = True - def makenarrowmanifestlog(mfl, repo): class narrowmanifestlog(mfl.__class__): def get(self, dir, node, verify=True): diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py --- a/hgext/narrow/narrowrepo.py +++ b/hgext/narrow/narrowrepo.py @@ -50,11 +50,6 @@ class narrowrepository(repo.__class__): -def _constructmanifest(self): -manifest = super(narrowrepository, self)._constructmanifest() -narrowrevlog.makenarrowmanifestrevlog(manifest, repo) -return manifest - @cacheprop('00manifest.i') def manifestlog(self): mfl = super(narrowrepository, self).manifestlog To: martinvonz, durin42, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3140: rebase: remove unnecessary and incorrect handling of nullid
martinvonz updated this revision to Diff 7742. martinvonz edited the summary of this revision. martinvonz retitled this revision from "rebase: fix explicit handling of nullid in rebase state" to "rebase: remove unnecessary and incorrect handling of nullid". REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3140?vs=7741&id=7742 REVISION DETAIL https://phab.mercurial-scm.org/D3140 AFFECTED FILES hgext/rebase.py CHANGE DETAILS diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -21,7 +21,6 @@ from mercurial.i18n import _ from mercurial.node import ( -nullid, nullrev, short, ) @@ -252,7 +251,7 @@ else: destrev = legacydest destmap[oldrev] = destrev -if newrev in (nullid, revtodostr): +if newrev == revtodostr: state[oldrev] = revtodo # Legacy compat special case else: To: martinvonz, #hg-reviewers, quark Cc: quark, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3140: rebase: remove unnecessary and incorrect handling of nullid
martinvonz added a comment. In https://phab.mercurial-scm.org/D3140#50376, @quark wrote: > Hmm... maybe just remove it. Done. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3140 To: martinvonz, #hg-reviewers, quark Cc: quark, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3120: tests: add test for `hg children -r `
martinvonz abandoned this revision. martinvonz added a comment. Folded into https://phab.mercurial-scm.org/D3085 REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3120 To: martinvonz, #hg-reviewers, pulkit, indygreg Cc: pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3138: rebase: make "destnode" consistently a revnum and rename it to "destrev"
quark accepted this revision. quark added a comment. Thanks. I was not too happy about the old code using `rev` as `node`s. But I didn't spend much time changing them. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3138 To: martinvonz, #hg-reviewers, quark Cc: quark, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3120: tests: add test for `hg children -r `
indygreg added a comment. @martinvonz looks like you'll need to mark this as abandoned so it disappears from Phabricator. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3120 To: martinvonz, #hg-reviewers, pulkit, indygreg Cc: pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3139: rebase: convert "oldrev" to revnum earlier
quark accepted this revision. quark added a comment. Nice catch. I guess my initial consideration was `oldrev` was not always a valid node. But it seems no longer a concern. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3139 To: martinvonz, #hg-reviewers, quark Cc: quark, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3140: rebase: fix explicit handling of nullid in rebase state
quark accepted this revision. quark added a comment. Hmm... maybe just remove it. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3140 To: martinvonz, #hg-reviewers, quark Cc: quark, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3140: rebase: fix explicit handling of nullid in rebase state
martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY We used to write a nullid as hex to the rebase state file and interpret it as the "todo" state (value -1). However, when reading it, we compared the string value to (binary) nullid, which would of course not match. AFAICT, it still worked because when the read nodeid did not match nullid (which, again, it didn't), we'd use the normal path which did repo[].rev(), and that also happens to return -1. It seems to have been this way ever since https://phab.mercurial-scm.org/rHG9972758ab4c5972038a7d0ae740a5d7a7a54e344 (rebase: handle revtodo as a special value when storing/restoring state, 2014-12-02). We could just remove it and continue to handle it the way it's always been done, but it seems better to be explicit. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3140 AFFECTED FILES hgext/rebase.py CHANGE DETAILS diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -21,7 +21,7 @@ from mercurial.i18n import _ from mercurial.node import ( -nullid, +nullhex, nullrev, short, ) @@ -252,7 +252,7 @@ else: destrev = legacydest destmap[oldrev] = destrev -if newrev in (nullid, revtodostr): +if newrev in (nullhex, revtodostr): state[oldrev] = revtodo # Legacy compat special case else: 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
D3139: rebase: convert "oldrev" to revnum earlier
martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY It was done in 3 places before, now just 1. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3139 AFFECTED FILES hgext/rebase.py CHANGE DETAILS diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -243,20 +243,20 @@ activebookmark = l else: args = l.split(':') -oldrev = args[0] +oldrev = repo[args[0]].rev() newrev = args[1] if newrev in legacystates: continue if len(args) > 2: destrev = repo[args[2]].rev() else: destrev = legacydest -destmap[repo[oldrev].rev()] = destrev +destmap[oldrev] = destrev if newrev in (nullid, revtodostr): -state[repo[oldrev].rev()] = revtodo +state[oldrev] = revtodo # Legacy compat special case else: -state[repo[oldrev].rev()] = repo[newrev].rev() +state[oldrev] = repo[newrev].rev() except IOError as err: if err.errno != errno.ENOENT: 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
D3138: rebase: make "destnode" consistently a revnum and rename it to "destrev"
martinvonz 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/D3138 AFFECTED FILES hgext/rebase.py CHANGE DETAILS diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -248,10 +248,10 @@ if newrev in legacystates: continue if len(args) > 2: -destnode = args[2] +destrev = repo[args[2]].rev() else: -destnode = legacydest -destmap[repo[oldrev].rev()] = repo[destnode].rev() +destrev = legacydest +destmap[repo[oldrev].rev()] = destrev if newrev in (nullid, revtodostr): state[repo[oldrev].rev()] = revtodo # Legacy compat special case 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
[PATCH 1 of 2 v2] copies: create and use _loosenext function for _related
# HG changeset patch # User Gábor Stefanik # Date 1522943551 -7200 # Thu Apr 05 17:52:31 2018 +0200 # Node ID 7d13af1b5cd6e5c95dceefc7d905429889583c8c # Parent 656ac240f39284eec4435d25c01d71056aa4e8a5 copies: create and use _loosenext function for _related _loosenext is going to be a variant of the next function that tries to follow grafts and similar relationship when the regular next raises StopIteration. This is needed for bug 5834. diff -r 656ac240f392 -r 7d13af1b5cd6 mercurial/copies.py --- a/mercurial/copies.py Sat Mar 24 01:30:50 2018 -0400 +++ b/mercurial/copies.py Thu Apr 05 17:52:31 2018 +0200 @@ -731,6 +731,12 @@ return copies, {}, {}, {}, {} +def _loosenext(g): +try: +return next(g), g +except StopIteration: +raise + def _related(f1, f2, limit): """return True if f1 and f2 filectx have a common ancestor @@ -748,16 +754,16 @@ f1r, f2r = f1.linkrev(), f2.linkrev() if f1r is None: -f1 = next(g1) +f1, g1 = _loosenext(g1) if f2r is None: -f2 = next(g2) +f2, g2 = _loosenext(g2) while True: f1r, f2r = f1.linkrev(), f2.linkrev() if f1r > f2r: -f1 = next(g1) +f1, g1 = _loosenext(g1) elif f2r > f1r: -f2 = next(g2) +f2, g2 = _loosenext(g2) elif f1 == f2: return f1 # a match elif f1r == f2r or f1r < limit or f2r < limit: This message, including its attachments, is confidential and the property of NNG Llc. For more information please read NNG's email policy here: https://www.nng.com/email-policy/ By responding to this email you accept the email policy. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2398: histedit: use the new stack definition for histedit
lothiraldan marked an inline comment as done. lothiraldan added inline comments. INLINE COMMENTS > yuja wrote in destutil.py:356 > Can be `return revs.min()`? It seems so and it's much simpler to read. I have sent a follow-up: https://phab.mercurial-scm.org/D3137 REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2398 To: lothiraldan, #hg-reviewers, indygreg, durin42 Cc: yuja, indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2396: stack: import Evolve stack test file
lothiraldan marked 3 inline comments as done. lothiraldan added inline comments. INLINE COMMENTS > yuja wrote in revset.py:1549 > This breaks the order of `tip:0 & stack()` for example, and is moot > since > https://phab.mercurial-scm.org/rHG68fcc5503ec55bda2d6be2887f8fc3f61000c666, > which makes stacks follow the standard order. I have send a follow-up https://phab.mercurial-scm.org/D3136 REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2396 To: lothiraldan, #hg-reviewers, indygreg Cc: martinvonz, yuja, indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3137: histedit: simplify desthistedit
lothiraldan created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Instead of sorting the revset and take the first one, take the minimum revision. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3137 AFFECTED FILES mercurial/destutil.py CHANGE DETAILS diff --git a/mercurial/destutil.py b/mercurial/destutil.py --- a/mercurial/destutil.py +++ b/mercurial/destutil.py @@ -350,10 +350,8 @@ revs = scmutil.revrange(repo, [default]) if revs: -# The revset supplied by the user may not be in ascending order nor -# take the first revision. So do this manually. -revs.sort() -return revs.first() +# Take the first revision of the revset as the root +return revs.min() return None To: lothiraldan, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3136: stack: follow-up on the stack revset
lothiraldan created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Follow good-practice for defining the stack revset. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3136 AFFECTED FILES mercurial/revset.py CHANGE DETAILS diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -28,7 +28,7 @@ revsetlang, scmutil, smartset, -stack, +stack as stackmod, util, ) from .utils import ( @@ -1539,19 +1539,19 @@ return _phase(repo, subset, target) @predicate('stack([revs])', safe=True) -def _stack(repo, subset, x): -# experimental revset for the stack of changesets or working directory -# parent +def stack(repo, subset, x): +"""Experimental revset for the stack of changesets or working directory +parent. (EXPERIMENTAL) +""" if x is None: -stacks = stack.getstack(repo, x) +stacks = stackmod.getstack(repo, x) else: stacks = smartset.baseset([]) for revision in getset(repo, fullreposet(repo), x): -currentstack = stack.getstack(repo, revision) +currentstack = stackmod.getstack(repo, revision) stacks = stacks + currentstack -# Force to use the order of the stacks instead of the subset one -return stacks & subset +return subset & stacks def parentspec(repo, subset, x, n, order): """``set^0`` To: lothiraldan, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2400: stack: begin to make the stack revset configurable
lothiraldan updated this revision to Diff 7733. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2400?vs=6216&id=7733 REVISION DETAIL https://phab.mercurial-scm.org/D2400 AFFECTED FILES mercurial/configitems.py mercurial/stack.py CHANGE DETAILS diff --git a/mercurial/stack.py b/mercurial/stack.py --- a/mercurial/stack.py +++ b/mercurial/stack.py @@ -12,18 +12,34 @@ scmutil, ) +baserevspec = "only(%s) and not public()" + def getstack(repo, rev=None): """return a sorted smartrev of the stack containing either rev if it is not None or the current working directory parent. The stack will always contain all drafts changesets which are ancestors to -the revision and are not merges. +the revision. + +There are several config options to restrict the changesets that will be +part of the stack: + +[stack] +not-merge = (boolean) # The stack will contains only non-merge changesets + # if set to True (default: True) """ if rev is None: rev = '.' -revspec = 'reverse(only(%s) and not public() and not ::merge())' -revset = revsetlang.formatspec(revspec, rev) +revspecargs = [revsetlang.formatspec(baserevspec, rev)] +revspec = ["%r"] + +if repo.ui.configbool("stack", "not-merge"): +revspecargs.append("not ::merge()") +revspec.append("%r") + +finalrevspec = " and ".join(revspec) +revset = revsetlang.formatspec(finalrevspec, *revspecargs) revisions = scmutil.revrange(repo, [revset]) revisions.sort() return revisions diff --git a/mercurial/configitems.py b/mercurial/configitems.py --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -962,6 +962,9 @@ coreconfigitem('sparse', 'missingwarning', default=True, ) +coreconfigitem('stack', 'not-merge', +default=True, +) coreconfigitem('subrepos', 'allowed', default=dynamicdefault, # to make backporting simpler ) To: lothiraldan, #hg-reviewers, indygreg Cc: indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2402: stack: introduce an option to limit the selection on the current branch
lothiraldan updated this revision to Diff 7735. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2402?vs=6218&id=7735 REVISION DETAIL https://phab.mercurial-scm.org/D2402 AFFECTED FILES mercurial/configitems.py mercurial/stack.py tests/test-stack.t CHANGE DETAILS diff --git a/tests/test-stack.t b/tests/test-stack.t --- a/tests/test-stack.t +++ b/tests/test-stack.t @@ -51,6 +51,36 @@ o 0 other draft c_a +Check that stack show draft changesets from all branches by default +--- + + $ hg log -G -r "stack()" + @ 5 foo draft c_f + | + o 4 foo draft c_e + | + o 3 foo draft c_d + | + o 2 foo draft c_c + | + o 1 other draft c_b + | + o 0 other draft c_a + + +But not if we restrict on the branch + + $ hg log -G -r "stack()" --config experimental.stack.same-branch=true + @ 5 foo draft c_f + | + o 4 foo draft c_e + | + o 3 foo draft c_d + | + o 2 foo draft c_c + | + ~ + Check that stack doesn't include public changesets -- diff --git a/mercurial/stack.py b/mercurial/stack.py --- a/mercurial/stack.py +++ b/mercurial/stack.py @@ -44,6 +44,10 @@ revspecargs.append("not ::merge()") revspec.append("%r") +if repo.ui.configbool("experimental", "stack.same-branch"): +revspecargs.append(revsetlang.formatspec("branch(%s)", rev)) +revspec.append("%r") + finalrevspec = " and ".join(revspec) revset = revsetlang.formatspec(finalrevspec, *revspecargs) revisions = scmutil.revrange(repo, [revset]) diff --git a/mercurial/configitems.py b/mercurial/configitems.py --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -968,6 +968,9 @@ coreconfigitem('stack', 'restrict-ancestors', default=True, ) +coreconfigitem('experimental', 'stack.same-branch', +default=False, +) coreconfigitem('subrepos', 'allowed', default=dynamicdefault, # to make backporting simpler ) To: lothiraldan, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2403: stack: remove destutil.stackbase
lothiraldan updated this revision to Diff 7736. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2403?vs=6219&id=7736 REVISION DETAIL https://phab.mercurial-scm.org/D2403 AFFECTED FILES hgext/show.py mercurial/destutil.py CHANGE DETAILS diff --git a/mercurial/destutil.py b/mercurial/destutil.py --- a/mercurial/destutil.py +++ b/mercurial/destutil.py @@ -357,10 +357,6 @@ return None -def stackbase(ui, repo): -revs = stack.getstack(repo) -return revs.first() if revs else None - def _statusotherbook(ui, repo): bmheads = bookmarks.headsforactive(repo) curhead = repo[repo._activebookmark].node() diff --git a/hgext/show.py b/hgext/show.py --- a/hgext/show.py +++ b/hgext/show.py @@ -35,7 +35,6 @@ from mercurial import ( cmdutil, commands, -destutil, error, formatter, graphmod, @@ -45,6 +44,7 @@ registrar, revset, revsetlang, +stack ) # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for @@ -193,17 +193,17 @@ 'changeset)\n')) return -# TODO extract "find stack" into a function to facilitate -# customization and reuse. - -baserev = destutil.stackbase(ui, repo) basectx = None +_stack = stack.getstack(repo) +baserev = _stack.first() + +# TODO doesn't yet handle case where wdir is a draft merge if baserev is None: baserev = wdirctx.rev() stackrevs = {wdirctx.rev()} else: -stackrevs = set(repo.revs('%d::.', baserev)) +stackrevs = set(_stack) ctx = repo[baserev] if ctx.p1().rev() != nullrev: To: lothiraldan, #hg-reviewers Cc: indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2401: stack: introduce an option to disable the restriction on ancestor
lothiraldan updated this revision to Diff 7734. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2401?vs=6217&id=7734 REVISION DETAIL https://phab.mercurial-scm.org/D2401 AFFECTED FILES mercurial/configitems.py mercurial/stack.py CHANGE DETAILS diff --git a/mercurial/stack.py b/mercurial/stack.py --- a/mercurial/stack.py +++ b/mercurial/stack.py @@ -12,28 +12,34 @@ scmutil, ) -baserevspec = "only(%s) and not public()" +baserevspec = "not public()" def getstack(repo, rev=None): """return a sorted smartrev of the stack containing either rev if it is not None or the current working directory parent. -The stack will always contain all drafts changesets which are ancestors to -the revision. +The stack will always contain all drafts changesets. There are several config options to restrict the changesets that will be part of the stack: [stack] not-merge = (boolean) # The stack will contains only non-merge changesets # if set to True (default: True) +restrict-ancestors = (boolean) # The stack will contain only the + # ancestors of the revision if set to True + # (default: True) """ if rev is None: rev = '.' -revspecargs = [revsetlang.formatspec(baserevspec, rev)] +revspecargs = [baserevspec] revspec = ["%r"] +if repo.ui.configbool("stack", "restrict-ancestors"): +revspecargs.append(revsetlang.formatspec("only(%s)", rev)) +revspec.append("%r") + if repo.ui.configbool("stack", "not-merge"): revspecargs.append("not ::merge()") revspec.append("%r") diff --git a/mercurial/configitems.py b/mercurial/configitems.py --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -965,6 +965,9 @@ coreconfigitem('stack', 'not-merge', default=True, ) +coreconfigitem('stack', 'restrict-ancestors', +default=True, +) coreconfigitem('subrepos', 'allowed', default=dynamicdefault, # to make backporting simpler ) To: lothiraldan, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2399: stack: return a sorted smartrev by default
lothiraldan marked an inline comment as done. lothiraldan added inline comments. INLINE COMMENTS > yuja wrote in stack.py:25 > `reverse()` can be removed as well? reverse is removed in the next commit https://phab.mercurial-scm.org/D2400 REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2399 To: lothiraldan, #hg-reviewers, indygreg Cc: yuja, indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3135: bookmarks: drop always-None argument from calculateupdate()
martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Thanks to Yuya for noticing. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3135 AFFECTED FILES mercurial/bookmarks.py mercurial/destutil.py CHANGE DETAILS diff --git a/mercurial/destutil.py b/mercurial/destutil.py --- a/mercurial/destutil.py +++ b/mercurial/destutil.py @@ -56,7 +56,7 @@ """decide on an update destination from active bookmark""" # we also move the active bookmark, if any node = None -activemark, movemark = bookmarks.calculateupdate(repo.ui, repo, None) +activemark, movemark = bookmarks.calculateupdate(repo.ui, repo) if activemark is not None: node = repo.lookup(activemark) return node, movemark, activemark diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py --- a/mercurial/bookmarks.py +++ b/mercurial/bookmarks.py @@ -348,17 +348,16 @@ heads.append(n) return heads -def calculateupdate(ui, repo, checkout): +def calculateupdate(ui, repo): '''Return a tuple (activemark, movemarkfrom) indicating the active bookmark and where to move the active bookmark from, if needed.''' -movemarkfrom = None -if checkout is None: -activemark = repo._activebookmark -if isactivewdirparent(repo): -movemarkfrom = repo['.'].node() -elif activemark: -ui.status(_("updating to active bookmark %s\n") % activemark) -checkout = activemark +checkout, movemarkfrom = None, None +activemark = repo._activebookmark +if isactivewdirparent(repo): +movemarkfrom = repo['.'].node() +elif activemark: +ui.status(_("updating to active bookmark %s\n") % activemark) +checkout = activemark return (checkout, movemarkfrom) def update(repo, parents, node): 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
D2400: stack: begin to make the stack revset configurable
lothiraldan added a comment. The goal of this series is to define a clean API so that commands and tools can be built in a stack-definition agnostic way. It's not to define a one-size-fits-all stack definition. People and companies have different workflows and needs. Their definition of a stack will likely to be different to better match their workflow. I tried finding a way to configure stack as easily as possible. I have the impression that using configuration options is slightly easier than defining a custom extension. I also avoided using directly a revset from the configuration file as I'm not sure it would be the best way to express all situations. I don't know if the config options best place are in the `stack` section though. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2400 To: lothiraldan, #hg-reviewers, indygreg Cc: indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2396: stack: import Evolve stack test file
lothiraldan added inline comments. INLINE COMMENTS > martinvonz wrote in test-stack.t:96-108 > I think I would have preferred to see all of these in my stack rather than > just commit 6. Would you? The goal of this series is to define a clean stack definition API. We started by reusing the existing bits from histsedit and show stack. I've added a first way to configure the stack definition through configuration. I think seeing all the drafts is a good idea and we will works in a later series to have a way to include them in the stack. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2396 To: lothiraldan, #hg-reviewers, indygreg Cc: martinvonz, yuja, indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 4 of 8] hgweb: fix summary {tags} and {shortlog} to not forcibly expand template
# HG changeset patch # User Yuya Nishihara # Date 1521376543 -32400 # Sun Mar 18 21:35:43 2018 +0900 # Node ID 9e623cb78522c9a52eeb25092c75b7f439c9e045 # Parent 083ce2cf66079739b029f7e067a2e9339704c006 hgweb: fix summary {tags} and {shortlog} to not forcibly expand template The same sort of bug as the previous patch. In this case, JSON template was wrong. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -713,7 +713,7 @@ def summary(web): """ i = reversed(web.repo.tagslist()) -def tagentries(**map): +def tagentries(context): parity = paritygen(web.stripecount) count = 0 for k, n in i: @@ -724,12 +724,12 @@ def summary(web): if count > 10: # limit to 10 tags break -yield web.tmpl.generate('tagentry', { +yield { 'parity': next(parity), 'tag': k, 'node': hex(n), 'date': web.repo[n].date(), -}) +} def bookmarks(**map): parity = paritygen(web.stripecount) @@ -742,7 +742,7 @@ def summary(web): 'date': web.repo[n].date(), 'node': hex(n)} -def changelist(**map): +def changelist(context): parity = paritygen(web.stripecount, offset=start - end) l = [] # build a list in forward order for efficiency revs = [] @@ -752,7 +752,7 @@ def summary(web): ctx = web.repo[i] lm = webutil.commonentry(web.repo, ctx) lm['parity'] = next(parity) -l.append(web.tmpl.generate('shortlogentry', lm)) +l.append(lm) for entry in reversed(l): yield entry @@ -771,10 +771,11 @@ def summary(web): desc=desc, owner=get_contact(web.config) or 'unknown', lastchange=tip.date(), -tags=tagentries, +tags=templateutil.mappinggenerator(tagentries, name='tagentry'), bookmarks=bookmarks, branches=webutil.branchentries(web.repo, web.stripecount, 10), -shortlog=changelist, +shortlog=templateutil.mappinggenerator(changelist, + name='shortlogentry'), node=tip.hex(), symrev='tip', archives=web.archivelist('tip'), diff --git a/mercurial/templates/gitweb/summary.tmpl b/mercurial/templates/gitweb/summary.tmpl --- a/mercurial/templates/gitweb/summary.tmpl +++ b/mercurial/templates/gitweb/summary.tmpl @@ -36,13 +36,13 @@ summary | changes -{shortlog} +{shortlog%shortlogentry} ... tags -{tags} +{tags%tagentry} ... diff --git a/mercurial/templates/monoblue/summary.tmpl b/mercurial/templates/monoblue/summary.tmpl --- a/mercurial/templates/monoblue/summary.tmpl +++ b/mercurial/templates/monoblue/summary.tmpl @@ -39,7 +39,7 @@ Changes -{shortlog} +{shortlog%shortlogentry} ... @@ -47,7 +47,7 @@ Tags -{tags} +{tags%tagentry} ... ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 1 of 8] templater: add function that expands internal literal templates
# HG changeset patch # User Yuya Nishihara # Date 1521295009 -32400 # Sat Mar 17 22:56:49 2018 +0900 # Node ID befd68a9bd8bb3ee4e450d20e6e7d279464f3f36 # Parent d3286dd2ca2f9f9e2b332e00c4b25b21729c54f5 templater: add function that expands internal literal templates This will be used when rendering nested formatter items with the default template, e.g. fm.nested('parents', tmpl='{rev}:{node|formatnode}', sep=' ') ^^^ the default item template diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -603,6 +603,7 @@ class engine(object): self._resources = resources self._aliasmap = _aliasrules.buildmap(aliases) self._cache = {} # key: (func, data) +self._tmplcache = {} # literal template: (func, data) def overlaymap(self, origmapping, newmapping): """Create combined mapping from the original mapping and partial @@ -659,6 +660,13 @@ class engine(object): raise return self._cache[t] +def _parse(self, tmpl): +"""Parse and cache a literal template""" +if tmpl not in self._tmplcache: +x = parse(tmpl) +self._tmplcache[tmpl] = compileexp(x, self, methods) +return self._tmplcache[tmpl] + def preload(self, t): """Load, parse, and cache the specified template if available""" try: @@ -672,6 +680,18 @@ class engine(object): mapping contains added elements for use during expansion. Is a generator.''' func, data = self._load(t) +return self._expand(func, data, mapping) + +def expand(self, tmpl, mapping): +"""Perform expansion over a literal template + +No user aliases will be expanded since this is supposed to be called +with an internal template string. +""" +func, data = self._parse(tmpl) +return self._expand(func, data, mapping) + +def _expand(self, func, data, mapping): # populate additional items only if they don't exist in the given # mapping. this is slightly different from overlaymap() because the # initial 'revcache' may contain pre-computed items. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 8 of 8] templater: deduplicate iterator of overlay mappings
# HG changeset patch # User Yuya Nishihara # Date 1522673652 -32400 # Mon Apr 02 21:54:12 2018 +0900 # Node ID 0e92d8efaea91db21670c7158b1128f924b30cf4 # Parent 00c9dda81b49f4242f174fd218c68b5c8bbc5fea templater: deduplicate iterator of overlay mappings diff --git a/mercurial/templateutil.py b/mercurial/templateutil.py --- a/mercurial/templateutil.py +++ b/mercurial/templateutil.py @@ -599,9 +599,7 @@ def runmap(context, mapping, data): diter = d.itermaps(context) else: diter = _checkeditermaps(darg, d) -for i, v in enumerate(diter): -lm = context.overlaymap(mapping, v) -lm['index'] = i +for lm in _iteroverlaymaps(context, mapping, diter): yield evalrawexp(context, lm, targ) def runmember(context, mapping, data): ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 7 of 8] templater: complain about invalid application of '%' operator (BC)
# HG changeset patch # User Yuya Nishihara # Date 1521374483 -32400 # Sun Mar 18 21:01:23 2018 +0900 # Node ID 00c9dda81b49f4242f174fd218c68b5c8bbc5fea # Parent 1c22443660286f711ea1c6993f6aef77d82a5c63 templater: complain about invalid application of '%' operator (BC) Before, '{x % y % z ...}' was silently evaluated as '{x % y}'. We no longer need this hack since the web template bugs was fixed by earlier patches. At this point, the error message may contain '', which will be fixed later. diff --git a/mercurial/templateutil.py b/mercurial/templateutil.py --- a/mercurial/templateutil.py +++ b/mercurial/templateutil.py @@ -567,6 +567,20 @@ def _formatfiltererror(arg, filt): return (_("template filter '%s' is not compatible with keyword '%s'") % (fn, sym)) +def _checkeditermaps(darg, d): +try: +for v in d: +if not isinstance(v, dict): +raise TypeError +yield v +except TypeError: +sym = findsymbolicname(darg) +if sym: +raise error.ParseError(_("keyword '%s' is not iterable of mappings") + % sym) +else: +raise error.ParseError(_("%r is not iterable of mappings") % d) + def _iteroverlaymaps(context, origmapping, newmappings): """Generate combined mappings from the original mapping and an iterable of partial mappings to override the original""" @@ -578,28 +592,17 @@ def _iteroverlaymaps(context, origmappin def runmap(context, mapping, data): darg, targ = data d = evalrawexp(context, mapping, darg) +# TODO: a generator should be rejected because it is a thunk of lazy +# string, but we can't because hgweb abuses generator as a keyword +# that returns a list of dicts. if isinstance(d, wrapped): diter = d.itermaps(context) else: -try: -diter = iter(d) -except TypeError: -sym = findsymbolicname(darg) -if sym: -raise error.ParseError(_("keyword '%s' is not iterable") % sym) -else: -raise error.ParseError(_("%r is not iterable") % d) - +diter = _checkeditermaps(darg, d) for i, v in enumerate(diter): -if isinstance(v, dict): -lm = context.overlaymap(mapping, v) -lm['index'] = i -yield evalrawexp(context, lm, targ) -else: -# v is not an iterable of dicts, this happen when 'key' -# has been fully expanded already and format is useless. -# If so, return the expanded value. -yield v +lm = context.overlaymap(mapping, v) +lm['index'] = i +yield evalrawexp(context, lm, targ) def runmember(context, mapping, data): darg, memb = data diff --git a/tests/test-command-template.t b/tests/test-command-template.t --- a/tests/test-command-template.t +++ b/tests/test-command-template.t @@ -3210,10 +3210,13 @@ Test new-style inline templating: $ hg log -R latesttag -r tip -T '{rev % "a"}\n' - hg: parse error: keyword 'rev' is not iterable + hg: parse error: keyword 'rev' is not iterable of mappings [255] $ hg log -R latesttag -r tip -T '{get(extras, "unknown") % "a"}\n' - hg: parse error: None is not iterable + hg: parse error: None is not iterable of mappings + [255] + $ hg log -R latesttag -r tip -T '{extras % "{key}\n" % "{key}\n"}' + hg: parse error: is not iterable of mappings (glob) [255] Test new-style inline templating of non-list/dict type: @@ -3228,7 +3231,7 @@ Test new-style inline templating of non- $ hg log -R latesttag -r tip -T '{get(extras, "branch") % "{key}: {value}\n"}' branch: default $ hg log -R latesttag -r tip -T '{get(extras, "unknown") % "{key}\n"}' - hg: parse error: None is not iterable + hg: parse error: None is not iterable of mappings [255] $ hg log -R latesttag -r tip -T '{min(extras) % "{key}: {value}\n"}' branch: default ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 3 of 8] hgweb: fix search {entries} to not return results of template expansion
# HG changeset patch # User Yuya Nishihara # Date 1521373899 -32400 # Sun Mar 18 20:51:39 2018 +0900 # Node ID 083ce2cf66079739b029f7e067a2e9339704c006 # Parent 41f4b8e798c8c46261aa4b6060f5aae4954c1b24 hgweb: fix search {entries} to not return results of template expansion "{entries%changelogentry}" in raw/search.tmpl was utterly wrong because "{entries}" here was a generator yielding results of template expansion. That's why we have a weird hack in runmap(), which I'm going to get rid of. https://www.mercurial-scm.org/repo/hg/file/4.5.2/mercurial/templater.py#l469 We have two choices: a) drop "%changelogentry" from raw/search.tmpl b) fix "{entries}" to yield mappings I take (b) because that's what the other log-like "{entries}" do. The "entries" keyword is wrapped by mappinggenerator so "{entries}" without "%searchentry" still works. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -36,6 +36,7 @@ from .. import ( scmutil, smartset, templater, +templateutil, ) from ..utils import ( @@ -287,7 +288,7 @@ def _search(web): LookupError): return MODE_KEYWORD, query -def changelist(**map): +def changelist(context): count = 0 for ctx in searchfunc[0](funcarg): @@ -303,7 +304,7 @@ def _search(web): 'changelogtag': showtags, 'files': files, }) -yield web.tmpl.generate('searchentry', lm) +yield lm if count >= revcount: break @@ -349,7 +350,7 @@ def _search(web): query=query, node=tip.hex(), symrev='tip', -entries=changelist, +entries=templateutil.mappinggenerator(changelist, name='searchentry'), archives=web.archivelist('tip'), morevars=morevars, lessvars=lessvars, diff --git a/mercurial/templates/gitweb/map b/mercurial/templates/gitweb/map --- a/mercurial/templates/gitweb/map +++ b/mercurial/templates/gitweb/map @@ -57,7 +57,6 @@ filenav = '{before%filenaventry}{after%f fileellipses = '...' changelogentry = changelogentry.tmpl -searchentry = changelogentry.tmpl changeset = changeset.tmpl manifest = manifest.tmpl direntry = ' diff --git a/mercurial/templates/gitweb/search.tmpl b/mercurial/templates/gitweb/search.tmpl --- a/mercurial/templates/gitweb/search.tmpl +++ b/mercurial/templates/gitweb/search.tmpl @@ -30,6 +30,6 @@ searching for {query|escape} -{entries} +{entries%changelogentry} {footer} diff --git a/mercurial/templates/json/map b/mercurial/templates/json/map --- a/mercurial/templates/json/map +++ b/mercurial/templates/json/map @@ -18,9 +18,8 @@ lineentry = '\{ search = '\{ "node": {node|json}, "query": {query|json}, - "entries": [{join(entries%searchentry, ", ")}] + "entries": [{join(entries%changelistentry, ", ")}] }' -searchentry = '{changelistentry}' # changelog and shortlog are the same web API but with different # number of entries. changelog = changelist.tmpl diff --git a/mercurial/templates/monoblue/map b/mercurial/templates/monoblue/map --- a/mercurial/templates/monoblue/map +++ b/mercurial/templates/monoblue/map @@ -57,7 +57,6 @@ filenav = '{before%filenaventry}{after%f fileellipses = '...' changelogentry = changelogentry.tmpl -searchentry = changelogentry.tmpl changeset = changeset.tmpl manifest = manifest.tmpl direntry = ' diff --git a/mercurial/templates/monoblue/search.tmpl b/mercurial/templates/monoblue/search.tmpl --- a/mercurial/templates/monoblue/search.tmpl +++ b/mercurial/templates/monoblue/search.tmpl @@ -26,6 +26,6 @@ searching for {query|escape} -{entries} +{entries%changelogentry} {footer} diff --git a/mercurial/templates/paper/map b/mercurial/templates/paper/map --- a/mercurial/templates/paper/map +++ b/mercurial/templates/paper/map @@ -33,7 +33,6 @@ fileellipses = '...' diffstatlink = diffstat.tmpl diffstatnolink = diffstat.tmpl changelogentry = shortlogentry.tmpl -searchentry = shortlogentry.tmpl changeset = changeset.tmpl manifest = manifest.tmpl diff --git a/mercurial/templates/paper/search.tmpl b/mercurial/templates/paper/search.tmpl --- a/mercurial/templates/paper/search.tmpl +++ b/mercurial/templates/paper/search.tmpl @@ -49,7 +49,7 @@ Use {showunforcekw} instead.')} -{entries} +{entries%changelogentry} diff --git a/mercurial/templates/raw/map b/mercurial/templates/raw/map --- a/mercurial/templates/raw/map +++ b/mercurial/templates/raw/map @@ -3,7 +3,6 @@ shortlog = "'raw' is not a browsable sty changelog = changelog.tmpl changelogentry = logentry.tmpl search = search.tmpl -searchentry = logentry.tmpl mimetype = 'text/plain; charset={encoding}' header = '' footer = '' diff --git a/mercurial/templates/spartan/map b/mercurial/templates/spartan/map --- a/mercurial/templates/spartan/map +++ b/mercurial/templates/spartan/map
[PATCH 2 of 8] templater: add class representing a nested mappings
# HG changeset patch # User Yuya Nishihara # Date 1521294422 -32400 # Sat Mar 17 22:47:02 2018 +0900 # Node ID 41f4b8e798c8c46261aa4b6060f5aae4954c1b24 # Parent befd68a9bd8bb3ee4e450d20e6e7d279464f3f36 templater: add class representing a nested mappings The mappinggenerator class is necessary to fix hgweb bugs without BC. The mappinglist is for nested formatter items. They are similar, so factored out the base class. The mappinglist could be implemented by using the mappinggenerator, but we'll probably need a direct access to the raw list, so they are implemented as separate classes. Note that tovalue() isn't conforming to the spec yet in that it may return a list of dicts containing unprintable resources. This problem will be fixed later. Tests will be added by subsequent patches. diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -44,6 +44,10 @@ hybrid mappable represents a scalar printable value, also supports % operator. + +mappinggenerator, mappinglist +represents mappings (i.e. a list of dicts), which may have default +output format. """ from __future__ import absolute_import, print_function diff --git a/mercurial/templateutil.py b/mercurial/templateutil.py --- a/mercurial/templateutil.py +++ b/mercurial/templateutil.py @@ -170,6 +170,63 @@ class mappable(wrapped): def tovalue(self, context, mapping): return _unthunk(context, mapping, self._value) +class _mappingsequence(wrapped): +"""Wrapper for sequence of template mappings + +This represents an inner template structure (i.e. a list of dicts), +which can also be rendered by the specified named/literal template. + +Template mappings may be nested. +""" + +def __init__(self, name=None, tmpl=None, sep=''): +if name is not None and tmpl is not None: +raise error.ProgrammingError('name and tmpl are mutually exclusive') +self._name = name +self._tmpl = tmpl +self._defaultsep = sep + +def join(self, context, mapping, sep): +mapsiter = _iteroverlaymaps(context, mapping, self.itermaps(context)) +if self._name: +itemiter = (context.process(self._name, m) for m in mapsiter) +elif self._tmpl: +itemiter = (context.expand(self._tmpl, m) for m in mapsiter) +else: +raise error.ParseError(_('not displayable without template')) +return joinitems(itemiter, sep) + +def show(self, context, mapping): +return self.join(context, mapping, self._defaultsep) + +def tovalue(self, context, mapping): +return list(self.itermaps(context)) + +class mappinggenerator(_mappingsequence): +"""Wrapper for generator of template mappings + +The function ``make(context, *args)`` should return a generator of +mapping dicts. +""" + +def __init__(self, make, args=(), name=None, tmpl=None, sep=''): +super(mappinggenerator, self).__init__(name, tmpl, sep) +self._make = make +self._args = args + +def itermaps(self, context): +return self._make(context, *self._args) + +class mappinglist(_mappingsequence): +"""Wrapper for list of template mappings""" + +def __init__(self, mappings, name=None, tmpl=None, sep=''): +super(mappinglist, self).__init__(name, tmpl, sep) +self._mappings = mappings + +def itermaps(self, context): +return iter(self._mappings) + def hybriddict(data, key='key', value='value', fmt=None, gen=None): """Wrap data to support both dict-like and string-like operations""" prefmt = pycompat.identity @@ -510,6 +567,14 @@ def _formatfiltererror(arg, filt): return (_("template filter '%s' is not compatible with keyword '%s'") % (fn, sym)) +def _iteroverlaymaps(context, origmapping, newmappings): +"""Generate combined mappings from the original mapping and an iterable +of partial mappings to override the original""" +for i, nm in enumerate(newmappings): +lm = context.overlaymap(origmapping, nm) +lm['index'] = i +yield lm + def runmap(context, mapping, data): darg, targ = data d = evalrawexp(context, mapping, darg) ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 5 of 8] hgweb: fix {diff} expansion in JSON template
# HG changeset patch # User Yuya Nishihara # Date 1521377180 -32400 # Sun Mar 18 21:46:20 2018 +0900 # Node ID a55c83d928093ea1e1b8d40eee4e799fb3bfe0cd # Parent 9e623cb78522c9a52eeb25092c75b7f439c9e045 hgweb: fix {diff} expansion in JSON template The same sort of bug as the previous patch. In this case, I decided to fix the JSON template since we aren't ready to fix the {diff} keyword without BC. I'll rework it later. diff --git a/mercurial/templates/json/map b/mercurial/templates/json/map --- a/mercurial/templates/json/map +++ b/mercurial/templates/json/map @@ -142,7 +142,7 @@ filediff = '\{ "author": {author|utf8|json}, "parents": [{join(parent%changesetparent, ", ")}], "children": [{join(child%changesetparent, ", ")}], - "diff": [{join(diff%diffblock, ", ")}] + "diff": [{join(diff, ", ")}] }' diffblock = '\{ "blockno": {blockno|json}, ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 6 of 8] hgweb: fix type of {nav} keyword when linerange filter is active
# HG changeset patch # User Yuya Nishihara # Date 1521375537 -32400 # Sun Mar 18 21:18:57 2018 +0900 # Node ID 1c22443660286f711ea1c6993f6aef77d82a5c63 # Parent a55c83d928093ea1e1b8d40eee4e799fb3bfe0cd hgweb: fix type of {nav} keyword when linerange filter is active Spotted by making '%' operator check the operand type more strictly. Before, "{nav}" would be evaluated to a lazy "" (empty string) and {"" % x} would yield one empty string. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -1082,7 +1082,7 @@ def filelog(web): linerange = webutil.formatlinerange(*lrange) # deactivate numeric nav links when linerange is specified as this # would required a dedicated "revnav" class -nav = None +nav = [] if descend: it = dagop.blockdescendants(fctx, *lrange) else: diff --git a/tests/test-hgweb-filelog.t b/tests/test-hgweb-filelog.t --- a/tests/test-hgweb-filelog.t +++ b/tests/test-hgweb-filelog.t @@ -755,7 +755,7 @@ before addition - error less more - | + | @@ -791,7 +791,7 @@ before addition - error less more - | + | @@ -875,7 +875,7 @@ before addition - error less more - | + | @@ -902,7 +902,7 @@ before addition - error less more - | + | @@ -1394,7 +1394,7 @@ filelog with 'linerange' and 'patch' less more - | + | @@ -1500,7 +1500,7 @@ filelog with 'linerange' and 'patch' less more - | + | @@ -1651,7 +1651,7 @@ filelog with 'linerange' and 'patch' less more - | + | @@ -1696,7 +1696,7 @@ filelog with 'linerange' and 'patch' less more - | + | ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3134: util: whitelist apfs for hardlink support
durin42 created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Seems to work fine for me. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3134 AFFECTED FILES mercurial/util.py CHANGE DETAILS diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1544,6 +1544,7 @@ # a whilelist of known filesystems where hardlink works reliably _hardlinkfswhitelist = { +'apfs', 'btrfs', 'ext2', 'ext3', 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
D3130: py3: suppress output from f.write() function class
This revision was automatically updated to reflect the committed changes. Closed by commit rHG22f19da5736e: py3: suppress output from f.write() function class (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3130?vs=7713&id=7728 REVISION DETAIL https://phab.mercurial-scm.org/D3130 AFFECTED FILES tests/test-diff-unified.t CHANGE DETAILS diff --git a/tests/test-diff-unified.t b/tests/test-diff-unified.t --- a/tests/test-diff-unified.t +++ b/tests/test-diff-unified.t @@ -394,33 +394,33 @@ $ cd longfunc >>> with open('a', 'wb') as f: - ... f.write(b'a' * 39 + b'bb' + b'\n') - ... f.write(b' .\n' * 3) - ... f.write(b' 0 b\n') - ... f.write(b' .\n' * 3) - ... f.write(b'a' * 39 + b'\xc3\xa0' + b'\n') - ... f.write(b' .\n' * 3) - ... f.write(b' 0 a with grave (single code point)\n') - ... f.write(b' .\n' * 3) - ... f.write(b'a' * 39 + b'a\xcc\x80' + b'\n') - ... f.write(b' .\n' * 3) - ... f.write(b' 0 a with grave (composition)\n') - ... f.write(b' .\n' * 3) + ... f.write(b'a' * 39 + b'bb' + b'\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b' 0 b\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b'a' * 39 + b'\xc3\xa0' + b'\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b' 0 a with grave (single code point)\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b'a' * 39 + b'a\xcc\x80' + b'\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b' 0 a with grave (composition)\n') and None + ... f.write(b' .\n' * 3) and None $ hg ci -qAm0 >>> with open('a', 'wb') as f: - ... f.write(b'a' * 39 + b'bb' + b'\n') - ... f.write(b' .\n' * 3) - ... f.write(b' 1 b\n') - ... f.write(b' .\n' * 3) - ... f.write(b'a' * 39 + b'\xc3\xa0' + b'\n') - ... f.write(b' .\n' * 3) - ... f.write(b' 1 a with grave (single code point)\n') - ... f.write(b' .\n' * 3) - ... f.write(b'a' * 39 + b'a\xcc\x80' + b'\n') - ... f.write(b' .\n' * 3) - ... f.write(b' 1 a with grave (composition)\n') - ... f.write(b' .\n' * 3) + ... f.write(b'a' * 39 + b'bb' + b'\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b' 1 b\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b'a' * 39 + b'\xc3\xa0' + b'\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b' 1 a with grave (single code point)\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b'a' * 39 + b'a\xcc\x80' + b'\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b' 1 a with grave (composition)\n') and None + ... f.write(b' .\n' * 3) and None $ hg ci -m1 $ hg diff -c1 --nodates --show-function To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3127: py3: return bytes from util.removeauth()
This revision was automatically updated to reflect the committed changes. Closed by commit rHGb23e3cc1afd4: py3: return bytes from util.removeauth() (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3127?vs=7710&id=7725 REVISION DETAIL https://phab.mercurial-scm.org/D3127 AFFECTED FILES mercurial/util.py CHANGE DETAILS diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -2864,7 +2864,7 @@ '''remove all authentication information from a url string''' u = url(u) u.user = u.passwd = None -return str(u) +return bytes(u) timecount = unitcountfn( (1, 1e3, _('%.0f s')), To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3128: py3: suppress the output of open() using `and None`
This revision was automatically updated to reflect the committed changes. Closed by commit rHG87c4253bebdb: py3: suppress the output of open() using `and None` (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3128?vs=7711&id=7726 REVISION DETAIL https://phab.mercurial-scm.org/D3128 AFFECTED FILES tests/test-diffstat.t CHANGE DETAILS diff --git a/tests/test-diffstat.t b/tests/test-diffstat.t --- a/tests/test-diffstat.t +++ b/tests/test-diffstat.t @@ -35,7 +35,7 @@ $ hg ci -m appenda - >>> open("c", "wb").write(b"\0") + >>> open("c", "wb").write(b"\0") and None $ touch d $ hg add c d @@ -54,7 +54,7 @@ $ hg ci -m createb - >>> open("file with spaces", "wb").write(b"\0") + >>> open("file with spaces", "wb").write(b"\0") and None $ hg add "file with spaces" Filename with spaces diffstat: To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3132: py3: add missing b'' prefix in mdiff.py
This revision was automatically updated to reflect the committed changes. Closed by commit rHGd3286dd2ca2f: py3: add missing b'' prefix in mdiff.py (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3132?vs=7715&id=7730 REVISION DETAIL https://phab.mercurial-scm.org/D3132 AFFECTED FILES mercurial/mdiff.py CHANGE DETAILS diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py --- a/mercurial/mdiff.py +++ b/mercurial/mdiff.py @@ -97,7 +97,7 @@ if blank and opts.ignoreblanklines: text = re.sub('\n+', '\n', text).strip('\n') if opts.ignorewseol: -text = re.sub(br'[ \t\r\f]+\n', r'\n', text) +text = re.sub(br'[ \t\r\f]+\n', br'\n', text) return text def splitblock(base1, lines1, base2, lines2, opts): To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3131: py3: fix error string with bytestr() on repr()d value
This revision was automatically updated to reflect the committed changes. Closed by commit rHGb6de372b4309: py3: fix error string with bytestr() on repr()d value (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3131?vs=7714&id=7729 REVISION DETAIL https://phab.mercurial-scm.org/D3131 AFFECTED FILES mercurial/mdiff.py CHANGE DETAILS diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py --- a/mercurial/mdiff.py +++ b/mercurial/mdiff.py @@ -78,7 +78,8 @@ self.context = int(self.context) except ValueError: raise error.Abort(_('diff context lines count must be ' - 'an integer, not %r') % self.context) +'an integer, not %r') % + pycompat.bytestr(self.context)) def copy(self, **kwargs): opts = dict((k, getattr(self, k)) for k in self.defaults) To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3126: py3: use bytes instead of str in instance()
This revision was automatically updated to reflect the committed changes. Closed by commit rHG1ccd75027abb: py3: use bytes instead of str in instance() (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3126?vs=7709&id=7724 REVISION DETAIL https://phab.mercurial-scm.org/D3126 AFFECTED FILES mercurial/logexchange.py CHANGE DETAILS diff --git a/mercurial/logexchange.py b/mercurial/logexchange.py --- a/mercurial/logexchange.py +++ b/mercurial/logexchange.py @@ -106,7 +106,7 @@ rpath = remote if local: rpath = remote._repo.root -elif not isinstance(remote, str): +elif not isinstance(remote, bytes): rpath = remote._url # represent the remotepath with user defined path name if exists To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3129: py3: use pycompat.byteskwargs() in tests/autodiff.py
This revision was automatically updated to reflect the committed changes. Closed by commit rHGcdccfe20eed7: py3: use pycompat.byteskwargs() in tests/autodiff.py (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3129?vs=7712&id=7727 REVISION DETAIL https://phab.mercurial-scm.org/D3129 AFFECTED FILES tests/autodiff.py CHANGE DETAILS diff --git a/tests/autodiff.py b/tests/autodiff.py --- a/tests/autodiff.py +++ b/tests/autodiff.py @@ -5,6 +5,7 @@ from mercurial import ( error, patch, +pycompat, registrar, scmutil, ) @@ -16,6 +17,7 @@ [(b'', b'git', b'', b'git upgrade mode (yes/no/auto/warn/abort)')], b'[OPTION]... [FILE]...') def autodiff(ui, repo, *pats, **opts): +opts = pycompat.byteskwargs(opts) diffopts = patch.difffeatureopts(ui, opts) git = opts.get(b'git', b'no') brokenfiles = set() To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3124: py3: use pycompat.bytestr in test-journal.t
This revision was automatically updated to reflect the committed changes. Closed by commit rHG1d26f745a10b: py3: use pycompat.bytestr in test-journal.t (authored by pulkit, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3124?vs=7707&id=7723 REVISION DETAIL https://phab.mercurial-scm.org/D3124 AFFECTED FILES tests/test-journal.t CHANGE DETAILS diff --git a/tests/test-journal.t b/tests/test-journal.t --- a/tests/test-journal.t +++ b/tests/test-journal.t @@ -3,7 +3,7 @@ $ cat >> testmocks.py << EOF > # mock out procutil.getuser() and util.makedate() to supply testable values > import os - > from mercurial import util + > from mercurial import util, pycompat > from mercurial.utils import dateutil, procutil > def mockgetuser(): > return 'foobar' @@ -16,7 +16,7 @@ > except IOError: > time = 0.0 > with open(filename, 'wb') as timef: - > timef.write(str(time)) + > timef.write(pycompat.bytestr(time)) > return (time, 0) > > procutil.getuser = mockgetuser To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3125: py3: convert user value to bytes using pycompat.fsencode()
yuja requested changes to this revision. yuja added a comment. This revision now requires changes to proceed. Unicode issue is handled by posix.py. The problem is `mockgetuser()` returns a unicode string. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3125 To: pulkit, #hg-reviewers, yuja Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3123: py3: use list comprehension instead of map()
yuja requested changes to this revision. yuja added a comment. This revision now requires changes to proceed. That shouldn't matter here because bytes.join() takes an iterable. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3123 To: pulkit, #hg-reviewers, yuja Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3086: pull: pass rev to check out as integer to postincoming()
This revision was automatically updated to reflect the committed changes. Closed by commit rHGd5e1678026fd: pull: pass rev to check out as integer to postincoming() (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3086?vs=7660&id=7717 REVISION DETAIL https://phab.mercurial-scm.org/D3086 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 @@ -4034,7 +4034,7 @@ brev = None if checkout: -checkout = "%d" % repo.changelog.rev(checkout) +checkout = repo.changelog.rev(checkout) # order below depends on implementation of # hg.addbranchrevs(). opts['bookmark'] is ignored, 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
D3122: hgweb: don't include hidden revisions in /filelog/ view
This revision was automatically updated to reflect the committed changes. Closed by commit rHGd3a236e6: hgweb: don't include hidden revisions in /filelog/ view (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3122?vs=7704&id=7722 REVISION DETAIL https://phab.mercurial-scm.org/D3122 AFFECTED FILES mercurial/hgweb/webcommands.py tests/test-obsolete.t CHANGE DETAILS diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t --- a/tests/test-obsolete.t +++ b/tests/test-obsolete.t @@ -897,65 +897,7 @@ check filelog view for hidden commits (obsolete ones are hidden here) $ get-with-headers.py localhost:$HGPORT 'log/'`hg log -r . -T "{node}"`/'babar' | grep obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete - draft obsolete + [1] $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/68' 200 Script output follows diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -1058,7 +1058,9 @@ parity = paritygen(web.stripecount, offset=start - end) repo = web.repo -revs = fctx.filelog().revs(start, end - 1) +filelog = fctx.filelog() +revs = [filerev for filerev in filelog.revs(start, end - 1) +if filelog.linkrev(filerev) in repo] entries = [] diffstyle = web.config('web', 'style') To: martinvonz, #hg-reviewers, yuja Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3121: tests: show that hgweb contains hidden revisions in /filelog/ view
This revision was automatically updated to reflect the committed changes. Closed by commit rHGc16b55edd408: tests: show that hgweb contains hidden revisions in /filelog/ view (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3121?vs=7703&id=7721 REVISION DETAIL https://phab.mercurial-scm.org/D3121 AFFECTED FILES tests/test-obsolete.t CHANGE DETAILS diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t --- a/tests/test-obsolete.t +++ b/tests/test-obsolete.t @@ -894,6 +894,69 @@ $ get-with-headers.py --headeronly localhost:$HGPORT 'log/'`hg log -r . -T "{node}"`/'babar' 200 Script output follows +check filelog view for hidden commits (obsolete ones are hidden here) + + $ get-with-headers.py localhost:$HGPORT 'log/'`hg log -r . -T "{node}"`/'babar' | grep obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + draft obsolete + $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/68' 200 Script output follows $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/67' 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
D3088: extdatasource: use revsymbol() for converting to node
This revision was automatically updated to reflect the committed changes. Closed by commit rHGd0d55980ffa7: extdatasource: use revsymbol() for converting to node (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3088?vs=7662&id=7719 REVISION DETAIL https://phab.mercurial-scm.org/D3088 AFFECTED FILES mercurial/scmutil.py CHANGE DETAILS diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -1134,7 +1134,7 @@ k = encoding.tolocal(k) try: -data[repo[k].rev()] = encoding.tolocal(v) +data[revsingle(repo, k).rev()] = encoding.tolocal(v) except (error.LookupError, error.RepoLookupError): pass # we ignore data for nodes that don't exist locally finally: To: martinvonz, #hg-reviewers, yuja Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3089: convert: use repo.lookup() for converting to nodeid
This revision was automatically updated to reflect the committed changes. Closed by commit rHGe45545f7895e: convert: use repo.lookup() for converting to nodeid (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3089?vs=7663&id=7720 REVISION DETAIL https://phab.mercurial-scm.org/D3089 AFFECTED FILES hgext/convert/hg.py CHANGE DETAILS diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py --- a/hgext/convert/hg.py +++ b/hgext/convert/hg.py @@ -481,7 +481,7 @@ else: self.keep = util.always if revs: -self._heads = [self.repo[r].node() for r in revs] +self._heads = [self.repo.lookup(r) for r in revs] else: self._heads = self.repo.heads() else: 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
D3087: bookmarks: calculateupdate() returns a bookmark, not a rev
This revision was automatically updated to reflect the committed changes. Closed by commit rHGe27298bf11dd: bookmarks: calculateupdate() returns a bookmark, not a rev (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3087?vs=7661&id=7718 REVISION DETAIL https://phab.mercurial-scm.org/D3087 AFFECTED FILES mercurial/bookmarks.py mercurial/destutil.py CHANGE DETAILS diff --git a/mercurial/destutil.py b/mercurial/destutil.py --- a/mercurial/destutil.py +++ b/mercurial/destutil.py @@ -55,10 +55,10 @@ def _destupdatebook(repo, clean): """decide on an update destination from active bookmark""" # we also move the active bookmark, if any -activemark = None -node, movemark = bookmarks.calculateupdate(repo.ui, repo, None) -if node is not None: -activemark = node +node = None +activemark, movemark = bookmarks.calculateupdate(repo.ui, repo, None) +if activemark is not None: +node = repo.lookup(activemark) return node, movemark, activemark def _destupdatebranch(repo, clean): diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py --- a/mercurial/bookmarks.py +++ b/mercurial/bookmarks.py @@ -349,8 +349,8 @@ return heads def calculateupdate(ui, repo, checkout): -'''Return a tuple (targetrev, movemarkfrom) indicating the rev to -check out and where to move the active bookmark from, if needed.''' +'''Return a tuple (activemark, movemarkfrom) indicating the active bookmark +and where to move the active bookmark from, if needed.''' movemarkfrom = None if checkout is None: activemark = repo._activebookmark To: martinvonz, #hg-reviewers, yuja Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3122: hgweb: don't include hidden revisions in /filelog/ view
yuja accepted this revision. yuja added a comment. This revision is now accepted and ready to land. It's a bit scary to rely on `linkrev()`, but the way how hgweb handles fctxs effectively disables linkrev adjustment. So this should be good enough for now. Queued, thanks. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3122 To: martinvonz, #hg-reviewers, yuja Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3088: extdatasource: use revsymbol() for converting to node
yuja accepted this revision. yuja added a comment. This revision is now accepted and ready to land. > Perhaps it should just be nodeids? I think it should be, but the test disagree. Maybe we can make BC since it's still an experimental feature. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3088 To: martinvonz, #hg-reviewers, yuja Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3087: bookmarks: calculateupdate() returns a bookmark, not a rev
yuja accepted this revision. yuja added inline comments. This revision is now accepted and ready to land. INLINE COMMENTS > bookmarks.py:353 > +'''Return a tuple (activemark, movemarkfrom) indicating the active > bookmark > +and where to move the active bookmark from, if needed.''' > movemarkfrom = None That's true only if `checkout` is None. Perhaps we should remove the checkout argument. Can you send a follow up? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3087 To: martinvonz, #hg-reviewers, yuja Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 1 of 2] copies: create and use _loose_next function for _related
On Wed, 04 Apr 2018 15:35:33 +0200, Gábor Stefanik wrote: > # HG changeset patch > # User Gábor Stefanik > # Date 1522848489 -7200 > # Wed Apr 04 15:28:09 2018 +0200 > # Node ID d72ca973100a1f1a4451a7d1efdc3e43ebc2912e > # Parent 656ac240f39284eec4435d25c01d71056aa4e8a5 > copies: create and use _loose_next function for _related > > _loose_next is going to be a variant of the next function that tries to follow > grafts and similar relationship when the regular next raises StopIteration. > This is needed for bug 5834. Can you send this with the actual fix? It's unclear how _loose_next() will be used to address the problem. > +def _loose_next(g): s/_loose_next/_loosenext/ per coding style. > @@ -748,16 +754,16 @@ > f1r, f2r = f1.linkrev(), f2.linkrev() > > if f1r is None: > -f1 = next(g1) > +f1, g1 = _loose_next(g1) > if f2r is None: > -f2 = next(g2) > +f1, g1 = _loose_next(g1) s/g1/g2/g > while True: > f1r, f2r = f1.linkrev(), f2.linkrev() > if f1r > f2r: > -f1 = next(g1) > +f1, g1 = _loose_next(g1) > elif f2r > f1r: > -f2 = next(g2) > +f1, g1 = _loose_next(g1) s/g1/g2/g ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 2 of 2] copies: clean up _related logic
On Wed, 04 Apr 2018 15:35:34 +0200, Gábor Stefanik wrote: > # HG changeset patch > # User Gábor Stefanik > # Date 1522848882 -7200 > # Wed Apr 04 15:34:42 2018 +0200 > # Node ID 084ee003f2f3cb4d51129c4f1bb63e1ff4db14d0 > # Parent d72ca973100a1f1a4451a7d1efdc3e43ebc2912e > copies: clean up _related logic > > The limit parameter was never actually used, since the only way the 4th case > could be reached was if f1r and f2r converged. The new code makes this clear, > and additionally reduces the conditional block to just 3 cases. Yeah. I suspect the limit should be tested first, but doing that breaks some tests. So, perhaps we have to handle the case of f.linkrev() < anc.rev() anyway. > diff -r d72ca973100a -r 084ee003f2f3 mercurial/copies.py > --- a/mercurial/copies.py Wed Apr 04 15:28:09 2018 +0200 > +++ b/mercurial/copies.py Wed Apr 04 15:34:42 2018 +0200 > @@ -737,7 +737,7 @@ > except StopIteration: > raise > > -def _related(f1, f2, limit): > +def _related(f1, f2): There's one more caller of _related(). > @@ -764,10 +764,8 @@ > f1, g1 = _loose_next(g1) > elif f2r > f1r: > f1, g1 = _loose_next(g1) > -elif f1 == f2: > -return f1 # a match > -elif f1r == f2r or f1r < limit or f2r < limit: > -return False # copy no longer relevant > +else: # f1 and f2 point to files in the same linkrev > +return f1 == f2 # true if they point to the same file ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3132: py3: add missing b'' prefix in mdiff.py
pulkit created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Transformer won't add b'' prefix because that value is already have a r'' prefix. 1. skip-blame because just b'' prefix REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3132 AFFECTED FILES mercurial/mdiff.py CHANGE DETAILS diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py --- a/mercurial/mdiff.py +++ b/mercurial/mdiff.py @@ -97,7 +97,7 @@ if blank and opts.ignoreblanklines: text = re.sub('\n+', '\n', text).strip('\n') if opts.ignorewseol: -text = re.sub(br'[ \t\r\f]+\n', r'\n', text) +text = re.sub(br'[ \t\r\f]+\n', br'\n', text) return text def splitblock(base1, lines1, base2, lines2, opts): To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3133: py3: whitelist 13 new passing tests
pulkit created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Some tests were passing before the series too. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3133 AFFECTED FILES contrib/python3-whitelist CHANGE DETAILS diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -82,18 +82,24 @@ test-diff-change.t test-diff-copy-depth.t test-diff-hashes.t +test-diff-ignore-whitespace.t +test-diff-indent-heuristic.t (case bdiff) +test-diff-indent-heuristic.t (case xdiff) test-diff-issue2761.t test-diff-newlines.t test-diff-reverse.t test-diff-subdir.t +test-diff-unified.t +test-diff-upgrade.t test-diffdir.t test-directaccess.t test-dirstate-backup.t test-dirstate-nonnormalset.t test-doctest.py test-double-merge.t test-drawdag.t test-duplicateoptions.py +test-editor-filename.t test-empty-dir.t test-empty-file.t test-empty-group.t @@ -184,20 +190,25 @@ test-issue586.t test-issue612.t test-issue619.t +test-issue660.t test-issue672.t test-issue842.t test-journal-exists.t +test-journal-share.t +test-journal.t test-largefiles-cache.t test-largefiles-misc.t test-largefiles-small-disk.t test-largefiles-update.t test-lfs-largefiles.t test-locate.t test-lock-badness.t +test-log-linerange.t test-log.t test-logexchange.t test-lrucachedict.py test-mactext.t +test-mailmap.t test-manifest-merging.t test-manifest.py test-manifest.t @@ -327,6 +338,7 @@ test-rebase-cache.t test-rebase-check-restore.t test-rebase-collapse.t +test-rebase-conflicts.t test-rebase-dest.t test-rebase-detach.t test-rebase-emptycommit.t @@ -380,6 +392,7 @@ test-ssh-clone-r.t test-ssh-proto.t test-sshserver.py +test-stack.t test-status-rev.t test-status-terse.t test-strip-cross.t To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3131: py3: fix error string with bytestr() on repr()d value
pulkit 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/D3131 AFFECTED FILES mercurial/mdiff.py CHANGE DETAILS diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py --- a/mercurial/mdiff.py +++ b/mercurial/mdiff.py @@ -78,7 +78,8 @@ self.context = int(self.context) except ValueError: raise error.Abort(_('diff context lines count must be ' - 'an integer, not %r') % self.context) +'an integer, not %r') % + pycompat.bytestr(self.context)) def copy(self, **kwargs): opts = dict((k, getattr(self, k)) for k in self.defaults) To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3127: py3: return bytes from util.removeauth()
pulkit created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY util.hidepassword() also returns bytes and we should deal in bytes as much as possible. This makes test-logexchange.t pass on Python 3.5 REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3127 AFFECTED FILES mercurial/util.py CHANGE DETAILS diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -2864,7 +2864,7 @@ '''remove all authentication information from a url string''' u = url(u) u.user = u.passwd = None -return str(u) +return bytes(u) timecount = unitcountfn( (1, 1e3, _('%.0f s')), To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3130: py3: suppress output from f.write() function class
pulkit created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY We need to suppress them because the output is not present on Python 2 REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3130 AFFECTED FILES tests/test-diff-unified.t CHANGE DETAILS diff --git a/tests/test-diff-unified.t b/tests/test-diff-unified.t --- a/tests/test-diff-unified.t +++ b/tests/test-diff-unified.t @@ -394,33 +394,33 @@ $ cd longfunc >>> with open('a', 'wb') as f: - ... f.write(b'a' * 39 + b'bb' + b'\n') - ... f.write(b' .\n' * 3) - ... f.write(b' 0 b\n') - ... f.write(b' .\n' * 3) - ... f.write(b'a' * 39 + b'\xc3\xa0' + b'\n') - ... f.write(b' .\n' * 3) - ... f.write(b' 0 a with grave (single code point)\n') - ... f.write(b' .\n' * 3) - ... f.write(b'a' * 39 + b'a\xcc\x80' + b'\n') - ... f.write(b' .\n' * 3) - ... f.write(b' 0 a with grave (composition)\n') - ... f.write(b' .\n' * 3) + ... f.write(b'a' * 39 + b'bb' + b'\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b' 0 b\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b'a' * 39 + b'\xc3\xa0' + b'\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b' 0 a with grave (single code point)\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b'a' * 39 + b'a\xcc\x80' + b'\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b' 0 a with grave (composition)\n') and None + ... f.write(b' .\n' * 3) and None $ hg ci -qAm0 >>> with open('a', 'wb') as f: - ... f.write(b'a' * 39 + b'bb' + b'\n') - ... f.write(b' .\n' * 3) - ... f.write(b' 1 b\n') - ... f.write(b' .\n' * 3) - ... f.write(b'a' * 39 + b'\xc3\xa0' + b'\n') - ... f.write(b' .\n' * 3) - ... f.write(b' 1 a with grave (single code point)\n') - ... f.write(b' .\n' * 3) - ... f.write(b'a' * 39 + b'a\xcc\x80' + b'\n') - ... f.write(b' .\n' * 3) - ... f.write(b' 1 a with grave (composition)\n') - ... f.write(b' .\n' * 3) + ... f.write(b'a' * 39 + b'bb' + b'\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b' 1 b\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b'a' * 39 + b'\xc3\xa0' + b'\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b' 1 a with grave (single code point)\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b'a' * 39 + b'a\xcc\x80' + b'\n') and None + ... f.write(b' .\n' * 3) and None + ... f.write(b' 1 a with grave (composition)\n') and None + ... f.write(b' .\n' * 3) and None $ hg ci -m1 $ hg diff -c1 --nodates --show-function To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3129: py3: use pycompat.byteskwargs() in tests/autodiff.py
pulkit 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/D3129 AFFECTED FILES tests/autodiff.py CHANGE DETAILS diff --git a/tests/autodiff.py b/tests/autodiff.py --- a/tests/autodiff.py +++ b/tests/autodiff.py @@ -5,6 +5,7 @@ from mercurial import ( error, patch, +pycompat, registrar, scmutil, ) @@ -16,6 +17,7 @@ [(b'', b'git', b'', b'git upgrade mode (yes/no/auto/warn/abort)')], b'[OPTION]... [FILE]...') def autodiff(ui, repo, *pats, **opts): +opts = pycompat.byteskwargs(opts) diffopts = patch.difffeatureopts(ui, opts) git = opts.get(b'git', b'no') brokenfiles = set() To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3126: py3: use bytes instead of str in instance()
pulkit created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY We deal internally with bytes, so we should check whether the remote is a bytes or not. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3126 AFFECTED FILES mercurial/logexchange.py CHANGE DETAILS diff --git a/mercurial/logexchange.py b/mercurial/logexchange.py --- a/mercurial/logexchange.py +++ b/mercurial/logexchange.py @@ -106,7 +106,7 @@ rpath = remote if local: rpath = remote._repo.root -elif not isinstance(remote, str): +elif not isinstance(remote, bytes): rpath = remote._url # represent the remotepath with user defined path name if exists To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3124: py3: use pycompat.bytestr in test-journal.t
pulkit 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/D3124 AFFECTED FILES tests/test-journal.t CHANGE DETAILS diff --git a/tests/test-journal.t b/tests/test-journal.t --- a/tests/test-journal.t +++ b/tests/test-journal.t @@ -3,7 +3,7 @@ $ cat >> testmocks.py << EOF > # mock out procutil.getuser() and util.makedate() to supply testable values > import os - > from mercurial import util + > from mercurial import util, pycompat > from mercurial.utils import dateutil, procutil > def mockgetuser(): > return 'foobar' @@ -16,7 +16,7 @@ > except IOError: > time = 0.0 > with open(filename, 'wb') as timef: - > timef.write(str(time)) + > timef.write(pycompat.bytestr(time)) > return (time, 0) > > procutil.getuser = mockgetuser To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3125: py3: convert user value to bytes using pycompat.fsencode()
pulkit created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY procutil.getuser() can return unicode values. Let's convert them to bytes. This makes test-journal* pass on Python 3.5. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3125 AFFECTED FILES hgext/journal.py CHANGE DETAILS diff --git a/hgext/journal.py b/hgext/journal.py --- a/hgext/journal.py +++ b/hgext/journal.py @@ -256,7 +256,7 @@ _lockref = None def __init__(self, repo): -self.user = procutil.getuser() +self.user = pycompat.fsencode(procutil.getuser()) self.ui = repo.ui self.vfs = repo.vfs To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3128: py3: suppress the output of open() using `and None`
pulkit created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This patch suppresses the output of open() on Python 3 as it does not return any output on Python 2. This makes test-diffstat.t pass on Python 3.5 REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3128 AFFECTED FILES tests/test-diffstat.t CHANGE DETAILS diff --git a/tests/test-diffstat.t b/tests/test-diffstat.t --- a/tests/test-diffstat.t +++ b/tests/test-diffstat.t @@ -35,7 +35,7 @@ $ hg ci -m appenda - >>> open("c", "wb").write(b"\0") + >>> open("c", "wb").write(b"\0") and None $ touch d $ hg add c d @@ -54,7 +54,7 @@ $ hg ci -m createb - >>> open("file with spaces", "wb").write(b"\0") + >>> open("file with spaces", "wb").write(b"\0") and None $ hg add "file with spaces" Filename with spaces diffstat: To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3123: py3: use list comprehension instead of map()
pulkit created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY map() on Python 3 returns a map object not a list, so let's use list comprehension where we require list. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3123 AFFECTED FILES hgext/journal.py CHANGE DETAILS diff --git a/hgext/journal.py b/hgext/journal.py --- a/hgext/journal.py +++ b/hgext/journal.py @@ -226,7 +226,7 @@ def __bytes__(self): """bytes representation for storage""" -time = ' '.join(map(pycompat.bytestr, self.timestamp)) +time = ' '.join([pycompat.bytestr(a) for a in self.timestamp]) oldhashes = ','.join([node.hex(hash) for hash in self.oldhashes]) newhashes = ','.join([node.hex(hash) for hash in self.newhashes]) return '\n'.join(( @@ -273,7 +273,7 @@ @property def command(self): commandstr = ' '.join( -map(procutil.shellquote, journalstorage._currentcommand)) +[procutil.shellquote(a) for a in journalstorage._currentcommand]) if '\n' in commandstr: # truncate multi-line commands commandstr = commandstr.partition('\n')[0] + ' ...' To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
mercurial@37287: 2 new changesets (2 on stable)
2 new changesets (2 on stable) in mercurial: https://www.mercurial-scm.org/repo/hg/rev/61f6cee88940 changeset: 37286:61f6cee88940 branch: stable parent: 37156:7de7bd407251 user:Augie Fackler date:Wed Apr 04 10:35:09 2018 -0400 summary: Added tag 4.5.3 for changeset 7de7bd407251 https://www.mercurial-scm.org/repo/hg/rev/fb92df8b634c changeset: 37287:fb92df8b634c branch: stable tag: tip user:Augie Fackler date:Wed Apr 04 10:35:09 2018 -0400 summary: Added signature for changeset 7de7bd407251 -- 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