comparison mercurial/localrepo.py @ 10432:8a8030fc57d6

localrepo: provide indeterminate progress information while bundling
author Augie Fackler <durin42@gmail.com>
date Tue, 09 Feb 2010 10:02:01 -0600
parents 5cef810e588f
children 956498af9812
comparison
equal deleted inserted replaced
10431:ba5e508b5e92 10432:8a8030fc57d6
1814 collect = changegroup.collector(cl, msng_mnfst_set, changedfiles) 1814 collect = changegroup.collector(cl, msng_mnfst_set, changedfiles)
1815 1815
1816 # Create a changenode group generator that will call our functions 1816 # Create a changenode group generator that will call our functions
1817 # back to lookup the owning changenode and collect information. 1817 # back to lookup the owning changenode and collect information.
1818 group = cl.group(msng_cl_lst, identity, collect) 1818 group = cl.group(msng_cl_lst, identity, collect)
1819 cnt = 0
1819 for chnk in group: 1820 for chnk in group:
1820 yield chnk 1821 yield chnk
1822 self.ui.progress('bundle changes', cnt, unit='chunks')
1823 cnt += 1
1824 self.ui.progress('bundle changes', None, unit='chunks')
1825
1821 1826
1822 # Figure out which manifest nodes (of the ones we think might be 1827 # Figure out which manifest nodes (of the ones we think might be
1823 # part of the changegroup) the recipient must know about and 1828 # part of the changegroup) the recipient must know about and
1824 # remove them from the changegroup. 1829 # remove them from the changegroup.
1825 has_mnfst_set = set() 1830 has_mnfst_set = set()
1837 msng_mnfst_lst.sort(key=mnfst.rev) 1842 msng_mnfst_lst.sort(key=mnfst.rev)
1838 # Create a generator for the manifestnodes that calls our lookup 1843 # Create a generator for the manifestnodes that calls our lookup
1839 # and data collection functions back. 1844 # and data collection functions back.
1840 group = mnfst.group(msng_mnfst_lst, lookup_manifest_link, 1845 group = mnfst.group(msng_mnfst_lst, lookup_manifest_link,
1841 filenode_collector(changedfiles)) 1846 filenode_collector(changedfiles))
1847 cnt = 0
1842 for chnk in group: 1848 for chnk in group:
1843 yield chnk 1849 yield chnk
1850 self.ui.progress('bundle manifests', cnt, unit='chunks')
1851 cnt += 1
1852 self.ui.progress('bundle manifests', None, unit='chunks')
1844 1853
1845 # These are no longer needed, dereference and toss the memory for 1854 # These are no longer needed, dereference and toss the memory for
1846 # them. 1855 # them.
1847 msng_mnfst_lst = None 1856 msng_mnfst_lst = None
1848 msng_mnfst_set.clear() 1857 msng_mnfst_set.clear()
1852 if isinstance(fname, int): 1861 if isinstance(fname, int):
1853 continue 1862 continue
1854 msng_filenode_set.setdefault(fname, {}) 1863 msng_filenode_set.setdefault(fname, {})
1855 changedfiles[fname] = 1 1864 changedfiles[fname] = 1
1856 # Go through all our files in order sorted by name. 1865 # Go through all our files in order sorted by name.
1866 cnt = 0
1857 for fname in sorted(changedfiles): 1867 for fname in sorted(changedfiles):
1858 filerevlog = self.file(fname) 1868 filerevlog = self.file(fname)
1859 if not len(filerevlog): 1869 if not len(filerevlog):
1860 raise util.Abort(_("empty or missing revlog for %s") % fname) 1870 raise util.Abort(_("empty or missing revlog for %s") % fname)
1861 # Toss out the filenodes that the recipient isn't really 1871 # Toss out the filenodes that the recipient isn't really
1877 # lookup function as we need to collect no information 1887 # lookup function as we need to collect no information
1878 # from filenodes. 1888 # from filenodes.
1879 group = filerevlog.group(msng_filenode_lst, 1889 group = filerevlog.group(msng_filenode_lst,
1880 lookup_filenode_link_func(fname)) 1890 lookup_filenode_link_func(fname))
1881 for chnk in group: 1891 for chnk in group:
1892 self.ui.progress(
1893 'bundle files', cnt, item=fname, unit='chunks')
1894 cnt += 1
1882 yield chnk 1895 yield chnk
1883 if fname in msng_filenode_set: 1896 if fname in msng_filenode_set:
1884 # Don't need this anymore, toss it to free memory. 1897 # Don't need this anymore, toss it to free memory.
1885 del msng_filenode_set[fname] 1898 del msng_filenode_set[fname]
1886 # Signal that no more groups are left. 1899 # Signal that no more groups are left.
1887 yield changegroup.closechunk() 1900 yield changegroup.closechunk()
1901 self.ui.progress('bundle files', None, unit='chunks')
1888 1902
1889 if msng_cl_lst: 1903 if msng_cl_lst:
1890 self.hook('outgoing', node=hex(msng_cl_lst[0]), source=source) 1904 self.hook('outgoing', node=hex(msng_cl_lst[0]), source=source)
1891 1905
1892 return util.chunkbuffer(gengroup()) 1906 return util.chunkbuffer(gengroup())
1929 # construct a list of all changed files 1943 # construct a list of all changed files
1930 changedfiles = {} 1944 changedfiles = {}
1931 mmfs = {} 1945 mmfs = {}
1932 collect = changegroup.collector(cl, mmfs, changedfiles) 1946 collect = changegroup.collector(cl, mmfs, changedfiles)
1933 1947
1948 cnt = 0
1934 for chnk in cl.group(nodes, identity, collect): 1949 for chnk in cl.group(nodes, identity, collect):
1950 self.ui.progress('bundle changes', cnt, unit='chunks')
1951 cnt += 1
1935 yield chnk 1952 yield chnk
1953 self.ui.progress('bundle changes', None, unit='chunks')
1936 1954
1937 mnfst = self.manifest 1955 mnfst = self.manifest
1938 nodeiter = gennodelst(mnfst) 1956 nodeiter = gennodelst(mnfst)
1957 cnt = 0
1939 for chnk in mnfst.group(nodeiter, lookuprevlink_func(mnfst)): 1958 for chnk in mnfst.group(nodeiter, lookuprevlink_func(mnfst)):
1959 self.ui.progress('bundle manifests', cnt, unit='chunks')
1960 cnt += 1
1940 yield chnk 1961 yield chnk
1941 1962 self.ui.progress('bundle manifests', None, unit='chunks')
1963
1964 cnt = 0
1942 for fname in sorted(changedfiles): 1965 for fname in sorted(changedfiles):
1943 filerevlog = self.file(fname) 1966 filerevlog = self.file(fname)
1944 if not len(filerevlog): 1967 if not len(filerevlog):
1945 raise util.Abort(_("empty or missing revlog for %s") % fname) 1968 raise util.Abort(_("empty or missing revlog for %s") % fname)
1946 nodeiter = gennodelst(filerevlog) 1969 nodeiter = gennodelst(filerevlog)
1948 if nodeiter: 1971 if nodeiter:
1949 yield changegroup.chunkheader(len(fname)) 1972 yield changegroup.chunkheader(len(fname))
1950 yield fname 1973 yield fname
1951 lookup = lookuprevlink_func(filerevlog) 1974 lookup = lookuprevlink_func(filerevlog)
1952 for chnk in filerevlog.group(nodeiter, lookup): 1975 for chnk in filerevlog.group(nodeiter, lookup):
1976 self.ui.progress(
1977 'bundle files', cnt, item=fname, unit='chunks')
1978 cnt += 1
1953 yield chnk 1979 yield chnk
1980 self.ui.progress('bundle files', None, unit='chunks')
1954 1981
1955 yield changegroup.closechunk() 1982 yield changegroup.closechunk()
1956 1983
1957 if nodes: 1984 if nodes:
1958 self.hook('outgoing', node=hex(nodes[0]), source=source) 1985 self.hook('outgoing', node=hex(nodes[0]), source=source)