Show More
@@ -1867,74 +1867,6 def copy(ui, repo, *pats, **opts): | |||||
1867 | with repo.wlock(False): |
|
1867 | with repo.wlock(False): | |
1868 | return cmdutil.copy(ui, repo, pats, opts) |
|
1868 | return cmdutil.copy(ui, repo, pats, opts) | |
1869 |
|
1869 | |||
1870 | @command('debugbundle', |
|
|||
1871 | [('a', 'all', None, _('show all details')), |
|
|||
1872 | ('', 'spec', None, _('print the bundlespec of the bundle'))], |
|
|||
1873 | _('FILE'), |
|
|||
1874 | norepo=True) |
|
|||
1875 | def debugbundle(ui, bundlepath, all=None, spec=None, **opts): |
|
|||
1876 | """lists the contents of a bundle""" |
|
|||
1877 | with hg.openpath(ui, bundlepath) as f: |
|
|||
1878 | if spec: |
|
|||
1879 | spec = exchange.getbundlespec(ui, f) |
|
|||
1880 | ui.write('%s\n' % spec) |
|
|||
1881 | return |
|
|||
1882 |
|
||||
1883 | gen = exchange.readbundle(ui, f, bundlepath) |
|
|||
1884 | if isinstance(gen, bundle2.unbundle20): |
|
|||
1885 | return _debugbundle2(ui, gen, all=all, **opts) |
|
|||
1886 | _debugchangegroup(ui, gen, all=all, **opts) |
|
|||
1887 |
|
||||
1888 | def _debugchangegroup(ui, gen, all=None, indent=0, **opts): |
|
|||
1889 | indent_string = ' ' * indent |
|
|||
1890 | if all: |
|
|||
1891 | ui.write(("%sformat: id, p1, p2, cset, delta base, len(delta)\n") |
|
|||
1892 | % indent_string) |
|
|||
1893 |
|
||||
1894 | def showchunks(named): |
|
|||
1895 | ui.write("\n%s%s\n" % (indent_string, named)) |
|
|||
1896 | chain = None |
|
|||
1897 | for chunkdata in iter(lambda: gen.deltachunk(chain), {}): |
|
|||
1898 | node = chunkdata['node'] |
|
|||
1899 | p1 = chunkdata['p1'] |
|
|||
1900 | p2 = chunkdata['p2'] |
|
|||
1901 | cs = chunkdata['cs'] |
|
|||
1902 | deltabase = chunkdata['deltabase'] |
|
|||
1903 | delta = chunkdata['delta'] |
|
|||
1904 | ui.write("%s%s %s %s %s %s %s\n" % |
|
|||
1905 | (indent_string, hex(node), hex(p1), hex(p2), |
|
|||
1906 | hex(cs), hex(deltabase), len(delta))) |
|
|||
1907 | chain = node |
|
|||
1908 |
|
||||
1909 | chunkdata = gen.changelogheader() |
|
|||
1910 | showchunks("changelog") |
|
|||
1911 | chunkdata = gen.manifestheader() |
|
|||
1912 | showchunks("manifest") |
|
|||
1913 | for chunkdata in iter(gen.filelogheader, {}): |
|
|||
1914 | fname = chunkdata['filename'] |
|
|||
1915 | showchunks(fname) |
|
|||
1916 | else: |
|
|||
1917 | if isinstance(gen, bundle2.unbundle20): |
|
|||
1918 | raise error.Abort(_('use debugbundle2 for this file')) |
|
|||
1919 | chunkdata = gen.changelogheader() |
|
|||
1920 | chain = None |
|
|||
1921 | for chunkdata in iter(lambda: gen.deltachunk(chain), {}): |
|
|||
1922 | node = chunkdata['node'] |
|
|||
1923 | ui.write("%s%s\n" % (indent_string, hex(node))) |
|
|||
1924 | chain = node |
|
|||
1925 |
|
||||
1926 | def _debugbundle2(ui, gen, all=None, **opts): |
|
|||
1927 | """lists the contents of a bundle2""" |
|
|||
1928 | if not isinstance(gen, bundle2.unbundle20): |
|
|||
1929 | raise error.Abort(_('not a bundle2 file')) |
|
|||
1930 | ui.write(('Stream params: %s\n' % repr(gen.params))) |
|
|||
1931 | for part in gen.iterparts(): |
|
|||
1932 | ui.write('%s -- %r\n' % (part.type, repr(part.params))) |
|
|||
1933 | if part.type == 'changegroup': |
|
|||
1934 | version = part.params.get('version', '01') |
|
|||
1935 | cg = changegroup.getunbundler(version, part, 'UN') |
|
|||
1936 | _debugchangegroup(ui, cg, all=all, indent=4, **opts) |
|
|||
1937 |
|
||||
1938 | @command('debugcreatestreamclonebundle', [], 'FILE') |
|
1870 | @command('debugcreatestreamclonebundle', [], 'FILE') | |
1939 | def debugcreatestreamclonebundle(ui, repo, fname): |
|
1871 | def debugcreatestreamclonebundle(ui, repo, fname): | |
1940 | """create a stream clone bundle file |
|
1872 | """create a stream clone bundle file |
@@ -14,11 +14,15 from .node import ( | |||||
14 | hex, |
|
14 | hex, | |
15 | ) |
|
15 | ) | |
16 | from . import ( |
|
16 | from . import ( | |
|
17 | bundle2, | |||
|
18 | changegroup, | |||
17 | cmdutil, |
|
19 | cmdutil, | |
18 | commands, |
|
20 | commands, | |
19 | context, |
|
21 | context, | |
20 | dagparser, |
|
22 | dagparser, | |
21 | error, |
|
23 | error, | |
|
24 | exchange, | |||
|
25 | hg, | |||
22 | lock as lockmod, |
|
26 | lock as lockmod, | |
23 | revlog, |
|
27 | revlog, | |
24 | scmutil, |
|
28 | scmutil, | |
@@ -201,3 +205,71 def debugbuilddag(ui, repo, text=None, | |||||
201 | finally: |
|
205 | finally: | |
202 | ui.progress(_('building'), None) |
|
206 | ui.progress(_('building'), None) | |
203 | release(tr, lock, wlock) |
|
207 | release(tr, lock, wlock) | |
|
208 | ||||
|
209 | @command('debugbundle', | |||
|
210 | [('a', 'all', None, _('show all details')), | |||
|
211 | ('', 'spec', None, _('print the bundlespec of the bundle'))], | |||
|
212 | _('FILE'), | |||
|
213 | norepo=True) | |||
|
214 | def debugbundle(ui, bundlepath, all=None, spec=None, **opts): | |||
|
215 | """lists the contents of a bundle""" | |||
|
216 | with hg.openpath(ui, bundlepath) as f: | |||
|
217 | if spec: | |||
|
218 | spec = exchange.getbundlespec(ui, f) | |||
|
219 | ui.write('%s\n' % spec) | |||
|
220 | return | |||
|
221 | ||||
|
222 | gen = exchange.readbundle(ui, f, bundlepath) | |||
|
223 | if isinstance(gen, bundle2.unbundle20): | |||
|
224 | return _debugbundle2(ui, gen, all=all, **opts) | |||
|
225 | _debugchangegroup(ui, gen, all=all, **opts) | |||
|
226 | ||||
|
227 | def _debugchangegroup(ui, gen, all=None, indent=0, **opts): | |||
|
228 | indent_string = ' ' * indent | |||
|
229 | if all: | |||
|
230 | ui.write(("%sformat: id, p1, p2, cset, delta base, len(delta)\n") | |||
|
231 | % indent_string) | |||
|
232 | ||||
|
233 | def showchunks(named): | |||
|
234 | ui.write("\n%s%s\n" % (indent_string, named)) | |||
|
235 | chain = None | |||
|
236 | for chunkdata in iter(lambda: gen.deltachunk(chain), {}): | |||
|
237 | node = chunkdata['node'] | |||
|
238 | p1 = chunkdata['p1'] | |||
|
239 | p2 = chunkdata['p2'] | |||
|
240 | cs = chunkdata['cs'] | |||
|
241 | deltabase = chunkdata['deltabase'] | |||
|
242 | delta = chunkdata['delta'] | |||
|
243 | ui.write("%s%s %s %s %s %s %s\n" % | |||
|
244 | (indent_string, hex(node), hex(p1), hex(p2), | |||
|
245 | hex(cs), hex(deltabase), len(delta))) | |||
|
246 | chain = node | |||
|
247 | ||||
|
248 | chunkdata = gen.changelogheader() | |||
|
249 | showchunks("changelog") | |||
|
250 | chunkdata = gen.manifestheader() | |||
|
251 | showchunks("manifest") | |||
|
252 | for chunkdata in iter(gen.filelogheader, {}): | |||
|
253 | fname = chunkdata['filename'] | |||
|
254 | showchunks(fname) | |||
|
255 | else: | |||
|
256 | if isinstance(gen, bundle2.unbundle20): | |||
|
257 | raise error.Abort(_('use debugbundle2 for this file')) | |||
|
258 | chunkdata = gen.changelogheader() | |||
|
259 | chain = None | |||
|
260 | for chunkdata in iter(lambda: gen.deltachunk(chain), {}): | |||
|
261 | node = chunkdata['node'] | |||
|
262 | ui.write("%s%s\n" % (indent_string, hex(node))) | |||
|
263 | chain = node | |||
|
264 | ||||
|
265 | def _debugbundle2(ui, gen, all=None, **opts): | |||
|
266 | """lists the contents of a bundle2""" | |||
|
267 | if not isinstance(gen, bundle2.unbundle20): | |||
|
268 | raise error.Abort(_('not a bundle2 file')) | |||
|
269 | ui.write(('Stream params: %s\n' % repr(gen.params))) | |||
|
270 | for part in gen.iterparts(): | |||
|
271 | ui.write('%s -- %r\n' % (part.type, repr(part.params))) | |||
|
272 | if part.type == 'changegroup': | |||
|
273 | version = part.params.get('version', '01') | |||
|
274 | cg = changegroup.getunbundler(version, part, 'UN') | |||
|
275 | _debugchangegroup(ui, cg, all=all, indent=4, **opts) |
General Comments 0
You need to be logged in to leave comments.
Login now