~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to shelf.py

  • Committer: Michael Ellerman
  • Date: 2006-06-05 14:18:25 UTC
  • mto: (0.3.1 shelf-dev)
  • mto: This revision was merged to the branch mainline in revision 393.
  • Revision ID: michael@ellerman.id.au-20060605141825-835ebbb5ffbff21d
Code cleanup, more explicit variable names.

Show diffs side-by-side

added added

removed removed

Lines of Context:
136
136
    def unshelve(self, patch_source, all=False, force=False):
137
137
        self._check_upgrade()
138
138
 
139
 
        patch_name = self.last_patch()
 
139
        patch_path = self.last_patch()
140
140
 
141
 
        if patch_name is None:
 
141
        if patch_path is None:
142
142
            raise CommandError("No patch found on shelf %s" % self.name)
143
143
 
144
 
        patches = FilePatchSource(patch_name).readpatches()
 
144
        patches = FilePatchSource(patch_path).readpatches()
145
145
        if all:
146
146
            to_unshelve = patches
147
147
            to_remain = []
151
151
        if len(to_unshelve) == 0:
152
152
            raise CommandError('Nothing to unshelve')
153
153
 
154
 
        message = self.get_patch_message(patch_name)
 
154
        message = self.get_patch_message(patch_path)
155
155
        if message is None:
156
156
            message = "No message saved with patch."
157
157
        self.log('Unshelving from %s/%s: "%s"\n' % \
158
 
                (self.name, os.path.basename(patch_name), message))
 
158
                (self.name, os.path.basename(patch_path), message))
159
159
 
160
160
        try:
161
161
            self._run_patch(to_unshelve, dry_run=True)
177
177
                    "longer applies cleanly to the working tree!")
178
178
 
179
179
        # Backup the shelved patch
180
 
        os.rename(patch_name, '%s~' % patch_name)
 
180
        os.rename(patch_path, '%s~' % patch_path)
181
181
 
182
182
        if len(to_remain) > 0:
183
 
            f = open(patch_name, 'w')
 
183
            f = open(patch_path, 'w')
184
184
            for patch in to_remain:
185
185
                f.write(str(patch))
186
186
            f.close()
202
202
            timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
203
203
            message = "Changes shelved on %s" % timestamp
204
204
 
205
 
        patch_name = self.next_patch()
 
205
        patch_path = self.next_patch()
206
206
        self.log('Shelving to %s/%s: "%s"\n' % \
207
 
                (self.name, os.path.basename(patch_name), message))
 
207
                (self.name, os.path.basename(patch_path), message))
208
208
 
209
 
        f = open(patch_name, 'a')
 
209
        f = open(patch_path, 'a')
210
210
 
211
211
        assert '\n' not in message
212
212
        f.write("%s%s\n" % (self.MESSAGE_PREFIX, message))