changeset 27:7af6be6683da

Streamline fsnap/fseed support for keeping children at tip. Added -t/--tip option to fsnap to record tip instead of each actual current child revision found. Also -t alias for --tip in fseed. (translation of 2d991bfffb86 for forest-mercurial-0.9.1-branch)
author Mark White <mark@celos.net>
date Tue, 07 Nov 2006 12:37:54 +0000
parents 363fd78db7ce
children 5bd28695a35b
files forest.py
diffstat 1 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/forest.py	Mon Nov 06 16:52:33 2006 +0100
+++ b/forest.py	Tue Nov 07 12:37:54 2006 +0000
@@ -165,7 +165,7 @@
             ui.write("\n")
 
 
-    def update(self, ui, repo):
+    def update(self, ui, repo, tip):
         """Update a snapshot by scanning a forest.
 
         If the ForestSnapshot instance to update was initialized from
@@ -182,7 +182,10 @@
                 raise util.Abort(_("'%s' has mq patches applied") % root)
             if root != '.':
                 repo = repository(ui, root)
-            rev = node.hex(repo.dirstate.parents()[0])
+            if tip:
+                rev = 'tip'
+            else:
+                rev = node.hex(repo.dirstate.parents()[0])
             paths = dict(repo.ui.configitems('paths'))
             if self.rootmap.has_key(root):
                 tree = self.rootmap[root]
@@ -306,18 +309,18 @@
         commands.clone(ui, source, dest, **opts)
         if not opts['tip']:
             rev = cfg.get(section, 'revision')
-            if rev and rev != node.nullid:
+            if rev and rev != 'tip' and rev != node.nullid:
                 repo = repository(ui, dest)
                 commands.update(repo.ui, repo, node=rev)
         ui.write("\n")
 
 
 
-def snapshot(ui, repo, snapfile=None):
+def snapshot(ui, repo, snapfile=None, **opts):
     """Generate a new or updated forest snapshot and display it."""
 
     snapshot = ForestSnapshot(snapfile)
-    snapshot.update(ui, repo)
+    snapshot.update(ui, repo, opts['tip'])
     snapshot.write(ui)
 
 
@@ -356,14 +359,16 @@
          _('hg fpush [OPTIONS] SNAPSHOT-FILE PATH-ALIAS')),
     "fseed" :
         (seed,
-         [('', 'tip', None,
+         [('t', 'tip', None,
            _("use tip instead of revisions stored in the snapshot file")),
           ('', 'root', '',
-           _("Create root as well as children under <root>"))] +
+           _("create root as well as children under <root>"))] +
          cmd_options('clone', remove=('r',)),
          _('hg fseed [OPTIONS] SNAPSHOT-FILE [PATH-ALIAS]')),
     "fsnap" :
-        (snapshot, [],
+        (snapshot,
+         [('t', 'tip', None,
+           _("record tip instead of actual child revisions"))],
          'hg fsnap [SNAPSHOT-FILE]'),
     "fstatus" :
         (status,