chiark / gitweb /
Fixes to gotorevision(None)
authorDaniel Martí <mvdan@mvdan.cc>
Sun, 15 Sep 2013 21:20:27 +0000 (23:20 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Sun, 15 Sep 2013 21:20:42 +0000 (23:20 +0200)
Up until now, this would do nothing in most cases

fdroidserver/checkupdates.py
fdroidserver/common.py

index 9c39a2b38fff70c1480da82983c05c9cdf50f8bf..99df041710c141ef78775b65cb3774d00fff6bf1 100644 (file)
@@ -121,22 +121,14 @@ def check_repomanifest(app, sdk_path, branch=None):
 
         if vcs.repotype() == 'git':
             if branch:
-                vcs.gotorevision('origin/'+branch)
-            else:
-                vcs.gotorevision('origin/master')
-                pass
+                branch = 'origin/'+branch
+            vcs.gotorevision(branch)
         elif vcs.repotype() == 'git-svn':
-            if branch:
-                vcs.gotorevision(branch)
-            else:
-                vcs.gotorevision(None)
+            vcs.gotorevision(branch)
         elif vcs.repotype() == 'svn':
             vcs.gotorevision(None)
         elif vcs.repotype() == 'hg':
-            if branch:
-                vcs.gotorevision(branch)
-            else:
-                vcs.gotorevision('default')
+            vcs.gotorevision(branch)
         elif vcs.repotype() == 'bzr':
             vcs.gotorevision(None)
 
index e16d007d018792a8f66a77017929631b87214f1c..8679c0b5e6b4319281db985e0619a905ccbcbb80 100644 (file)
@@ -169,9 +169,9 @@ class vcs_git(vcs):
                     raise VCSException("Git fetch failed")
                 self.refreshed = True
         # Check out the appropriate revision...
-        if rev:
-            if subprocess.call(['git', 'checkout', rev], cwd=self.local) != 0:
-                raise VCSException("Git checkout failed")
+        rev = str(rev if rev else 'origin/master')
+        if subprocess.call(['git', 'checkout', rev], cwd=self.local) != 0:
+            raise VCSException("Git checkout failed")
         # Get rid of any uncontrolled files left behind...
         if subprocess.call(['git', 'clean', '-dffx'], cwd=self.local) != 0:
             raise VCSException("Git clean failed")
@@ -242,6 +242,8 @@ class vcs_gitsvn(vcs):
                         cwd=self.local) != 0:
                     raise VCSException("Git svn rebase failed")
                 self.refreshed = True
+
+        rev = str(rev if rev else 'master')
         if rev:
             nospaces_rev = rev.replace(' ', '%20')
             # Try finding a svn tag
@@ -311,11 +313,11 @@ class vcs_svn(vcs):
                         self.userargs(), cwd=self.local) != 0:
                     raise VCSException("Svn update failed")
                 self.refreshed = True
-        if rev:
-            revargs = ['-r', rev]
-            if subprocess.call(['svn', 'update', '--force'] + revargs +
-                    self.userargs(), cwd=self.local) != 0:
-                raise VCSException("Svn update failed")
+
+        revargs = list(['-r', rev] if rev else [])
+        if subprocess.call(['svn', 'update', '--force'] + revargs +
+                self.userargs(), cwd=self.local) != 0:
+            raise VCSException("Svn update failed")
 
 
 class vcs_hg(vcs):
@@ -336,6 +338,8 @@ class vcs_hg(vcs):
                         cwd=self.local) != 0:
                     raise VCSException("Hg pull failed")
                 self.refreshed = True
+
+        rev = str(rev if rev else 'default')
         if rev:
             revargs = [rev]
             if subprocess.call(['hg', 'checkout', '-C'] + revargs,
@@ -366,11 +370,11 @@ class vcs_bzr(vcs):
                         cwd=self.local) != 0:
                     raise VCSException("Bzr update failed")
                 self.refreshed = True
-        if rev:
-            revargs = ['-r', rev]
-            if subprocess.call(['bzr', 'revert'] + revargs,
-                    cwd=self.local) != 0:
-                raise VCSException("Bzr revert failed")
+
+        revargs = list(['-r', rev] if rev else [])
+        if subprocess.call(['bzr', 'revert'] + revargs,
+                cwd=self.local) != 0:
+            raise VCSException("Bzr revert failed")
 
     def __init__(self, remote, local, sdk_path):