changeset 79:1858f812ef71

Implement a "[forest] partial" configuration option to set partial by default.
author Simon Law <simon@akoha.org>
date Fri, 30 Nov 2007 15:44:12 -0500
parents 97152eaa30fa
children 7403cc6df41c
files forest.py test-forest test-forest.out
diffstat 3 files changed, 75 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/forest.py	Thu Nov 29 20:48:02 2007 -0800
+++ b/forest.py	Fri Nov 30 15:44:12 2007 -0500
@@ -39,9 +39,14 @@
 walkhg = (0|no|false|1|yes|true)
 
   Whether repositories directly under a .hg directory should be
-  skipped (0|no|false) or not (1|yes|true). The default value is 0.
+  skipped (0|no|false) or not (1|yes|true). The default value is true.
   Some commands accept the --walkhg command-line option to override
   the behavior selected by this item.
+
+partial = (0|no|false|1|yes|true)
+
+  Whether fpull should default to partial. The default value is 0.
+
 """
 
 import ConfigParser
@@ -106,6 +111,17 @@
         raise util.Abort(_("invalid value for 'walkhg': %s" % walkhg))
     return res
 
+def partialenabled(ui, partial):
+    if partial:
+        return partial
+    else:
+        partial = ui.config('forest', 'partial', 'false')
+    try:
+        res = { '0' : False, 'false' : False, 'no' : False,
+                '1' : True, 'true' : True, 'yes' : True }[partial.lower()]
+    except KeyError:
+        raise util.Abort(_("invalid value for 'partial': %s" % partial))
+    return res
 
 def _localrepo_forests(self, walkhg):
     """Shim this function into mercurial.localrepo.localrepository so
@@ -845,7 +861,10 @@
             fetch.fetch(ui, tree.getrepo(ui), srcpath, **opts)
         except Exception, err:
             ui.warn(_("skipped: %s\n") % err)
-            tree.repo.transaction().__del__()
+            try:
+                tree.repo.transaction().__del__()
+            except AttributeError:
+                pass
 
     @Forest.Tree.skip
     def check_mq(tree):
@@ -940,6 +959,9 @@
     command.  For each tree in this file, pull the specified revision
     from the specified source path.
 
