[PATCH] update, merge: add option -n / revision 2

Adrian Buehlmann adrian at cadifra.com
Wed May 28 06:18:16 CDT 2008


Changes since revision 1 of this patch:
* corrected strings: long option name is "dry-run" (not "dry_run")
* rebased to 5868d0b8509f and reran testsuite on FreeBSD 6.2

# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1211963167 -7200
# Node ID 779c8ab143e39545bca1759ac83fc4a612732408
# Parent  5868d0b8509f7cdd9ca4d82e6c94c376f6c76883
update, merge: add option -n (--dry-run)

Files that need file merging are listed in output, but no file merges
are actually attempted, which implies that file merge conflicts won't
be uncovered with --dry-run

diff -r 5868d0b8509f -r 779c8ab143e3 mercurial/commands.py
--- a/mercurial/commands.py	Sun May 25 13:39:08 2008 -0700
+++ b/mercurial/commands.py	Wed May 28 10:26:07 2008 +0200
@@ -1868,7 +1868,7 @@
             ui.write("%3s %1s " % (perm, type))
         ui.write("%s\n" % f)

-def merge(ui, repo, node=None, force=None, rev=None):
+def merge(ui, repo, node=None, force=None, rev=None, dry_run=None):
     """merge working directory with another revision

     Merge the contents of the current working directory and the
@@ -1880,6 +1880,10 @@
     head revision, and the repository contains exactly one other head,
     the other head is merged with by default. Otherwise, an explicit
     revision to merge with must be provided.
+
+    No file merges are actually attempted when option -n is specified,
+    so the dry run output may be different compared to the output
+    produced without -n.
     """

     if rev and node:
@@ -1904,7 +1908,7 @@
             raise util.Abort(_('working dir not at a head rev - '
                                'use "hg update" or merge with an explicit rev'))
         node = parent == heads[0] and heads[-1] or heads[0]
-    return hg.merge(repo, node, force=force)
+    return hg.merge(repo, node, force=force, dry_run=dry_run)

 def outgoing(ui, repo, dest=None, **opts):
     """show changesets not found in destination
@@ -2804,7 +2808,7 @@

     return postincoming(ui, repo, modheads, opts['update'], None)

-def update(ui, repo, node=None, rev=None, clean=False, date=None):
+def update(ui, repo, node=None, rev=None, clean=False, date=None, dry_run=None):
     """update working directory

     Update the working directory to the specified revision, or the
@@ -2820,6 +2824,10 @@
     working directory is clean, update quietly switches branches.

     See 'hg help dates' for a list of formats valid for --date.
+
+    No file merges are actually attempted when option -n is specified,
+    so the dry run output may be different compared to the output
+    produced without -n.
     """
     if rev and node:
         raise util.Abort(_("please specify just one revision"))
@@ -2833,9 +2841,9 @@
         rev = cmdutil.finddate(ui, repo, date)

     if clean:
-        return hg.clean(repo, rev)
+        return hg.clean(repo, rev, dry_run=dry_run)
     else:
-        return hg.update(repo, rev)
+        return hg.update(repo, rev, dry_run=dry_run)

 def verify(ui, repo):
     """verify the integrity of the repository
@@ -3173,8 +3181,8 @@
         (merge,
          [('f', 'force', None, _('force a merge with outstanding changes')),
           ('r', 'rev', '', _('revision to merge')),
-             ],
-         _('hg merge [-f] [[-r] REV]')),
+         ] + dryrunopts,
+         _('hg merge [-f] [-n] [[-r] REV]')),
     "outgoing|out":
         (outgoing,
          [('f', 'force', None,
@@ -3304,8 +3312,9 @@
         (update,
          [('C', 'clean', None, _('overwrite locally modified files')),
           ('d', 'date', '', _('tipmost revision matching date')),
-          ('r', 'rev', '', _('revision'))],
-         _('hg update [-C] [-d DATE] [[-r] REV]')),
+          ('r', 'rev', '', _('revision'))
+         ] +  dryrunopts,
+         _('hg update [-C] [-d DATE] [-n] [[-r] REV]')),
     "verify": (verify, [], _('hg verify')),
     "version": (version_, [], _('hg version')),
 }
diff -r 5868d0b8509f -r 779c8ab143e3 mercurial/filemerge.py
--- a/mercurial/filemerge.py	Sun May 25 13:39:08 2008 -0700
+++ b/mercurial/filemerge.py	Wed May 28 10:26:07 2008 +0200
@@ -101,7 +101,7 @@
             if newdata != data:
                 open(file, "wb").write(newdata)

