From 863b386e195bb2b609b25614f732b1b502bc79a4 Mon Sep 17 00:00:00 2001 From: jez Date: Sat, 21 May 2011 10:13:45 +0000 Subject: Add progress tracking for git-clone. --- git/util.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'git/util.py') diff --git a/git/util.py b/git/util.py index 7cbef07f..b3a420b3 100644 --- a/git/util.py +++ b/git/util.py @@ -100,6 +100,40 @@ def get_user_id(): # END get username from login return "%s@%s" % (username, platform.node()) +def _digest_process_messages(fh, progress): + """Read progress messages from file-like object fh, supplying the respective + progress messages to the progress instance. + + :return: list(line, ...) list of lines without linebreaks that did + not contain progress information""" + line_so_far = '' + dropped_lines = list() + while True: + char = fh.read(1) + if not char: + break + + if char in ('\r', '\n'): + dropped_lines.extend(progress._parse_progress_line(line_so_far)) + line_so_far = '' + else: + line_so_far += char + # END process parsed line + # END while file is not done reading + return dropped_lines + +def _finalize_proc(proc): + """Wait for the process (clone, fetch, pull or push) and handle its errors accordingly""" + try: + proc.wait() + except GitCommandError,e: + # if a push has rejected items, the command has non-zero return status + # a return status of 128 indicates a connection error - reraise the previous one + if proc.poll() == 128: + raise + pass + # END exception handling + #} END utilities #{ Classes -- cgit v1.2.3 From 55eb3de3c31fd5d5ad35a8452060ee3be99a2d99 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 7 Jun 2011 21:25:38 +0200 Subject: Added conditional usage of the --progress flag to all relevant methods, that is push, fetch, pull and clone. This allows progress information to be sent in newer git versions without breaking older ones (ideally) --- git/util.py | 34 ---------------------------------- 1 file changed, 34 deletions(-) (limited to 'git/util.py') diff --git a/git/util.py b/git/util.py index b3a420b3..7cbef07f 100644 --- a/git/util.py +++ b/git/util.py @@ -100,40 +100,6 @@ def get_user_id(): # END get username from login return "%s@%s" % (username, platform.node()) -def _digest_process_messages(fh, progress): - """Read progress messages from file-like object fh, supplying the respective - progress messages to the progress instance. - - :return: list(line, ...) list of lines without linebreaks that did - not contain progress information""" - line_so_far = '' - dropped_lines = list() - while True: - char = fh.read(1) - if not char: - break - - if char in ('\r', '\n'): - dropped_lines.extend(progress._parse_progress_line(line_so_far)) - line_so_far = '' - else: - line_so_far += char - # END process parsed line - # END while file is not done reading - return dropped_lines - -def _finalize_proc(proc): - """Wait for the process (clone, fetch, pull or push) and handle its errors accordingly""" - try: - proc.wait() - except GitCommandError,e: - # if a push has rejected items, the command has non-zero return status - # a return status of 128 indicates a connection error - reraise the previous one - if proc.poll() == 128: - raise - pass - # END exception handling - #} END utilities #{ Classes -- cgit v1.2.3 From ab5b6af0c2c13794525ad84b0a80be9c42e9fcf1 Mon Sep 17 00:00:00 2001 From: jez Date: Sat, 21 May 2011 10:17:08 +0000 Subject: Parse more git-fetch operation log codes. --- git/util.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'git/util.py') diff --git a/git/util.py b/git/util.py index 7cbef07f..0492b63c 100644 --- a/git/util.py +++ b/git/util.py @@ -109,8 +109,8 @@ class RemoteProgress(object): Handler providing an interface to parse progress information emitted by git-push and git-fetch and to dispatch callbacks allowing subclasses to react to the progress. """ - _num_op_codes = 5 - BEGIN, END, COUNTING, COMPRESSING, WRITING = [1 << x for x in range(_num_op_codes)] + _num_op_codes = 7 + BEGIN, END, COUNTING, COMPRESSING, WRITING, RECEIVING, RESOLVING = [1 << x for x in range(_num_op_codes)] STAGE_MASK = BEGIN|END OP_MASK = ~STAGE_MASK @@ -168,6 +168,10 @@ class RemoteProgress(object): op_code |= self.COMPRESSING elif op_name == "Writing objects": op_code |= self.WRITING + elif op_name == 'Receiving objects': + op_code |= self.RECEIVING + elif op_name == 'Resolving deltas': + op_code |= self.RESOLVING else: raise ValueError("Operation name %r unknown" % op_name) -- cgit v1.2.3