Attachment 'fixcase.py'

Download

   1 # fixcase.py - pull and merge remote changes
   2 #
   3 # Copyright 2008 Andrei Vermel <andrei.vermel@gmail.com>
   4 #
   5 # This software may be used and distributed according to the terms
   6 # of the GNU General Public License, incorporated herein by reference.
   7 
   8 from mercurial.i18n import _
   9 from mercurial.node import *
  10 from mercurial import commands, cmdutil, hg, node, util
  11 import os
  12 
  13 def fixcase(ui, repo, *pats, **opts):
  14     '''Revert case changes in filenames'''
  15 
  16     all = None
  17     node1, node2 = cmdutil.revpair(repo, None)
  18 
  19     unknown = repo.status(node1, node2, cmdutil.match(repo, pats, opts),
  20                        None, None, True)[4]
  21                              
  22     file_map={} 
  23     for cp in repo[None].parents():
  24       node=cp.node()                        
  25       m = repo.changectx(node).manifest()
  26       files = m.keys()
  27       for file in files:
  28       	file_map[file.lower()]=file
  29       	
  30     for file in unknown:
  31       file_lower=file.lower()
  32       if file_lower in file_map:
  33       	ui.status(_('Reverted %s to %s\n') % (file, 
  34       	  file_map[file_lower]))
  35       	os.rename(repo.wjoin(file), repo.wjoin(file_map[file_lower]))     	
  36 
  37 cmdtable = {
  38     'fixcase':
  39         (fixcase,
  40          commands.walkopts,
  41         _('hg fixcase [SOURCE]')),
  42 }

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2010-04-21 16:50:54, 1.2 KB) [[attachment:fixcase.py]]
 All files | Selected Files: delete move to page

You are not allowed to attach a file to this page.