-def filemerge(repo, mynode, orig, fcd, fco, fca):
+def filemerge(repo, mynode, orig, fcd, fco, fca, dry_run):
     """perform a 3-way merge in the working directory

     mynode = parent node before merge
@@ -126,11 +126,14 @@
         except IOError:
             return False

-    if not fco.cmp(fcd.data()): # files identical?
-        return None
-
     ui = repo.ui
     fd = fcd.path()
+
+    # fd may be inexistent on dry runs due to renames
+    if (not dry_run) or util.lexists(fd):
+        if not fco.cmp(fcd.data()): # files identical?
+            return None
+
     binary = isbin(fcd) or isbin(fco) or isbin(fca)
     symlink = fcd.islink() or fco.islink()
     tool, toolpath = _picktool(repo, ui, fd, binary, symlink)
@@ -146,10 +149,21 @@
     if tool == "internal:local":
         return 0
     if tool == "internal:other":
-        repo.wwrite(fd, fco.data(), fco.fileflags())
+        if not dry_run:
+            repo.wwrite(fd, fco.data(), fco.fileflags())
         return 0
     if tool == "internal:fail":
         return 1
+
+    if orig != fco.path():
+        repo.ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd))
+    else:
+        repo.ui.status(_("merging %s\n") % fd)
+
+    repo.ui.debug(_("my %s other %s ancestor %s\n") % (fcd, fco, fca))
+
+    if dry_run:
+       return 0

     # do the actual merge
     a = repo.wjoin(fd)
@@ -158,13 +172,6 @@
     out = ""
     back = a + ".orig"
     util.copyfile(a, back)
-
-    if orig != fco.path():
-        repo.ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd))
-    else:
-        repo.ui.status(_("merging %s\n") % fd)
-
-    repo.ui.debug(_("my %s other %s ancestor %s\n") % (fcd, fco, fca))

     # do we attempt to simplemerge first?
     if _toolbool(ui, tool, "premerge", not (binary or symlink)):
diff -r 5868d0b8509f -r 779c8ab143e3 mercurial/hg.py
--- a/mercurial/hg.py	Sun May 25 13:39:08 2008 -0700
+++ b/mercurial/hg.py	Wed May 28 10:26:07 2008 +0200
@@ -268,35 +268,43 @@

 def _update(repo, node): return update(repo, node)

-def update(repo, node):
+def _dryrunstatus(repo, dry_run):
+    if dry_run:
+        repo.ui.status(_("(this was a dry run, no actions were performed)\n"))
+    return dry_run
+
+def update(repo, node, dry_run=False):
     """update the working directory to node, merging linear changes"""
     pl = repo.parents()
-    stats = _merge.update(repo, node, False, False, None)
+    stats = _merge.update(repo, node, False, False, None, dry_run)
     _showstats(repo, stats)
-    if stats[3]:
-        repo.ui.status(_("use 'hg resolve' to retry unresolved file merges\n"))
+    if not _dryrunstatus(repo, dry_run):
+        if stats[3]:
+            repo.ui.status(_("use 'hg resolve' to retry unresolved file merges\n"))
     return stats[3] > 0

-def clean(repo, node, show_stats=True):
+def clean(repo, node, show_stats=True, dry_run=False):
     """forcibly switch the working directory to node, clobbering changes"""
-    stats = _merge.update(repo, node, False, True, None)
+    stats = _merge.update(repo, node, False, True, None, dry_run)
     if show_stats: _showstats(repo, stats)
+    _dryrunstatus(repo, dry_run)
     return stats[3] > 0

-def merge(repo, node, force=None, remind=True):
+def merge(repo, node, force=None, remind=True, dry_run=False):
     """branch merge with node, resolving changes"""
-    stats = _merge.update(repo, node, True, force, False)
+    stats = _merge.update(repo, node, True, force, False, dry_run)
     _showstats(repo, stats)
-    if stats[3]:
-        pl = repo.parents()
-        repo.ui.status(_("use 'hg resolve' to retry unresolved file merges\n"))
-    elif remind:
-        repo.ui.status(_("(branch merge, don't forget to commit)\n"))
+    if not _dryrunstatus(repo, dry_run):
+        if stats[3]:
+            pl = repo.parents()
+            repo.ui.status(_("use 'hg resolve' to retry unresolved file merges\n"))
+        elif remind:
+            repo.ui.status(_("(branch merge, don't forget to commit)\n"))
     return stats[3] > 0

 def revert(repo, node, choose):
     """revert changes to revision in node without updating dirstate"""
-    return _merge.update(repo, node, False, True, choose)[3] > 0
+    return _merge.update(repo, node, False, True, choose, False)[3] > 0

 def verify(repo):
     """verify the consistency of a repository"""
diff -r 5868d0b8509f -r 779c8ab143e3 mercurial/merge.py
--- a/mercurial/merge.py	Sun May 25 13:39:08 2008 -0700
+++ b/mercurial/merge.py	Wed May 28 10:26:07 2008 +0200
@@ -11,15 +11,19 @@

 class mergestate(object):
     '''track 3-way merge state of individual files'''
-    def __init__(self, repo):
+    def __init__(self, repo, dry_run=False):
         self._repo = repo
+        self._dry_run = dry_run
         self._read()
     def reset(self, node):
         self._state = {}
         self._local = node
-        shutil.rmtree(self._repo.join("merge"), True)
+        if not self._dry_run:
+            shutil.rmtree(self._repo.join("merge"), True)
     def _read(self):
         self._state = {}
+        if self._dry_run:
+            return
         try:
             localnode = None
             f = self._repo.opener("merge/state")
@@ -34,13 +38,16 @@
             if err.errno != errno.ENOENT:
                 raise
     def _write(self):
+        if self._dry_run:
+            return
         f = self._repo.opener("merge/state", "w")
         f.write(hex(self._local) + "\n")
         for d, v in self._state.items():
             f.write("\0".join([d] + v) + "\n")
     def add(self, fcl, fco, fca, fd, flags):
         hash = util.sha1(fcl.path()).hexdigest()
-        self._repo.opener("merge/" + hash, "w").write(fcl.data())
+        if not self._dry_run:
+            self._repo.opener("merge/" + hash, "w").write(fcl.data())
         self._state[fd] = ['u', hash, fcl.path(), fca.path(),
                            hex(fca.filenode()), fco.path(), flags]
         self._write()
@@ -60,12 +67,13 @@
         if self[dfile] == 'r':
             return 0
         state, hash, lfile, afile, anode, ofile, flags = self._state[dfile]
-        f = self._repo.opener("merge/" + hash)
-        self._repo.wwrite(dfile, f.read(), flags)
+        if not self._dry_run:
+            f = self._repo.opener("merge/" + hash)
+            self._repo.wwrite(dfile, f.read(), flags)
         fcd = wctx[dfile]
         fco = octx[ofile]
         fca = self._repo.filectx(afile, fileid=anode)
-        r = filemerge.filemerge(self._repo, self._local, lfile, fcd, fco, fca)
+        r = filemerge.filemerge(self._repo, self._local, lfile, fcd, fco, fca, self._dry_run)
         if not r:
             self.mark(dfile, 'r')
         return r
@@ -258,13 +266,13 @@

     return action

-def applyupdates(repo, action, wctx, mctx):
+def applyupdates(repo, action, wctx, mctx, dry_run):
     "apply the merge action list to the working directory"

     updated, merged, removed, unresolved = 0, 0, 0, 0
     action.sort()

-    ms = mergestate(repo)
+    ms = mergestate(repo, dry_run)
     ms.reset(wctx.parents()[0].node())
     moves = []

@@ -285,7 +293,8 @@
     for f in moves:
         if util.lexists(repo.wjoin(f)):
             repo.ui.debug(_("removing %s\n") % f)
-            os.unlink(repo.wjoin(f))
+            if not dry_run:
+                os.unlink(repo.wjoin(f))

     audit_path = util.path_auditor(repo.root)

@@ -297,7 +306,8 @@
             repo.ui.note(_("removing %s\n") % f)
             audit_path(f)
             try:
-                util.unlink(repo.wjoin(f))
+                if not dry_run:
+                    util.unlink(repo.wjoin(f))
             except OSError, inst:
                 if inst.errno != errno.ENOENT:
                     repo.ui.warn(_("update failed to remove %s: %s!\n") %
@@ -317,19 +327,22 @@
             flags = a[2]
             repo.ui.note(_("getting %s\n") % f)
             t = mctx.filectx(f).data()
-            repo.wwrite(f, t, flags)
+            if not dry_run:
+                repo.wwrite(f, t, flags)
             updated += 1
         elif m == "d": # directory rename
             f2, fd, flags = a[2:]
             if f:
                 repo.ui.note(_("moving %s to %s\n") % (f, fd))
                 t = wctx.filectx(f).data()
-                repo.wwrite(fd, t, flags)
-                util.unlink(repo.wjoin(f))
+                if not dry_run:
+                    repo.wwrite(fd, t, flags)
+                    util.unlink(repo.wjoin(f))
             if f2:
                 repo.ui.note(_("getting %s to %s\n") % (f2, fd))
                 t = mctx.filectx(f2).data()
-                repo.wwrite(fd, t, flags)
+                if not dry_run:
+                    repo.wwrite(fd, t, flags)
             updated += 1
         elif m == "dr": # divergent renames
             fl = a[2]
@@ -338,7 +351,8 @@
                 repo.ui.warn(" %s\n" % nf)
         elif m == "e": # exec
             flags = a[2]
-            util.set_flags(repo.wjoin(f), flags)
+            if not dry_run:
+                util.set_flags(repo.wjoin(f), flags)

     return updated, merged, removed, unresolved

@@ -398,7 +412,7 @@
                 if f:
                     repo.dirstate.forget(f)

-def update(repo, node, branchmerge, force, partial):
+def update(repo, node, branchmerge, force, partial, dry_run=False):
     """
     Perform a merge between the working directory and the given node

