A patch which allows one to do a webrev against the local repository and a range of changesets analog to "hg diff -r n:m" --- ./bin/webrev.orig Sat May 19 19:32:06 2012 +++ ./bin/webrev Sun Jun 10 23:22:11 2012 @@ -14,6 +14,8 @@ # man page. # +typeset -ft $(typeset +f) + REMOVED_COLOR=brown CHANGED_COLOR=blue NEW_COLOR=blue @@ -1751,9 +1753,15 @@ { typeset child=$1 typeset parent=$2 + typeset revs=$3 + if [[ $revs != ":" ]]; then + revs="-r $revs" + else + revs="" + fi TMPFLIST=/tmp/$$.active - $HG_ACTIVE -w $child -p $parent -o $TMPFLIST + $HG_ACTIVE -w $child -p $parent -o $TMPFLIST $revs wxfile=$TMPFLIST } @@ -1766,6 +1774,7 @@ { typeset child=$1 typeset parent=$2 + typeset revs=$3 print " File list from: hg-active -p $parent ...\c" if [[ ! -x $HG_ACTIVE ]]; then @@ -1773,7 +1782,7 @@ print -u2 "Error: hg-active tool not found. Exiting" exit 1 fi - hg_active_wxfile $child $parent + hg_active_wxfile $child $parent $revs # flist_from_wx prints the Done, so we don't have to. flist_from_wx $TMPFLIST @@ -2096,6 +2105,8 @@ -U: upload the webrev to remote destination -w : Use specified wx active file. -z Compress the webrev into ZIP format. + -r : Compare locally analog to "hg diff -r N:M" + -S: use the full (absolute) workspace path name in index.html (do not strip) Environment: WDIR: Control the output directory. @@ -2193,12 +2204,15 @@ wflag= zflag= remote_target= +revisionN= +revisionM= +Sflag= # # NOTE: when adding/removing options it is necessary to sync the list # with usr/src/tools/onbld/hgext/cdm.py # -while getopts "C:Di:I:lnNo:Op:t:Uwz" opt +while getopts "C:Di:I:lnNo:Op:t:Uwzr:S" opt do case $opt in C) Cflag=1 @@ -2242,6 +2256,10 @@ z) zflag=1;; + r) revisionN="$OPTARG";; + + S) Sflag=1;; + ?) usage;; esac done @@ -2269,6 +2287,28 @@ exit 1 fi +if [[ -n $revisionN ]]; then + if [[ -n $pflag ]]; then + echo "option -p and -r are mutally exclusive. Use only one of them" + exit 1 + fi + revisionM=${revisionN#*:} + if [[ -z $revisionM ]]; then + revisionM="tip" + else + revisionN=${revisionN%:*} + if [[ -z $revisionN ]]; then + echo "invalid revision string. Use N[:M] but not :M" + exit 1 + fi + fi + if [[ ${revisionN#*:} != $revisionN || ${revisionM#:*} != $revisionM ]] + then + echo "invalid revision string. Only one ':' is allowed" + exit 1 + fi +fi + # # For the invocation "webrev -n -U" with no other options, webrev will assume # that the webrev exists in ${CWS}/webrev, but will upload it using the name @@ -2553,6 +2593,10 @@ # or taken from hg's default path. # + if [[ -z $codemgr_parent && -n $revisionN ]]; then + codemgr_parent=$CWS + fi + if [[ -z $codemgr_parent && -n $CODEMGR_PARENT ]]; then codemgr_parent=$CODEMGR_PARENT fi @@ -2560,8 +2604,12 @@ if [[ -z $codemgr_parent ]]; then codemgr_parent=`hg path -R $codemgr_ws default 2>/dev/null` fi - - CWS_REV=`hg parent -R $codemgr_ws --template '{node|short}' 2>/dev/null` + + if [[ -n $revisionN ]]; then + CWS_REV=`hg parent -R $codemgr_ws --template '{rev}:{node|short}' -r $revisionN 2>/dev/null` + else + CWS_REV=`hg parent -R $codemgr_ws --template '{rev}:{node|short}' 2>/dev/null` + fi PWS=$codemgr_parent # @@ -2573,6 +2621,10 @@ else real_parent=$PWS fi + # wanna have an int + [[ $revisionN == "tip" ]] && revisionM=${CWS_REV%%:*} + [[ $revisionM == "tip" ]] && + revisionM=`hg identify -R $codemgr_ws -n -r tip 2>/dev/null` # # If hg-active exists, then we run it. In the case of no explicit @@ -2581,7 +2633,7 @@ # files mentioned in the flist. # if [[ -z $flist_done ]]; then - flist_from_mercurial $CWS $real_parent + flist_from_mercurial $CWS $real_parent "$revisionN":"$revisionM" flist_done=1 fi @@ -2907,10 +2959,17 @@ if [[ -n $parent_webrev ]]; then print "Compare against: webrev at $parent_webrev" else - if [[ -n $HG_PARENT ]]; then + if [[ -n $revisionN ]]; then + hg_parent_short=${ hg id -R $codemgr_ws -r $revisionN; } + hg_parent_short_local=${ hg id -R $codemgr_ws -n -r $revisionN; } + hg_parent_short2=${ hg id -R $codemgr_ws -r $revisionM; } + hg_parent_short_local2=${ hg id -R $codemgr_ws -n -r $revisionM; } + print "Compare against: ${hg_parent_short_local}:$hg_parent_short .. ${hg_parent_short_local2}:$hg_parent_short2" + elif [[ -n $HG_PARENT ]]; then hg_parent_short=`echo $HG_PARENT \ | $SED -e 's/\([0-9a-f]\{12\}\).*/\1/'` - print "Compare against: $PWS (at $hg_parent_short)" + hg_parent_short_local=${ hg id -R $PWS -n -r $HG_PARENT; } + print "Compare against: $PWS (at ${short}:$hg_parent_short)" else print "Compare against: $PWS" fi @@ -3264,7 +3323,12 @@ PREPDATE=$(LC_ALL=C /usr/bin/date +%Y-%b-%d\ %R\ %z\ %Z) print "Prepared by:$preparer on $PREPDATE" -print "Workspace:$CWS" +if [[ -n $Sflag ]]; then + OCWS=$CWS +else + OCWS=${CWS##*/} +fi +print "Workspace:$OCWS" if [[ -n $CWS_REV ]]; then print "(at $CWS_REV)" fi @@ -3271,11 +3335,23 @@ print "" print "Compare against:" if [[ -n $parent_webrev ]]; then - print "webrev at $parent_webrev" + if [[ -n $Sflag ]]; then + OCWS=$parent_webrev + else + OCWS=${parent_webrev##*/} + fi + print "webrev at $OCWS" +elif [[ -n $revisionN ]]; then + print "${hg_parent_short_local}:$hg_parent_short .. ${hg_parent_short_local2}:$hg_parent_short2" else - print "$PWS" + if [[ -n $Sflag ]]; then + OCWS=$PWS + else + OCWS=${PWS##*/} + fi + print "$OCWS" if [[ -n $hg_parent_short ]]; then - print "(at $hg_parent_short)" + print "(at ${hg_parent_short_local}:$hg_parent_short)" fi fi print "" --- ./bin/hg-active.orig Sat May 19 19:32:06 2012 +++ ./bin/hg-active Sun Jun 10 21:49:14 2012 @@ -56,7 +56,7 @@ def main(argv): try: - opts = getopt.getopt(argv, 'w:o:p:')[0] + opts = getopt.getopt(argv, 'w:o:p:r:')[0] except getopt.GetoptError, e: sys.stderr.write(str(e) + '\n') usage() @@ -64,6 +64,7 @@ parentpath = None wspath = None outputfile = None + revstr = None for opt, arg in opts: if opt == '-w': @@ -72,6 +73,8 @@ outputfile = arg elif opt == '-p': parentpath = arg + elif opt == '-r': + revstr = arg if not wspath: usage() @@ -82,7 +85,7 @@ sys.stderr.write("failed to open repository: %s\n" % e) sys.exit(1) - ws = WorkSpace(repository) + ws = WorkSpace(repository, revstr) act = ws.active(parentpath) node = act.parenttip.node() --- ./lib/python2.6/onbld/Scm/WorkSpace.py.orig Sun Jun 10 22:02:16 2012 +++ ./lib/python2.6/onbld/Scm/WorkSpace.py Mon Jun 11 00:03:20 2012 @@ -461,11 +461,17 @@ class WorkSpace(object): - def __init__(self, repository): + def __init__(self, repository, revstr=None): self.repo = repository self.ui = self.repo.ui self.name = self.repo.root + if revstr: + # later revs use scmutils.revrange...: a list of all revision nums + self.myrevs = cmdutil.revrange(self.repo, [revstr]) + else: + self.myrevs = None + self.activecache = {} def parent(self, spec=None): @@ -612,6 +618,12 @@ if parent in self.activecache: return self.activecache[parent] + if self.myrevs: + outgoing = [ self.repo.changectx(n) for n in self.myrevs ] + act = ActiveList(self, outgoing[0].parents()[0], outgoing) + self.activecache[parent] = act + return act + if parent: outgoing = self.findoutgoing(parent) outnodes = self.repo.changelog.nodesbetween(outgoing)[0] @@ -809,7 +821,10 @@ return q.applied def workingctx(self): - return self.repo.changectx(None) + if self.myrevs: + return self.repo.changectx(self.myrevs[0]) + else: + return self.repo.changectx(None) def diff(self, node1=None, node2=None, match=None, opts=None): ret = cStringIO.StringIO()