changeset 15471:f520c9616db5

merge with stable
author Matt Mackall <mpm@selenic.com>
date Thu, 10 Nov 2011 11:00:27 -0600
parents 99824055d323 (current diff) 93273948cdce (diff)
children d90b0b30464b
files hgext/rebase.py mercurial/commands.py mercurial/mdiff.py tests/test-rebase-detach.t
diffstat 9 files changed, 270 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/bzr.py	Thu Nov 10 10:59:03 2011 -0600
+++ b/hgext/convert/bzr.py	Thu Nov 10 11:00:27 2011 -0600
@@ -173,8 +173,14 @@
         revid = current._revision_id
         changes = []
         renames = {}
+        seen = set()
+        # Process the entries by reverse lexicographic name order to
+        # handle nested renames correctly, most specific first.
+        curchanges = sorted(current.iter_changes(origin),
+                            key=lambda c: c[1][0] or c[1][1],
+                            reverse=True)
         for (fileid, paths, changed_content, versioned, parent, name,
-            kind, executable) in current.iter_changes(origin):
+            kind, executable) in curchanges:
 
             if paths[0] == u'' or paths[1] == u'':
                 # ignore changes to tree root
@@ -188,7 +194,8 @@
                     # so it can be removed.
                     changes.append((self.recode(paths[0]), revid))
 
-                if None not in paths and paths[0] != paths[1]:
+                if kind[0] == 'directory' and None not in paths:
+                    renaming = paths[0] != paths[1]
                     # neither an add nor an delete - a move
                     # rename all directory contents manually
                     subdir = origin.inventory.path2id(paths[0])
@@ -198,6 +205,16 @@
                         if entry.kind == 'directory':
                             continue
                         frompath = self.recode(paths[0] + '/' + name)
+                        if frompath in seen:
+                            # Already handled by a more specific change entry
+                            # This is important when you have:
+                            # a => b
+                            # a/c => a/c
+                            # Here a/c must not be renamed into b/c
+                            continue
+                        seen.add(frompath)
+                        if not renaming:
+                            continue
                         topath = self.recode(paths[1] + '/' + name)
                         # register the files as changed
                         changes.append((frompath, revid))
@@ -215,6 +232,7 @@
 
             # we got unicode paths, need to convert them
             path, topath = [self.recode(part) for part in paths]
+            seen.add(path or topath)
 
             if topath is None:
                 # file deleted
--- a/hgext/rebase.py	Thu Nov 10 10:59:03 2011 -0600
+++ b/hgext/rebase.py	Thu Nov 10 11:00:27 2011 -0600
@@ -213,6 +213,7 @@
                 originalwd, target, state = result
                 if collapsef:
                     targetancestors = set(repo.changelog.ancestors(target))
+                    targetancestors.add(target)
                     external = checkexternal(repo, state, targetancestors)
 
         if keepbranchesf:
@@ -477,7 +478,10 @@
     f.write('%d\n' % int(keepbranches))
     for d, v in state.iteritems():
         oldrev = repo[d].hex()
-        newrev = repo[v].hex()
+        if v != nullmerge:
+            newrev = repo[v].hex()
+        else:
+            newrev = v
         f.write("%s:%s\n" % (oldrev, newrev))
     f.close()
     repo.ui.debug('rebase status stored\n')
@@ -510,7 +514,10 @@
                 keepbranches = bool(int(l))
             else:
                 oldrev, newrev = l.split(':')
-                state[repo[oldrev].rev()] = repo[newrev].rev()
+                if newrev != str(nullmerge):
+                    state[repo[oldrev].rev()] = repo[newrev].rev()
+                else:
+                    state[repo[oldrev].rev()] = int(newrev)
         skipped = set()
         # recompute the set of skipped revs
         if not collapse:
--- a/mercurial/commands.py	Thu Nov 10 10:59:03 2011 -0600
+++ b/mercurial/commands.py	Thu Nov 10 11:00:27 2011 -0600
@@ -2561,7 +2561,7 @@
 
     for pos, ctx in enumerate(repo.set("%ld", revs)):
         current = repo['.']
-        ui.status('grafting revision %s\n' % ctx.rev())
+        ui.status(_('grafting revision %s\n') % ctx.rev())
 
         # we don't merge the first commit when continuing
         if not cont:
--- a/mercurial/mdiff.py	Thu Nov 10 10:59:03 2011 -0600
+++ b/mercurial/mdiff.py	Thu Nov 10 11:00:27 2011 -0600
@@ -183,8 +183,14 @@
             # the file more than once.
             lastfunc[0] = astart
 
