# HG changeset patch # User Simon Law # Date 1239260441 14400 # Node ID 351ee65e69a98c3202aaa692fbaecebb6dc250a5 # Parent 9a9e57d8bdc8d81f5d5580ccb99af5a7cbf98343 hg ftag lets you tag across the forest diff -r 9a9e57d8bdc8 -r 351ee65e69a9 forest.py --- a/forest.py Thu Apr 09 03:00:26 2009 -0400 +++ b/forest.py Thu Apr 09 03:00:41 2009 -0400 @@ -1242,6 +1242,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 . + + 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 @@ -1373,6 +1415,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, diff -r 9a9e57d8bdc8 -r 351ee65e69a9 test-forest --- a/test-forest Thu Apr 09 03:00:26 2009 -0400 +++ b/test-forest Thu Apr 09 03:00:41 2009 -0400 @@ -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 diff -r 9a9e57d8bdc8 -r 351ee65e69a9 test-forest.out --- a/test-forest.out Thu Apr 09 03:00:26 2009 -0400 +++ b/test-forest.out Thu Apr 09 03:00:41 2009 -0400 @@ -70,6 +70,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