changeset 5336:24de027551c1

Merge with crew-stable
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Mon, 24 Sep 2007 19:14:18 -0300
parents 8d00788ca578 (current diff) 88e931f74e8b (diff)
children 8c5ef3b87cb1
files hgext/convert/git.py hgext/mq.py mercurial/commands.py mercurial/hgweb/hgweb_mod.py mercurial/hgweb/hgwebdir_mod.py mercurial/httprepo.py tests/test-convert-git.out
diffstat 12 files changed, 92 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/git.py	Mon Sep 24 12:42:25 2007 -0500
+++ b/hgext/convert/git.py	Mon Sep 24 19:14:18 2007 -0300
@@ -56,9 +56,14 @@
         self.modecache = {}
         fh = self.gitcmd("git-diff-tree --root -m -r %s" % version)
         changes = []
+        seen = {}
         for l in fh:
-            if "\t" not in l: continue
+            if "\t" not in l:
+                continue
             m, f = l[:-1].split("\t")
+            if f in seen:
+                continue
+            seen[f] = 1
             m = m.split()
             h = m[3]
             p = (m[1] == "100755")
--- a/hgext/mq.py	Mon Sep 24 12:42:25 2007 -0500
+++ b/hgext/mq.py	Mon Sep 24 19:14:18 2007 -0300
@@ -1638,6 +1638,9 @@
     q = repo.mq
     message = cmdutil.logmessage(opts)
     if opts['edit']:
+        if not q.applied:
+            ui.write(_("No patches applied\n"))
+            return 1
         if message:
             raise util.Abort(_('option "-e" incompatible with "-m" or "-l"'))
         patch = q.applied[-1].name
--- a/mercurial/commands.py	Mon Sep 24 12:42:25 2007 -0500
+++ b/mercurial/commands.py	Mon Sep 24 19:14:18 2007 -0300
@@ -598,9 +598,12 @@
         raise util.Abort(_('no destination specified'))
     dest = pats.pop()
     destdirexists = os.path.isdir(dest)
-    if (len(pats) > 1 or util.patkind(pats[0], None)[0]) and not destdirexists:
-        raise util.Abort(_('with multiple sources, destination must be an '
-                         'existing directory'))
+    if not destdirexists:
+        if len(pats) > 1 or util.patkind(pats[0], None)[0]:
+            raise util.Abort(_('with multiple sources, destination must be an '
+                               'existing directory'))
+        if dest.endswith(os.sep) or os.altsep and dest.endswith(os.altsep):
+            raise util.Abort(_('destination %s is not a directory') % dest)
     if opts['after']:
         tfn = targetpathafterfn
     else:
