Anonymous avatar Anonymous committed 1858f81

Implement a "[forest] partial" configuration option to set partial by default.

Comments (0)

Files changed (3)

 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
         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
             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):
     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.
     """
 
     opts['pull'] = True
     opts['uncompressed'] = None
     opts['noupdate'] = not opts['update']
+    partial = partialenabled(ui, opts['partial'])
 
     def function(tree, srcpath, opts):
         if snapfile:
             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
             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):
         "^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" :
 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"
 [.]
 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
 [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
 [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
 [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
 [.]
 [.]
 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
 [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
 [.]
 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
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.