1 # Copyright (c) 2005 Mark Williamson <mark.williamson@cl.cam.ac.uk>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License version 2 as
5 # published by the Free Software Foundation.
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
12 # You should have received a copy of the GNU General Public License
13 # along with this program; if not, write to the Free Software
14 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 def doCommit(keepFiles
, filesToCommit
, msg
):
22 for f
in filesToCommit
:
23 commitFileNames
.append(f
.dstName
)
24 runProgram(['hg', 'commit', '-A', '-l', '-'] + commitFileNames
, msg
)
27 def __init__(self
, unknown
=False):
30 def getPatchImpl(self
):
33 def fileSetFactory(addCallback
, removeCallback
):
34 return FileSet(addCallback
, removeCallback
)
36 parseDiffRE
= re
.compile('([AMR?]) (.*)')
38 def getPatch(file, otherFile
= None):
39 if file.change
== 'M' or \
40 file.change
== 'R' or \
42 return runProgram(['hg', 'diff', file.dstName
])
43 elif file.change
== '?':
44 return runProgram(['diff', '-u', '/dev/null', file.dstName
],
45 expectedexits
=[0,1,2])
50 inp
= runProgram(['hg', 'status'])
53 recs
= inp
.split("\n")
54 recs
.pop() # remove last entry (which is '')
58 m
= parseDiffRE
.match(rec
)
61 print "Unknown output from hg status!: " + rec
+ "\n"
67 if f
.change
== '?' and not settings().showUnknown
:
70 f
.srcName
= f
.dstName
= m
.group(2)
78 def updateFiles(fileSet
):
79 for f
in list([x
for x
in fileSet
]):
82 files
= __parseStatus()
86 f
.text
= 'Added file: ' + f
.srcName
88 f
.text
= 'New file: ' + f
.srcName
90 f
.text
= 'Removed file: ' + f
.srcName
97 def basicsFailed(msg
):
98 print "hg status: " + msg
99 print "Make sure that the current working directory contains a '.hg' directory."
103 runProgram(['hg', 'status'])
105 basicsFailed(e
.strerror
)
106 except ProgramError
, e
:
107 basicsFailed(e
.error
)
109 def doUpdateCache(file):
112 def discardFile(file):
113 if file.change
== "M":
114 runProgram(['hg', 'revert', file.dstName
])
115 elif file.change
== "?":
116 runProgram(['rm', '-f', file.dstName
])
119 def ignoreFile(file):
120 hgignore
= open('.hgignore', 'a')
121 print >> hgignore
, "^" + re
.escape(file.dstName
) + "$"
125 # Not yet implemented
132 # Not yet implemented
133 def getCurrentBranch():