@@ -468,12 +482,12 @@
         ### apply phase
         if not branchmerge: # just jump to the new rev
             fp1, fp2, xp1, xp2 = fp2, nullid, xp2, ''
-        if not partial:
+        if not partial and not dry_run:
             repo.hook('preupdate', throw=True, parent1=xp1, parent2=xp2)

-        stats = applyupdates(repo, action, wc, p2)
+        stats = applyupdates(repo, action, wc, p2, dry_run)

-        if not partial:
+        if not partial and not dry_run:
             recordupdates(repo, action, branchmerge)
             repo.dirstate.setparents(fp1, fp2)
             if not branchmerge and not fastforward:
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge-commit
--- a/tests/test-merge-commit	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge-commit	Wed May 28 10:26:07 2008 +0200
@@ -12,6 +12,8 @@
 echo line2 >> foo
 hg ci -m '1: change foo' -d '0 0'

+echo testing dry update:
+hg up -C -n 0
 hg up -C 0
 hg mv foo bar
 rm bar
@@ -19,6 +21,8 @@
 echo line1 >> bar
 hg ci -m '2: mv foo bar; change bar' -d '0 0'

+echo testing dry merge:
+hg merge -n 1
 hg merge 1
 echo '% contents of bar should be line0 line1 line2'
 cat bar
