Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

hgignore: allow edit of user-wide ignore files

If any ignore files are specified in ui.ignore[.*] they are added
to a combo box in the user interface and are selectable at runtime.

Fixes #178

Changeset c3101dcfa988

Parent f4be49ce0717

by Steve Borho

Changes to one file · Browse files at c3101dcfa988 Showing diff from parent f4be49ce0717 Diff from another changeset...

Change 1 of 6 Show Entire File hggtk/​hgignore.py Stacked
 
54
55
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
58
59
 
79
80
81
 
82
83
84
 
103
104
105
 
106
107
108
 
113
114
115
 
 
 
 
 
116
117
118
 
171
172
173
174
 
175
176
177
 
191
192
193
194
 
195
196
197
198
199
 
200
201
202
 
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 
96
97
98
99
100
101
102
 
121
122
123
124
125
126
127
 
132
133
134
135
136
137
138
139
140
141
142
 
195
196
197
 
198
199
200
201
 
215
216
217
 
218
219
220
221
222
 
223
224
225
226
@@ -54,6 +54,23 @@
  regexp_button.connect('clicked', self.add_regexp, regexp_entry)   regexp_entry.connect('activate', self.add_regexp, regexp_entry)   mainvbox.pack_start(hbox, False, False) + mainvbox.set_border_width(2) + + try: repo = hg.repository(ui.ui(), path=self.root) + except: self.destroy() + ignorefiles = [repo.wjoin('.hgignore')] + for name, value in repo.ui.configitems('ui'): + if name == 'ignore' or name.startswith('ignore.'): + ignorefiles.append(os.path.expanduser(value)) + + if len(ignorefiles) > 1: + combo = gtk.combo_box_new_text() + for f in ignorefiles: + combo.append_text(f) + combo.set_active(0) + combo.connect('changed', self.fileselect) + mainvbox.pack_start(combo, False, False, 4) + self.ignorefile = ignorefiles[0]     hbox = gtk.HBox()   frame = gtk.Frame(_('Filters')) @@ -79,6 +96,7 @@
  remove.set_sensitive(False)   bhbox.pack_start(remove, False, False, 2)   vbox.pack_start(bhbox, False, False, 2) + vbox.set_border_width(2)   frame.add(vbox)     frame = gtk.Frame(_('Unknown Files')) @@ -103,6 +121,7 @@
  self.connect('thg-refresh', self.thgrefresh)   bhbox.pack_start(refresh, False, False, 2)   vbox.pack_start(bhbox, False, False, 2) + vbox.set_border_width(2)   frame.add(vbox)     mainvbox.pack_start(hbox, True, True) @@ -113,6 +132,11 @@
  unknowntree.get_selection().connect('changed', self.unknown_rowchanged)   gobject.idle_add(self.refresh)   + def fileselect(self, combo): + 'select another ignore file' + self.ignorefile = combo.get_active_text() + self.refresh() +   def unknown_search(self, model, column, key, iter):   'case insensitive filename search'   key = key.lower() @@ -171,7 +195,7 @@
  for u in unknown:   self.unkmodel.append([hglib.toutf(u), u])   try: - l = open(repo.wjoin('.hgignore'), 'rb').readlines() + l = open(self.ignorefile, 'rb').readlines()   self.doseoln = l[0].endswith('\r\n')   except (IOError, ValueError, IndexError):   self.doseoln = os.name == 'nt' @@ -191,12 +215,12 @@
  else:   out = [line + '\n' for line in self.ignorelines]   try: - f = open(self.repo.wjoin('.hgignore'), 'wb') + f = open(self.ignorefile, 'wb')   f.writelines(out)   f.close()   except IOError:   pass - shlib.shell_notify([self.repo.wjoin('.hgignore')]) + shlib.shell_notify([self.ignorefile])   if self.notify_func: self.notify_func()    def run(_ui, *pats, **opts):