# HG changeset patch # User Matt Mackall # Date 1134619938 21600 # Node ID 4737b36e324ee3e9c030d3c3de473dd1f01dfdb9 # Parent bcdc030c59f8956ce0ed4f893014771b61a7fca2# Parent 85803ec2daab5c97c7f871af01158652a5db7bb3 Merge http://sh0n.net/jeffpc/repos/hg-gitweb/ diff -r 85803ec2daab -r 4737b36e324e mercurial/commands.py --- a/mercurial/commands.py Mon Dec 12 02:05:08 2005 -0500 +++ b/mercurial/commands.py Wed Dec 14 22:12:18 2005 -0600 @@ -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 = ':' @@ -1123,9 +1124,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) @@ -1136,8 +1140,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") @@ -1168,6 +1172,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")) @@ -1287,7 +1294,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: @@ -1550,7 +1557,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) @@ -1566,7 +1573,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 @@ -1583,7 +1590,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]: @@ -2262,7 +2269,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, diff -r 85803ec2daab -r 4737b36e324e mercurial/ui.py --- a/mercurial/ui.py Mon Dec 12 02:05:08 2005 -0500 +++ b/mercurial/ui.py Wed Dec 14 22:12:18 2005 -0600 @@ -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 85803ec2daab -r 4737b36e324e tests/test-remove --- a/tests/test-remove Mon Dec 12 02:05:08 2005 -0500 +++ b/tests/test-remove Wed Dec 14 22:12:18 2005 -0600 @@ -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 85803ec2daab -r 4737b36e324e tests/test-remove.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-remove.out Wed Dec 14 22:12:18 2005 -0600 @@ -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 + +