comparison hgext/mq.py @ 2807:bdc067ff6cf5

Make mq camelcase consistent with the rest of hg.
author Brendan Cully <brendan@kublai.com>
date Mon, 07 Aug 2006 14:59:32 -0700
parents 52516e48e3f3
children 766ecdc83e43
comparison
equal deleted inserted replaced
2806:ff3edd1c1e27 2807:bdc067ff6cf5
37 37
38 versionstr = "0.45" 38 versionstr = "0.45"
39 39
40 commands.norepo += " qclone qversion" 40 commands.norepo += " qclone qversion"
41 41
42 class StatusEntry: 42 class statusentry:
43 def __init__(self, rev, name=None): 43 def __init__(self, rev, name=None):
44 if not name: 44 if not name:
45 fields = rev.split(':') 45 fields = rev.split(':')
46 if len(fields) == 2: 46 if len(fields) == 2:
47 self.rev, self.name = fields 47 self.rev, self.name = fields
72 if os.path.exists(os.path.join(self.path, self.series_path)): 72 if os.path.exists(os.path.join(self.path, self.series_path)):
73 self.full_series = self.opener(self.series_path).read().splitlines() 73 self.full_series = self.opener(self.series_path).read().splitlines()
74 self.parse_series() 74 self.parse_series()
75 75
76 if os.path.exists(os.path.join(self.path, self.status_path)): 76 if os.path.exists(os.path.join(self.path, self.status_path)):
77 self.applied = [StatusEntry(l) 77 self.applied = [statusentry(l)
78 for l in self.opener(self.status_path).read().splitlines()] 78 for l in self.opener(self.status_path).read().splitlines()]
79 79
80 def find_series(self, patch): 80 def find_series(self, patch):
81 pre = re.compile("(\s*)([^#]+)") 81 pre = re.compile("(\s*)([^#]+)")
82 index = 0 82 index = 0
245 # the first patch in the queue is never a merge patch 245 # the first patch in the queue is never a merge patch
246 # 246 #
247 pname = ".hg.patches.merge.marker" 247 pname = ".hg.patches.merge.marker"
248 n = repo.commit(None, '[mq]: merge marker', user=None, force=1, 248 n = repo.commit(None, '[mq]: merge marker', user=None, force=1,
249 wlock=wlock) 249 wlock=wlock)
250 self.applied.append(StatusEntry(revlog.hex(n), pname)) 250 self.applied.append(statusentry(revlog.hex(n), pname))
251 self.applied_dirty = 1 251 self.applied_dirty = 1
252 252
253 head = self.qparents(repo) 253 head = self.qparents(repo)
254 254
255 for patch in series: 255 for patch in series:
263 self.ui.warn("patch %s is not applied\n" % patch) 263 self.ui.warn("patch %s is not applied\n" % patch)
264 return (1, None) 264 return (1, None)
265 rev = revlog.bin(info[1]) 265 rev = revlog.bin(info[1])
266 (err, head) = self.mergeone(repo, mergeq, head, patch, rev, wlock) 266 (err, head) = self.mergeone(repo, mergeq, head, patch, rev, wlock)
267 if head: 267 if head:
268 self.applied.append(StatusEntry(revlog.hex(head), patch)) 268 self.applied.append(statusentry(revlog.hex(head), patch))
269 self.applied_dirty = 1 269 self.applied_dirty = 1
270 if err: 270 if err:
271 return (err, head) 271 return (err, head)
272 return (0, head) 272 return (0, head)
273 273
358 358
359 if n == None: 359 if n == None:
360 raise util.Abort(_("repo commit failed")) 360 raise util.Abort(_("repo commit failed"))
361 361
362 if update_status: 362 if update_status:
363 self.applied.append(StatusEntry(revlog.hex(n), patch)) 363 self.applied.append(statusentry(revlog.hex(n), patch))
364 364
365 if patcherr: 365 if patcherr:
366 if not patchfound: 366 if not patchfound:
367 self.ui.warn("patch %s is empty\n" % patch) 367 self.ui.warn("patch %s is empty\n" % patch)
368 err = 0 368 err = 0
427 n = repo.commit(commitfiles, 427 n = repo.commit(commitfiles,
428 "New patch: %s" % patch, force=True, wlock=wlock) 428 "New patch: %s" % patch, force=True, wlock=wlock)
429 if n == None: 429 if n == None:
430 raise util.Abort(_("repo commit failed")) 430 raise util.Abort(_("repo commit failed"))
431 self.full_series[insert:insert] = [patch] 431 self.full_series[insert:insert] = [patch]
432 self.applied.append(StatusEntry(revlog.hex(n), patch)) 432 self.applied.append(statusentry(revlog.hex(n), patch))
433 self.parse_series() 433 self.parse_series()
434 self.series_dirty = 1 434 self.series_dirty = 1
435 self.applied_dirty = 1 435 self.applied_dirty = 1
436 p = self.opener(patch, "w") 436 p = self.opener(patch, "w")
437 if msg: 437 if msg:
902 else: 902 else:
903 message = msg 903 message = msg
904 904
905 self.strip(repo, top, update=False, backup='strip', wlock=wlock) 905 self.strip(repo, top, update=False, backup='strip', wlock=wlock)
906 n = repo.commit(filelist, message, changes[1], force=1, wlock=wlock) 906 n = repo.commit(filelist, message, changes[1], force=1, wlock=wlock)
907 self.applied[-1] = StatusEntry(revlog.hex(n), patch) 907 self.applied[-1] = statusentry(revlog.hex(n), patch)
908 self.applied_dirty = 1 908 self.applied_dirty = 1
909 else: 909 else:
910 commands.dodiff(patchf, self.ui, repo, patchparent, None) 910 commands.dodiff(patchf, self.ui, repo, patchparent, None)
911 patchf.close() 911 patchf.close()
912 self.pop(repo, force=True, wlock=wlock) 912 self.pop(repo, force=True, wlock=wlock)
985 l = lines[i].rstrip() 985 l = lines[i].rstrip()
986 l = l[10:].split(' ') 986 l = l[10:].split(' ')
987 qpp = [ hg.bin(x) for x in l ] 987 qpp = [ hg.bin(x) for x in l ]
988 elif datastart != None: 988 elif datastart != None:
989 l = lines[i].rstrip() 989 l = lines[i].rstrip()
990 se = StatusEntry(l) 990 se = statusentry(l)
991 file_ = se.name 991 file_ = se.name
992 if se.rev: 992 if se.rev:
993 applied.append(se) 993 applied.append(se)
994 series.append(file_) 994 series.append(file_)
995 if datastart == None: 995 if datastart == None:
1046 "\n".join(ar) + '\n' or "") 1046 "\n".join(ar) + '\n' or "")
1047 n = repo.commit(None, text, user=None, force=1) 1047 n = repo.commit(None, text, user=None, force=1)
1048 if not n: 1048 if not n:
1049 self.ui.warn("repo commit failed\n") 1049 self.ui.warn("repo commit failed\n")
1050 return 1 1050 return 1
1051 self.applied.append(StatusEntry(revlog.hex(n),'.hg.patches.save.line')) 1051 self.applied.append(statusentry(revlog.hex(n),'.hg.patches.save.line'))
1052 self.applied_dirty = 1 1052 self.applied_dirty = 1
1053 1053
1054 def full_series_end(self): 1054 def full_series_end(self):
1055 if len(self.applied) > 0: 1055 if len(self.applied) > 0:
1056 p = self.applied[-1].name 1056 p = self.applied[-1].name
1480 q.parse_series() 1480 q.parse_series()
1481 q.series_dirty = 1 1481 q.series_dirty = 1
1482 1482
1483 info = q.isapplied(patch) 1483 info = q.isapplied(patch)
1484 if info: 1484 if info:
1485 q.applied[info[0]] = StatusEntry(info[1], name) 1485 q.applied[info[0]] = statusentry(info[1], name)
1486 q.applied_dirty = 1 1486 q.applied_dirty = 1
1487 1487
1488 util.rename(os.path.join(q.path, patch), absdest) 1488 util.rename(os.path.join(q.path, patch), absdest)
1489 r = q.qrepo() 1489 r = q.qrepo()
1490 if r: 1490 if r:
1550 """print the version number of the mq extension""" 1550 """print the version number of the mq extension"""
1551 ui.write("mq version %s\n" % versionstr) 1551 ui.write("mq version %s\n" % versionstr)
1552 return 0 1552 return 0
1553 1553
1554 def reposetup(ui, repo): 1554 def reposetup(ui, repo):
1555 class MqRepo(repo.__class__): 1555 class mqrepo(repo.__class__):
1556 def tags(self): 1556 def tags(self):
1557 if self.tagscache: 1557 if self.tagscache:
1558 return self.tagscache 1558 return self.tagscache
1559 1559
1560 tagscache = super(MqRepo, self).tags() 1560 tagscache = super(mqrepo, self).tags()
1561 1561
1562 q = self.mq 1562 q = self.mq
1563 if not q.applied: 1563 if not q.applied:
1564 return tagscache 1564 return tagscache
1565 1565
1572 else: 1572 else:
1573 tagscache[patch[1]] = revlog.bin(patch[0]) 1573 tagscache[patch[1]] = revlog.bin(patch[0])
1574 1574
1575 return tagscache 1575 return tagscache
1576 1576
1577 repo.__class__ = MqRepo 1577 repo.__class__ = mqrepo
1578 repo.mq = queue(ui, repo.join("")) 1578 repo.mq = queue(ui, repo.join(""))
1579 1579
1580 cmdtable = { 1580 cmdtable = {
1581 "qapplied": (applied, [], 'hg qapplied [PATCH]'), 1581 "qapplied": (applied, [], 'hg qapplied [PATCH]'),
1582 "qclone": (clone, 1582 "qclone": (clone,