Changeset 304 in tailor
- Timestamp:
- 05/18/05 17:17:43 (8 years ago)
- Hash name:
- 20050518151743-2a8e2-9eb92aff73a452ba64d21bb7fb11ab0dc5f6fbc4
- File:
-
- 1 edited
-
vcpx/monotone.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vcpx/monotone.py
r296 r304 12 12 __docformat__ = 'reStructuredText' 13 13 14 from shwrap import SystemCommand, shrepr 14 from shwrap import SystemCommand, shrepr, ReopenableNamedTemporaryFile 15 15 from source import UpdatableSourceWorkingDir, \ 16 16 ChangesetApplicationFailure, GetUpstreamChangesetsFailure 17 17 from target import SyncronizableTargetWorkingDir, TargetInitializationFailure 18 from sys import stderr 18 19 19 20 class MonotoneCommit(SystemCommand): 20 COMMAND = "monotone commit --author=\"%(key)s\" --date=\"%(date)s\" "21 COMMAND = "monotone commit --author=\"%(key)s\" --date=\"%(date)s\" --message-file=\"%(logfile)s\" 2>&1" 21 22 22 23 def __call__(self, output=None, dry_run=False, **kwargs): 23 24 24 from os.path import exists, join 25 26 if not exists(join(self.working_dir, 'MT')): 27 # If MonotoneCommit is called outside the working copy 28 # (i.e. there is no MT directory) we test if we are given 29 # only the subdir as entry to commit. In that case, switch 30 # to root/subdir as working directory and issue a commit 31 # without any entries. 32 33 entries = kwargs['entries'] 34 entries = entries.replace(' ', '') 35 entries = entries.strip('\"') 36 if (exists(join(self.working_dir, entries))): 37 self.working_dir = join(self.working_dir, entries) 38 kwargs['entries'] = "" 39 else: 40 raise TargetInitializationFailure("not a valid monotone working copy (MT directory is missing in %s)" % self.working_dir) 41 42 log = open(self.working_dir + "/MT/log", "w"); 43 25 # the log message is written on a temporary file 26 rontf = ReopenableNamedTemporaryFile('mtn', 'tailor') 44 27 logmessage = kwargs.get('logmessage') 45 28 if logmessage: 46 log.write(logmessage + "\n") 47 48 log.close(); 29 log = open(rontf.name, "w") 30 log.write(logmessage) 31 log.close() 32 kwargs['logfile'] = rontf.name 49 33 50 34 return SystemCommand.__call__(self, output=output, … … 89 73 else: 90 74 changelog = "**** empty log message ****" 91 changelog = changelog.replace('"', '\\"')92 75 93 # monotone date must be expressed as ISO860176 # monotone dates must be expressed as ISO8601 94 77 outstr = c(output=True, key=author, logmessage=changelog, 95 78 date=date.isoformat(), entries=entries) … … 99 82 if c.exit_status: 100 83 if outstr.getvalue().find("monotone: misuse: no changes to commit") == -1: 84 stderr.write(outstr.getvalue()) 101 85 outstr.close() 102 86 raise TargetInitializationFailure( 103 87 "'monotone commit returned %s" % c.exit_status) 88 else: 89 stderr.write("No changes to commit - changeset ignored\n") 90 104 91 outstr.close() 105 92 … … 131 118 132 119 from os.path import exists, join 133 134 if not exists(join(root, subdir, 'MT')):135 raise TargetInitializationFailure("Please setup %s as a monotone working directory." % root)136 120 137 c = SystemCommand(working_dir=join(root, subdir), 121 if not exists(join(root, 'MT')): 122 raise TargetInitializationFailure("Please setup '%s' as a monotone working directory" % root) 123 124 c = SystemCommand(working_dir=root, 138 125 command="monotone add %(names)s") 139 c(names= '.')126 c(names=subdir)
Note: See TracChangeset
for help on using the changeset viewer.