-        yield "@@ -%d,%d +%d,%d @@%s\n" % (astart + 1, alen,
-                                           bstart + 1, blen, func)
+        # zero-length hunk ranges report their start line as one less
+        if alen:
+            astart += 1
+        if blen:
+            bstart += 1
+
+        yield "@@ -%d,%d +%d,%d @@%s\n" % (astart, alen,
+                                           bstart, blen, func)
         for x in delta:
             yield x
         for x in xrange(a2, aend):
--- a/mercurial/patch.py	Thu Nov 10 10:59:03 2011 -0600
+++ b/mercurial/patch.py	Thu Nov 10 11:00:27 2011 -0600
@@ -723,11 +723,10 @@
 
         # fast case first, no offsets, no fuzz
         old = h.old()
-        # patch starts counting at 1 unless we are adding the file
-        if h.starta == 0:
-            start = 0
-        else:
-            start = h.starta + self.offset - 1
+        start = h.starta + self.offset
+        # zero length hunk ranges already have their start decremented
+        if h.lena:
+            start -= 1
         orig_start = start
         # if there's skew we want to emit the "(offset %d lines)" even
         # when the hunk cleanly applies at start + skew, so skip the
--- a/tests/test-convert-bzr-directories.t	Thu Nov 10 10:59:03 2011 -0600
+++ b/tests/test-convert-bzr-directories.t	Thu Nov 10 11:00:27 2011 -0600
@@ -149,3 +149,45 @@
   644   second/something
   644   third/dummy
   $ cd ..
+
+divergent nested renames (issue3089)
+
+  $ mkdir test-divergent-renames
+  $ cd test-divergent-renames
+  $ bzr init -q source
+  $ cd source
+  $ mkdir -p a/c
+  $ echo a > a/fa
+  $ echo c > a/c/fc
+  $ bzr add -q a
+  $ bzr commit -q -m 'Initial layout'
+  $ bzr mv a b
+  a => b
+  $ mkdir a
+  $ bzr add a
+  adding a
+  $ bzr mv b/c a/c
+  b/c => a/c
+  $ bzr status
+  added:
+    a/
+  renamed:
+    a/ => b/
+    a/c/ => a/c/
+  $ bzr commit -q -m 'Divergent renames'
+  $ cd ..
+  $ hg convert source source-hg
+  initializing destination source-hg repository
+  scanning source...
+  sorting...
+  converting...
+  1 Initial layout
+  0 Divergent renames
+  $ hg -R source-hg st -C --change 1
+  A b/fa
+    a/fa
+  R a/fa
+  $ hg -R source-hg manifest -r 1
+  a/c/fc
+  b/fa
+  $ cd ..
--- a/tests/test-diff-unified.t	Thu Nov 10 10:59:03 2011 -0600
+++ b/tests/test-diff-unified.t	Thu Nov 10 11:00:27 2011 -0600
@@ -89,23 +89,65 @@
   abort: diff context lines count must be an integer, not 'foo'
   [255]
 
-test off-by-one error with diff -p
+0 lines of context hunk header matches gnu diff hunk header
+
+  $ hg init diffzero
+  $ cd diffzero
+  $ cat > f1 << EOF
+  > c2
+  > c4
+  > c5
+  > EOF
+  $ hg commit -Am0
+  adding f1
+
+  $ cat > f2 << EOF
+  > c1
+  > c2
+  > c3
+  > c4
+  > EOF
+  $ diff -U0 f1 f2
+  --- f1	* (glob)
+  +++ f2	* (glob)
+  @@ -0,0 +1 @@
+  +c1
+  @@ -1,0 +3 @@
+  +c3
+  @@ -3 +4,0 @@
+  -c5
+  [1]
 
-  $ hg init diffp
-  $ cd diffp
-  $ echo a > a
-  $ hg ci -Ama
-  adding a
-  $ rm a
-  $ echo b > a
-  $ echo a >> a
-  $ echo c >> a
-  $ hg diff -U0 -p --nodates
-  diff -r cb9a9f314b8b a
-  --- a/a
-  +++ b/a
-  @@ -1,0 +1,1 @@
-  +b
-  @@ -2,0 +3,1 @@ a
-  +c
+  $ mv f2 f1
+  $ hg diff -U0 --nodates
+  diff -r 55d8ff78db23 f1
+  --- a/f1
+  +++ b/f1
+  @@ -0,0 +1,1 @@
+  +c1
+  @@ -1,0 +3,1 @@
+  +c3
+  @@ -3,1 +4,0 @@
+  -c5
 