@@ -28,6 +32,8 @@
 hg debugindex .hg/store/data/foo.i

 # revert the content change from rev 2
+echo testing dry update:
+hg up -C -n 2
 hg up -C 2
 rm bar
 echo line1 > bar
@@ -49,7 +55,11 @@
 hg clone -U -r 1 -r 2 a b
 cd b

+echo testing dry update:
+hg up -C -n 1
 hg up -C 1
+echo testing dry merge:
+hg merge -n 2
 hg merge 2
 echo '% contents of bar should be line0 line1 line2'
 cat bar
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge-commit.out
--- a/tests/test-merge-commit.out	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge-commit.out	Wed May 28 10:26:07 2008 +0200
@@ -1,5 +1,12 @@
+testing dry update:
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 created new head
+testing dry merge:
+merging bar and foo to bar
+0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 merging bar and foo to bar
 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
@@ -14,6 +21,9 @@
    rev    offset  length   base linkrev nodeid       p1           p2
      0         0       7      0       0 690b295714ae 000000000000 000000000000
      1         7      13      1       1 9e25c27b8757 690b295714ae 000000000000
+testing dry update:
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 created new head
 4:2d2f9a22c82b 2:0a3ab4856510
@@ -49,7 +59,14 @@
 adding manifests
 adding file changes
 added 3 changesets with 3 changes to 2 files (+1 heads)
+testing dry update:
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+testing dry merge:
+merging foo and bar to bar
+0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 merging foo and bar to bar
 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge-force
--- a/tests/test-merge-force	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge-force	Wed May 28 10:26:07 2008 +0200
@@ -17,7 +17,11 @@
 rm a

 echo '% local deleted a file, remote removed'
+echo testing dry merge:
+hg merge -n
 hg merge # should fail, since there are deleted files
+echo testing dry merge:
+hg -v merge --force -n
 hg -v merge --force
 echo % should show a as removed
 hg st
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge-force.out
--- a/tests/test-merge-force.out	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge-force.out	Wed May 28 10:26:07 2008 +0200
@@ -1,6 +1,13 @@
 created new head
 % local deleted a file, remote removed
+testing dry merge:
 abort: outstanding uncommitted changes
+abort: outstanding uncommitted changes
+testing dry merge:
+resolving manifests
+removing a
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 resolving manifests
 removing a
 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge-remove
--- a/tests/test-merge-remove	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge-remove	Wed May 28 10:26:07 2008 +0200
@@ -17,6 +17,8 @@
 hg cat foo >> foo1
 hg ci -m 'mv foo foo1'

+echo testing dry merge:
+hg merge -n
 hg merge
 hg debugstate --nodates
 hg st -q
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge-remove.out
--- a/tests/test-merge-remove.out	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge-remove.out	Wed May 28 10:26:07 2008 +0200
@@ -1,4 +1,8 @@
 created new head
+testing dry merge:
+merging foo1 and foo to foo1
+1 files updated, 1 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 merging foo1 and foo to foo1
 1 files updated, 1 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge-revert2
--- a/tests/test-merge-revert2	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge-revert2	Wed May 28 10:26:07 2008 +0200
@@ -26,6 +26,8 @@
 hg id
 hg update -C 0
 echo "changed file1 different" >> file1
+echo testing dry update:
+hg update -n
 hg update
 hg diff --nodates
 hg status
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge-revert2.out
--- a/tests/test-merge-revert2.out	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge-revert2.out	Wed May 28 10:26:07 2008 +0200
@@ -9,6 +9,10 @@
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 f248da0d4c3e tip
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+testing dry update:
+merging file1
+0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 merging file1
 warning: conflicts during merge.
 merging file1 failed!
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge-types
--- a/tests/test-merge-types	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge-types	Wed May 28 10:26:07 2008 +0200
@@ -11,6 +11,8 @@
 rm a
 ln -s symlink a
 hg ci -msymlink    # 2
+echo testing dry merge:
+hg merge --debug -n
 hg merge --debug

 echo % symlink is local parent, executable is other
@@ -25,6 +27,8 @@
 fi

 hg update -C 1
+echo testing dry merge:
+hg merge --debug -n
 hg merge --debug

 echo % symlink is other parent, executable is local
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge-types.out
--- a/tests/test-merge-types.out	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge-types.out	Wed May 28 10:26:07 2008 +0200
@@ -1,6 +1,14 @@
 adding a
 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 created new head
