5
5
from bzrlib.commands import Command
6
from bzrlib.branch import Branch
7
6
from bzrlib.errors import BzrCommandError
8
7
from hunk_selector import ShelveHunkSelector, UnshelveHunkSelector
9
8
from diffstat import DiffStat
10
9
from patchsource import PatchSource, FilePatchSource
12
13
class Shelf(object):
13
def __init__(self, location, name='default'):
14
self.branch = Branch.open_containing(location)[0]
15
base = self.branch.controlfilename('x-shelf')
16
self.shelf_dir = os.path.join(base, name)
14
def __init__(self, base, name='default'):
16
shelf_base = os.path.join(self.base, BASE_DIR)
17
self.shelf_dir = os.path.join(shelf_base, name)
18
# FIXME surely there's an easier way to do this?
19
t = self.branch._transport
20
for dir in [base, self.shelf_dir]:
19
for dir in [shelf_base, self.shelf_dir]:
20
if not os.path.isdir(dir):
24
23
def __path(self, idx):
25
24
return os.path.join(self.shelf_dir, '%.2d' % idx)
122
120
print >>sys.stderr, "Reverting shelved patches"
123
pipe = os.popen('patch -d %s -sR -p0' % self.branch.base, 'w')
121
pipe = os.popen('patch -d %s -sR -p0' % self.base, 'w')
124
122
for patch in to_shelve:
125
123
pipe.write(str(patch))