# HG changeset patch # User Dan Villiom Podlaski Christiansen <danchr@gmail.com> # Date 1627822053 -7200 # Sun Aug 01 14:47:33 2021 +0200 # Node ID 88657cbf4eba4c447da484bed9164207a532e883 # Parent 6bbb7f38c34e436cac3fd01c73b5327e72a35af4 progress: handle indeterminate progress and inline errors diff --git a/hggit/git_handler.py b/hggit/git_handler.py --- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -59,7 +59,8 @@ br'(?P<sepr>[:/])(?P<path>.*)$') RE_NEWLINES = re.compile(br'[\r\n]') -RE_GIT_PROGRESS = re.compile(br'\((\d+)/(\d+)\)') +RE_GIT_DETERMINATE_PROGRESS = re.compile(br'\((\d+)/(\d+)\)') +RE_GIT_INDETERMINATE_PROGRESS = re.compile(br'(\d+)') RE_AUTHOR_FILE = re.compile(br'\s*=\s*') @@ -87,14 +88,20 @@ continue topic = td[0] - m = RE_GIT_PROGRESS.search(data) - if m: + determinate = RE_GIT_DETERMINATE_PROGRESS.search(data) + indeterminate = RE_GIT_INDETERMINATE_PROGRESS.search(data) + + if determinate or indeterminate: if self._progress and self._progress.topic != topic: self.flush() if not self._progress: self._progress = self.ui.makeprogress(topic) - pos, total = map(int, m.group(1, 2)) + if determinate: + pos, total = map(int, determinate.group(1, 2)) + else: + pos = int(indeterminate.group(1)) + total = None self._progress.update(pos, total=total) else: self.flush(msg) @@ -104,10 +111,13 @@ return self._progress.complete() self._progress = None - if self.remote: - self.ui.status(b'remote: %s\n' % (msg or self.msgbuf)) - elif msg is not None and msg.strip(): - self.ui.note(msg + b'\n') + if msg is None: + msg = self.msgbuf + if msg is not None and msg.strip(): + if self.remote: + self.ui.status(b'remote: %s\n' % msg) + else: + self.ui.note(msg + b'\n') def get_repo_and_gitdir(repo): diff --git a/tests/test-push-to-head.t b/tests/test-push-to-head.t --- a/tests/test-push-to-head.t +++ b/tests/test-push-to-head.t @@ -30,6 +30,7 @@ pushing to $TESTTMP/gitrepo searching for changes adding objects + remote: error: refusing to update checked out branch: refs/heads/master added 1 commits with 1 trees and 1 blobs warning: failed to update refs/heads/master; branch is currently checked out @@ -37,6 +38,7 @@ pushing to $TESTTMP/gitrepo searching for changes adding objects + remote: error: refusing to update checked out branch: refs/heads/master added 1 commits with 1 trees and 1 blobs warning: failed to update refs/heads/master; branch is currently checked out @@ -47,6 +49,7 @@ pushing to $TESTTMP/gitrepo searching for changes adding objects + remote: error: refusing to update checked out branch: refs/heads/master abort: git remote error: refs/heads/master failed to update [255] #endif diff --git a/tests/test-serve-dulwich.t b/tests/test-serve-dulwich.t --- a/tests/test-serve-dulwich.t +++ b/tests/test-serve-dulwich.t @@ -34,6 +34,16 @@ $ hg clone -U git+http://localhost:$HGPORT copy 2>&1 \r (no-eol) (esc) + counting objects 6 [ <=> ]\r (no-eol) (esc) (no-dulwich0204 !) + counting objects 1 [ <=> ]\r (no-eol) (esc) (dulwich0204 !) + counting objects 2 [ <=> ]\r (no-eol) (esc) (dulwich0204 !) + counting objects 3 [ <=> ]\r (no-eol) (esc) (dulwich0204 !) + counting objects 4 [ <=> ]\r (no-eol) (esc) (dulwich0204 !) + counting objects 5 [ <=> ]\r (no-eol) (esc) (dulwich0204 !) + counting objects 6 [ <=> ]\r (no-eol) (esc) (dulwich0204 !) + counting objects 6 [ <=> ]\r (no-eol) (esc) (dulwich0204 !) + \r (no-eol) (esc) + \r (no-eol) (esc) importing commits 1/2 [================> ]\r (no-eol) (esc) importing commits 2/2 [==================================>]\r (no-eol) (esc) \r (no-eol) (esc) @@ -59,6 +69,11 @@ \r (no-eol) (esc) exporting 1/1 [==========================================>]\r (no-eol) (esc) \r (no-eol) (esc) + \r (no-eol) (esc) + counting objects 4 [ <=> ]\r (no-eol) (esc) + counting objects 5 [ <=> ]\r (no-eol) (esc) + counting objects 6 [ <=> ]\r (no-eol) (esc) + \r (no-eol) (esc) pushing to git+http://localhost:$HGPORT/ searching for changes adding objects diff --git a/tests/test-serve-git.t b/tests/test-serve-git.t --- a/tests/test-serve-git.t +++ b/tests/test-serve-git.t @@ -34,6 +34,9 @@ $ hg clone -U git://localhost:$HGPORT/test copy 2>&1 \r (no-eol) (esc) + Enumerating objects 6 [ <=> ]\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) Counting objects 1/6 [=====> ]\r (no-eol) (esc) Counting objects 2/6 [===========> ]\r (no-eol) (esc) Counting objects 3/6 [=================> ]\r (no-eol) (esc)