# HG changeset patch # User Patrick Mezard # Date 1253793007 -7200 # Node ID 4b2c5c4ffeffdc9d577adfcb8bec0e9409dd10dc # Parent 872a57531db634ca557375d6adb222e2a8e33c08# Parent 43f2315ce536e8be448120d53bf791315b990a01 Merge with main Tested against 1.3.1 diff -r 872a57531db6 -r 4b2c5c4ffeff forest.py --- 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 . + + 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" diff -r 872a57531db6 -r 4b2c5c4ffeff test-forest --- 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 diff -r 872a57531db6 -r 4b2c5c4ffeff test-forest.out --- 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 .