# HG changeset patch # User Thomas Arendsen Hein # Date 1134657560 -3600 # Node ID 5c5aaaa9ab6fa697414d3dc78bf7a2edf95d58e7 # Parent d7c4b9bfcc948ab5790e3cd6c14458ceb5a2a679# Parent db10b7114de0132b1482f87b96b9bec5cf6f620c Merge with upstream. diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f mercurial/commands.py --- a/mercurial/commands.py Mon Dec 12 07:50:43 2005 -0800 +++ b/mercurial/commands.py Thu Dec 15 15:39:20 2005 +0100 @@ -66,7 +66,7 @@ window, we first walk forwards to gather data, then in the desired order (usually backwards) to display it. - This function returns an (iterator, getchange) pair. The + This function returns an (iterator, getchange, matchfn) tuple. The getchange function returns the changelog entry for a numeric revision. The iterator yields 3-tuples. They will be of one of the following forms: @@ -82,10 +82,11 @@ "iter", rev, None: in-order traversal of the revs earlier iterated over with "add" - use to display data''' + files, matchfn, anypats, cwd = matchpats(repo, pats, opts) + if repo.changelog.count() == 0: - return [], False + return [], False, matchfn - files, matchfn, anypats, cwd = matchpats(repo, pats, opts) revs = map(int, revrange(ui, repo, opts['rev'] or ['tip:0'])) wanted = {} slowpath = anypats @@ -153,7 +154,7 @@ yield 'add', rev, fns for rev in nrevs: yield 'iter', rev, None - return iterate(), getchange + return iterate(), getchange, matchfn revrangesep = ':' @@ -1117,9 +1118,12 @@ def doexport(ui, repo, changeset, seqno, total, revwidth, opts): node = repo.lookup(changeset) - prev, other = repo.changelog.parents(node) + parents = [p for p in repo.changelog.parents(node) if p != nullid] + prev = (parents and parents[0]) or nullid change = repo.changelog.read(node) + if opts['switch_parent']: + parents.reverse() fp = make_file(repo, repo.changelog, opts['output'], node=node, total=total, seqno=seqno, revwidth=revwidth) @@ -1130,8 +1134,8 @@ fp.write("# User %s\n" % change[1]) fp.write("# Node ID %s\n" % hex(node)) fp.write("# Parent %s\n" % hex(prev)) - if other != nullid: - fp.write("# Parent %s\n" % hex(other)) + if len(parents) > 1: + fp.write("# Parent %s\n" % hex(parents[1])) fp.write(change[4].rstrip()) fp.write("\n\n") @@ -1162,6 +1166,9 @@ Without the -a option, export will avoid generating diffs of files it detects as binary. With -a, export will generate a diff anyway, probably with undesirable results. + + With the --switch-parent option, the diff will be against the second + parent. It can be useful to review a merge. """ if not changesets: raise util.Abort(_("export requires at least one changeset")) @@ -1281,7 +1288,7 @@ fstate = {} skip = {} - changeiter, getchange = walkchangerevs(ui, repo, pats, opts) + changeiter, getchange, matchfn = walkchangerevs(ui, repo, pats, opts) count = 0 incrementing = False for st, rev, fns in changeiter: @@ -1544,7 +1551,7 @@ self.write(*args) def __getattr__(self, key): return getattr(self.ui, key) - changeiter, getchange = walkchangerevs(ui, repo, pats, opts) + changeiter, getchange, matchfn = walkchangerevs(ui, repo, pats, opts) for st, rev, fns in changeiter: if st == 'window': du = dui(ui) @@ -1560,7 +1567,7 @@ br = None if opts['keyword']: - changes = repo.changelog.read(repo.changelog.node(rev)) + changes = getchange(rev) miss = 0 for k in [kw.lower() for kw in opts['keyword']]: if not (k in changes[1].lower() or @@ -1577,7 +1584,7 @@ show_changeset(du, repo, rev, brinfo=br) if opts['patch']: prev = (parents and parents[0]) or nullid - dodiff(du, du, repo, prev, changenode, fns) + dodiff(du, du, repo, prev, changenode, match=matchfn) du.write("\n\n") elif st == 'iter': for args in du.hunk[rev]: @@ -2122,7 +2129,8 @@ """ repo.undo() -def update(ui, repo, node=None, merge=False, clean=False, branch=None): +def update(ui, repo, node=None, merge=False, clean=False, force=None, + branch=None): """update or merge working directory Update the working directory to the specified revision. @@ -2159,7 +2167,7 @@ return 1 else: node = node and repo.lookup(node) or repo.changelog.tip() - return repo.update(node, allow=merge, force=clean) + return repo.update(node, allow=merge, force=clean, forcemerge=force) def verify(ui, repo): """verify the integrity of the repository @@ -2256,7 +2264,8 @@ "^export": (export, [('o', 'output', "", _('print output to file with formatted name')), - ('a', 'text', None, _('treat all files as text'))], + ('a', 'text', None, _('treat all files as text')), + ('', 'switch-parent', None, _('diff against the second parent'))], "hg export [-a] [-o OUTFILE] REV..."), "forget": (forget, @@ -2404,8 +2413,9 @@ (update, [('b', 'branch', "", _('checkout the head of a specific branch')), ('m', 'merge', None, _('allow merging of branches')), - ('C', 'clean', None, _('overwrite locally modified files'))], - _('hg update [-b TAG] [-m] [-C] [REV]')), + ('C', 'clean', None, _('overwrite locally modified files')), + ('f', 'force', None, _('force a merge with outstanding changes'))], + _('hg update [-b TAG] [-m] [-C] [-f] [REV]')), "verify": (verify, [], _('hg verify')), "version": (show_version, [], _('hg version')), } diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f mercurial/hgweb.py --- a/mercurial/hgweb.py Mon Dec 12 07:50:43 2005 -0800 +++ b/mercurial/hgweb.py Thu Dec 15 15:39:20 2005 +0100 @@ -632,6 +632,8 @@ for k,n in i: yield {"parity": parity, "tag": k, + "tagmanifest": hex(cl.read(n)[0]), + "date": cl.read(n)[2], "node": hex(n)} parity = 1 - parity @@ -639,6 +641,76 @@ manifest=hex(mf), entries=entries) + def summary(self): + cl = self.repo.changelog + mf = cl.read(cl.tip())[0] + + i = self.repo.tagslist() + i.reverse() + + def tagentries(**map): + parity = 0 + count = 0 + for k,n in i: + if k == "tip": # skip tip + continue; + + count += 1 + if count > 10: # limit to 10 tags + break; + + c = cl.read(n) + m = c[0] + t = c[2] + + yield self.t("tagentry", + parity = parity, + tag = k, + node = hex(n), + date = t, + tagmanifest = hex(m)) + parity = 1 - parity + + def changelist(**map): + parity = 0 + cl = self.repo.changelog + l = [] # build a list in forward order for efficiency + for i in range(start, end): + n = cl.node(i) + changes = cl.read(n) + hn = hex(n) + t = changes[2] + + l.insert(0, self.t( + 'shortlogentry', + parity = parity, + author = changes[1], + manifest = hex(changes[0]), + desc = changes[4], + date = t, + rev = i, + node = hn)) + parity = 1 - parity + + yield l + + cl = self.repo.changelog + mf = cl.read(cl.tip())[0] + count = cl.count() + start = max(0, count - self.maxchanges) + end = min(count, start + self.maxchanges) + pos = end - 1 + + yield self.t("summary", + desc = self.repo.ui.config("web", "description", "unknown"), + owner = (self.repo.ui.config("ui", "username") or # preferred + self.repo.ui.config("web", "contact") or # deprecated + self.repo.ui.config("web", "author", "unknown")), # also + lastchange = (0, 0), # FIXME + manifest = hex(mf), + tags = tagentries, + shortlog = changelist) + def filediff(self, file, changeset): cl = self.repo.changelog n = self.repo.lookup(changeset) @@ -798,6 +870,9 @@ elif req.form['cmd'][0] == 'tags': req.write(self.tags()) + elif req.form['cmd'][0] == 'summary': + req.write(self.summary()) + elif req.form['cmd'][0] == 'filediff': req.write(self.filediff(req.form['file'][0], req.form['node'][0])) diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f mercurial/localrepo.py --- a/mercurial/localrepo.py Mon Dec 12 07:50:43 2005 -0800 +++ b/mercurial/localrepo.py Thu Dec 15 15:39:20 2005 +0100 @@ -1364,7 +1364,7 @@ return def update(self, node, allow=False, force=False, choose=None, - moddirstate=True): + moddirstate=True, forcemerge=False): pl = self.dirstate.parents() if not force and pl[1] != nullid: self.ui.warn(_("aborting: outstanding uncommitted merges\n")) @@ -1384,6 +1384,18 @@ (c, a, d, u) = self.changes() + if allow and not forcemerge: + if c or a or d: + raise util.Abort(_("outstanding uncommited changes")) + if not forcemerge and not force: + for f in u: + if f in m2: + t1 = self.wread(f) + t2 = self.file(f).read(m2[f]) + if cmp(t1, t2) != 0: + raise util.Abort(_("'%s' already exists in the working" + " dir and differs from remote") % f) + # is this a jump, or a merge? i.e. is there a linear path # from p1 to p2? linear_path = (pa == p1 or pa == p2) diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f mercurial/ui.py --- a/mercurial/ui.py Mon Dec 12 07:50:43 2005 -0800 +++ b/mercurial/ui.py Thu Dec 15 15:39:20 2005 +0100 @@ -145,7 +145,7 @@ os.environ.get("EDITOR", "vi")) os.environ["HGUSER"] = self.username() - util.system("%s %s" % (editor, name), errprefix=_("edit failed")) + util.system("%s \"%s\"" % (editor, name), errprefix=_("edit failed")) t = open(name).read() t = re.sub("(?m)^HG:.*\n", "", t) diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f templates/changelog-gitweb.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/changelog-gitweb.tmpl Thu Dec 15 15:39:20 2005 +0100 @@ -0,0 +1,30 @@ +#header# +#repo|escape#: Changelog + + + + + + +
+ +
+ + + + +#entries%changelogentry# + +#footer# diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f templates/changelogentry-gitweb.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/changelogentry-gitweb.tmpl Thu Dec 15 15:39:20 2005 +0100 @@ -0,0 +1,14 @@ +
+#date|age# ago#desc|firstline|escape# +
+
+ +#author|obfuscate# [#date|rfc822date#]
+
+
+#desc|addbreaks# +
+
+
diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f templates/changeset-gitweb.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/changeset-gitweb.tmpl Thu Dec 15 15:39:20 2005 +0100 @@ -0,0 +1,40 @@ +#header# +#repo|escape#: Changeset + + + + + + + + +
+#desc|escape|firstline# +
+
+ + + + + +#parent%changesetparent# +#changesettag# +
author#author|obfuscate#
#date|date# (#date|age# ago)
changeset#node|short#
manifest#manifest|short#
+ +
+#desc|addbreaks# +
+ +
+ +#files# +
+ +
#diff#
+ +#footer# diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f templates/error-gitweb.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/error-gitweb.tmpl Thu Dec 15 15:39:20 2005 +0100 @@ -0,0 +1,12 @@ +#header# + + +
+
+Error parsing query string
+
+
+ +#footer# diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f templates/fileannotate-gitweb.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/fileannotate-gitweb.tmpl Thu Dec 15 15:39:20 2005 +0100 @@ -0,0 +1,43 @@ +#header# +#repo|escape#: Annotate + + + + + + + + +
#file#
+ + + + + +#parent%fileannotateparent# + + + + + + + + + + + + +
changeset #rev#:#node|short#
manifest:#manifest|short#
author:#author|obfuscate#
date:#date|date# (#date|age# ago)
permissions:#permissions|permissions#
+ +
+ +#annotate%annotateline# +
+
+ +#footer# diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f templates/filelog-gitweb.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/filelog-gitweb.tmpl Thu Dec 15 15:39:20 2005 +0100 @@ -0,0 +1,20 @@ +#header# +#repo|escape#: Manifest + + + + + + + + + +#entries%filelogentry# +
+ +#footer# diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f templates/filerevision-gitweb.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/filerevision-gitweb.tmpl Thu Dec 15 15:39:20 2005 +0100 @@ -0,0 +1,41 @@ +#header# +#repo|escape#: File revision + + + + + + + + +
#file#
+ + + + + +#parent%fileannotateparent# + + + + + + + + + + + + +
changeset #rev#:#node|short#
manifest:#manifest|short#
author:#author|obfuscate#
date:#date|date# (#date|age# ago)
permissions:#permissions|permissions#
+ +
+#text%fileline# +
+ +#footer# diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f templates/footer-gitweb.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/footer-gitweb.tmpl Thu Dec 15 15:39:20 2005 +0100 @@ -0,0 +1,6 @@ + + + diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f templates/header-gitweb.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/header-gitweb.tmpl Thu Dec 15 15:39:20 2005 +0100 @@ -0,0 +1,59 @@ +Content-type: text/html + + + + + + + + + diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f templates/manifest-gitweb.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/manifest-gitweb.tmpl Thu Dec 15 15:39:20 2005 +0100 @@ -0,0 +1,27 @@ +#header# +#repo|escape#: Manifest + + + + + + + + +
#path|escape#
+
+ + + + + + +#dentries%manifestdirentry# +#fentries%manifestfileentry# +
drwxr-xr-x[up]
+#footer# diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f templates/map-gitweb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/map-gitweb Thu Dec 15 15:39:20 2005 +0100 @@ -0,0 +1,42 @@ +default = "summary" +header = header-gitweb.tmpl +footer = footer-gitweb.tmpl +search = search-gitweb.tmpl +changelog = changelog-gitweb.tmpl +summary = summary-gitweb.tmpl +error = error-gitweb.tmpl +naventry = "#label# " +navshortentry = "#label# " +filedifflink = "#file# " +filenodelink = "#file#file | revisions" +fileellipses = "..." +changelogentry = changelogentry-gitweb.tmpl +searchentry = changelogentry-gitweb.tmpl +changeset = changeset-gitweb.tmpl +manifest = manifest-gitweb.tmpl +manifestdirentry = "drwxr-xr-x#basename#/manifest" +manifestfileentry = "#permissions|permissions##basename#file | revisions | annotate" +filerevision = filerevision-gitweb.tmpl +fileannotate = fileannotate-gitweb.tmpl +filelog = filelog-gitweb.tmpl +fileline = "
#linenumber# #line|escape#
" +filelogentry = filelogentry-gitweb.tmpl +annotateline = "#author|obfuscate#@#rev##line|escape#" +difflineplus = "
#line|escape#
" +difflineminus = "
#line|escape#
" +difflineat = "
#line|escape#
" +diffline = "
#line|escape#
" +changelogparent = "parent #rev#:#node|short#" +changesetparent = "parent#node|short#" +filerevparent = "parent:#node|short#" +fileannotateparent = "parent:#node|short#" +tags = tags-gitweb.tmpl +tagentry = "#date|age# ago#tag#changeset | changelog | manifest" +diffblock = "#lines#" +changelogtag = "tag:#tag#" +changesettag = "tag#tag#" +filediffparent = "parent #rev#:#node|short#" +filelogparent = "parent #rev#: #node|short#" +shortlog = shortlog-gitweb.tmpl +shortlogentry = "#date|age# ago#desc|firstline|escape#changeset | manifest" +filelogentry = "#date|age# ago#desc|firstline|escape# annotate" diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f templates/search-gitweb.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/search-gitweb.tmpl Thu Dec 15 15:39:20 2005 +0100 @@ -0,0 +1,24 @@ +#header# + + +