+testing dry merge:
+resolving manifests
+ overwrite None partial False
+ ancestor c334dc3be0da local 521a1e40188f+ remote 3574f3e69b1c
+  searching for copies back to rev 1
+ a: update permissions -> e
+0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 resolving manifests
  overwrite None partial False
  ancestor c334dc3be0da local 521a1e40188f+ remote 3574f3e69b1c
@@ -11,6 +19,15 @@
 % symlink is local parent, executable is other
 a has no flags (default for conflicts)
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+testing dry merge:
+resolving manifests
+ overwrite None partial False
+ ancestor c334dc3be0da local 3574f3e69b1c+ remote 521a1e40188f
+  searching for copies back to rev 1
+ a: remote is newer -> g
+getting a
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 resolving manifests
  overwrite None partial False
  ancestor c334dc3be0da local 3574f3e69b1c+ remote 521a1e40188f
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge1
--- a/tests/test-merge1	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge1	Wed May 28 10:26:07 2008 +0200
@@ -22,6 +22,8 @@
 hg commit -m "commit #2" -d "1000000 0"
 echo This is file b1 > b
 echo %% no merges expected
+echo testing dry merge:
+hg merge -n 1
 hg merge 1
 hg diff --nodates
 hg status
@@ -43,8 +45,12 @@
 hg commit -m "commit #2" -d "1000000 0"
 echo This is file b2 > b
 echo %% merge should fail
+echo testing dry merge:
+hg merge -n 1
 hg merge 1
 echo %% merge of b expected
+echo testing dry merge:
+hg merge -f -n 1
 hg merge -f 1
 hg diff --nodates
 hg status
@@ -72,8 +78,12 @@

 echo This is file b22 > b
 echo %% merge fails
+echo testing dry merge:
+hg merge -n 2
 hg merge 2
 echo %% merge expected!
+echo testing dry merge:
+hg merge -f -n 2
 hg merge -f 2
 hg diff --nodates
 hg status
@@ -96,8 +106,12 @@
 hg commit -m "commit #3" -d "1000000 0"
 echo This is file b33 > b
 echo %% merge of b should fail
+echo testing dry merge:
+hg merge -n 2
 hg merge 2
 echo %% merge of b expected
+echo testing dry merge:
+hg merge -f -n 2
 hg merge -f 2
 hg diff --nodates
 hg status
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge1.out
--- a/tests/test-merge1.out	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge1.out	Wed May 28 10:26:07 2008 +0200
@@ -1,6 +1,9 @@
 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
 created new head
 %% no merges expected
+testing dry merge:
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
 diff -r d9e5953b9dec b
@@ -12,8 +15,14 @@
 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
 created new head
 %% merge should fail
+testing dry merge:
+abort: untracked file in working directory differs from file in requested revision: 'b'
 abort: untracked file in working directory differs from file in requested revision: 'b'
 %% merge of b expected
+testing dry merge:
+merging b
+0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 merging for b
 merging b
 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
@@ -30,8 +39,13 @@
 Contents of b should be "this is file b1"
 This is file b1
 %% merge fails
+testing dry merge:
+abort: outstanding uncommitted changes
 abort: outstanding uncommitted changes
 %% merge expected!
+testing dry merge:
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
 diff -r c1dd73cbf59f b
@@ -44,8 +58,14 @@
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 created new head
 %% merge of b should fail
+testing dry merge:
+abort: outstanding uncommitted changes
 abort: outstanding uncommitted changes
 %% merge of b expected
+testing dry merge:
+merging b
+0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 merging for b
 merging b
 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge10
--- a/tests/test-merge10	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge10	Wed May 28 10:26:07 2008 +0200
@@ -27,7 +27,11 @@
 hg add newdir/beta
 hg commit -u test -d '1000000 0' -m local-addition
 hg pull ../a
+echo testing dry update:
+hg up -C -n 2
 hg up -C 2
+echo testing dry merge:
+hg merge -n
 hg merge
 hg stat
 hg diff --nodates
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge10.out
--- a/tests/test-merge10.out	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge10.out	Wed May 28 10:26:07 2008 +0200
@@ -7,7 +7,14 @@
 adding file changes
 added 1 changesets with 1 changes to 1 files (+1 heads)
 (run 'hg heads' to see heads, 'hg merge' to merge)
+testing dry update:
 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
+0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+testing dry merge:
+merging testdir/subdir/a and testdir/a to testdir/subdir/a
+0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 merging testdir/subdir/a and testdir/a to testdir/subdir/a
 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge6
--- a/tests/test-merge6	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge6	Wed May 28 10:26:07 2008 +0200
@@ -32,6 +32,8 @@

 cd A1
 hg pull ../B1
+echo testing dry merge:
+hg merge -n
 hg merge
 hg commit -m "commit test" -d "1000000 0"
 echo bar should remain deleted.
@@ -39,6 +41,8 @@

 cd ../B2
 hg pull ../A2
