changeset 66:e19e732274b7

`hg fsnap` now uses the Forest framework
author Simon Law <simon@akoha.org>
date Mon, 27 Aug 2007 13:45:44 -0400
parents 0c80cfba6b38
children f0d10035b058
files forest.py test-forest test-forest.out
diffstat 3 files changed, 57 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/forest.py	Mon Aug 27 13:45:18 2007 -0400
+++ b/forest.py	Mon Aug 27 13:45:44 2007 -0400
@@ -1012,12 +1012,29 @@
         ui.status("\n")
 
 
-def snapshot(ui, repo, snapfile=None, tip=False, walkhg='', **opts):
-    """Generate a new or updated forest snapshot and display it."""
+def snap(ui, top, snapshot=None, **opts):
+    """take a snapshot of the forest and show it
+
+    Shows the current state of the forest.
+
+    You can use the output of this command as with the --snapfile
+    option of other forest commands.
+
+    When you provide a snapshot file, only the trees mentioned in that
+    file will be shown.
+    """
 
-    snapshot = ForestSnapshot(snapfile)
-    snapshot.update(ui, repo, True, walkhgenabled(ui, walkhg), tip)
-    snapshot.write(ui)
+    snapfile = snapshot or opts['snapfile']
+    tip = opts['tip']
+    forest = Forest(top=top, snapfile=snapfile,
+                    walkhg=walkhgenabled(ui, opts['walkhg']))
+    if snapfile:
+        forest.update(ui)
+    for tree in forest.trees:
+        tree.die_on_mq(top.root)
+        if not tip:
+            tree.revs = tree.working_revs()
+    forest.write(ui, opts['compatible'])
 
 
 def status(ui, repo, walkhg='', *pats, **opts):
@@ -1103,11 +1120,14 @@
              + cmd_options(ui, 'clone', remove=('r',)),
              _('hg fseed [OPTION]... SNAPSHOT-FILE [PATH-ALIAS]')),
         "fsnap" :
-            (snapshot,
-             [('t', 'tip', False,
+            (snap,
+             [('', 'compatible', False,
+               _("write snapshot file compatible with older forest versions")),
+              snapfileopts,
+              ('t', 'tip', False,
                _("record tip instead of actual child revisions")),
               walkhgopts],
-             _('hg fsnap [OPTIONS] [SNAPSHOT-FILE]')),
+             _('hg fsnap [OPTION]... [SNAPSHOT-FILE]')),
         "fstatus" :
             (status,
              [walkhgopts] + cmd_options(ui, 'status'),
--- a/test-forest	Mon Aug 27 13:45:18 2007 -0400
+++ b/test-forest	Mon Aug 27 13:45:44 2007 -0400
@@ -71,6 +71,7 @@
 hg fseed -R newtop top-snap default
 rm -rf newtop
 hg fseed --traceback --root newtop top-snap default >/dev/null
+hg fsnap --cwd newtop --compatible | sed "s@\(/private\)*$HGTMP@HGTMP@g"
 hg fsnap --cwd newtop | sed "s@\(/private\)*$HGTMP@HGTMP@g"
 rm -rf newtop
 
--- a/test-forest.out	Mon Aug 27 13:45:18 2007 -0400
+++ b/test-forest.out	Mon Aug 27 13:45:44 2007 -0400
@@ -61,17 +61,15 @@
 -revision = fccf42f55033a9715e9e990fcc1749e3d0d19d39
 +revision = bc7d06dbb331e93b327d848dc724e61cd2dc2d66
  
- [tree1.paths]
- 
-@@ -24,7 +24,7 @@
+ [tree2]
+ root = d/d/t
+@@ -16,5 +16,5 @@
  
  [tree5]
  root = t/t
 -revision = 5d60830890a20c050332e222b8307bbb70940a3f
 +revision = e7ef7301b2ddca4eca0c4e80fe0cc8c943d05645
  
- [tree5.paths]
- 
 # fupdate
 changeset:   0:11d08ba64b67
 tag:         tip
@@ -165,6 +163,31 @@
 [tree5.paths]
 default = HGTMP/test-forest/toplevel/t/t
 
+[tree1]
+root = .
+revision = fccf42f55033a9715e9e990fcc1749e3d0d19d39
+path.default = HGTMP/test-forest/toplevel
+
+[tree2]
+root = d/d/t
+revision = 11d08ba64b676ed2f87a16089f3a0e5060c7bc36
+path.default = HGTMP/test-forest/toplevel/d/d/t
+
+[tree3]
+root = e/d
+revision = 87ae3032128b3306de675b7b390bc7b594ed74eb
+path.default = HGTMP/test-forest/toplevel/e/d
+
+[tree4]
+root = t
+revision = 37c7c7838b045dddb0718588a6318f002f0bed0a
+path.default = HGTMP/test-forest/toplevel/t
+
+[tree5]
+root = t/t
+revision = 5d60830890a20c050332e222b8307bbb70940a3f
+path.default = HGTMP/test-forest/toplevel/t/t
+
 # fpull
 [.]
 pulling from HGTMP/test-forest/toplevel