diff mercurial_all_paths.py @ 48:00995da9c204

Implemented priorities, fixed bugs in ignoring, both should work. Testfixes
author Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
date Sun, 25 Sep 2016 21:20:31 +0200
parents 916b05f73b53
children 55469dbb19c4
line wrap: on
line diff
--- a/mercurial_all_paths.py	Sun Sep 25 10:22:37 2016 +0200
+++ b/mercurial_all_paths.py	Sun Sep 25 21:20:31 2016 +0200
@@ -19,21 +19,26 @@
     Finds all paths defined for repo
     :return: list of pairs (alias, path)
     """
-    paths = ui.configitems(group)
+    paths = ui.configitems("paths")
     if not paths:
         raise mercurial.util.Abort(_('No paths defined for repository'))
 
     if skip_ignored:
         ignored = ui.configlist("all_paths", "ignore")
-        paths = [(alias, path) for alias, path in paths if alias not in ignored]
-        if not paths:
-            raise mercurial.util.Abort(_('All paths defined for this repository are ignored'))
+        if ignored:
+            paths = [(alias, path) for alias, path in paths if alias not in ignored]
+            if not paths:
+                raise mercurial.util.Abort(_('All paths defined for this repository are ignored'))
 
     if sort_by_priority:
-        #priority = ui.configlist("all_paths", "priority")
-        #paths.sort(…)
-        pass # TODO
-
+        prior = ui.configlist("all_paths", "prioritize")
+        if prior:
+            prior_val = {}
+            for idx, item in enumerate(prior):
+                prior_val[item] = idx
+            higher = len(prior)
+            paths.sort(key = lambda it: prior_val.get(it[0], higher))
+        
     return paths
 
 def _find_paths(ui, group=None):
@@ -48,6 +53,8 @@
     if not group:
         return _find_all_paths(ui, skip_ignored=True, sort_by_priority=True)
 
+    print "DBG:GRR", group
+    
     # „Modern” syntax
     grp_def = ui.configlist("all_paths", "group." + group)
     if grp_def:
@@ -126,7 +133,7 @@
 
 
 EXT_OPTS = [
-    ('g', 'group', 'paths', _('use a named group of paths')),
+    ('g', 'group', None, _('use a named group instead of all paths')),
     ('', 'ignore-errors', None, _('continue execution despite errors')),
 ]