This patch drops infinitepushcommands.py and the tests which were related to the
command debugfillinfinitepushmetadata introduced in the commit.
The patch also drops a config option which was related to
debuginfinitepushmetadata command.
indygreg |
hg-reviewers |
This patch drops infinitepushcommands.py and the tests which were related to the
command debugfillinfinitepushmetadata introduced in the commit.
The patch also drops a config option which was related to
debuginfinitepushmetadata command.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | hgext/infinitepush/__init__.py (5 lines) | |||
D | M | hgext/infinitepush/infinitepushcommands.py (101 lines) | ||
M | tests/test-infinitepush.t (77 lines) |
registrar, | registrar, | ||||
util, | util, | ||||
wireproto, | wireproto, | ||||
) | ) | ||||
from . import ( | from . import ( | ||||
bundleparts, | bundleparts, | ||||
common, | common, | ||||
infinitepushcommands, | |||||
) | ) | ||||
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | ||||
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | ||||
# be specifying the version(s) of Mercurial they are tested with, or | # be specifying the version(s) of Mercurial they are tested with, or | ||||
# leave the attribute unspecified. | # leave the attribute unspecified. | ||||
testedwith = 'ships-with-hg-core' | testedwith = 'ships-with-hg-core' | ||||
default='', | default='', | ||||
) | ) | ||||
configitem('scratchbranch', 'storepath', | configitem('scratchbranch', 'storepath', | ||||
default='', | default='', | ||||
) | ) | ||||
configitem('infinitepush', 'branchpattern', | configitem('infinitepush', 'branchpattern', | ||||
default='', | default='', | ||||
) | ) | ||||
configitem('infinitepush', 'metadatafilelimit', | |||||
default=100, | |||||
) | |||||
configitem('experimental', 'server-bundlestore-bookmark', | configitem('experimental', 'server-bundlestore-bookmark', | ||||
default='', | default='', | ||||
) | ) | ||||
configitem('experimental', 'infinitepush-scratchpush', | configitem('experimental', 'infinitepush-scratchpush', | ||||
default=False, | default=False, | ||||
) | ) | ||||
configitem('experimental', 'non-forward-move', | configitem('experimental', 'non-forward-move', | ||||
default=False, | default=False, | ||||
) | ) | ||||
experimental = 'experimental' | experimental = 'experimental' | ||||
configbookmark = 'server-bundlestore-bookmark' | configbookmark = 'server-bundlestore-bookmark' | ||||
configscratchpush = 'infinitepush-scratchpush' | configscratchpush = 'infinitepush-scratchpush' | ||||
confignonforwardmove = 'non-forward-move' | confignonforwardmove = 'non-forward-move' | ||||
scratchbranchparttype = bundleparts.scratchbranchparttype | scratchbranchparttype = bundleparts.scratchbranchparttype | ||||
cmdtable = infinitepushcommands.cmdtable | |||||
revsetpredicate = registrar.revsetpredicate() | revsetpredicate = registrar.revsetpredicate() | ||||
templatekeyword = registrar.templatekeyword() | templatekeyword = registrar.templatekeyword() | ||||
_scratchbranchmatcher = lambda x: False | _scratchbranchmatcher = lambda x: False | ||||
_maybehash = re.compile(r'^[a-f0-9]+$').search | _maybehash = re.compile(r'^[a-f0-9]+$').search | ||||
def _buildexternalbundlestore(ui): | def _buildexternalbundlestore(ui): | ||||
put_args = ui.configlist('infinitepush', 'put_args', []) | put_args = ui.configlist('infinitepush', 'put_args', []) | ||||
put_binary = ui.config('infinitepush', 'put_binary') | put_binary = ui.config('infinitepush', 'put_binary') |
# 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) |
added 1 changesets with 1 changes to 2 files | added 1 changesets with 1 changes to 2 files | ||||
new changesets d8fde0ddfc96 | new changesets d8fde0ddfc96 | ||||
(run 'hg update' to get a working copy) | (run 'hg update' to get a working copy) | ||||
'scratch/mybranch' found remotely | 'scratch/mybranch' found remotely | ||||
2 files updated, 0 files merged, 1 files removed, 0 files unresolved | 2 files updated, 0 files merged, 1 files removed, 0 files unresolved | ||||
(activating bookmark scratch/mybranch) | (activating bookmark scratch/mybranch) | ||||
$ hg log -r scratch/mybranch -T '{node}' | $ hg log -r scratch/mybranch -T '{node}' | ||||
d8fde0ddfc962183977f92d2bc52d303b8840f9d (no-eol) | 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) |