comparison mercurial/localrepo.py @ 10430:5cef810e588f

localrepo: show indeterminate progress for incoming data This has some quirks, like showing progress bars for importing bundles, including during rebase.
author Augie Fackler <durin42@gmail.com>
date Sun, 07 Feb 2010 12:00:40 -0600
parents 1c50a954a524
children 8a8030fc57d6
comparison
equal deleted inserted replaced
10429:1c50a954a524 10430:5cef810e588f
1992 try: 1992 try:
1993 trp = weakref.proxy(tr) 1993 trp = weakref.proxy(tr)
1994 # pull off the changeset group 1994 # pull off the changeset group
1995 self.ui.status(_("adding changesets\n")) 1995 self.ui.status(_("adding changesets\n"))
1996 clstart = len(cl) 1996 clstart = len(cl)
1997 chunkiter = changegroup.chunkiter(source) 1997 class prog(object):
1998 step = 'changesets'
1999 count = 1
2000 ui = self.ui
2001 def __call__(self):
2002 self.ui.progress(self.step, self.count, unit='chunks')
2003 self.count += 1
2004 pr = prog()
2005 chunkiter = changegroup.chunkiter(source, progress=pr)
1998 if cl.addgroup(chunkiter, csmap, trp) is None and not emptyok: 2006 if cl.addgroup(chunkiter, csmap, trp) is None and not emptyok:
1999 raise util.Abort(_("received changelog group is empty")) 2007 raise util.Abort(_("received changelog group is empty"))
2000 clend = len(cl) 2008 clend = len(cl)
2001 changesets = clend - clstart 2009 changesets = clend - clstart
2010 self.ui.progress('changesets', None)
2002 2011
2003 # pull off the manifest group 2012 # pull off the manifest group
2004 self.ui.status(_("adding manifests\n")) 2013 self.ui.status(_("adding manifests\n"))
2005 chunkiter = changegroup.chunkiter(source) 2014 pr.step = 'manifests'
2015 pr.count = 1
2016 chunkiter = changegroup.chunkiter(source, progress=pr)
2006 # no need to check for empty manifest group here: 2017 # no need to check for empty manifest group here:
2007 # if the result of the merge of 1 and 2 is the same in 3 and 4, 2018 # if the result of the merge of 1 and 2 is the same in 3 and 4,
2008 # no new manifest will be created and the manifest group will 2019 # no new manifest will be created and the manifest group will
2009 # be empty during the pull 2020 # be empty during the pull
2010 self.manifest.addgroup(chunkiter, revmap, trp) 2021 self.manifest.addgroup(chunkiter, revmap, trp)
2022 self.ui.progress('manifests', None)
2011 2023
2012 needfiles = {} 2024 needfiles = {}
2013 if self.ui.configbool('server', 'validate', default=False): 2025 if self.ui.configbool('server', 'validate', default=False):
2014 # validate incoming csets have their manifests 2026 # validate incoming csets have their manifests
2015 for cset in xrange(clstart, clend): 2027 for cset in xrange(clstart, clend):
2019 for f, n in mfest.iteritems(): 2031 for f, n in mfest.iteritems():
2020 needfiles.setdefault(f, set()).add(n) 2032 needfiles.setdefault(f, set()).add(n)
2021 2033
2022 # process the files 2034 # process the files
2023 self.ui.status(_("adding file changes\n")) 2035 self.ui.status(_("adding file changes\n"))
2036 pr.step = 'files'
2037 pr.count = 1
2024 while 1: 2038 while 1:
2025 f = changegroup.getchunk(source) 2039 f = changegroup.getchunk(source)
2026 if not f: 2040 if not f:
2027 break 2041 break
2028 self.ui.debug("adding %s revisions\n" % f) 2042 self.ui.debug("adding %s revisions\n" % f)
2029 fl = self.file(f) 2043 fl = self.file(f)
2030 o = len(fl) 2044 o = len(fl)
2031 chunkiter = changegroup.chunkiter(source) 2045 chunkiter = changegroup.chunkiter(source, progress=pr)
2032 if fl.addgroup(chunkiter, revmap, trp) is None: 2046 if fl.addgroup(chunkiter, revmap, trp) is None:
2033 raise util.Abort(_("received file revlog group is empty")) 2047 raise util.Abort(_("received file revlog group is empty"))
2034 revisions += len(fl) - o 2048 revisions += len(fl) - o
2035 files += 1 2049 files += 1
2036 if f in needfiles: 2050 if f in needfiles:
2039 n = fl.node(new) 2053 n = fl.node(new)
2040 if n in needs: 2054 if n in needs:
2041 needs.remove(n) 2055 needs.remove(n)
2042 if not needs: 2056 if not needs:
2043 del needfiles[f] 2057 del needfiles[f]
2058 self.ui.progress('files', None)
2044 2059
2045 for f, needs in needfiles.iteritems(): 2060 for f, needs in needfiles.iteritems():
2046 fl = self.file(f) 2061 fl = self.file(f)
2047 for n in needs: 2062 for n in needs:
2048 try: 2063 try: