,(format "--pretty=tformat:%s" (car vc-git-root-log-format))
"--abbrev-commit"
,@(ensure-list vc-git-shortlog-switches)
- ,(concat (if (string= remote-location "")
+ ,(concat (if (string-empty-p remote-location)
"@{upstream}"
remote-location)
"..HEAD"))))
+(defun vc-git--fetch-incoming (remote-location)
+ (vc-git-command nil 0 nil "fetch"
+ (and (not (string-empty-p remote-location))
+ ;; Extract remote from "remote/branch".
+ (replace-regexp-in-string "/.*" ""
+ remote-location))))
+
(defun vc-git-log-incoming (buffer remote-location)
(vc-setup-buffer buffer)
- (vc-git-command nil 0 nil "fetch"
- (unless (string= remote-location "")
- ;; `remote-location' is in format "repository/branch",
- ;; so remove everything except a repository name.
- (replace-regexp-in-string
- "/.*" "" remote-location)))
+ (vc-git--fetch-incoming remote-location)
(apply #'vc-git-command buffer 'async nil
`("log"
"--no-color" "--graph" "--decorate" "--date=short"
,(format "--pretty=tformat:%s" (car vc-git-root-log-format))
"--abbrev-commit"
,@(ensure-list vc-git-shortlog-switches)
- ,(concat "HEAD.." (if (string= remote-location "")
+ ,(concat "HEAD.." (if (string-empty-p remote-location)
"@{upstream}"
remote-location)))))
+(defun vc-git-incoming-revision (remote-location)
+ (vc-git--fetch-incoming remote-location)
+ (ignore-errors ; in order to return nil if no such branch
+ (with-output-to-string
+ (vc-git-command standard-output 0 nil
+ "log" "--max-count=1" "--pretty=format:%H"
+ (if (string-empty-p remote-location)
+ "@{upstream}"
+ remote-location)))))
+
(defun vc-git-log-search (buffer pattern)
"Search the log of changes for PATTERN and output results into BUFFER.
(defun vc-hg-log-incoming (buffer remote-location)
(vc-setup-buffer buffer)
- (vc-hg-command buffer 1 nil "incoming" "-n" (unless (string= remote-location "")
- remote-location)))
+ (vc-hg-command buffer 1 nil "incoming" "-n"
+ (and (not (string-empty-p remote-location))
+ remote-location)))
+
+(defun vc-hg-incoming-revision (remote-location)
+ (let ((output (with-output-to-string
+ ;; Exits 1 to mean nothing to pull.
+ (vc-hg-command standard-output 1 nil
+ "incoming" "-qn" "--limit=1"
+ "--template={node}"
+ (and (not (string-empty-p remote-location))
+ remote-location)))))
+ (and (not (string-empty-p output))
+ output)))
(defun vc-hg-log-outgoing (buffer remote-location)
(vc-setup-buffer buffer)
- (vc-hg-command buffer 1 nil "outgoing" "-n" (unless (string= remote-location "")
- remote-location)))
+ (vc-hg-command buffer 1 nil "outgoing" "-n"
+ (and (not (string-empty-p remote-location))
+ remote-location)))
(defvar vc-hg-error-regexp-alist
'(("^M \\(.+\\)" 1 nil nil 0))
;; Insert in BUFFER the revision log for the changes that will be
;; received when performing a pull operation from REMOTE-LOCATION.
;;
+;; * incoming-revision (remote-location)
+;;
+;; Return revision at the head of the branch at REMOTE-LOCATION.
+;; If there is no such branch there, return nil. (Should signal an
+;; error, not return nil, in the case that fetching data fails.)
+;;
;; - log-search (buffer pattern)
;;
;; Search for PATTERN in the revision log and output results into BUFFER.