comparison hgext/mq.py @ 10682:8ed350051896

mq: simplify statusentry(), fix restore broken by ee48e5ef8753
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sun, 14 Mar 2010 01:35:54 +0100
parents 3f6a6407a3c7
children cfbf064f0069
comparison
equal deleted inserted replaced
10681:3f6a6407a3c7 10682:8ed350051896
52 # Patch names looks like unix-file names. 52 # Patch names looks like unix-file names.
53 # They must be joinable with queue directory and result in the patch path. 53 # They must be joinable with queue directory and result in the patch path.
54 normname = util.normpath 54 normname = util.normpath
55 55
56 class statusentry(object): 56 class statusentry(object):
57 def __init__(self, node, name=None): 57 def __init__(self, node, name):
58 if not name: 58 self.node, self.name = node, name
59 fields = node.split(':', 1)
60 if len(fields) == 2:
61 n, name = fields
62 self.node, self.name = bin(n), name
63 else:
64 self.node, self.name = None, None
65 else:
66 self.node, self.name = node, name
67 59
68 def __str__(self): 60 def __str__(self):
69 return hex(self.node) + ':' + self.name 61 return hex(self.node) + ':' + self.name
70 62
71 class patchheader(object): 63 class patchheader(object):
267 self.plainmode = ui.configbool('mq', 'plain', False) 259 self.plainmode = ui.configbool('mq', 'plain', False)
268 260
269 @util.propertycache 261 @util.propertycache
270 def applied(self): 262 def applied(self):
271 if os.path.exists(self.join(self.status_path)): 263 if os.path.exists(self.join(self.status_path)):
264 def parse(l):
265 n, name = l.split(':', 1)
266 return statusentry(bin(n), name)
272 lines = self.opener(self.status_path).read().splitlines() 267 lines = self.opener(self.status_path).read().splitlines()
273 return [statusentry(l) for l in lines] 268 return [parse(l) for l in lines]
274 return [] 269 return []
275 270
276 @util.propertycache 271 @util.propertycache
277 def full_series(self): 272 def full_series(self):
278 if os.path.exists(self.join(self.series_path)): 273 if os.path.exists(self.join(self.series_path)):
1491 l = line.rstrip() 1486 l = line.rstrip()
1492 l = l[10:].split(' ') 1487 l = l[10:].split(' ')
1493 qpp = [bin(x) for x in l] 1488 qpp = [bin(x) for x in l]
1494 elif datastart != None: 1489 elif datastart != None:
1495 l = line.rstrip() 1490 l = line.rstrip()
1496 se = statusentry(l) 1491 try:
1497 file_ = se.name 1492 n, name = l.split(':', 1)
1498 if se.node: 1493 except ValueError:
1499 applied.append(se) 1494 series.append(l)
1500 else: # XXX file_ is equal to None? 1495 else:
1501 series.append(file_) 1496 applied.append(statusentry(bin(n), name))
1502 if datastart is None: 1497 if datastart is None:
1503 self.ui.warn(_("No saved patch data found\n")) 1498 self.ui.warn(_("No saved patch data found\n"))
1504 return 1 1499 return 1
1505 self.ui.warn(_("restoring status: %s\n") % lines[0]) 1500 self.ui.warn(_("restoring status: %s\n") % lines[0])
1506 self.full_series = series 1501 self.full_series = series