+echo testing dry merge:
+hg merge -n
 hg merge
 hg commit -m "commit test" -d "1000000 0"
 echo bar should remain deleted.
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge6.out
--- a/tests/test-merge6.out	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge6.out	Wed May 28 10:26:07 2008 +0200
@@ -11,6 +11,9 @@
 adding file changes
 added 1 changesets with 1 changes to 1 files (+1 heads)
 (run 'hg heads' to see heads, 'hg merge' to merge)
+testing dry merge:
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
 bar should remain deleted.
@@ -22,6 +25,9 @@
 adding file changes
 added 1 changesets with 0 changes to 0 files (+1 heads)
 (run 'hg heads' to see heads, 'hg merge' to merge)
+testing dry merge:
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
 bar should remain deleted.
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge7
--- a/tests/test-merge7	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge7	Wed May 28 10:26:07 2008 +0200
@@ -35,6 +35,8 @@

 # now pull and merge from test-a
 hg pull ../test-a
+echo testing dry merge:
+hg merge -n
 hg merge
 # resolve conflict
 cat >test.txt <<"EOF"
@@ -57,6 +59,8 @@
 # pull and merge from test-a again
 cd ../test-b
 hg pull ../test-a
+echo testing dry merge:
+hg merge --debug -n
 hg merge --debug

 cat test.txt
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge7.out
--- a/tests/test-merge7.out	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge7.out	Wed May 28 10:26:07 2008 +0200
@@ -7,6 +7,10 @@
 adding file changes
 added 1 changesets with 1 changes to 1 files (+1 heads)
 (run 'hg heads' to see heads, 'hg merge' to merge)
+testing dry merge:
+merging test.txt
+0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 merging test.txt
 warning: conflicts during merge.
 merging test.txt failed!
@@ -19,6 +23,18 @@
 adding file changes
 added 1 changesets with 1 changes to 1 files (+1 heads)
 (run 'hg heads' to see heads, 'hg merge' to merge)
+testing dry merge:
+resolving manifests
+ overwrite None partial False
+ ancestor faaea63e63a9 local 451c744aabcc+ remote a070d41e8360
+  searching for copies back to rev 1
+ test.txt: versions differ -> m
+preserving test.txt for resolve of test.txt
+picked tool 'internal:merge' for test.txt (binary False symlink False)
+merging test.txt
+my test.txt at 451c744aabcc+ other test.txt at a070d41e8360 ancestor test.txt at faaea63e63a9
+0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 resolving manifests
  overwrite None partial False
  ancestor faaea63e63a9 local 451c744aabcc+ remote a070d41e8360
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge8
--- a/tests/test-merge8	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge8	Wed May 28 10:26:07 2008 +0200
@@ -16,4 +16,6 @@
 hg commit -m b
 cd ../b
 hg pull ../a
+echo testing dry update:
+hg update -n
 hg update
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-merge8.out
--- a/tests/test-merge8.out	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-merge8.out	Wed May 28 10:26:07 2008 +0200
@@ -7,4 +7,7 @@
 adding file changes
 added 2 changesets with 2 changes to 1 files
 (run 'hg update' to get a working copy)
+testing dry update:
 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
+1 files updated, 0 files merged, 1 files removed, 0 files unresolved
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-rename-after-merge
--- a/tests/test-rename-after-merge	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-rename-after-merge	Wed May 28 10:26:07 2008 +0200
@@ -23,6 +23,8 @@

 echo % merge repositories
 hg pull ../t2
+echo testing dry merge:
+hg merge -n
 hg merge
 hg st

diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-rename-after-merge.out
--- a/tests/test-rename-after-merge.out	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-rename-after-merge.out	Wed May 28 10:26:07 2008 +0200
@@ -13,6 +13,9 @@
 adding file changes
 added 1 changesets with 1 changes to 1 files (+1 heads)
 (run 'hg heads' to see heads, 'hg merge' to merge)
+testing dry merge:
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
 M b
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-rename-dir-merge
--- a/tests/test-rename-dir-merge	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-rename-dir-merge	Wed May 28 10:26:07 2008 +0200
@@ -19,13 +19,19 @@
 hg add a/c
 hg ci -m "2 add a/c" -d "0 0"

