[cig-commits] commit: Implement a "[forest] partial" configuration option to set partial by default.

Mercurial hg at geodynamics.org
Mon Nov 24 11:27:17 PST 2008


changeset:   79:1858f812ef71
user:        Simon Law <simon at akoha.org>
date:        Fri Nov 30 15:44:12 2007 -0500
files:       forest.py test-forest test-forest.out
description:
Implement a "[forest] partial" configuration option to set partial by default.


diff -r 97152eaa30fa -r 1858f812ef71 forest.py
--- 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)
 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 @@ def walkhgenabled(ui, walkhg):
         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 @@ def fetch(ui, top, source="default", **o
             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):
@@ -939,6 +958,9 @@ def pull(ui, top, source="default", path
     You may specify a snapshot file, which is generated by the fsnap
     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 @@ def pull(ui, top, source="default", path
     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 @@ def pull(ui, top, source="default", path
             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 @@ def push(ui, top, dest=None, pathalias=N
             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 @@ def uisetup(ui):
         "^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" :
diff -r 97152eaa30fa -r 1858f812ef71 test-forest
--- 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 
 hg commit --cwd partial/b -A -m init -d "0 0"
 hg fclone partial partial-clone | sed "s@\(/private\)*$HGTMP at HGTMP@g"
 rm -rf partial-clone/b
-hg --cwd partial-clone fpull --partial | sed "s@\(/private\)*$HGTMP at HGTMP@g"
+hg --cwd partial-clone fpull --partial 2>&1 | sed "s@\(/private\)*$HGTMP at 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 at 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 at HGTMP@g"
diff -r 97152eaa30fa -r 1858f812ef71 test-forest.out
--- 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 @@ path.default = HGTMP/test-forest/topleve
 [.]
 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 @@ no changes found
 [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 @@ no changes found
 [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 @@ no changes found
 [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 @@ t/t
 [.]
 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 @@ no changes found
 [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
 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
+



More information about the CIG-COMMITS mailing list