# HG changeset patch # User Patrick Mezard # Date 1182457181 -7200 # Node ID d8442fc0da8dd45becf49a1915f014c4e6df2881 # Parent 150afe6becf62f04e28f1ccbf92f971ccb3f2924# Parent 272c0a09b2032046de3671eada475e1eace2b772 Merge with crew diff -r 272c0a09b203 -r d8442fc0da8d doc/hgrc.5.txt diff -r 272c0a09b203 -r d8442fc0da8d mercurial/cmdutil.py --- a/mercurial/cmdutil.py Thu Jun 21 21:58:18 2007 +0200 +++ b/mercurial/cmdutil.py Thu Jun 21 22:19:41 2007 +0200 @@ -262,11 +262,9 @@ os.chdir(cwd) # read the local repository .hgrc into a local ui object - # this will trigger its extensions to load - path = earlygetopt(["-R", "--repository", "--repo"], args) + path = findrepo() or "" if not path: - path = findrepo() or "" - lui = ui + lui = ui if path: try: lui = commands.ui.ui(parentui=ui) @@ -274,6 +272,13 @@ except IOError: pass + # now we can expand paths, even ones in .hg/hgrc + rpath = earlygetopt(["-R", "--repository", "--repo"], args) + if rpath: + path = lui.expandpath(rpath) + lui = commands.ui.ui(parentui=ui) + lui.readconfig(os.path.join(path, ".hg", "hgrc")) + extensions.loadall(lui) # check for fallback encoding fallback = lui.config('ui', 'fallbackencoding') diff -r 272c0a09b203 -r d8442fc0da8d mercurial/commands.py --- a/mercurial/commands.py Thu Jun 21 21:58:18 2007 +0200 +++ b/mercurial/commands.py Thu Jun 21 22:19:41 2007 +0200 @@ -1432,38 +1432,69 @@ else: ui.write("%s\n" % first) -def identify(ui, repo): - """print information about the working copy - - Print a short summary of the current state of the repo. +def identify(ui, repo, source=None, + rev=None, num=None, id=None, branch=None, tags=None): + """identify the working copy or specified revision + + With no revision, print a summary of the current state of the repo. + + With a path, do a lookup in another repository. This summary identifies the repository state using one or two parent hash identifiers, followed by a "+" if there are uncommitted changes - in the working directory, followed by a list of tags for this revision. + in the working directory, a list of tags for this revision and a branch + name for non-default branches. """ - parents = [p for p in repo.dirstate.parents() if p != nullid] - if not parents: - ui.write(_("unknown\n")) - return hexfunc = ui.debugflag and hex or short - modified, added, removed, deleted = repo.status()[:4] - output = ["%s%s" % - ('+'.join([hexfunc(parent) for parent in parents]), - (modified or added or removed or deleted) and "+" or "")] - - if not ui.quiet: - - branch = util.tolocal(repo.workingctx().branch()) - if branch != 'default': - output.append("(%s)" % branch) + default = not (num or id or branch or tags) + output = [] + + if source: + source, revs = cmdutil.parseurl(ui.expandpath(source), []) + srepo = hg.repository(ui, source) + if not rev and revs: + rev = revs[0] + if not rev: + rev = "tip" + if num or branch or tags: + raise util.Abort( + "can't query remote revision number, branch, or tags") + output = [hexfunc(srepo.lookup(rev))] + elif not rev: + ctx = repo.workingctx() + parents = ctx.parents() + changed = False + if default or id or num: + changed = ctx.files() + ctx.deleted() + if default or id: + output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]), + (changed) and "+" or "")] + if num: + output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]), + (changed) and "+" or "")) + else: + ctx = repo.changectx(rev) + if default or id: + output = [hexfunc(ctx.node())] + if num: + output.append(str(ctx.rev())) + + if not source and default and not ui.quiet: + b = util.tolocal(ctx.branch()) + if b != 'default': + output.append("(%s)" % b) # multiple tags for a single parent separated by '/' - parenttags = ['/'.join(tags) - for tags in map(repo.nodetags, parents) if tags] - # tags for multiple parents separated by ' + ' - if parenttags: - output.append(' + '.join(parenttags)) + t = "/".join(ctx.tags()) + if t: + output.append(t) + + if branch: + output.append(util.tolocal(ctx.branch())) + + if tags: + output.extend(ctx.tags()) ui.write("%s\n" % ' '.join(output)) @@ -2826,7 +2857,14 @@ ('', 'template', '', _('display with template'))], _('hg heads [-r REV] [REV]...')), "help": (help_, [], _('hg help [COMMAND]')), - "identify|id": (identify, [], _('hg identify')), + "identify|id": + (identify, + [('r', 'rev', '', _('identify the specified rev')), + ('n', 'num', None, _('show local revision number')), + ('i', 'id', None, _('show global revision id')), + ('b', 'branch', None, _('show branch')), + ('t', 'tags', None, _('show tags'))], + _('hg identify [-nibt] [-r REV] [SOURCE]')), "import|patch": (import_, [('p', 'strip', 1, diff -r 272c0a09b203 -r d8442fc0da8d mercurial/context.py --- a/mercurial/context.py Thu Jun 21 21:58:18 2007 +0200 +++ b/mercurial/context.py Thu Jun 21 22:19:41 2007 +0200 @@ -67,6 +67,7 @@ def files(self): return self._changeset[3] def description(self): return self._changeset[4] def branch(self): return self._changeset[5].get("branch") + def tags(self): return self._repo.nodetags(self._node) def parents(self): """return contexts for each parent changeset""" @@ -413,6 +414,11 @@ def clean(self): return self._status[5] def branch(self): return self._repo.dirstate.branch() + def tags(self): + t = [] + [t.extend(p.tags()) for p in self.parents()] + return t + def parents(self): """return contexts for each parent changeset""" return self._parents diff -r 272c0a09b203 -r d8442fc0da8d mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py Thu Jun 21 21:58:18 2007 +0200 +++ b/mercurial/hgweb/hgweb_mod.py Thu Jun 21 22:19:41 2007 +0200 @@ -619,11 +619,11 @@ 'zip': ('application/zip', 'zip', '.zip', None), } - def archive(self, req, id, type_): + def archive(self, req, key, type_): reponame = re.sub(r"\W+", "-", os.path.basename(self.reponame)) - cnode = self.repo.lookup(id) - arch_version = id - if cnode == id or id == 'tip': + cnode = self.repo.lookup(key) + arch_version = key + if cnode == key or key == 'tip': arch_version = short(cnode) name = "%s-%s" % (reponame, arch_version) mimetype, artype, extension, encoding = self.archive_specs[type_] diff -r 272c0a09b203 -r d8442fc0da8d mercurial/util.py --- a/mercurial/util.py Thu Jun 21 21:58:18 2007 +0200 +++ b/mercurial/util.py Thu Jun 21 22:19:41 2007 +0200 @@ -1155,9 +1155,6 @@ this function is used to hide the details of COW semantics and remote file access from higher level code. """ - p = base - audit_p = audit - def mktempcopy(name, emptyok=False): d, fn = os.path.split(name) fd, temp = tempfile.mkstemp(prefix='.%s-' % fn, dir=d) @@ -1212,9 +1209,9 @@ posixfile.close(self) def o(path, mode="r", text=False, atomictemp=False): - if audit_p: + if audit: audit_path(path) - f = os.path.join(p, path) + f = os.path.join(base, path) if not text: mode += "b" # for that other OS diff -r 272c0a09b203 -r d8442fc0da8d tests/test-globalopts.out --- a/tests/test-globalopts.out Thu Jun 21 21:58:18 2007 +0200 +++ b/tests/test-globalopts.out Thu Jun 21 22:19:41 2007 +0200 @@ -136,7 +136,7 @@ grep search for a pattern in specified files and revisions heads show current repository heads or show branch heads help show help for a command, extension, or list of commands - identify print information about the working copy + identify identify the working copy or specified revision import import an ordered set of patches incoming show new changesets found in source init create a new repository in the given directory @@ -188,7 +188,7 @@ grep search for a pattern in specified files and revisions heads show current repository heads or show branch heads help show help for a command, extension, or list of commands - identify print information about the working copy + identify identify the working copy or specified revision import import an ordered set of patches incoming show new changesets found in source init create a new repository in the given directory diff -r 272c0a09b203 -r d8442fc0da8d tests/test-help.out --- a/tests/test-help.out Thu Jun 21 21:58:18 2007 +0200 +++ b/tests/test-help.out Thu Jun 21 22:19:41 2007 +0200 @@ -59,7 +59,7 @@ grep search for a pattern in specified files and revisions heads show current repository heads or show branch heads help show help for a command, extension, or list of commands - identify print information about the working copy + identify identify the working copy or specified revision import import an ordered set of patches incoming show new changesets found in source init create a new repository in the given directory @@ -107,7 +107,7 @@ grep search for a pattern in specified files and revisions heads show current repository heads or show branch heads help show help for a command, extension, or list of commands - identify print information about the working copy + identify identify the working copy or specified revision import import an ordered set of patches incoming show new changesets found in source init create a new repository in the given directory diff -r 272c0a09b203 -r d8442fc0da8d tests/test-tags.out --- a/tests/test-tags.out Thu Jun 21 21:58:18 2007 +0200 +++ b/tests/test-tags.out Thu Jun 21 22:19:41 2007 +0200 @@ -1,4 +1,4 @@ -unknown +000000000000 tip 0 files updated, 0 files merged, 0 files removed, 0 files unresolved 0acdaf898367 tip tip 0:0acdaf898367