+echo testing dry merge:
+hg merge --debug -n 1
 hg merge --debug 1
 echo a/* b/*
 hg st -C
 hg ci -m "3 merge 2+1" -d "0 0"
 hg debugrename b/c

+echo testing dry update:
+hg co -C -n 1
 hg co -C 1
+echo testing dry merge:
+hg merge --debug -n 2
 hg merge --debug 2
 echo a/* b/*
 hg st -C
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-rename-dir-merge.out
--- a/tests/test-rename-dir-merge.out	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-rename-dir-merge.out	Wed May 28 10:26:07 2008 +0200
@@ -5,6 +5,38 @@
 moving a/b to b/b
 2 files updated, 0 files merged, 2 files removed, 0 files unresolved
 created new head
+testing dry merge:
+resolving manifests
+ overwrite None partial False
+ ancestor f9b20c0d4c51 local ce36d17b18fb+ remote 55119e611c80
+  searching for copies back to rev 1
+  unmatched files in local:
+   a/c
+   a/d
+  unmatched files in other:
+   b/a
+   b/b
+  all copies found (* = to merge, ! = divergent):
+   b/a -> a/a
+   b/b -> a/b
+  checking for directory renames
+  dir a/ -> b/
+  file a/c -> b/c
+  file a/d -> b/d
+ a/d: remote renamed directory to b/d -> d
+ a/c: remote renamed directory to b/c -> d
+ a/b: other deleted -> r
+ a/a: other deleted -> r
+ b/a: remote created -> g
+ b/b: remote created -> g
+removing a/a
+removing a/b
+moving a/c to b/c
+moving a/d to b/d
+getting b/a
+getting b/b
+4 files updated, 0 files merged, 2 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 resolving manifests
  overwrite None partial False
  ancestor f9b20c0d4c51 local ce36d17b18fb+ remote 55119e611c80
@@ -46,7 +78,31 @@
 R a/c
 ? b/d
 b/c renamed from a/c:354ae8da6e890359ef49ade27b68bbc361f3ca88
+testing dry update:
 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+testing dry merge:
+resolving manifests
+ overwrite None partial False
+ ancestor f9b20c0d4c51 local 55119e611c80+ remote ce36d17b18fb
+  searching for copies back to rev 1
+  unmatched files in local:
+   b/a
+   b/b
+   b/d
+  unmatched files in other:
+   a/c
+  all copies found (* = to merge, ! = divergent):
+   b/a -> a/a
+   b/b -> a/b
+  checking for directory renames
+  dir a/ -> b/
+  file a/c -> b/c
+ None: local renamed directory to b/c -> d
+getting a/c to b/c
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 resolving manifests
  overwrite None partial False
  ancestor f9b20c0d4c51 local 55119e611c80+ remote ce36d17b18fb
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-rename-dir-merge2
--- a/tests/test-rename-dir-merge2	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-rename-dir-merge2	Wed May 28 10:26:07 2008 +0200
@@ -23,6 +23,8 @@
 hg ci -m "a/aa/g"
 hg pull ../r2

+echo testing dry merge:
+hg merge -n
 hg merge

 hg st -C
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-rename-dir-merge2.out
--- a/tests/test-rename-dir-merge2.out	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-rename-dir-merge2.out	Wed May 28 10:26:07 2008 +0200
@@ -10,6 +10,9 @@
 adding file changes
 added 1 changesets with 1 changes to 1 files (+1 heads)
 (run 'hg heads' to see heads, 'hg merge' to merge)
+testing dry merge:
+2 files updated, 0 files merged, 1 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
 M b/f
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-rename-merge1
--- a/tests/test-rename-merge1	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-rename-merge1	Wed May 28 10:26:07 2008 +0200
@@ -18,6 +18,8 @@
 echo blahblah > a2
 hg mv a2 c2
 hg ci -m "modify" -d "0 0"
+echo testing dry merge:
+hg merge -y --debug -n
 echo "merge"
 hg merge -y --debug
 hg status -AC
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-rename-merge1.out
--- a/tests/test-rename-merge1.out	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-rename-merge1.out	Wed May 28 10:26:07 2008 +0200
@@ -1,6 +1,35 @@
 checkout
 2 files updated, 0 files merged, 2 files removed, 0 files unresolved
 created new head
+testing dry merge:
+resolving manifests
+ overwrite None partial False
+ ancestor af1939970a1c local f26ec4fc3fa3+ remote 8e765a822af2
+  searching for copies back to rev 1
+  unmatched files in local:
+   c2
+  unmatched files in other:
+   b
+   b2
+  all copies found (* = to merge, ! = divergent):
+   c2 -> a2 !
+   b -> a *
+   b2 -> a2 !
+  checking for directory renames
+ a2: divergent renames -> dr
+ a: remote moved to b -> m
+ b2: remote created -> g
+preserving a for resolve of b
+removing a
+picked tool 'internal:merge' for b (binary False symlink False)
+merging a and b to b
+my b at f26ec4fc3fa3+ other b at 8e765a822af2 ancestor a at af1939970a1c
+warning: detected divergent renames of a2 to:
+ c2
+ b2
+getting b2
+1 files updated, 1 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 merge
 resolving manifests
  overwrite None partial False
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-up-local-change
--- a/tests/test-up-local-change	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-up-local-change	Wed May 28 10:26:07 2008 +0200
@@ -12,6 +12,8 @@

 hg clone . ../r2
 cd ../r2
+echo testing dry update:
+hg up -n
 hg up
 echo abc > a
 hg diff --nodates
@@ -26,12 +28,18 @@
 hg -q pull ../r1
 hg status
 hg parents
+echo testing dry update:
+hg --debug up -n
 hg --debug up
 hg parents
+echo testing dry update:
+hg --debug up -n 0
 hg --debug up 0
 hg parents
 hg --debug merge || echo failed
 hg parents
+echo testing dry update:
+hg --debug up -n
 hg --debug up
 hg parents
 hg -v history
@@ -39,6 +47,8 @@

 # create a second head
 cd ../r1
+echo testing dry update:
+hg up -n 0
 hg up 0
 echo b2 > b
 echo a3 > a
@@ -51,6 +61,8 @@
 hg parents
 hg --debug up || echo failed
 hg --debug merge || echo failed
+echo testing dry merge:
+hg --debug merge -f -n
 hg --debug merge -f
 hg parents
 hg diff --nodates
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-up-local-change.out
--- a/tests/test-up-local-change.out	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-up-local-change.out	Wed May 28 10:26:07 2008 +0200
@@ -1,6 +1,9 @@
 adding a
 updating working directory
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+testing dry update:
+0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 diff -r 33aaa84a386b a
 --- a/a
@@ -15,6 +18,22 @@
 date:        Mon Jan 12 13:46:40 1970 +0000
 summary:     1

+testing dry update:
+resolving manifests
+ overwrite False partial False
+ ancestor 33aaa84a386b local 33aaa84a386b+ remote 802f095af299
+  searching for copies back to rev 1
+  unmatched files in other:
+   b
+ a: versions differ -> m
+ b: remote created -> g
+preserving a for resolve of a
+picked tool 'true' for a (binary False symlink False)
+merging a
+my a at 33aaa84a386b+ other a at 802f095af299 ancestor a at 33aaa84a386b
+getting b
+1 files updated, 1 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 resolving manifests
  overwrite False partial False
  ancestor 33aaa84a386b local 33aaa84a386b+ remote 802f095af299
@@ -35,6 +54,14 @@
 date:        Mon Jan 12 13:46:40 1970 +0000
 summary:     2

+testing dry update:
+resolving manifests
+ overwrite False partial False
+ ancestor 33aaa84a386b local 802f095af299+ remote 33aaa84a386b
+ b: remote deleted -> r
+removing b
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 resolving manifests
  overwrite False partial False
  ancestor 33aaa84a386b local 802f095af299+ remote 33aaa84a386b
@@ -53,6 +80,22 @@
 date:        Mon Jan 12 13:46:40 1970 +0000
 summary:     1

+testing dry update:
+resolving manifests
+ overwrite False partial False
+ ancestor 33aaa84a386b local 33aaa84a386b+ remote 802f095af299
+  searching for copies back to rev 1
+  unmatched files in other:
+   b
+ a: versions differ -> m
+ b: remote created -> g
+preserving a for resolve of a
+picked tool 'true' for a (binary False symlink False)
+merging a
+my a at 33aaa84a386b+ other a at 802f095af299 ancestor a at 33aaa84a386b
+getting b
+1 files updated, 1 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 resolving manifests
  overwrite False partial False
  ancestor 33aaa84a386b local 33aaa84a386b+ remote 802f095af299
@@ -96,6 +139,9 @@
 @@ -1,1 +1,1 @@
 -a2
 +abc
+testing dry update:
+1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 adding b
 created new head
@@ -109,6 +155,23 @@
 failed
 abort: outstanding uncommitted changes
 failed
+testing dry merge:
+resolving manifests
+ overwrite False partial False
+ ancestor 33aaa84a386b local 802f095af299+ remote 030602aee63d
+  searching for copies back to rev 1
+ a: versions differ -> m
+ b: versions differ -> m
+preserving a for resolve of a
+preserving b for resolve of b
+picked tool 'true' for a (binary False symlink False)
+merging a
+my a at 802f095af299+ other a at 030602aee63d ancestor a at 33aaa84a386b
+picked tool 'true' for b (binary False symlink False)
+merging b
+my b at 802f095af299+ other b at 030602aee63d ancestor b at 000000000000
+0 files updated, 2 files merged, 0 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 resolving manifests
  overwrite False partial False
  ancestor 33aaa84a386b local 802f095af299+ remote 030602aee63d
diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-update-reverse
--- a/tests/test-update-reverse	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-update-reverse	Wed May 28 10:26:07 2008 +0200
@@ -25,6 +25,9 @@
 echo Should have two heads, side2 and main
 hg heads

+echo testing dry update:
+hg update --debug -C -n 1
+
 echo Should show "a side1 side2"
 ls

diff -r 5868d0b8509f -r 779c8ab143e3 tests/test-update-reverse.out
--- a/tests/test-update-reverse.out	Sun May 25 13:39:08 2008 -0700
+++ b/tests/test-update-reverse.out	Wed May 28 10:26:07 2008 +0200
@@ -36,6 +36,18 @@
 date:        Mon Jan 12 13:46:40 1970 +0000
 summary:     Added main

+testing dry update:
+resolving manifests
+ overwrite True partial False
+ ancestor 537353581d3d local ded32b0db104+ remote 221226fb2bd8
+ side2: remote deleted -> r
+ side1: remote deleted -> r
+ main: remote created -> g
+getting main
+removing side1
+removing side2
+1 files updated, 0 files merged, 2 files removed, 0 files unresolved
+(this was a dry run, no actions were performed)
 Should show a side1 side2
 a
 side1



More information about the Mercurial-devel mailing list