Commits

Andrew Petersen  committed aeb98cc

race for a cure

  • Participants
  • Parent commits 7b7fb3e

Comments (0)

Files changed (2)

 '''allows for easy(er) management of mutiple subrepositories at once'''
 
-from mercurial import hg
-from mercurial import dispatch
-from mercurial import re
+from mercurial.i18n import _
+from mercurial import hg, dispatch, re
 import shlex
 import os 
 import os.path
 
-def subrepo(ui, repo, cmd=None, **opts):
+def subrepo(ui, repo, cmd, **opts):
 	'''
 	what this does...
 	'''
 	
-	if cmd == "list":
+	if cmd == "show":
 		ui.status("listing subrepos:\n-------\n")
 		listSubrepos(ui, repo)
 		ui.status("-------\n")
-	elif cmd == "reclone":
+	
+	if cmd == "reclone":
 		ui.status("checking for missing subrepo clones...\n")
 		rs = getSubreposFromHgsub(repo)
 		for r in rs:
 			if os.path.exists(r[0]):
-				ui.status("* " + r[0] + " exists\n");
+				ui.status("* " + r[0] + " exists\n")
 			else:
-				ui.status("* " + r[0] + " is missing, recloning...\n");
-				args = shlex.split("clone "+r[1]+" "+r[0])
-				dispatch._runcatch(ui, args)
-	else:
+				recloneSubrepo(ui, r[0], r[1])
+	
+	if cmd == "pull":
+		ui.status("pulling all subrepos...\n");
+		rs = getSubreposFromHgsub(repo)
+		for r in rs:
+			if os.path.exists(r[0]):
+				ui.status(r[0]+"\n")
+			else:
+				recloneSubrepo(ui, r[0], r[1])
+	
+	if cmd is None:
 		ui.status("No command given, listing subrepos:\n-------\n")
 		listSubrepos(ui, repo)
 		ui.status("-------\n")
 def listSubrepos(ui, repo):
 	for r in getSubreposFromHgsub(repo):
 		ui.status( "* " + r[0] + "	@ " + r[1] + "\n" )
-		
+
+def recloneSubrepo(ui, local, remote):
+	ui.status("* " + local + " is missing, recloning...\n");
+	args = shlex.split("clone "+remote+" "+local)
+	dispatch._runcatch(ui, args)
+	
 # Macro extension meta-data
 cmdtable = {
 	# "command-name": (function-call, options-list, help-string)
     #"subrepo": (subrepo, [('ls', 'list', None, 'list current subrepos')], "hg subrepo [cmd]")
-	"subrepo": (subrepo, [], "hg subrepo [cmd]")
+	"subrepos": 
+		(subrepo, 
+		 [],
+		  #('l', 'show', None, _('list current subrepositories')),
+		  #('c', 'clone', None, _('reclone subrepositories if missing'))], 
+		 _('hg subrepo [ show | reclone | pull ]'))
 }

File subrepo.pyc

Binary file modified.