Add a project progress meter to 'repo sync'

This way users can see how much is left during fetch.  Its
especially useful when most syncs are no-ops but there are
hundreds of repositories to poll.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-04-10 16:48:52 -07:00
parent b1562faee0
commit 68194f42b0
2 changed files with 53 additions and 1 deletions

View File

@ -23,6 +23,7 @@ from git_command import GIT
from command import Command, MirrorSafeCommand
from error import RepoChangedException, GitError
from project import R_HEADS
from progress import Progress
class Sync(Command, MirrorSafeCommand):
common = True
@ -71,12 +72,16 @@ revision is temporarily needed.
def _Fetch(self, *projects):
fetched = set()
pm = Progress('Fetching projects', len(projects))
for project in projects:
pm.update()
if project.Sync_NetworkHalf():
fetched.add(project.gitdir)
else:
print >>sys.stderr, 'error: Cannot fetch %s' % project.name
sys.exit(1)
pm.end()
return fetched
def Execute(self, opt, args):
@ -130,12 +135,14 @@ revision is temporarily needed.
missing.append(project)
self._Fetch(*missing)
pm = Progress('Syncing work tree', len(all))
for project in all:
pm.update()
if project.worktree:
if not project.Sync_LocalHalf(
detach_head=opt.detach_head):
sys.exit(1)
pm.end()
def _VerifyTag(project):
gpg_dir = os.path.expanduser('~/.repoconfig/gnupg')