~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to shelf.py

  • Committer: Michael Ellerman
  • Date: 2006-02-06 14:14:02 UTC
  • mto: (0.1.73 shelf-tmp)
  • mto: This revision was merged to the branch mainline in revision 334.
  • Revision ID: michael@ellerman.id.au-20060206141402-7cb3e6917f8e517e
Make some of the messages a bit more readable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
class Shelf(object):
13
13
    def __init__(self, base, name='default'):
 
14
        self.name = name
14
15
        self.base = base
15
16
        shelf_base = os.path.join(self.base, BASE_DIR)
16
17
        self.shelf_dir = os.path.join(shelf_base, name)
48
49
 
49
50
    def __show_status(self, source):
50
51
        if source.can_live_update():
51
 
            diff_stat = DiffStat(source.readlines())
52
 
            print 'Diff status is now:\n', diff_stat
 
52
            diff_stat = str(DiffStat(source.readlines()))
 
53
            if len(diff_stat) > 0:
 
54
                print >> sys.stderr, 'Diff status is now:\n', diff_stat
 
55
            else:
 
56
                print >> sys.stderr, 'No changes left in working tree.'
53
57
 
54
58
    def unshelve(self, patch_source, pick_hunks=False):
55
59
        shelf = self.last_shelf()
104
108
            raise CommandError('Nothing to shelve')
105
109
 
106
110
        shelf = self.next_shelf()
107
 
        print >>sys.stderr, "Saving shelved patches to", shelf
 
111
        print >>sys.stderr, "Saving to shelf '%s', patch '%s'" % \
 
112
                (self.name, os.path.basename(shelf))
108
113
        shelf = open(shelf, 'a')
109
114
        if message is not None:
110
115
            assert '\n' not in message
116
121
        os.fsync(shelf.fileno())
117
122
        shelf.close()
118
123
 
119
 
        print >>sys.stderr, "Reverting shelved patches"
 
124
        print >>sys.stderr, "Reverting shelved patches."
120
125
        pipe = os.popen('patch -d %s -sR -p0' % self.base, 'w')
121
126
        for patch in to_shelve:
122
127
            pipe.write(str(patch))