changeset 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 d76b40291d10
files mercurial_all_paths.py tests/groups-modern.t tests/ignore_and_prioritize.t
diffstat 3 files changed, 57 insertions(+), 32 deletions(-) [+]
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')),
 ]
 
--- a/tests/groups-modern.t	Sun Sep 25 10:22:37 2016 +0200
+++ b/tests/groups-modern.t	Sun Sep 25 21:20:31 2016 +0200
@@ -250,10 +250,32 @@
 But global access works
 
   $ hg --cwd $BASE pushall
-  HMM
+  pushing to */rep1 (glob)
+  searching for changes
+  abort: push creates new remote head *! (glob)
+  (merge or see "hg help push" for details about pushing new heads)
+  [255]
 
   $ hg --cwd $BASE pullall
-  HMM
+  pulling from */rep1 (glob)
+  searching for changes
+  no changes found
+  
+  pulling from */rep2 (glob)
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  (run 'hg update' to get a working copy)
+  
+  pulling from */rep3 (glob)
+  searching for changes
+  no changes found
+  
+  pulling from */rep4 (glob)
+  searching for changes
+  no changes found
 
 Finally let's test that push options work
 
@@ -269,7 +291,7 @@
   $ hg --cwd $BASE commit -m 'Br1'
 
   $ hg --cwd $BASE update default
-  2 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ cat >> $BASE/file.txt << EOF
   > later text
   > EOF
@@ -281,24 +303,27 @@
   adding changesets
   adding manifests
   adding file changes
-  added 1 changesets with 1 changes to 1 files
+  added 3 changesets with 3 changes to 1 files (+1 heads)
   
   pushing to */rep3 (glob)
   searching for changes
   adding changesets
   adding manifests
   adding file changes
-  added 2 changesets with 2 changes to 2 files
+  added 3 changesets with 3 changes to 1 files
 
   $ hg --cwd $BASE log  -T '{rev}: {desc}\n'
-  4: Normal
-  3: Br1
+  5: Normal
+  4: Br1
+  3: In repo2
   2: In repo1
   1: Second
   0: First
 
   $ hg --cwd $REP1 log  -T '{rev}: {desc}\n'
-  2: Normal
+  4: Normal
+  3: In repo2
+  2: Second
   1: In repo1
   0: First
 
@@ -308,8 +333,8 @@
   0: First
 
   $ hg --cwd $REP3 log  -T '{rev}: {desc}\n'
-  2: Normal
-  1: In repo1
+  3: Normal
+  2: In repo2
+  1: Second
   0: First
 
-.
--- a/tests/ignore_and_prioritize.t	Sun Sep 25 10:22:37 2016 +0200
+++ b/tests/ignore_and_prioritize.t	Sun Sep 25 21:20:31 2016 +0200
@@ -23,8 +23,8 @@
   > [extensions]
   > mercurial_all_paths =
   > [all_paths]
-  > ignore = unknown rep2
-  > prioritize = rep3 mystery rep1
+  > ignore = unknown remote2
+  > prioritize = remote3 mystery remote1
   > EOF
 
 We need some repositories to test.
@@ -58,9 +58,7 @@
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files
-
-  Skipping ignored rep2
-
+  
   pushing to */rep1 (glob)
   searching for changes
   adding changesets
@@ -91,21 +89,20 @@
 
 
   $ hg --cwd $REP2 update
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
   $ cat >> $REP2/file.txt << EOF
   > From repo2…
   > EOF
 
   $ hg --cwd $REP2 add
+  adding file.txt
   $ hg --cwd $REP2 commit -m "In repo2"
 
   $ hg --cwd $BASE incomingall
   comparing with */rep3 (glob)
   searching for changes
   no changes found
-
-  Skipping ignored rep2
   
   comparing with */rep1 (glob)
   searching for changes
@@ -119,8 +116,6 @@
   pulling from */rep3 (glob)
   searching for changes
   no changes found
-
-  Skipping ignored rep2
   
   pulling from */rep1 (glob)
   searching for changes
@@ -144,8 +139,6 @@
   date:        .* (re)
   summary:     In repo2
   
-  Skipping ignored rep2
-  
   comparing with */rep3 (glob)
   searching for changes
   changeset:   1:* (glob)