comparison hq/main.py @ 5:448c248b3738

start the path to using the __init__ function for realz
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 26 May 2010 08:18:36 -0700
parents 44ea39c3e98f
children 321721b581f1
comparison
equal deleted inserted replaced
4:44ea39c3e98f 5:448c248b3738
21 class HQ(object): 21 class HQ(object):
22 """ 22 """
23 mercurial queue extension front-end policy manager 23 mercurial queue extension front-end policy manager
24 """ 24 """
25 25
26 def __init__(self, parser, options): 26 def __init__(self, queue_host=None, network=True)
27 """initialize global options""" 27 """initialize global options"""
28 # TODO: look at hgrc file 28 # TODO: look at hgrc file
29 # for [defaults] repository_host 29 # for [defaults] repository_host
30 # XXX ???
31
32 # check for network
33 self.network = network
34
35 self.queue_host = queue_host
30 36
31 def clone(self, repo, patch=None, queue=None): 37 def clone(self, repo, patch=None, queue=None):
32 """ 38 """
33 clone the repository and begin a patch queue 39 clone the repository and begin a patch queue
34 - path: name of a new patch to initiate 40 - path: name of a new patch to initiate
56 """ 62 """
57 63
58 def commit(self, message): 64 def commit(self, message):
59 """ 65 """
60 commit a patch and push it to the master repository 66 commit a patch and push it to the master repository
67 - message : commit message
61 """ 68 """
62 call(['hg', 'qrefresh']) 69 call(['hg', 'qrefresh'])
63 call(['hg', 'qcommit', '-m', message]) 70 call(['hg', 'qcommit', '-m', message])
64 self._patch_command(*['hg', 'push']) 71 if self.network:
72 self._patch_command(*['hg', 'push'])
65 73
66 def pull(self, repo=None): 74 def pull(self, repo=None):
67 """ 75 """
68 pull from the root repository 76 pull from the root repository
69 """ 77 """
72 call(['hg', 'pull'] + repo and [repo] or []) 80 call(['hg', 'pull'] + repo and [repo] or [])
73 call(['hg', 'qpush', '--all']) 81 call(['hg', 'qpush', '--all'])
74 82
75 def goto(self, patch): 83 def goto(self, patch):
76 """ 84 """
77 goto a specific patch 85 go to a specific patch and apply it
86 - patch: name of patch to go to
78 """ 87 """
79 # TODO 88 # TODO
80 process = subprocess.Popen(['hg', 'qapplied'], stdout=subprocess.PIPE) 89 process = subprocess.Popen(['hg', 'qapplied'], stdout=subprocess.PIPE)
81 stdout, stderr = process.communicate() 90 stdout, stderr = process.communicate()
82 applied = [ i.strip() for i in stdout.splitlines() 91 applied = [ i.strip() for i in stdout.splitlines()