+  $ hg diff -U0 --nodates --git
+  diff --git a/f1 b/f1
+  --- a/f1
+  +++ b/f1
+  @@ -0,0 +1,1 @@
+  +c1
+  @@ -1,0 +3,1 @@
+  +c3
+  @@ -3,1 +4,0 @@
+  -c5
+
+  $ hg diff -U0 --nodates -p
+  diff -r 55d8ff78db23 f1
+  --- a/f1
+  +++ b/f1
+  @@ -0,0 +1,1 @@
+  +c1
+  @@ -1,0 +3,1 @@ c2
+  +c3
+  @@ -3,1 +4,0 @@ c4
+  -c5
--- a/tests/test-import.t	Thu Nov 10 10:59:03 2011 -0600
+++ b/tests/test-import.t	Thu Nov 10 11:00:27 2011 -0600
@@ -958,3 +958,39 @@
   $ diff want have
   $ cd ..
 
+import a unified diff with no lines of context (diff -U0)
+
+  $ hg init diffzero
+  $ cd diffzero
+  $ cat > f << EOF
+  > c2
+  > c4
+  > c5
+  > EOF
+  $ hg commit -Am0
+  adding f
+
+  $ hg import --no-commit - << EOF
+  > # HG changeset patch
+  > # User test
+  > # Date 0 0
+  > # Node ID f4974ab632f3dee767567b0576c0ec9a4508575c
+  > # Parent  8679a12a975b819fae5f7ad3853a2886d143d794
+  > 1
+  > diff -r 8679a12a975b -r f4974ab632f3 f
+  > --- a/f	Thu Jan 01 00:00:00 1970 +0000
+  > +++ b/f	Thu Jan 01 00:00:00 1970 +0000
+  > @@ -0,0 +1,1 @@
+  > +c1
+  > @@ -1,0 +3,1 @@
+  > +c3
+  > @@ -3,1 +4,0 @@
+  > -c5
+  > EOF
+  applying patch from stdin
+
+  $ cat f
+  c1
+  c2
+  c3
+  c4
--- a/tests/test-rebase-detach.t	Thu Nov 10 10:59:03 2011 -0600
+++ b/tests/test-rebase-detach.t	Thu Nov 10 11:00:27 2011 -0600
@@ -303,3 +303,93 @@
   |/
   o  0: 'A'
   
+  $ cd ..
+
+Verify that target is not selected as external rev (issue3085)
+
+  $ hg clone -q -U a a6
+  $ cd a6
+  $ hg up -q 6
+
+  $ echo "I" >> E
+  $ hg ci -m "I"
+  $ hg merge 7
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg ci -m "Merge"
+  $ echo "J" >> F
+  $ hg ci -m "J"
+
+  $ hg rebase -s 8 -d 7 --collapse --detach --config ui.merge=internal:other
+  remote changed E which local deleted
+  use (c)hanged version or leave (d)eleted? c
+  saved backup bundle to $TESTTMP/a6/.hg/strip-backup/*-backup.hg (glob)
+
+  $ hg tglog
+  @  8: 'Collapsed revision
+  |  * I
+  |  * Merge
+  |  * J'
+  o  7: 'H'
+  |
+  | o  6: 'G'
+  |/|
+  o |  5: 'F'
+  | |
+  | o  4: 'E'
+  |/
+  | o  3: 'D'
+  | |
+  | o  2: 'C'
+  | |
+  | o  1: 'B'
+  |/
+  o  0: 'A'
+  
+
+  $ hg parents
+  changeset:   8:9472f4b1d736
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     Collapsed revision
+  
+
+  $ cd ..
+
+Ensure --continue restores a correct state (issue3046):
+  $ hg clone -q a a7
+  $ cd a7
+  $ hg up -q 3
+  $ echo 'H2' > H
+  $ hg ci -A -m 'H2'
+  adding H
+  $ hg rebase -s 8 -d 7 --detach --config ui.merge=internal:fail
+  merging H
+  warning: conflicts during merge.
+  merging H failed!
+  abort: unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [255]
+  $ hg resolve --all -t internal:local
+  $ hg rebase -c
+  saved backup bundle to $TESTTMP/a7/.hg/strip-backup/6215fafa5447-backup.hg
+  $ hg tglog
+  @  8: 'H2'
+  |
+  o  7: 'H'
+  |
+  | o  6: 'G'
+  |/|
+  o |  5: 'F'
+  | |
+  | o  4: 'E'
+  |/
+  | o  3: 'D'
+  | |
+  | o  2: 'C'
+  | |
+  | o  1: 'B'
+  |/
+  o  0: 'A'
+  
+