changeset 3:8bc27dbf0214

add stub for goto
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 25 May 2010 13:39:19 -0700
parents dedf4c4c2ba2
children 44ea39c3e98f
files hq/main.py
diffstat 1 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hq/main.py	Tue May 25 10:52:06 2010 -0700
+++ b/hq/main.py	Tue May 25 13:39:19 2010 -0700
@@ -28,12 +28,21 @@
         # TODO: look at hgrc file
         # for [defaults] repository_host
 
-    def clone(self, repo, patch=None):
-        """clone the repository and begin a patch queue"""
+    def clone(self, repo, patch=None, queue=None):
+        """
+        clone the repository and begin a patch queue
+        - path: name of a new patch to initiate
+        - queue: name of the remote queue
+        """
         directory = repo.rsplit('/', 1)
         call(['hg', 'clone', repo, directory])
         os.chdir(directory)
         call(['hg', 'qinit', '-c'])
+        if queue:
+            _oldcwd = os.getcwd()
+            os.chdir(os.path.join('.hg', 'patches'))
+            call(['hg', 'pull', '--update', queue])
+            os.chdir(_oldcwd)
         if patch:
             call(['hg', 'qnew', patch])
 
@@ -62,6 +71,17 @@
         call(['hg', 'pull'] + repo and [repo] or [])
         call(['hg', 'qpush', '--all'])
 
+    def goto(self, patch):
+        """
+        goto a specific patch
+        """
+        # TODO
+        process = subprocess.Popen(['hg', 'qapplied'], stdout=subprocess.PIPE)
+        stdout, stderr = process.communicate()
+        applied = [ i.strip() for i in stdout.splitlines()
+                    if i ]
+        raise NotImplementedError
+
     def files(self):
         """
         list the files added by the top patch