diff --git a/hgext/infinitepush/__init__.py b/hgext/infinitepush/__init__.py --- a/hgext/infinitepush/__init__.py +++ b/hgext/infinitepush/__init__.py @@ -124,7 +124,6 @@ from . import ( bundleparts, common, - infinitepushcommands, ) # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for @@ -160,9 +159,6 @@ configitem('infinitepush', 'branchpattern', default='', ) -configitem('infinitepush', 'metadatafilelimit', - default=100, -) configitem('experimental', 'server-bundlestore-bookmark', default='', ) @@ -179,7 +175,6 @@ confignonforwardmove = 'non-forward-move' scratchbranchparttype = bundleparts.scratchbranchparttype -cmdtable = infinitepushcommands.cmdtable revsetpredicate = registrar.revsetpredicate() templatekeyword = registrar.templatekeyword() _scratchbranchmatcher = lambda x: False diff --git a/hgext/infinitepush/infinitepushcommands.py b/hgext/infinitepush/infinitepushcommands.py deleted file mode 100644 --- a/hgext/infinitepush/infinitepushcommands.py +++ /dev/null @@ -1,101 +0,0 @@ -# Copyright 2016 Facebook, Inc. -# -# This software may be used and distributed according to the terms of the -# GNU General Public License version 2 or any later version. -""" -config:: - - [infinitepush] - # limit number of files in the node metadata. This is to make sure we don't - # waste too much space on huge codemod commits. - metadatafilelimit = 100 -""" - -from __future__ import absolute_import - -import json - -from mercurial.node import bin -from mercurial.i18n import _ - -from mercurial import ( - copies as copiesmod, - encoding, - error, - hg, - patch, - registrar, - scmutil, - util, -) - -from . import ( - common, -) - -downloadbundle = common.downloadbundle - -cmdtable = {} -command = registrar.command(cmdtable) - -@command('debugfillinfinitepushmetadata', - [('', 'node', [], 'node to fill metadata for')]) -def debugfillinfinitepushmetadata(ui, repo, **opts): - '''Special command that fills infinitepush metadata for a node - ''' - - nodes = opts['node'] - if not nodes: - raise error.Abort(_('nodes are not specified')) - - filelimit = ui.configint('infinitepush', 'metadatafilelimit', 100) - nodesmetadata = {} - for node in nodes: - index = repo.bundlestore.index - if not bool(index.getbundle(node)): - raise error.Abort(_('node %s is not found') % node) - - if node not in repo: - newbundlefile = downloadbundle(repo, bin(node)) - bundlepath = "bundle:%s+%s" % (repo.root, newbundlefile) - bundlerepo = hg.repository(ui, bundlepath) - repo = bundlerepo - - p1 = repo[node].p1().node() - diffopts = patch.diffallopts(ui, {}) - match = scmutil.matchall(repo) - chunks = patch.diff(repo, p1, node, match, None, diffopts, relroot='') - difflines = util.iterlines(chunks) - - states = 'modified added removed deleted unknown ignored clean'.split() - status = repo.status(p1, node) - status = zip(states, status) - - filestatus = {} - for state, files in status: - for f in files: - filestatus[f] = state - - diffstat = patch.diffstatdata(difflines) - changed_files = {} - copies = copiesmod.pathcopies(repo[p1], repo[node]) - for filename, adds, removes, isbinary in diffstat[:filelimit]: - # use special encoding that allows non-utf8 filenames - filename = encoding.jsonescape(filename, paranoid=True) - changed_files[filename] = { - 'adds': adds, 'removes': removes, 'isbinary': isbinary, - 'status': filestatus.get(filename, 'unknown') - } - if filename in copies: - changed_files[filename]['copies'] = copies[filename] - - output = {} - output['changed_files'] = changed_files - if len(diffstat) > filelimit: - output['changed_files_truncated'] = True - nodesmetadata[node] = output - - with index: - for node, metadata in nodesmetadata.iteritems(): - dumped = json.dumps(metadata, sort_keys=True) - index.saveoptionaljsonmetadata(node, dumped) diff --git a/tests/test-infinitepush.t b/tests/test-infinitepush.t --- a/tests/test-infinitepush.t +++ b/tests/test-infinitepush.t @@ -211,80 +211,3 @@ (activating bookmark scratch/mybranch) $ hg log -r scratch/mybranch -T '{node}' d8fde0ddfc962183977f92d2bc52d303b8840f9d (no-eol) - -Test debugfillinfinitepushmetadata - $ cd ../repo - $ hg debugfillinfinitepushmetadata - abort: nodes are not specified - [255] - $ hg debugfillinfinitepushmetadata --node randomnode - abort: node randomnode is not found - [255] - $ hg debugfillinfinitepushmetadata --node d8fde0ddfc962183977f92d2bc52d303b8840f9d - $ cat .hg/scratchbranches/index/nodemetadatamap/d8fde0ddfc962183977f92d2bc52d303b8840f9d - {"changed_files": {"testpullbycommithash2": {"adds": 1, "isbinary": false, "removes": 0, "status": "added"}}} (no-eol) - - $ cd ../client - $ hg up d8fde0ddfc962183977f92d2bc52d303b8840f9d - 'd8fde0ddfc962183977f92d2bc52d303b8840f9d' does not exist locally - looking for it remotely... - pulling from ssh://user@dummy/repo - searching for changes - adding changesets - adding manifests - adding file changes - added 2 changesets with 2 changes to 2 files (+1 heads) - new changesets 33910bfe6ffe:d8fde0ddfc96 - (run 'hg heads .' to see heads, 'hg merge' to merge) - 'd8fde0ddfc962183977f92d2bc52d303b8840f9d' found remotely - 2 files updated, 0 files merged, 1 files removed, 0 files unresolved - $ echo file > file - $ hg add file - $ hg rm testpullbycommithash2 - $ hg ci -m 'add and rm files' - $ hg log -r . -T '{node}\n' - 3edfe7e9089ab9f728eb8e0d0c62a5d18cf19239 - $ hg cp file cpfile - $ hg mv file mvfile - $ hg ci -m 'cpfile and mvfile' - $ hg log -r . -T '{node}\n' - c7ac39f638c6b39bcdacf868fa21b6195670f8ae - $ hg push -r . --bundle-store - pushing to ssh://user@dummy/repo - searching for changes - remote: pushing 4 commits: - remote: 33910bfe6ffe testpullbycommithash1 - remote: d8fde0ddfc96 testpullbycommithash2 - remote: 3edfe7e9089a add and rm files - remote: c7ac39f638c6 cpfile and mvfile - $ cd ../repo - $ hg debugfillinfinitepushmetadata --node 3edfe7e9089ab9f728eb8e0d0c62a5d18cf19239 --node c7ac39f638c6b39bcdacf868fa21b6195670f8ae - $ cat .hg/scratchbranches/index/nodemetadatamap/3edfe7e9089ab9f728eb8e0d0c62a5d18cf19239 - {"changed_files": {"file": {"adds": 1, "isbinary": false, "removes": 0, "status": "added"}, "testpullbycommithash2": {"adds": 0, "isbinary": false, "removes": 1, "status": "removed"}}} (no-eol) - $ cat .hg/scratchbranches/index/nodemetadatamap/c7ac39f638c6b39bcdacf868fa21b6195670f8ae - {"changed_files": {"cpfile": {"adds": 1, "copies": "file", "isbinary": false, "removes": 0, "status": "added"}, "file": {"adds": 0, "isbinary": false, "removes": 1, "status": "removed"}, "mvfile": {"adds": 1, "copies": "file", "isbinary": false, "removes": 0, "status": "added"}}} (no-eol) - -Test infinitepush.metadatafilelimit number - $ cd ../client - $ echo file > file - $ hg add file - $ echo file1 > file1 - $ hg add file1 - $ echo file2 > file2 - $ hg add file2 - $ hg ci -m 'add many files' - $ hg log -r . -T '{node}' - 09904fb20c53ff351bd3b1d47681f569a4dab7e5 (no-eol) - $ hg push -r . --bundle-store - pushing to ssh://user@dummy/repo - searching for changes - remote: pushing 5 commits: - remote: 33910bfe6ffe testpullbycommithash1 - remote: d8fde0ddfc96 testpullbycommithash2 - remote: 3edfe7e9089a add and rm files - remote: c7ac39f638c6 cpfile and mvfile - remote: 09904fb20c53 add many files - - $ cd ../repo - $ hg debugfillinfinitepushmetadata --node 09904fb20c53ff351bd3b1d47681f569a4dab7e5 --config infinitepush.metadatafilelimit=2 - $ cat .hg/scratchbranches/index/nodemetadatamap/09904fb20c53ff351bd3b1d47681f569a4dab7e5 - {"changed_files": {"file": {"adds": 1, "isbinary": false, "removes": 0, "status": "added"}, "file1": {"adds": 1, "isbinary": false, "removes": 0, "status": "added"}}, "changed_files_truncated": true} (no-eol)