Changeset 393 in tailor for vcpx/monotone.py
- Timestamp:
- 07/03/05 19:13:06 (8 years ago)
- Hash name:
- 20050703171306-97f81-11c9593de1896089b8be2153d79f4656276e3d86
- File:
-
- 1 edited
-
vcpx/monotone.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vcpx/monotone.py
r390 r393 12 12 __docformat__ = 'reStructuredText' 13 13 14 from shwrap import SystemCommand, shrepr, ReopenableNamedTemporaryFile14 from shwrap import ExternalCommand, PIPE, ReopenableNamedTemporaryFile 15 15 from source import UpdatableSourceWorkingDir, \ 16 16 ChangesetApplicationFailure, GetUpstreamChangesetsFailure … … 18 18 from sys import stderr 19 19 20 class MonotoneCommit(SystemCommand): 21 COMMAND = "monotone commit --author=\"%(key)s\" --date=\"%(date)s\" --message-file=\"%(logfile)s\" 2>&1" 22 23 def __call__(self, output=None, dry_run=False, **kwargs): 24 25 # the log message is written on a temporary file 26 rontf = ReopenableNamedTemporaryFile('mtn', 'tailor') 27 logmessage = kwargs.get('logmessage') 28 if logmessage: 29 log = open(rontf.name, "w") 30 log.write(logmessage) 31 log.close() 32 kwargs['logfile'] = rontf.name 33 34 return SystemCommand.__call__(self, output=output, 35 dry_run=dry_run, **kwargs) 36 37 class MonotoneRemove(SystemCommand): 38 COMMAND = "monotone drop %(entry)s" 39 40 41 class MonotoneMv(SystemCommand): 42 COMMAND = "monotone rename %(old)s %(new)s" 43 20 MONOTONE_CMD = "monotone" 44 21 45 22 class MonotoneWorkingDir(SyncronizableTargetWorkingDir): … … 52 29 """ 53 30 54 c = SystemCommand(working_dir=root, command="monotone add %(names)s") 55 c(names=' '.join([shrepr(n) for n in names])) 31 cmd = [MONOTONE_CMD, "add"] 32 add = ExternalCommand(cwd=root, command=cmd) 33 add.execute(names) 56 34 57 35 def _commit(self,root, date, author, remark, changelog=None, entries=None): … … 60 38 """ 61 39 62 c = MonotoneCommit(working_dir=root) 40 rontf = ReopenableNamedTemporaryFile('mtn', 'tailor') 41 log = open(rontf.name, "w") 42 log.write(remark) 43 log.write('\n') 44 if changelog: 45 log.write(changelog) 46 log.write('\n') 47 log.close() 48 49 cmd = [MONOTONE_CMD, "commit", "--author", author, 50 "--date", date.isoformat(), 51 "--message-file", rontf.name] 52 commit = ExternalCommit(cwd=root, command=cmd) 63 53 64 if entries: 65 entries = ' '.join([shrepr(e) for e in entries]) 66 else: 67 entries = '.' 54 if not entries: 55 entries = ['.'] 68 56 69 # monotone doesn't like empty changelogs ... 70 if changelog == None or len(changelog)<1: 71 if len(remark)>0: 72 changelog = remark 73 else: 74 changelog = "**** empty log message ****" 75 76 # monotone dates must be expressed as ISO8601 77 outstr = c(output=True, key=author, logmessage=changelog, 78 date=date.isoformat(), entries=entries) 57 output = commit.execute(entries, stdout=PIPE) 79 58 80 59 # monotone complaints if there are no changes from the last commit. 81 60 # we ignore those errors ... 82 if c.exit_status: 83 if outstr.getvalue().find("monotone: misuse: no changes to commit") == -1: 84 stderr.write(outstr.getvalue()) 85 outstr.close() 86 raise TargetInitializationFailure( 87 "'monotone commit returned %s" % c.exit_status) 88 else: 89 stderr.write("No changes to commit - changeset ignored\n") 90 91 outstr.close() 61 if commit.exit_status: 62 text = output.read() 63 if text.find("monotone: misuse: no changes to commit") == -1: 64 stderr.write(text) 65 raise TargetInitializationFailure( 66 "%s returned status %s" % (str(commit),commit.exit_status)) 67 else: 68 stderr.write("No changes to commit - changeset ignored\n") 92 69 93 70 def _removePathnames(self, root, names): … … 96 73 """ 97 74 98 c = MonotoneRemove(working_dir=root) 99 c(entry=' '.join([shrepr(n) for n in names])) 75 cmd = [MONOTONE_CMD, "drop"] 76 drop = ExternalCommand(cwd=root, command=cmd) 77 drop.execute(names) 100 78 101 79 def _renamePathname(self, root, oldname, newname): … … 104 82 """ 105 83 106 c = MonotoneMv(working_dir=root) 107 c(old=shrepr(oldname), new=shrepr(newname)) 84 cmd = [MONOTONE_CMD, "rename"] 85 rename = ExternalCommand(cwd=root, command=cmd) 86 rename.execute(oldname, newname) 108 87 109 88 def _initializeWorkingDir(self, root, repository, module, subdir): … … 122 101 raise TargetInitializationFailure("Please setup '%s' as a monotone working directory" % root) 123 102 124 c = SystemCommand(working_dir=root, 125 command="monotone add %(names)s") 126 c(names=subdir) 103 self._addPathnames(root, [subdir])
Note: See TracChangeset
for help on using the changeset viewer.
