##// END OF EJS Templates
debugcommands: move 'debugdiscovery' in the module...
Gregory Szorc -
r30517:a3ec6db3 default
parent child Browse files
Show More
@@ -11,7 +11,6 b' import difflib'
11 import errno
11 import errno
12 import operator
12 import operator
13 import os
13 import os
14 import random
15 import re
14 import re
16 import shlex
15 import shlex
17 import socket
16 import socket
@@ -36,7 +35,6 b' from . import ('
36 changegroup,
35 changegroup,
37 cmdutil,
36 cmdutil,
38 copies,
37 copies,
39 dagutil,
40 destutil,
38 destutil,
41 dirstateguard,
39 dirstateguard,
42 discovery,
40 discovery,
@@ -50,7 +48,6 b' from . import ('
50 hbisect,
48 hbisect,
51 help,
49 help,
52 hg,
50 hg,
53 localrepo,
54 lock as lockmod,
51 lock as lockmod,
55 merge as mergemod,
52 merge as mergemod,
56 minirst,
53 minirst,
@@ -65,13 +62,11 b' from . import ('
65 revset,
62 revset,
66 scmutil,
63 scmutil,
67 server,
64 server,
68 setdiscovery,
69 sshserver,
65 sshserver,
70 sslutil,
66 sslutil,
71 streamclone,
67 streamclone,
72 templatekw,
68 templatekw,
73 templater,
69 templater,
74 treediscovery,
75 ui as uimod,
70 ui as uimod,
76 util,
71 util,
77 )
72 )
@@ -1865,72 +1860,6 b' def copy(ui, repo, *pats, **opts):'
1865 with repo.wlock(False):
1860 with repo.wlock(False):
1866 return cmdutil.copy(ui, repo, pats, opts)
1861 return cmdutil.copy(ui, repo, pats, opts)
1867
1862
1868 @command('debugdiscovery',
1869 [('', 'old', None, _('use old-style discovery')),
1870 ('', 'nonheads', None,
1871 _('use old-style discovery with non-heads included')),
1872 ] + remoteopts,
1873 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
1874 def debugdiscovery(ui, repo, remoteurl="default", **opts):
1875 """runs the changeset discovery protocol in isolation"""
1876 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
1877 opts.get('branch'))
1878 remote = hg.peer(repo, opts, remoteurl)
1879 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
1880
1881 # make sure tests are repeatable
1882 random.seed(12323)
1883
1884 def doit(localheads, remoteheads, remote=remote):
1885 if opts.get('old'):
1886 if localheads:
1887 raise error.Abort('cannot use localheads with old style '
1888 'discovery')
1889 if not util.safehasattr(remote, 'branches'):
1890 # enable in-client legacy support
1891 remote = localrepo.locallegacypeer(remote.local())
1892 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
1893 force=True)
1894 common = set(common)
1895 if not opts.get('nonheads'):
1896 ui.write(("unpruned common: %s\n") %
1897 " ".join(sorted(short(n) for n in common)))
1898 dag = dagutil.revlogdag(repo.changelog)
1899 all = dag.ancestorset(dag.internalizeall(common))
1900 common = dag.externalizeall(dag.headsetofconnecteds(all))
1901 else:
1902 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
1903 common = set(common)
1904 rheads = set(hds)
1905 lheads = set(repo.heads())
1906 ui.write(("common heads: %s\n") %
1907 " ".join(sorted(short(n) for n in common)))
1908 if lheads <= common:
1909 ui.write(("local is subset\n"))
1910 elif rheads <= common:
1911 ui.write(("remote is subset\n"))
1912
1913 serverlogs = opts.get('serverlog')
1914 if serverlogs:
1915 for filename in serverlogs:
1916 with open(filename, 'r') as logfile:
1917 line = logfile.readline()
1918 while line:
1919 parts = line.strip().split(';')
1920 op = parts[1]
1921 if op == 'cg':
1922 pass
1923 elif op == 'cgss':
1924 doit(parts[2].split(' '), parts[3].split(' '))
1925 elif op == 'unb':
1926 doit(parts[3].split(' '), parts[2].split(' '))
1927 line = logfile.readline()
1928 else:
1929 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
1930 opts.get('remote_head'))
1931 localrevs = opts.get('local_head')
1932 doit(localrevs, remoterevs)
1933
1934 @command('debugextensions', formatteropts, [], norepo=True)
1863 @command('debugextensions', formatteropts, [], norepo=True)
1935 def debugextensions(ui, **opts):
1864 def debugextensions(ui, **opts):
1936 '''show information about active extensions'''
1865 '''show information about active extensions'''
@@ -8,10 +8,12 b''
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import os
10 import os
11 import random
11
12
12 from .i18n import _
13 from .i18n import _
13 from .node import (
14 from .node import (
14 hex,
15 hex,
16 short,
15 )
17 )
16 from . import (
18 from . import (
17 bundle2,
19 bundle2,
@@ -20,14 +22,18 b' from . import ('
20 commands,
22 commands,
21 context,
23 context,
22 dagparser,
24 dagparser,
25 dagutil,
23 error,
26 error,
24 exchange,
27 exchange,
25 hg,
28 hg,
29 localrepo,
26 lock as lockmod,
30 lock as lockmod,
27 revlog,
31 revlog,
28 scmutil,
32 scmutil,
33 setdiscovery,
29 simplemerge,
34 simplemerge,
30 streamclone,
35 streamclone,
36 treediscovery,
31 util,
37 util,
32 )
38 )
33
39
@@ -451,3 +457,69 b' def debugdate(ui, date, range=None, **op'
451 if range:
457 if range:
452 m = util.matchdate(range)
458 m = util.matchdate(range)
453 ui.write(("match: %s\n") % m(d[0]))
459 ui.write(("match: %s\n") % m(d[0]))
460
461 @command('debugdiscovery',
462 [('', 'old', None, _('use old-style discovery')),
463 ('', 'nonheads', None,
464 _('use old-style discovery with non-heads included')),
465 ] + commands.remoteopts,
466 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
467 def debugdiscovery(ui, repo, remoteurl="default", **opts):
468 """runs the changeset discovery protocol in isolation"""
469 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
470 opts.get('branch'))
471 remote = hg.peer(repo, opts, remoteurl)
472 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
473
474 # make sure tests are repeatable
475 random.seed(12323)
476
477 def doit(localheads, remoteheads, remote=remote):
478 if opts.get('old'):
479 if localheads:
480 raise error.Abort('cannot use localheads with old style '
481 'discovery')
482 if not util.safehasattr(remote, 'branches'):
483 # enable in-client legacy support
484 remote = localrepo.locallegacypeer(remote.local())
485 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
486 force=True)
487 common = set(common)
488 if not opts.get('nonheads'):
489 ui.write(("unpruned common: %s\n") %
490 " ".join(sorted(short(n) for n in common)))
491 dag = dagutil.revlogdag(repo.changelog)
492 all = dag.ancestorset(dag.internalizeall(common))
493 common = dag.externalizeall(dag.headsetofconnecteds(all))
494 else:
495 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
496 common = set(common)
497 rheads = set(hds)
498 lheads = set(repo.heads())
499 ui.write(("common heads: %s\n") %
500 " ".join(sorted(short(n) for n in common)))
501 if lheads <= common:
502 ui.write(("local is subset\n"))
503 elif rheads <= common:
504 ui.write(("remote is subset\n"))
505
506 serverlogs = opts.get('serverlog')
507 if serverlogs:
508 for filename in serverlogs:
509 with open(filename, 'r') as logfile:
510 line = logfile.readline()
511 while line:
512 parts = line.strip().split(';')
513 op = parts[1]
514 if op == 'cg':
515 pass
516 elif op == 'cgss':
517 doit(parts[2].split(' '), parts[3].split(' '))
518 elif op == 'unb':
519 doit(parts[3].split(' '), parts[2].split(' '))
520 line = logfile.readline()
521 else:
522 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
523 opts.get('remote_head'))
524 localrevs = opts.get('local_head')
525 doit(localrevs, remoterevs)
General Comments 0
You need to be logged in to leave comments. Login now