changeset 97:4b2c5c4ffeff

Merge with main Tested against 1.3.1
author Patrick Mezard <pmezard@gmail.com>
date Thu, 24 Sep 2009 13:50:07 +0200
parents 872a57531db6 (current diff) 43f2315ce536 (diff)
children f5441510cbb0
files forest.py
diffstat 3 files changed, 109 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/forest.py	Tue Feb 03 22:05:11 2009 +0100
+++ b/forest.py	Thu Sep 24 13:50:07 2009 +0200
@@ -79,7 +79,7 @@
     findcmd.__doc__ = commands.findcmd.__doc__
 for m in (error, cmdutil, commands):
     if hasattr(m, "UnknownCommand"):
-        findcmd.UnknownCommand = m.UnknownCommand
+        UnknownCommand = m.UnknownCommand
         break
 try:
     # Assign the exceptions explicitely to avoid demandload issues
@@ -377,6 +377,8 @@
     """
     if revs is None:
         return
+    if not hasattr(revs, '__iter__'):
+        revs = [revs]
     for strrev in revs:
         try:
             intrev = int(strrev)
@@ -1244,6 +1246,48 @@
                  prehooks=[lambda tree: check_mq(tree)])
 
 
+def tag(ui, top, name, revision=None, **opts):
+    """add a tag for the current or given revision in the working forest
+
+    Name a particular revision using <name>.
+
+    Tags are used to name particular revisions of the repository and are
+    very useful to compare different revision, to go back to significant
+    earlier versions or to mark branch points as releases, etc.
+
+    If no revision is given, the parent of the working directory is used,
+    or tip if no revision is checked out.
+
+    To facilitate version control, distribution, and merging of tags,
+    they are stored as a file named ".hgtags" which is managed
+    similarly to other project files and can be hand-edited if
+    necessary.  The file '.hg/localtags' is used for local tags (not
+    shared among repositories).
+    """
+    if revision is not None:
+        ui.warn(_("use of 'hg ftag NAME [REV]' is deprecated, "
+                  "please use 'hg ftag [-r REV] NAME' instead\n"))
+        if opts['rev']:
+            raise util.Abort(_("use only one form to specify the revision"))
+        opts['rev'] = revision
+    forest = Forest(top=top, snapfile=None,
+                    walkhg=walkhgenabled(ui, opts['walkhg']))
+
+    def function(tree, ignore, opts):
+        try:
+            commands.tag(ui, tree.getrepo(ui), name, rev_=None, **opts)
+        except Exception, err:
+            ui.warn(_("skipped: %s\n") % err)
+            tree.repo.transaction().__del__()
+
+    @Forest.Tree.skip
+    def check_mq(tree):
+        tree.die_on_mq(top.root)
+
+    forest.apply(ui, function, None, opts,
+                 prehooks=[lambda tree: check_mq(tree)])
+
+
 def trees(ui, top, **opts):
     """show the roots of the repositories
 
@@ -1288,9 +1332,9 @@
                 ui.warn(_("warning: %s\n") % err)
             else:
                 raise err
-            snapfile = opts['snapfile']
-            opts['rev'] = revision
-    tip = opts['tip']
+    if snapfile is None:
+        snapfile = opts['snapfile']
+        opts['rev'] = revision
     forest = Forest(top=top, snapfile=snapfile,
                     walkhg=walkhgenabled(ui, opts['walkhg']))
 
@@ -1299,10 +1343,8 @@
             rev = opts['rev'] or None
         else:
             rev = None
-        if type(rev) is str:
-            rev = rev
-        elif rev:
-            rev = rev[0]
+        if hasattr(rev, '__iter__'):
+            rev = rev[-1]
         try:
             if rev is not None:
                 commands.update(ui, tree.getrepo(ui),
@@ -1377,6 +1419,10 @@
             (status,
              [walkhgopts] + cmd_options(ui, 'status'),
              _('hg fstatus [OPTION]... [FILE]...')),
+        "ftag":
+            (tag,
+             [walkhgopts] + cmd_options(ui, 'tag'),
+             _('hg ftag [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME')),
         "ftrees" :
             (trees,
              [('c', 'convert', False,
@@ -1404,7 +1450,7 @@
                                                   remove=('bundle',),
                                                   table=hgext.fetch.cmdtable),
                                     _('hg ffetch [OPTION]... [SOURCE]'))})
-    except findcmd.UnknownCommand:
+    except UnknownCommand:
         return
 
 commands.norepo += " fclone fseed"
--- a/test-forest	Tue Feb 03 22:05:11 2009 +0100
+++ b/test-forest	Thu Sep 24 13:50:07 2009 +0200
@@ -61,6 +61,17 @@
     sed -e 's/--- top-snap1.*$/--- top-snap1/' \
         -e 's/+++ top-snap2.*$/+++ top-snap2/'
 
+echo "# ftag"
+hg fclone toplevel newtop > /dev/null
+hg ftag -R newtop fred
+hg ftag -R newtop barney
+hg ftag -R newtop -r fred wilma
+hg tags --cwd newtop | sed -e 's/:.*//'
+echo
+hg tags --cwd newtop/d/d/t | sed -e 's/:.*//'
+echo
+rm -rf newtop
+
 echo "# fupdate"
 hg fclone toplevel newtop > /dev/null
 hg fupdate -R newtop top-snap
@@ -86,7 +97,7 @@
 
 echo "# fseed"
 hg clone toplevel newtop
-hg fseed -R newtop top-snap default
+hg fseed top-snap default
 rm -rf newtop
 hg fseed --traceback --root newtop top-snap default >/dev/null
 hg fsnap --cwd newtop --compatible | fixpath
--- a/test-forest.out	Tue Feb 03 22:05:11 2009 +0100
+++ b/test-forest.out	Thu Sep 24 13:50:07 2009 +0200
@@ -75,6 +75,47 @@
 -revision = 5d60830890a20c050332e222b8307bbb70940a3f
 +revision = e7ef7301b2ddca4eca0c4e80fe0cc8c943d05645
  
+# ftag
+[.]
+
+[d/d/t]
+
+[e/d]
+
+[t]
+
+[t/t]
+
+[.]
+
+[d/d/t]
+
+[e/d]
+
+[t]
+
+[t/t]
+
+[.]
+
+[d/d/t]
+
+[e/d]
+
+[t]
+
+[t/t]
+
+tip                                4
+barney                             2
+wilma                              1
+fred                               1
+
+tip                                3
+barney                             1
+wilma                              0
+fred                               0
+
 # fupdate
 [.]
 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
@@ -864,7 +905,7 @@
 skipped: 't/t' has mq patches applied
 
 [t/t/.hg/patches]
-skipped: branch default not found
+0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 # walk **/.hg
 .