53a7cc958b7e — sietse.brouwer 8 years ago
grsummary: handle hggit guest repos

grsummary looked for draft commits to see if a repo had outgoing
changes, but hggit guests [1] consist entirely of drafts, and so always
looked unpushed. Now grsummary checks if the guest is an hggit repo; if
it is, unpushed commits are found with the revset `not(fromgit())`,
instead.

[1] https://bitbucket.org/durin42/hg-git/
1 files changed, 9 insertions(+), 2 deletions(-)

M guestrepo/guestrepo.py
M guestrepo/guestrepo.py +9 -2
@@ 345,8 345,15 @@ def summary(ui, repo, **opts):
                 or guest.csid in guestctx.tags()
                 or guest.csid in guestctx.bookmarks()):
 
-                outgoing = [rev for rev in guestrepo.changelog
-                            if guestrepo[rev].phase() == draft]
+                # Does the guestrepo have unpushed commits?
+                if (hasattr(guestrepo, 'githandler')
+                    and guestrepo.ui.config('paths', 'default').startswith('git+')):
+                    # This is an hggit repo: unpushed commits have no git id
+                    outgoing = list(guestrepo.set('first(not(fromgit()))'))
+                else:
+                    # This is an hg repo: unpushed commits are in draft phase
+                    outgoing = [rev for rev in guestrepo.changelog
+                                if guestrepo[rev].phase() == draft]
 
                 if outgoing or gr_changed:
                     state = "localmods"