searching for #query|escape#

+ +
+search: + + + +
+ +#entries# + +
+search: + + + +
+ +#footer# diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f templates/shortlog-gitweb.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/shortlog-gitweb.tmpl Thu Dec 15 15:39:20 2005 +0100 @@ -0,0 +1,13 @@ +#header# + + + + +#entries# +
+ +#footer# diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f templates/summary-gitweb.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/summary-gitweb.tmpl Thu Dec 15 15:39:20 2005 +0100 @@ -0,0 +1,34 @@ +#header# +#repo|escape#: Summary + + + + + + + +
 
+ + + + +
description#desc#
owner#owner#
+ +
changes
+ +#shortlog# + +
...
+ +
tags
+ +#tags# + +
...
+ +#footer# diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f templates/tags-gitweb.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/tags-gitweb.tmpl Thu Dec 15 15:39:20 2005 +0100 @@ -0,0 +1,21 @@ +#header# +#repo|escape#: Tags + + + + + + + + + +#entries%tagentry# +
+ +#footer# diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f tests/test-merge1 --- a/tests/test-merge1 Mon Dec 12 07:50:43 2005 -0800 +++ b/tests/test-merge1 Thu Dec 15 15:39:20 2005 +0100 @@ -40,8 +40,10 @@ hg add c hg commit -m "commit #2" -d "0 0" echo This is file b2 > b +echo %% merge should fail +env HGMERGE=../merge hg update -m 1 echo %% merge of b expected -env HGMERGE=../merge hg update -m 1 +env HGMERGE=../merge hg update -f -m 1 cd ..; /bin/rm -rf t echo %% @@ -65,8 +67,10 @@ cat b echo This is file b22 > b +echo %% merge fails +env HGMERGE=../merge hg update -m 2 echo %% merge expected! -env HGMERGE=../merge hg update -m 2 +env HGMERGE=../merge hg update -f -m 2 cd ..; /bin/rm -rf t mkdir t @@ -85,6 +89,8 @@ hg add c hg commit -m "commit #3" -d "0 0" echo This is file b33 > b -echo %% merge of b expected +echo %% merge of b should fail env HGMERGE=../merge hg update -m 2 +echo %% merge of b expected +env HGMERGE=../merge hg update -f -m 2 cd ..; /bin/rm -rf t diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f tests/test-merge1.out --- a/tests/test-merge1.out Mon Dec 12 07:50:43 2005 -0800 +++ b/tests/test-merge1.out Thu Dec 15 15:39:20 2005 +0100 @@ -1,13 +1,19 @@ %% no merges expected +%% merge should fail +abort: 'b' already exists in the working dir and differs from remote %% merge of b expected merging for b merging b %% Contents of b should be "this is file b1" This is file b1 +%% merge fails +abort: outstanding uncommited changes %% merge expected! merging for b merging b +%% merge of b should fail +abort: outstanding uncommited changes %% merge of b expected merging for b merging b diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f tests/test-remove --- a/tests/test-remove Mon Dec 12 07:50:43 2005 -0800 +++ b/tests/test-remove Thu Dec 15 15:39:20 2005 +0100 @@ -8,6 +8,10 @@ rm foo hg remove foo hg commit -m 2 -d "0 0" +hg export 0 +hg export 1 +hg log -p -r 0 +hg log -p -r 1 cd .. hg clone a b diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f tests/test-remove.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-remove.out Thu Dec 15 15:39:20 2005 +0100 @@ -0,0 +1,47 @@ +# HG changeset patch +# User test +# Node ID b51ca55c20354097ca299529d18b5cd356976ba2 +# Parent 0000000000000000000000000000000000000000 +1 + +diff -r 000000000000 -r b51ca55c2035 foo +--- /dev/null Thu Jan 1 00:00:00 1970 +0000 ++++ b/foo Thu Jan 1 00:00:00 1970 +0000 +@@ -0,0 +1,1 @@ ++a +# HG changeset patch +# User test +# Node ID 1e555b9b85c52e1e9e8175446f1ede507b2d1ebb +# Parent b51ca55c20354097ca299529d18b5cd356976ba2 +2 + +diff -r b51ca55c2035 -r 1e555b9b85c5 foo +--- a/foo Thu Jan 1 00:00:00 1970 +0000 ++++ /dev/null Thu Jan 1 00:00:00 1970 +0000 +@@ -1,1 +0,0 @@ +-a +changeset: 0:b51ca55c2035 +user: test +date: Thu Jan 1 00:00:00 1970 +0000 +summary: 1 + +diff -r 000000000000 -r b51ca55c2035 foo +--- /dev/null Thu Jan 1 00:00:00 1970 +0000 ++++ b/foo Thu Jan 1 00:00:00 1970 +0000 +@@ -0,0 +1,1 @@ ++a + + +changeset: 1:1e555b9b85c5 +tag: tip +user: test +date: Thu Jan 1 00:00:00 1970 +0000 +summary: 2 + +diff -r b51ca55c2035 -r 1e555b9b85c5 foo +--- a/foo Thu Jan 1 00:00:00 1970 +0000 ++++ /dev/null Thu Jan 1 00:00:00 1970 +0000 +@@ -1,1 +0,0 @@ +-a + + diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f tests/test-up-local-change --- a/tests/test-up-local-change Mon Dec 12 07:50:43 2005 -0800 +++ b/tests/test-up-local-change Thu Dec 15 15:39:20 2005 +0100 @@ -25,7 +25,8 @@ hg -q pull ../r1 hg status hg --debug up -hg --debug up -m +hg --debug up -m || echo failed +hg --debug up -f -m hg parents hg -v history hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \ diff -r d7c4b9bfcc94 -r 5c5aaaa9ab6f tests/test-up-local-change.out --- a/tests/test-up-local-change.out Mon Dec 12 07:50:43 2005 -0800 +++ b/tests/test-up-local-change.out Thu Dec 15 15:39:20 2005 +0100 @@ -16,6 +16,8 @@ merging a resolving a file a: my b789fdd96dc2 other d730145abbf9 ancestor b789fdd96dc2 +abort: outstanding uncommited changes +failed resolving manifests force None allow 1 moddirstate True linear True ancestor 1165e8bd193e local 1165e8bd193e remote 1165e8bd193e