comparison 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
comparison
equal deleted inserted replaced
47:916b05f73b53 48:00995da9c204
17 def _find_all_paths(ui, skip_ignored=False, sort_by_priority=False): 17 def _find_all_paths(ui, skip_ignored=False, sort_by_priority=False):
18 """ 18 """
19 Finds all paths defined for repo 19 Finds all paths defined for repo
20 :return: list of pairs (alias, path) 20 :return: list of pairs (alias, path)
21 """ 21 """
22 paths = ui.configitems(group) 22 paths = ui.configitems("paths")
23 if not paths: 23 if not paths:
24 raise mercurial.util.Abort(_('No paths defined for repository')) 24 raise mercurial.util.Abort(_('No paths defined for repository'))
25 25
26 if skip_ignored: 26 if skip_ignored:
27 ignored = ui.configlist("all_paths", "ignore") 27 ignored = ui.configlist("all_paths", "ignore")
28 paths = [(alias, path) for alias, path in paths if alias not in ignored] 28 if ignored:
29 if not paths: 29 paths = [(alias, path) for alias, path in paths if alias not in ignored]
30 raise mercurial.util.Abort(_('All paths defined for this repository are ignored')) 30 if not paths:
31 raise mercurial.util.Abort(_('All paths defined for this repository are ignored'))
31 32
32 if sort_by_priority: 33 if sort_by_priority:
33 #priority = ui.configlist("all_paths", "priority") 34 prior = ui.configlist("all_paths", "prioritize")
34 #paths.sort(…) 35 if prior:
35 pass # TODO 36 prior_val = {}
36 37 for idx, item in enumerate(prior):
38 prior_val[item] = idx
39 higher = len(prior)
40 paths.sort(key = lambda it: prior_val.get(it[0], higher))
41
37 return paths 42 return paths
38 43
39 def _find_paths(ui, group=None): 44 def _find_paths(ui, group=None):
40 """ 45 """
41 Finds and returns all paths defined in given group, or all paths 46 Finds and returns all paths defined in given group, or all paths
46 :return: list of pairs (alias, path) 51 :return: list of pairs (alias, path)
47 """ 52 """
48 if not group: 53 if not group:
49 return _find_all_paths(ui, skip_ignored=True, sort_by_priority=True) 54 return _find_all_paths(ui, skip_ignored=True, sort_by_priority=True)
50 55
56 print "DBG:GRR", group
57
51 # „Modern” syntax 58 # „Modern” syntax
52 grp_def = ui.configlist("all_paths", "group." + group) 59 grp_def = ui.configlist("all_paths", "group." + group)
53 if grp_def: 60 if grp_def:
54 all_paths = dict(_find_all_paths(ui)) 61 all_paths = dict(_find_all_paths(ui))
55 paths = [] 62 paths = []
124 _, spec = mercurial.cmdutil.findcmd(cmdname, mercurial.commands.table) 131 _, spec = mercurial.cmdutil.findcmd(cmdname, mercurial.commands.table)
125 return spec[1] 132 return spec[1]
126 133
127 134
128 EXT_OPTS = [ 135 EXT_OPTS = [
129 ('g', 'group', 'paths', _('use a named group of paths')), 136 ('g', 'group', None, _('use a named group instead of all paths')),
130 ('', 'ignore-errors', None, _('continue execution despite errors')), 137 ('', 'ignore-errors', None, _('continue execution despite errors')),
131 ] 138 ]
132 139
133 cmdtable = { 140 cmdtable = {
134 "pushall": ( 141 "pushall": (