ananthakumaran / monky

Magit for Hg
http://ananthakumaran.in/monky/index.html
GNU General Public License v3.0
154 stars 30 forks source link

do not include empty remote when pushing to a repository #53

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hi,

This commit fixes the issue that I raised earlier https://github.com/ananthakumaran/monky/issues/52.

In summary, the variable monky-outgoing-repository is set to empty string "" by default, which may make the variable remote to become an empty string as well.

Later on, a list of arguments to a hg command will be concatenated using a whitespace separator `. This makes the hg command contains an empty space at the end like:(hg --config diff.git=Off push --branch branch-name ), which makes thehg push` command fails.

In my fix, when the variable remote is an empty string, I will not include it in the arguments of the hg command.

Bounga commented 6 years ago

I'd love to see this one being merged since it's broken and really annoying. I have to use vc-push from a file of my project (it doesn't work in Monky buffer) to push changes.

Good job @tddsg

ghost commented 6 years ago

@Bounga: Thanks for your interest! In the meantime, you can copy the patched function monky-push to your Emacs init file. This will temporarily override the default function monky-push.

(Note that if you see an error message like Hg returns an abnormally code 1, it means there is nothing to push)

(defun monky-push ()
  "Pushes current branch to the default path."
  (interactive)
  (let* ((branch (monky-current-branch))
         (remote (if current-prefix-arg
                     (monky-read-remote
                      (format "Push branch %s to : " branch))
                   monky-outgoing-repository)))
    (if (string= "" remote)
        (monky-run-hg-async "push" "--branch" branch)
      (monky-run-hg-async "push" "--branch" branch remote))))
Bounga commented 6 years ago

@tddsg Yes I'm going to copy it in my config file for now.