1
### Copyright (C) 2002-2005 Stephen Kennedy <stevek@gnome.org>
3
### Redistribution and use in source and binary forms, with or without
4
### modification, are permitted provided that the following conditions
7
### 1. Redistributions of source code must retain the above copyright
8
### notice, this list of conditions and the following disclaimer.
9
### 2. Redistributions in binary form must reproduce the above copyright
10
### notice, this list of conditions and the following disclaimer in the
11
### documentation and/or other materials provided with the distribution.
13
### THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14
### IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15
### OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16
### IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17
### INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18
### NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19
### DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20
### THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
### (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
### THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
# Mercurial diffs can be run in "git" mode
35
PATCH_INDEX_RE = "^diff (?:-r \w+ |--git a/.* b/)(.*)$"
40
"C": _vc.STATE_NORMAL,
41
"!": _vc.STATE_MISSING,
42
"I": _vc.STATE_IGNORED,
43
"M": _vc.STATE_MODIFIED,
44
"R": _vc.STATE_REMOVED,
47
def commit_command(self, message):
48
return [self.CMD,"commit","-m",message]
49
def diff_command(self):
50
ret = [self.CMD,"diff"]
51
if self.DIFF_GIT_MODE:
54
def update_command(self):
55
return [self.CMD,"update"]
56
def add_command(self, binary=0):
57
return [self.CMD,"add"]
58
def remove_command(self, force=0):
59
return [self.CMD,"rm"]
60
def revert_command(self):
61
return [self.CMD,"revert"]
62
def get_working_directory(self, workdir):
65
def _get_dirsandfiles(self, directory, dirs, files):
69
entries = _vc.popen([self.CMD, "status", "-A", "."], cwd=directory).read().split("\n")[:-1]
72
if e.errno != errno.EAGAIN:
78
for statekey, name in [ (entry[0], entry[2:]) for entry in entries if entry.find("/")==-1 ]:
79
path = os.path.join(directory, name)
80
rev, options, tag = "","",""
81
state = self.state_map.get(statekey, _vc.STATE_NONE)
82
retfiles.append( _vc.File(path, name, state, rev, tag, options) )
86
#state = ignore_re.match(f) == None and _vc.STATE_NONE or _vc.STATE_IGNORED
87
state = _vc.STATE_NORMAL
88
retfiles.append( _vc.File(path, f, state, "") )
91
#state = ignore_re.match(f) == None and _vc.STATE_NONE or _vc.STATE_IGNORED
92
state = _vc.STATE_NORMAL
93
retdirs.append( _vc.Dir(path, d, state) )
95
return retdirs, retfiles