[meld] Add unpushed commits summary for Git (bgo#699023)



commit 3aa6471ef0f22d3e8d05a2c69fba05bb5c6e4ae9
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Thu May 9 06:16:43 2013 +1000

    Add unpushed commits summary for Git (bgo#699023)
    
    This change adds a method to the new VC API that allows a VC to
    populate its root folder with some metadata, currently supported as
    the unpushed commits in a repository. Currently only Git uses this
    capability; hg outgoing would do the same very nicely, but since it
    moves data over the network, this isn't really acceptable.

 meld/vc/git.py |   11 +++++++++++
 meld/vcview.py |    8 ++++++++
 2 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/meld/vc/git.py b/meld/vc/git.py
index 743e226..778272f 100644
--- a/meld/vc/git.py
+++ b/meld/vc/git.py
@@ -97,6 +97,17 @@ class Vc(_vc.CachedVc):
 
     # Prototyping VC interface version 2
 
+    def get_commits_to_push_summary(self):
+        branch_refs = self.get_commits_to_push()
+        unpushed_branches = len(branch_refs.keys())
+        unpushed_commits = sum(len(v) for v in branch_refs.values())
+        if unpushed_commits:
+            label = _("%d unpushed commits in %d branches") % (
+                unpushed_commits, unpushed_branches)
+        else:
+            label = _("No unpushed commits found")
+        return label
+
     def get_commits_to_push(self):
         proc = _vc.popen([self.CMD, "for-each-ref",
                           "--format=%(refname:short) %(upstream:short)",
diff --git a/meld/vcview.py b/meld/vcview.py
index c10a8fd..bed9625 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -458,6 +458,14 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         # need to scan the rest of the repository
         if os.path.isdir(self.vc.location):
             root = self.model.get_iter_root()
+
+            try:
+                col = self.model.column_index(COL_OPTIONS, 0)
+                self.model.set_value(root, col,
+                                     self.vc.get_commits_to_push_summary())
+            except AttributeError:
+                pass
+
             self.scheduler.add_task(self._search_recursively_iter(root))
             self.scheduler.add_task(self.on_treeview_cursor_changed)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]