1 # This program is free software; you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License version 2 as
3 # published by the Free Software Foundation.
5 # This program is distributed in the hope that it will be useful,
6 # but WITHOUT ANY WARRANTY; without even the implied warranty of
7 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 # GNU General Public License for more details.
10 # You should have received a copy of the GNU General Public License
11 # along with this program; if not, write to the Free Software
12 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 def doCommit(keepFiles
, selFileNames
, msg
):
19 print "Commit message:" + msg
20 runProgram(['hg', 'commit', '-A', '-l', '-'] + selFileNames
, msg
)
23 parseDiffRE
= re
.compile('([AMR?]) (.*)')
25 def __getPatch(file, otherFile
= None):
31 return runProgram(['hg', 'diff'] + f
)
34 inp
= runProgram(['hg', 'status'])
38 recs
= inp
.split("\n")
39 recs
.pop() # remove last entry (which is '')
43 m
= parseDiffRE
.match(rec
)
46 print "Unknown output from hg status!: " + rec
+ "\n"
51 f
.srcName
= f
.dstName
= m
.group(2)
52 print "Getting patch for file " + f
.srcName
54 f
.patch
= __getPatch(f
.srcName
)
62 # HEAD is src in the returned File objects. That is, srcName is the
63 # name in HEAD and dstName is the name in the cache.
65 files
= __parseStatus()
69 f
.text
= 'Added file: ' + f
.srcName
71 f
.text
= 'New file: ' + f
.srcName
73 f
.text
= 'Removed file: ' + f
.srcName
81 def basicsFailed(msg
):
82 print "hg status: " + msg
83 print "Make sure that the current working directory contains a '.hg' directory."
87 runProgram(['hg', 'status'])
89 basicsFailed(e
.strerror
)
90 except ProgramError
, e
:
93 def doUpdateCache(file):
96 def discardFile(file):
97 runProgram(['hg', 'revert', file.dstName
])
100 def ignoreFile(file):
101 hgignore
= open('.hgignore', 'a')
102 print >> hgignore
, "^" + re
.escape(file.dstName
) + "$"