Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

fogcreek wctxactions: prompt to add files larger than 10 MB as bfiles

Changeset 057a60864ad4

Parent da95be84feda

by David Golub

Changes to 2 files · Browse files at 057a60864ad4 Showing diff from parent da95be84feda Diff from another changeset...

 
552
553
554
 
 
 
 
 
 
 
 
 
 
 
 
555
556
557
 
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
@@ -552,6 +552,18 @@
  btn.clicked.emit(False)   super(CustomPrompt, self).keyPressEvent(event)   +class BfilesPrompt(CustomPrompt): + def __init__(self, parent, files=None): + CustomPrompt.__init__(self, _('Confirm Add'), + _('Some of the files that you have selected are of a size ' + 'over 10 MB. You may make more efficient use of disk space ' + 'by adding these files as bfiles, which will store only the ' + 'most recent revision of each file in your local repository, ' + 'with older revisions available on the server. Do you wish ' + 'to add these files as bfiles?'), parent, + (_('Add as &Bfiles'), _('Add as &Normal Files'), _('Cancel')), + 0, 2, files) +  def setup_font_substitutions():   QFont.insertSubstitutions('monospace', ['monaco', 'courier new'])  
 
8
9
10
11
 
12
13
14
 
271
272
273
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
275
276
277
 
 
 
 
278
279
280
 
8
9
10
 
11
12
13
14
 
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
 
302
303
304
305
306
307
308
@@ -8,7 +8,7 @@
 import os  import re   -from mercurial import util, error, merge, commands, extensions +from mercurial import util, error, merge, commands, extensions, match  from tortoisehg.hgqt import qtlib, htmlui, visdiff  from tortoisehg.util import hglib, shlib  from tortoisehg.hgqt.i18n import _ @@ -271,10 +271,38 @@
   def add(parent, ui, repo, files):   if 'kbfiles' in repo.extensions(): + bfiles = [] + minsize = int(ui.config('kilnbfiles', 'size', default=10)) + patterns = ui.config('kilnbfiles', 'patterns', default=()) + if patterns: + patterns = patterns.split(' ') + matcher = match.match(repo.root, '', list(patterns)) + else: + matcher = None + if minsize == 0 or minsize >= 10: + for wfile in files: + if not matcher or not matcher(wfile): + filesize = os.path.getsize(repo.wjoin(wfile)) + if filesize >= 10*1024*1024 and filesize < minsize*1024*1024: + bfiles.append(wfile) + if bfiles: + ret = qtlib.BfilesPrompt(parent, files).run() + if ret == 0: + # add as bfiles + for bfile in bfiles: + files.remove(bfile) + elif ret == 1: + # add as normal files + bfiles = [] + elif ret == 2: + return False   for name, module in extensions.extensions():   if name == 'kbfiles':   override_add = module.bfsetup.override_add - override_add(commands.add, ui, repo, *files) + if files: + override_add(commands.add, ui, repo, *files) + if bfiles: + override_add(commands.add, ui, repo, *bfiles, bf=1)   return True   commands.add(ui, repo, *files)   return True