changeset 11:388528fb31c7

fixes to make things work under older versions of hg
author Atul Varma <varmaa@toolness.com>
date Thu, 03 Jun 2010 07:16:00 +0000
parents 5e305b2569fe
children 6de4d72474b9
files bzezpatch/app.py bzezpatch/hg.py
diffstat 2 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/bzezpatch/app.py	Thu Jun 03 07:04:21 2010 +0000
+++ b/bzezpatch/app.py	Thu Jun 03 07:16:00 2010 +0000
@@ -64,7 +64,7 @@
             except Exception:
                 return error_bad_request()
 
-            tmplog = tempfile.TemporaryFile(prefix='hg-trypatch-')
+            tmplog = tempfile.TemporaryFile(prefix='hg-trypatch-log-')
             try:
                 patch = self.hg.trypatch(url, out=tmplog)
                 info = {'success': True, 'patch': patch}
--- a/bzezpatch/hg.py	Thu Jun 03 07:04:21 2010 +0000
+++ b/bzezpatch/hg.py	Thu Jun 03 07:16:00 2010 +0000
@@ -1,3 +1,4 @@
+import os
 import sys
 import subprocess
 import tempfile
@@ -8,7 +9,8 @@
         self.__dict__.update(kwargs)
 
     def trypatch(self, pull_url, out=sys.stdout):
-        temp_repo = tempfile.mkdtemp(prefix='hg-trypatch-')
+        temp_dir = tempfile.mkdtemp(prefix='hg-trypatch-')
+        temp_repo = os.path.join(temp_dir, 'repo')
         try:
             # Step 1: Pull and update local canonical repo.
             out.write('pulling and updating local canonical repo\n')
@@ -34,8 +36,11 @@
 
             # Step 4: Apply the patch by pulling from the foreign repo.
             out.write('pulling from %s\n' % pull_url)
-            subprocess.check_call([self.hg, '-R', temp_repo, 'pull', pull_url,
-                                   '-u', '--rebase'],
+            subprocess.check_call([self.hg, '-R', temp_repo, 'pull', 
+                                   '--rebase', pull_url],
+                                  stdout=out, stderr=out)
+            subprocess.check_call([self.hg, '-R', temp_repo, 'pull', 
+                                   '--update', pull_url],
                                   stdout=out, stderr=out)
 
             # Step 5: Generate a patch by diffing the tip of the