Mercurial > hg-git
comparison hggit/git_handler.py @ 591:163c452531cf
push: add more output about what was added (issue #64)
l33t pointed out that currently, Hg-Git doesn't provide any confirmation that a
push was successful other than the exit code. Normal Mercurial provides a
couple other messages followed by "added X changesets with Y changes to
Z files". After this change, Hg-Git will provide much more similar output.
It's not identical, as the underlying model is substantially different, but the
concept is the same. The main message is "added X commits with Y trees and
Z blobs".
This change doesn't affect the output of what references/branches were touched.
That will be addressed in a subsequent commit.
Dulwich doesn't provide an easy hook to get the information needed for this
output. Instead of passing generate_pack_contents as the pack generator
function to send_pack, I pass a custom function that determines the "missing"
objects, stores the counts, and then calls generate_pack_contents (which then
will determine the "missing" objects again.
The new expected output:
searching for changes # unless quiet true
<N> commits found # if verbose true
list of commits: # if debugflag true and at least one commit found
<each hash> # if debugflag true and at least one commit found
adding objects # if at least one commit found unless quiet true
added <N> commits with <N> trees and <N> blobs # if at least one object unless
# quiet true
https://bitbucket.org/durin42/hg-git/issue/64/push-confirmation
author | David M. Carr <david@carrclan.us> |
---|---|
date | Sun, 06 Jan 2013 01:46:57 -0500 |
parents | 2320ab6ada36 |
children | a6b7ad535244 |
comparison
equal
deleted
inserted
replaced
590:2320ab6ada36 | 591:163c452531cf |
---|---|
869 ## PACK UPLOADING AND FETCHING | 869 ## PACK UPLOADING AND FETCHING |
870 | 870 |
871 def upload_pack(self, remote, revs, force): | 871 def upload_pack(self, remote, revs, force): |
872 client, path = self.get_transport_and_path(remote) | 872 client, path = self.get_transport_and_path(remote) |
873 old_refs = {} | 873 old_refs = {} |
874 change_totals = {} | |
875 | |
874 def changed(refs): | 876 def changed(refs): |
877 self.ui.status(_("searching for changes\n")) | |
875 old_refs.update(refs) | 878 old_refs.update(refs) |
876 to_push = revs or set(self.local_heads().values() + self.tags.values()) | 879 to_push = revs or set(self.local_heads().values() + self.tags.values()) |
877 return self.get_changed_refs(refs, to_push, force) | 880 return self.get_changed_refs(refs, to_push, force) |
878 | 881 |
879 genpack = self.git.object_store.generate_pack_contents | 882 def genpack(have, want): |
883 commits = [] | |
884 for mo in self.git.object_store.find_missing_objects(have, want): | |
885 (sha, name) = mo | |
886 o = self.git.object_store[sha] | |
887 t = type(o) | |
888 change_totals[t] = change_totals.get(t, 0) + 1 | |
889 if isinstance(o, Commit): | |
890 commits.append(sha) | |
891 commit_count = len(commits) | |
892 self.ui.note(_("%d commits found\n") % commit_count) | |
893 if commit_count > 0: | |
894 self.ui.debug(_("list of commits:\n")) | |
895 for commit in commits: | |
896 self.ui.debug("%s\n" % commit) | |
897 self.ui.status(_("adding objects\n")) | |
898 return self.git.object_store.generate_pack_contents(have, want) | |
899 | |
880 try: | 900 try: |
881 self.ui.status(_("searching for changes\n")) | |
882 self.ui.note(_("creating and sending data\n")) | |
883 new_refs = client.send_pack(path, changed, genpack) | 901 new_refs = client.send_pack(path, changed, genpack) |
902 if len(change_totals) > 0: | |
903 self.ui.status(_("added %d commits with %d trees" | |
904 " and %d blobs\n") % | |
905 (change_totals.get(Commit, 0), | |
906 change_totals.get(Tree, 0), | |
907 change_totals.get(Blob, 0))) | |
884 return old_refs, new_refs | 908 return old_refs, new_refs |
885 except (HangupException, GitProtocolError), e: | 909 except (HangupException, GitProtocolError), e: |
886 raise hgutil.Abort(_("git remote error: ") + str(e)) | 910 raise hgutil.Abort(_("git remote error: ") + str(e)) |
887 | 911 |
888 def get_changed_refs(self, refs, revs, force): | 912 def get_changed_refs(self, refs, revs, force): |