Mercurial > hg
changeset 2662:2c5d5cf35034
merge with crew.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Mon, 24 Jul 2006 14:36:32 -0700 |
parents | ad329294d808 (diff) 5c10b7ed3411 (current diff) |
children | 96950d39171d |
files | mercurial/commands.py |
diffstat | 13 files changed, 83 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgsigs Thu Jul 20 16:21:07 2006 -0700 +++ b/.hgsigs Mon Jul 24 14:36:32 2006 -0700 @@ -1,1 +1,2 @@ 35fb62a3a673d5322f6274a44ba6456e5e4b3b37 0 iD8DBQBEYmO2ywK+sNU5EO8RAnaYAKCO7x15xUn5mnhqWNXqk/ehlhRt2QCfRDfY0LrUq2q4oK/KypuJYPHgq1A= +2be3001847cb18a23c403439d9e7d0ace30804e9 0 iD8DBQBExUbjywK+sNU5EO8RAhzxAKCtyHAQUzcTSZTqlfJ0by6vhREwWQCghaQFHfkfN0l9/40EowNhuMOKnJk=
--- a/.hgtags Thu Jul 20 16:21:07 2006 -0700 +++ b/.hgtags Mon Jul 24 14:36:32 2006 -0700 @@ -11,3 +11,4 @@ 3a56574f329a368d645853e0f9e09472aee62349 0.8 6a03cff2b0f5d30281e6addefe96b993582f2eac 0.8.1 35fb62a3a673d5322f6274a44ba6456e5e4b3b37 0.9 +2be3001847cb18a23c403439d9e7d0ace30804e9 0.9.1
--- a/contrib/convert-repo Thu Jul 20 16:21:07 2006 -0700 +++ b/contrib/convert-repo Mon Jul 24 14:36:32 2006 -0700 @@ -28,7 +28,8 @@ self.path = path def getheads(self): - return [file(self.path + "/HEAD").read()[:-1]] + fh = os.popen("GIT_DIR=%s git-rev-parse --verify HEAD" % self.path) + return [fh.read()[:-1]] def catfile(self, rev, type): if rev == "0" * 40: raise IOError()
--- a/mercurial/commands.py Thu Jul 20 16:21:07 2006 -0700 +++ b/mercurial/commands.py Mon Jul 24 14:36:32 2006 -0700 @@ -943,7 +943,7 @@ %d dirname of file being printed, or '.' if in repo root %p root-relative path name of file being printed """ - ctx = repo.changectx(opts['rev'] or -1) + ctx = repo.changectx(opts['rev'] or "-1") for src, abs, rel, exact in walk(repo, (file1,) + pats, opts, ctx.node()): fp = make_file(repo, opts['output'], ctx.node(), pathname=abs) fp.write(ctx.filectx(abs).data()) @@ -2088,13 +2088,28 @@ dodiff(ui, ui, repo, prev, n) ui.write("\n") -def parents(ui, repo, rev=None, branches=None, **opts): +def parents(ui, repo, file_=None, rev=None, branches=None, **opts): """show the parents of the working dir or revision Print the working directory's parent revisions. """ + # legacy + if file_ and not rev: + try: + rev = repo.lookup(file_) + file_ = None + except hg.RepoError: + pass + else: + ui.warn(_("'hg parent REV' is deprecated, " + "please use 'hg parents -r REV instead\n")) + if rev: - p = repo.changelog.parents(repo.lookup(rev)) + if file_: + ctx = repo.filectx(file_, changeid=rev) + else: + ctx = repo.changectx(rev) + p = [cp.node() for cp in ctx.parents()] else: p = repo.dirstate.parents() @@ -2658,7 +2673,7 @@ 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 tip is used. + If no revision is given, the parent of the working directory is used. To facilitate version control, distribution, and merging of tags, they are stored as a file named ".hgtags" which is managed @@ -2678,7 +2693,12 @@ if rev_: r = hex(repo.lookup(rev_)) else: - r = hex(repo.changelog.tip()) + p1, p2 = repo.dirstate.parents() + if p1 == nullid: + raise util.Abort(_('no revision to tag')) + if p2 != nullid: + raise util.Abort(_('outstanding uncommitted merges')) + r = hex(p1) repo.tag(name, r, opts['local'], opts['message'], opts['user'], opts['date']) @@ -3051,9 +3071,10 @@ "^parents": (parents, [('b', 'branches', None, _('show branches')), + ('r', 'rev', '', _('show parents from the specified rev')), ('', 'style', '', _('display using template map file')), ('', 'template', '', _('display with template'))], - _('hg parents [-b] [REV]')), + _('hg parents [-b] [-r REV] [FILE]')), "paths": (paths, [], _('hg paths [NAME]')), "^pull": (pull,
--- a/mercurial/context.py Thu Jul 20 16:21:07 2006 -0700 +++ b/mercurial/context.py Mon Jul 24 14:36:32 2006 -0700 @@ -11,9 +11,8 @@ def __init__(self, repo, changeid): """changeid is a revision number, node, or tag""" self._repo = repo - self._id = changeid - self._node = self._repo.lookup(self._id) + self._node = self._repo.lookup(changeid) self._rev = self._repo.changelog.rev(self._node) def changeset(self): @@ -74,39 +73,40 @@ fileid can be a file revision or node.""" self._repo = repo self._path = path - self._id = changeid - self._fileid = fileid - if self._id: + assert changeid or fileid + + if not fileid: # if given a changeset id, go ahead and look up the file - self._changeset = self._repo.changelog.read(self._id) - node, flag = self._repo.manifest.find(self._changeset[0], path) + self._changeid = changeid + self._changectx = self.changectx() self._filelog = self._repo.file(self._path) - self._filenode = node - elif self._fileid: + self._filenode = self._changectx.filenode(self._path) + else: # else be lazy self._filelog = self._repo.file(self._path) - self._filenode = self._filelog.lookup(self._fileid) + self._filenode = self._filelog.lookup(fileid) + self._changeid = self._filelog.linkrev(self._filenode) self._filerev = self._filelog.rev(self._filenode) - def changeset(self): + def changectx(self): try: - return self._changeset + return self._changectx except AttributeError: - self._changeset = self._repo.changelog.read(self.node()) - return self._changeset + self._changectx = changectx(self._repo, self._changeid) + return self._changectx def filerev(self): return self._filerev def filenode(self): return self._filenode def filelog(self): return self._filelog - def rev(self): return self.changeset().rev() - def node(self): return self.changeset().node() - def user(self): return self.changeset().user() - def date(self): return self.changeset().date() - def files(self): return self.changeset().files() - def description(self): return self.changeset().description() - def manifest(self): return self.changeset().manifest() + def rev(self): return self.changectx().rev() + def node(self): return self.changectx().node() + def user(self): return self.changectx().user() + def date(self): return self.changectx().date() + def files(self): return self.changectx().files() + def description(self): return self.changectx().description() + def manifest(self): return self.changectx().manifest() def data(self): return self._filelog.read(self._filenode) def metadata(self): return self._filelog.readmeta(self._filenode)
--- a/mercurial/hgweb/server.py Thu Jul 20 16:21:07 2006 -0700 +++ b/mercurial/hgweb/server.py Mon Jul 24 14:36:32 2006 -0700 @@ -198,6 +198,7 @@ self.webdirmaker = hgwebdir self.repoviewmaker = hgweb self.reqmaker = wsgiapplication(self.make_handler) + self.daemon_threads = True def make_handler(self): if self.webdir_conf:
--- a/mercurial/revlog.py Thu Jul 20 16:21:07 2006 -0700 +++ b/mercurial/revlog.py Mon Jul 24 14:36:32 2006 -0700 @@ -469,7 +469,8 @@ return self.nodemap[node] except KeyError: raise RevlogError(_('%s: no node %s') % (self.indexfile, hex(node))) - def linkrev(self, node): return self.index[self.rev(node)][-4] + def linkrev(self, node): + return (node == nullid) and -1 or self.index[self.rev(node)][-4] def parents(self, node): if node == nullid: return (nullid, nullid) r = self.rev(node) @@ -746,10 +747,7 @@ if id in self.nodemap: return id if type(id) == type(0): - rev = id - if rev < 0: rev = self.count() + rev - if rev < 0 or rev >= self.count(): return None - return self.node(rev) + return self.node(id) try: rev = int(id) if str(rev) != id: raise ValueError
--- a/mercurial/templater.py Thu Jul 20 16:21:07 2006 -0700 +++ b/mercurial/templater.py Mon Jul 24 14:36:32 2006 -0700 @@ -241,6 +241,7 @@ return text.replace('\n', '<br/>\n') def obfuscate(text): + text = unicode(text, 'utf-8', 'replace') return ''.join(['&#%d;' % ord(c) for c in text]) def domain(author):
--- a/mercurial/ui.py Thu Jul 20 16:21:07 2006 -0700 +++ b/mercurial/ui.py Mon Jul 24 14:36:32 2006 -0700 @@ -197,7 +197,7 @@ user = os.environ.get("EMAIL") if user is None: try: - user = '%s@%s' % (getpass.getuser(), socket.getfqdn()) + user = '%s@%s' % (util.getuser(), socket.getfqdn()) except KeyError: raise util.Abort(_("Please specify a username.")) return user
--- a/mercurial/util.py Thu Jul 20 16:21:07 2006 -0700 +++ b/mercurial/util.py Mon Jul 24 14:36:32 2006 -0700 @@ -12,7 +12,7 @@ from i18n import gettext as _ from demandload import * -demandload(globals(), "cStringIO errno popen2 re shutil sys tempfile") +demandload(globals(), "cStringIO errno getpass popen2 re shutil sys tempfile") demandload(globals(), "os threading time") # used by parsedate @@ -510,6 +510,20 @@ except AttributeError: return os.name == 'nt' and 'command' in os.environ.get('comspec', '') +getuser_fallback = None + +def getuser(): + '''return name of current user''' + try: + return getpass.getuser() + except ImportError: + # import of pwd will fail on windows - try fallback + if getuser_fallback: + return getuser_fallback() + # raised if win32api not available + raise Abort(_('user name not available - set USERNAME ' + 'environment variable')) + # Platform specific variants if os.name == 'nt': demandload(globals(), "msvcrt")
--- a/mercurial/util_win32.py Thu Jul 20 16:21:07 2006 -0700 +++ b/mercurial/util_win32.py Mon Jul 24 14:36:32 2006 -0700 @@ -297,3 +297,5 @@ win32file.SetEndOfFile(self.handle) except pywintypes.error, err: raise WinIOError(err) + +getuser_fallback = win32api.GetUserName
--- a/tests/test-tag Thu Jul 20 16:21:07 2006 -0700 +++ b/tests/test-tag Mon Jul 24 14:36:32 2006 -0700 @@ -19,6 +19,11 @@ cat .hgtags cat .hg/localtags +hg update 0 +hg tag -d "1000000 0" "foobar" +cat .hgtags +cat .hg/localtags + hg tag -l 'xx newline' hg tag -l 'xx:xx'
--- a/tests/test-tag.out Thu Jul 20 16:21:07 2006 -0700 +++ b/tests/test-tag.out Mon Jul 24 14:36:32 2006 -0700 @@ -25,5 +25,8 @@ 0acdaf8983679e0aac16e811534eb49d7ee1f2b4 bleah 0acdaf8983679e0aac16e811534eb49d7ee1f2b4 bleah0 c5c60883086f5526bd3e36814b94a73a4e75e172 bleah1 +0 files updated, 0 files merged, 1 files removed, 0 files unresolved +0acdaf8983679e0aac16e811534eb49d7ee1f2b4 foobar +c5c60883086f5526bd3e36814b94a73a4e75e172 bleah1 abort: '\n' cannot be used in a tag name abort: ':' cannot be used in a tag name