+    By default, pull new remote repositories that it discovers.  If
+    you use the -p option, pull only the repositories available locally.
+
     Look at the help text for the pull command for more information.
     """
 
@@ -978,6 +1000,7 @@
     opts['pull'] = True
     opts['uncompressed'] = None
     opts['noupdate'] = not opts['update']
+    partial = partialenabled(ui, opts['partial'])
 
     def function(tree, srcpath, opts):
         if snapfile:
@@ -996,8 +1019,8 @@
             try:
                 tree.getrepo(ui)
             except RepoError:
-                if opts['partial']:
-                    ui.status(_("repository not previously cloned, skipping\n"))
+                if partial:
+                    ui.warn(_("skipped: new remote repository\n"))
                 else:
                     # Need to clone
                     quiet = ui.quiet
@@ -1056,7 +1079,10 @@
             commands.push(ui, tree.getrepo(ui), destpath, **opts)
         except Exception, err:
             ui.warn(_("skipped: %s\n") % err)
-            tree.repo.transaction().__del__()
+            try:
+                tree.repo.transaction().__del__()
+            except AttributeError:
+                pass
 
     @Forest.Tree.skip
     def check_mq(tree):
@@ -1299,7 +1325,7 @@
         "^fpull" :
             (pull,
              [('p', 'partial', False,
-               _("do not clone source repositories not previously cloned")),
+               _("do not pull new remote repositories")),
               walkhgopts, snapfileopts] + cmd_options(ui, 'pull', remove=('f',)),
              _('hg fpull [OPTION]... [SOURCE]')),
         "^fpush" :
--- a/test-forest	Thu Nov 29 20:48:02 2007 -0800
+++ b/test-forest	Fri Nov 30 15:44:12 2007 -0500
@@ -212,4 +212,10 @@
 hg commit --cwd partial/b -A -m init -d "0 0"
 hg fclone partial partial-clone | sed "s@\(/private\)*$HGTMP@HGTMP@g"
 rm -rf partial-clone/b
-hg --cwd partial-clone fpull --partial | sed "s@\(/private\)*$HGTMP@HGTMP@g"
+hg --cwd partial-clone fpull --partial 2>&1 | sed "s@\(/private\)*$HGTMP@HGTMP@g"
+echo "[forest]" >> partial-clone/.hg/hgrc
+echo "partial = Yes" >> partial-clone/.hg/hgrc
+hg --cwd partial-clone fpull 2>&1 | sed "s@\(/private\)*$HGTMP@HGTMP@g"
+echo "[forest]" >> partial-clone/.hg/hgrc
+echo "partial = No" >> partial-clone/.hg/hgrc
+hg --cwd partial-clone fpull 2>&1 | sed "s@\(/private\)*$HGTMP@HGTMP@g"
--- a/test-forest.out	Thu Nov 29 20:48:02 2007 -0800
+++ b/test-forest.out	Fri Nov 30 15:44:12 2007 -0500
@@ -290,10 +290,7 @@
 [.]
 pulling from HGTMP/test-forest/toplevel
 searching for changes
-adding changesets
-transaction abort!
-rollback completed
-skipped: received changelog group is empty
+no changes found
 
 [d/d/t]
 pulling from HGTMP/test-forest/toplevel/d/d/t
@@ -313,18 +310,12 @@
 [t/t]
 pulling from HGTMP/test-forest/toplevel/t/t
 searching for changes
-adding changesets
-transaction abort!
-rollback completed
-skipped: received changelog group is empty
+no changes found
 
 [.]
 pulling from HGTMP/test-forest/toplevel
 searching for changes
-adding changesets
-transaction abort!
-rollback completed
-skipped: received changelog group is empty
+no changes found
 
 [d/d/t]
 pulling from HGTMP/test-forest/toplevel/d/d/t
@@ -344,10 +335,7 @@
 [t/t]
 pulling from HGTMP/test-forest/toplevel/t/t
 searching for changes
-adding changesets
-transaction abort!
-rollback completed
-skipped: received changelog group is empty
+no changes found
 
 [.]
 pulling from HGTMP/test-forest/toplevel
@@ -675,10 +663,7 @@
 [t/t]
 pulling from HGTMP/test-forest/toplevel/t/t
 searching for changes
-adding changesets
-transaction abort!
-rollback completed
-skipped: received changelog group is empty
+no changes found
 
 # fseed and fpull, named section
 [.]
@@ -729,10 +714,7 @@
 [.]
 pulling from HGTMP/test-forest/toplevel
 searching for changes
-adding changesets
-transaction abort!
-rollback completed
-skipped: received changelog group is empty
+no changes found
 
 [d/d/t]
 pulling from HGTMP/test-forest/toplevel/d/d/t
@@ -752,10 +734,7 @@
 [t/t]
 pulling from HGTMP/test-forest/toplevel/t/t
 searching for changes
-adding changesets
-transaction abort!
-rollback completed
-skipped: received changelog group is empty
+no changes found
 
 # fstatus + mq
 [.]
@@ -908,5 +887,33 @@
 no changes found
 
 [b]
-repository not previously cloned, skipping
+skipped: new remote repository
+
+[.]
+pulling from HGTMP/test-forest/partial
+no changes found
+
+[a]
+pulling from HGTMP/test-forest/partial/a
+searching for changes
+no changes found
+
+[b]
+skipped: new remote repository
 
+[.]
+pulling from HGTMP/test-forest/partial
+no changes found
+
+[a]
+pulling from HGTMP/test-forest/partial/a
+searching for changes
+no changes found
+
+[b]
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+