@@ -1470,6 +1473,10 @@
     name for non-default branches.
     """
 
+    if not repo and not source:
+        raise util.Abort(_("There is no Mercurial repository here "
+                           "(.hg not found)"))
+
     hexfunc = ui.debugflag and hex or short
     default = not (num or id or branch or tags)
     output = []
@@ -3153,4 +3160,4 @@
 
 norepo = ("clone init version help debugancestor debugcomplete debugdata"
           " debugindex debugindexdot debugdate debuginstall")
-optionalrepo = ("paths serve showconfig")
+optionalrepo = ("identify paths serve showconfig")
--- a/mercurial/hgweb/hgweb_mod.py	Mon Sep 24 12:42:25 2007 -0500
+++ b/mercurial/hgweb/hgweb_mod.py	Mon Sep 24 19:14:18 2007 -0300
@@ -141,7 +141,10 @@
     def nodebranchdict(self, ctx):
         branches = []
         branch = ctx.branch()
-        if self.repo.branchtags()[branch] == ctx.node():
+        # If this is an empty repo, ctx.node() == nullid,
+        # ctx.branch() == 'default', but branchtags() is
+        # an empty dict. Using dict.get avoids a traceback.
+        if self.repo.branchtags().get(branch) == ctx.node():
             branches.append({"name": branch})
         return branches
 
--- a/mercurial/hgweb/hgwebdir_mod.py	Mon Sep 24 12:42:25 2007 -0500
+++ b/mercurial/hgweb/hgwebdir_mod.py	Mon Sep 24 19:14:18 2007 -0300
@@ -146,8 +146,9 @@
                 u = ui.ui(parentui=parentui)
                 try:
                     u.readconfig(os.path.join(path, '.hg', 'hgrc'))
-                except IOError:
-                    pass
+                except Exception, e:
+                    u.warn(_('error reading %s/.hg/hgrc: %s\n' % (path, e)))
+                    continue
                 def get(section, name, default=None):
                     return u.config(section, name, default, untrusted=True)
 
--- a/mercurial/httprepo.py	Mon Sep 24 12:42:25 2007 -0500
+++ b/mercurial/httprepo.py	Mon Sep 24 19:14:18 2007 -0300
@@ -298,8 +298,7 @@
         cu = "%s%s" % (self._url, qs)
         try:
             if data:
-                self.ui.debug(_("sending %s bytes\n") %
-                              headers.get('content-length', 'X'))
+                self.ui.debug(_("sending %s bytes\n") % len(data))
             resp = urllib2.urlopen(request(cu, data, headers))
         except urllib2.HTTPError, inst:
             if inst.code == 401:
--- a/tests/test-convert-git	Mon Sep 24 12:42:25 2007 -0500
+++ b/tests/test-convert-git	Mon Sep 24 19:14:18 2007 -0300
@@ -5,15 +5,42 @@
 echo "[extensions]" >> $HGRCPATH
 echo "convert=" >> $HGRCPATH
 
+GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
+GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
+GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
+GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
+GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
+GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
+
+count=10
+commit()
+{
+    GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
+    GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
+    git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
+    count=`expr $count + 1`
+}
+
 mkdir git-repo
 cd git-repo
 git init-db >/dev/null 2>/dev/null
 echo a > a
 git add a
-git commit -m t1 >/dev/null 2>/dev/null || echo "git commit error"
+commit -m t1
+
 echo b >> a
-git commit -a -m t2 >/dev/null || echo "git commit error"
+commit -a -m t2.1
+
+git checkout -b other HEAD^ >/dev/null 2>/dev/null
+echo c > a
+echo a >> a
+commit -a -m t2.2
+
+git checkout master >/dev/null 2>/dev/null
+git pull --no-commit . other > /dev/null 2>/dev/null
+commit -m 'Merge branch other'
 cd ..
 
-hg convert git-repo
+hg convert --datesort git-repo
 
+hg -R git-repo-hg tip -v
--- a/tests/test-convert-git.out	Mon Sep 24 12:42:25 2007 -0500
+++ b/tests/test-convert-git.out	Mon Sep 24 19:14:18 2007 -0300
@@ -3,5 +3,20 @@
 scanning source...
 sorting...
 converting...
-1 t1
-0 t2
+3 t1
+2 t2.1
+1 t2.2
+0 Merge branch other
+changeset:   3:69b3a302b4a1
+tag:         tip
+parent:      1:0de2a40e261b
+parent:      2:8815d3b33506
+user:        test <test@example.org>
+date:        Mon Jan 01 00:00:13 2007 +0000
+files:       a
+description:
+Merge branch other
+
+committer: test <test@example.org>
+
+
--- a/tests/test-mq-qrefresh-replace-log-message	Mon Sep 24 12:42:25 2007 -0500
+++ b/tests/test-mq-qrefresh-replace-log-message	Mon Sep 24 19:14:18 2007 -0300
@@ -8,6 +8,11 @@
 hg init
 hg qinit
 
+echo =======================
+echo "Should fail if no patches applied"
+hg qrefresh
+hg qrefresh -e
+
 hg qnew -m "First commit message" first-patch
 echo aaaa > file
 hg add file
--- a/tests/test-mq-qrefresh-replace-log-message.out	Mon Sep 24 12:42:25 2007 -0500
+++ b/tests/test-mq-qrefresh-replace-log-message.out	Mon Sep 24 19:14:18 2007 -0300
@@ -1,3 +1,7 @@
+=======================
+Should fail if no patches applied
+No patches applied
+No patches applied
 =======================
 Should display 'First commit message'
 description:
--- a/tests/test-rename	Mon Sep 24 12:42:25 2007 -0500
+++ b/tests/test-rename	Mon Sep 24 19:14:18 2007 -0300
@@ -88,6 +88,11 @@
 diff d1/b d2/b
 hg update -C
 
+echo "# attempt to move one file into a non-existent directory"
+hg rename d1/a dx/
+hg status -C
+hg update -C
+
 echo "# attempt to move potentially more than one file into a non-existent"
 echo "# directory"
 hg rename 'glob:d1/**' dx
--- a/tests/test-rename.out	Mon Sep 24 12:42:25 2007 -0500
+++ b/tests/test-rename.out	Mon Sep 24 19:14:18 2007 -0300
@@ -166,6 +166,9 @@
 ---
 > d2/b
 3 files updated, 0 files merged, 3 files removed, 0 files unresolved
+# attempt to move one file into a non-existent directory
+abort: destination dx/ is not a directory
+0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 # attempt to move potentially more than one file into a non-existent
 # directory
 abort: with multiple sources, destination must be an existing directory