From: <sv...@ww...> - 2004-07-07 04:08:10
|
Author: mkrose Date: 2004-07-06 21:08:02 -0700 (Tue, 06 Jul 2004) New Revision: 1145 Modified: trunk/CSP/tools/subcmd.py trunk/CSP/tools/sublib.py Log: Check for conflicts, with colored output and interactive submit. Fix bug parsing svn st output. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1145 Modified: trunk/CSP/tools/subcmd.py =================================================================== --- trunk/CSP/tools/subcmd.py 2004-07-07 04:03:55 UTC (rev 1144) +++ trunk/CSP/tools/subcmd.py 2004-07-07 04:08:02 UTC (rev 1145) @@ -118,6 +118,13 @@ class Changeset: + MODE_NAME = { + sublib.File.ADD: 'add', + sublib.File.DEL: 'delete', + sublib.File.MOD: 'modified', + sublib.File.CONFLICT: 'XXX conflict', + } + def __init__(self, name, files, pending=0): self._name = name self._description = [] @@ -180,7 +187,8 @@ for file in self._files: mode = file.mode path = file.path - addtext(' //%s # %s' % (path, mode.lower())) + comment = Changeset.MODE_NAME.get(mode, mode.lower()) + addtext(' //%s # %s' % (path, comment)) fileref[path] = file text = '\n'.join(text) result = edit(text, cursor) @@ -492,7 +500,13 @@ name = set._name else: name = '?' - print '%s (%s)' % (file, name) + if file.mode is sublib.File.CONFLICT: + # TODO make these escapes optional + sys.stdout.write('\033[1;31m') + print '>%s (%s)' % (file, name) + sys.stdout.write('\033[0m') + else: + print ' %s (%s)' % (file, name) return Result(0) def change(self, name, allow_default=0): @@ -561,6 +575,13 @@ return Error('Unknown changeset "%s"' % name) result = self.change(name) if not result.ok: return result + conflicts = filter(lambda x: x.mode is sublib.File.CONFLICT, sublib.svn_st()) + if conflicts: + print 'The following files have conflicts:' + for file in conflicts: print ' %s' % file.path + print 'Submit anyway [yN]? ', + input = sys.stdin.readline() + if input.rstrip() != 'y': return Error('Changeset not submitted.') result = cs.submit() if result.ok: del self._sets[name] Modified: trunk/CSP/tools/sublib.py =================================================================== --- trunk/CSP/tools/sublib.py 2004-07-07 04:03:55 UTC (rev 1144) +++ trunk/CSP/tools/sublib.py 2004-07-07 04:08:02 UTC (rev 1145) @@ -37,6 +37,7 @@ ADD = 'ADD' DEL = 'DEL' MOD = 'MOD' + CONFLICT = 'CON' def __init__(self, path, root, mode): self.mode = mode @@ -71,7 +72,7 @@ st = os.popen('svn st -q %s' % path).readlines() files = [] for line in st: - path = line[1:].strip() + path = line[7:].strip() abspath = os.path.abspath(path) assert(abspath.startswith(root)) relpath = abspath[len(root):] @@ -82,6 +83,7 @@ if line.startswith('M'): mode = File.MOD elif line.startswith('A'): mode = File.ADD elif line.startswith('D'): mode = File.DEL + elif line.startswith('C'): mode = File.CONFLICT else: continue files.append(File(relpath, root, mode)) return files |