Anonymous avatar Anonymous committed 351ee65

hg ftag lets you tag across the forest

Comments (0)

Files changed (3)

                  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
 
             (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,
     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
 -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
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.